예제 #1
0
def main(host=get_host_ip(), port=8890):
    server = SimpleXMLRPCServer((host, port))
    server.register_introspection_functions()
    server.register_function(ping)
    server.register_function(GetData)
    server.register_function(GetSubmitData)
    server.serve_forever()
예제 #2
0
def main(host=get_host_ip(), port=8890):
    server = SimpleXMLRPCServer((host, port))
    server.register_introspection_functions()
    server.register_function(ping)
    server.register_function(GetData)    
    server.register_function(GetSubmitData)
    server.serve_forever()
예제 #3
0
D = digitemp.Digitemp()

def GetData():
    return D.GetData()

def GetSubmitData():
    return D.GetData()

def ping():
    return 'pong'

def main(host=get_host_ip(), port=8890):
    server = SimpleXMLRPCServer((host, port))
    server.register_introspection_functions()
    server.register_function(ping)
    server.register_function(GetData)    
    server.register_function(GetSubmitData)
    server.serve_forever()

if __name__ == "__main__":
    
    parser = argparse.ArgumentParser(description='Process Input arguments, specify optional host ip and port number')
    parser.add_argument('--ip', default=get_host_ip(), type=str, help='IP of the server to which digitemp is connected')
    parser.add_argument('--port', default=8890, type=int)
    
    args = parser.parse_args()
    
    print "Starting Digitemp server on ip=%s, port=%d" % (args.ip, args.port)
    main(host=args.ip, port=args.port)
예제 #4
0
'''
Created on 2012-12-19

@author: borand
'''
import xmlrpclib
import argparse
from common import get_host_ip

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description=
        'Process Input arguments, specify optional server ip and port number')
    parser.add_argument('--ip',
                        default=get_host_ip(),
                        type=str,
                        help='IP of digitemp server')
    parser.add_argument('--port', default=8890, type=int)

    args = parser.parse_args()
    server_address = 'http://%s:%d' % (args.ip, args.port)
    RemoteDigitemp = xmlrpclib.ServerProxy(server_address)
    try:
        print "Sending ping to remote digitemp server at %s" % server_address
        ping_response = RemoteDigitemp.ping()

        print "Asking for Data"
        data_set = RemoteDigitemp.GetData()

        for data in data_set:
            print "Serial number %s, Temperature %f C" % (data[1], data[2])
예제 #5
0
 def __init__(self, from_host=get_host_ip(), to='', msg=''):
     self.from_host = from_host
     self.to        = to
     self.msg       = msg
예제 #6
0
'''
Created on 2012-12-19

@author: borand
'''
import xmlrpclib
import argparse
from common import get_host_ip

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Process Input arguments, specify optional server ip and port number')
    parser.add_argument('--ip', default=get_host_ip(), type=str, help='IP of digitemp server')
    parser.add_argument('--port', default=8890, type=int)
    
    args = parser.parse_args()     
    server_address = 'http://%s:%d' % (args.ip, args.port)
    RemoteDigitemp = xmlrpclib.ServerProxy(server_address)
    try:
        print "Sending ping to remote digitemp server at %s" % server_address
        ping_response = RemoteDigitemp.ping()
        
        print "Asking for Data"
        data_set = RemoteDigitemp.GetData()
            
        for data in data_set:
            print "Serial number %s, Temperature %f C" % (data[1], data[2])
    except Exception as inst:
        print type(inst)
        print inst.args
        print inst
예제 #7
0
파일: localentry.py 프로젝트: cuyu/decade
def main():
    args = parse_args()
    remote_path = args.remote_path or os.environ.get('DECADE_REMOTE_PATH')
    assert remote_path
    server_name = args.server_name
    ssh_port = args.ssh_port
    local_path = args.local_path or os.environ.get('DECADE_LOCAL_PATH')
    assert local_path
    assert os.path.isdir(local_path), "local project path is not a directory."
    local_ip = get_host_ip()
    local_port = get_unoccupied_port()
    project_name = os.path.basename(remote_path)

    ide_config = {
        "deployment": [{
            'tag': 'component',
            'attrib': {
                'serverName': server_name
            }
        }, {
            'tag': 'paths',
            'attrib': {
                'name': server_name
            }
        }, {
            'tag': 'mapping',
            'attrib': {
                'deploy': remote_path,
                'local': '$PROJECT_DIR$' + remote_path
            }
        }],
        "misc": [],
        "remote-mappings": [
            {
                'tag': 'mapping',
                'attrib': {
                    'local-root': '$PROJECT_DIR$' + remote_path,
                    'remote-root': remote_path
                }
            },
        ],
        "webServers": [],
    }

    client = Client(args.hostname, args.ssh_user, args.ssh_password,
                    args.ssh_port)

    client.send_files(
        os.path.join(pkgutil.get_loader("decade").filename, _REMOTE_ENTRY),
        os.path.join(remote_path, _REMOTE_ENTRY))

    # remove download
    # remote project is placed in the local project path. Modify this for consistency
    # local project path is empty
    local_project_path = os.path.join(local_path, project_name)

    if not os.path.exists(local_project_path):
        client.fetch_files(remote_path, local_project_path)
        # If need to download the source code from remote, the project path need to append the project name
    elif not os.path.exists(os.path.join(local_project_path, _REMOTE_ENTRY)):
        client.fetch_files(os.path.join(remote_path, _REMOTE_ENTRY),
                           os.path.join(local_project_path, _REMOTE_ENTRY))

    config_IDE(ide_config, remote_path, project_name, local_project_path,
               local_ip, local_port, ssh_port)

    setup_virtualenv(client, local_project_path, args.src_entry, remote_path)

    call(['open', '-a', 'PyCharm', local_project_path])

    _LOGGER.info('Please start the debug server in the PyCharm to continue')

    # use a loop to check if the debugger started(if port is occupied).
    while 1:
        port_open = False
        pid_list = get_pid_by_name('pycharm')
        for pid in pid_list:
            port_open = port_open or is_port_in_use(pid, local_port)
        if port_open:
            break
        _LOGGER.info('Still waiting...')
        time.sleep(10)
    _LOGGER.info('Detect the debugging port is open, ready to start')

    run_remote_cmd = 'python {remote_entry} --remote-path {remote_path} --src-entry {src_entry} --local-ip {ip} --local-port {port}'.format(
        **{
            'remote_entry': os.path.join(remote_path, _REMOTE_ENTRY),
            'remote_path': remote_path,
            'src_entry': args.src_entry,
            'ip': local_ip,
            'port': local_port,
        })
    client.execute(run_remote_cmd)