<commit_before>'''
WARNING: this file is deployed standalone to remote systems
Do not add uvscada dependencies
'''

from SimpleXMLRPCServer import SimpleXMLRPCServer
import linuxcnc

class Server(object):
    def __init__(self, bind='localhost', port=22617, verbose=False):
        self.server = None
        self.bind = bind
        self.port = port
        self.verbose = verbose
        
        self.s = linuxcnc.stat()
        self.c = linuxcnc.command()

    def poll(self):
        self.s.poll()
        ret = {}
        for attr in ['estop', 'enabled', 'homed', 'interp_state']:
            ret[attr] = getattr(self.s, attr)
        return ret

    def constants(self):
        return {
            'MODE_MDI': linuxcnc.MODE_MDI,
            'INTERP_IDLE': linuxcnc.INTERP_IDLE,
            }

    def run(self):
        print 'Starting server'<commit_msg>lcnc rpc: better constant support<commit_after>'''
WARNING: this file is deployed standalone to remote systems
Do not add uvscada dependencies
'''

from SimpleXMLRPCServer import SimpleXMLRPCServer
import linuxcnc

class Server(object):
    def __init__(self, bind='localhost', port=22617, verbose=False):
        self.server = None
        self.bind = bind
        self.port = port
        self.verbose = verbose
        
        self.s = linuxcnc.stat()
        self.c = linuxcnc.command()

    def poll(self):
        self.s.poll()
        ret = {}
        #for attr in ['axis', 'axes', 'estop', 'enabled', 'homed', 'interp_state']:
        #    ret[attr] = getattr(self.s, attr)
        for k, v in self.s.__dict__.iteritems():
            if k.startswith('_'):
                continue
            if not type(v) in [int, str]:
                continue
            ret[k] = v
        # dict
        ret['axis'] = self.s.axis
        return ret

    def constants(self):
        ret = {}
        for k, v in linuxcnc.__dict__.iteritems():
            if k.startswith('_'):
                continue
            if not type(v) in [int, str]:
                continue
            ret[k] = v
        return ret

    def run(self):
        print 'Starting server'
{'fraction_non_alphanumeric': 0.11147695202257761, 'fraction_numerical': 0.004703668861712135, 'mean_word_length': 1.9337931034482758, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7184399', 'n_tokens_mistral': 658, 'n_tokens_neox': 620, 'n_words': 176}