当前位置: 首页>>代码示例>>Python>>正文


Python jsonrpclib.Server类代码示例

本文整理汇总了Python中jsonrpclib.Server的典型用法代码示例。如果您正苦于以下问题:Python Server类的具体用法?Python Server怎么用?Python Server使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Server类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: nlp_parse

def nlp_parse(text):
    """
    pass the text to the stanford NLP core server and get the parsed data
    """
    server = Server("http://localhost:8080")
    parsed_data = loads(server.parse(text))
    return parsed_data
开发者ID:heaven00,项目名称:nlp-ner,代码行数:7,代码来源:ner.py

示例2: main

def main():
  
    argument_spec = dict( 
        vlan_id=dict(required=True), 
        vlan_name=dict(),
        host=dict(),
        username=dict(required=True),
        password=dict(required=True), 
        port=dict(required=False),
        transport=dict(choices=['http', 'https'],required=False)
    )

    module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
    
    vlan_id = module.params['vlan_id']
    vlan_name = module.params['vlan_name']
    host = str(module.params['host'])
    username = module.params['username']
    password = module.params['password']
    port = int(module.params['port'])
    transport = module.params['transport']

    conn = Server("https://%s:%[email protected]%s/command-api" %(username, password, host))
    
    list_cmds = [ "enable", "configure" ] 

    list_cmds.append("vlan %s" %(vlan_id))
    list_cmds.append("name %s" %(vlan_name))

    conn.runCmds(1, list_cmds, "json")

    module.exit_json(msg="Vlan created successfully")
开发者ID:deepgajjar5,项目名称:py_net,代码行数:32,代码来源:ansible_module_deep.py

示例3: main

def main():
    parser = argparse.ArgumentParser(description='Location,Ipaddress')
    parser.add_argument('-location', choices=['dc1','dc2'],
    help='Enter the colo location dc1|dc2')
    parser.add_argument('-ip', help='Enter switch ip address')
    args = parser.parse_args()
    if args.location == 'dc1':
         hostlist = arista_devices_dc1()
    elif args.location == 'dc2':
         hostlist = arista_devices_dc2()
    disable_https_cert()
    #----------------------------------------------------------------
    # Configuration section
    #----------------------------------------------------------------
    #-------------------Configuration - MUST Set ------------------------
    EAPI_USERNAME = os.getenv("USER")
    EAPI_PASSWORD = get_user_info()
    # http or https method
    EAPI_METHOD = 'https'

    for host in hostlist:
        switch = Server( '%s://%s:%[email protected]%s/command-api' %
                       ( EAPI_METHOD, EAPI_USERNAME, EAPI_PASSWORD, host ) )
        rc = switch.runCmds( 1, [ 'enable',
                        'configure',
                        'interface Vxlan1',
                        'vxlan flood vtep add %s' % args.ip  ] )
        print( 'Host configured: %s' % ( host ) )
开发者ID:shanecon,项目名称:arista,代码行数:28,代码来源:ileaf_vxlan_vtep.py

示例4: get_hostname

def get_hostname(ip_list):
    ip_to_hostname = {}
    for ip in ip_list:
        switch_cli = Server( "http://admin:[email protected]"+ip+"/command-api" )
        response_hostname = switch_cli.runCmds( 1, ["show hostname"])
        ip_to_hostname[ip] = response_hostname[0]["hostname"]
    return ip_to_hostname
开发者ID:vmware,项目名称:nsx-traceflow-pv,代码行数:7,代码来源:app.py

示例5: execute

 def execute(self, cleanup=True):
     """
     Execute the bugger
     :return:
     """
     res = None
     try:
         res = self._server.execute(self._pdict, cleanup)
     except KeyboardInterrupt:
         self.monitor.stop()
         server2 = Server(self.url)
         server2.kill()
     except socket.error:
         self.log.error("Server was interrupted")
         exit(1)
     finally:
         self.monitor.stop()
     if res is None:
         raise ValueError("Run failed")
     resstr = "%s\t%s\t %s\t %s\t %s\t %s\t %s" % (str(datetime.datetime.utcnow()), self.message, 
                                                   self._pdict["cpuRangeVal"], self._pdict["outputDir"],
                                                   res["Wallclock"], res["peak"]/1024.**3, res["avg"]/1024**3)
     self.log.info("date \t\t\t message \t\t cpu \t outputdir \t time \t peak_mem \t avg_mem")
     self.log.info(resstr)
     with open(os.path.expanduser("~/result.dat"), "a") as out:
         out.write(resstr+"\n")
开发者ID:sposs,项目名称:pythonWrapper,代码行数:26,代码来源:client.py

示例6: eApiShowInterfaces

def eApiShowInterfaces():
    switch = Server(commandApiUrl)
    response = switch.runCmds( 1, ["show interfaces"])
    if (request.query.callback):
        return directFlowJsonp(request)
    else:
        return json.dumps(eApiDirectFlow(), indent=4, sort_keys=True)
开发者ID:yashsdesai,项目名称:Arista_ASU_DEMO,代码行数:7,代码来源:apicalls.py

示例7: main

def main(args):
    ''' main '''
    parser = OptionParser()
    parser.add_option('-u', '--username', default='eapi', help='username')
    parser.add_option('-p', '--password', default='', help='password')
    parser.add_option('-P', '--port', default='8543', help='port')
    parser.add_option('-D', '--debug', action='store_true', help='debug')
    options, args = parser.parse_args()

    for switch in args:
        url = "https://{0}:{1}@{2}:{3}/command-api".format(
            options.username, options.password, switch, options.port
        )
        request = Server(url)
        response = request.runCmds(1, ["show interfaces"] )
        if options.debug:
            print json.dumps(response, indent=4, sort_keys=True)
        interfaces = sorted(response[0]['interfaces'].keys())
        print "Switch {0} interfaces:".format(switch)
        print "{:20} {:<20} {:<20}".format("Interface", "inOctets", "outOctets")
        for inf in interfaces:
            data = response[0]['interfaces'][inf]
            if 'interfaceCounters' in data:
                print "{:20} {:<20} {:<20}".format(
                    inf, data['interfaceCounters']['inOctets'], data['interfaceCounters']['outOctets']
                )
        print
开发者ID:sfromm,项目名称:pyn,代码行数:27,代码来源:5-1.py

示例8: ControlPlayer

 def ControlPlayer(self, action='', percent=''):
     xbmc = Server(self.url('/jsonrpc', True))
     player = xbmc.Player.GetActivePlayers()
     if action == 'SetMute':
         return xbmc.Application.SetMute(mute='toggle')
     elif action == 'Back':
         return xbmc.Input.Back()
     elif action == 'Down':
         return xbmc.Input.Down()
     elif action == 'Home':
         return xbmc.Input.Home()
     elif action == 'Left':
         return xbmc.Input.Left()
     elif action == 'Right':
         return xbmc.Input.Right()
     elif action == 'Select':
         return xbmc.Input.Select()
     elif action == 'Up':
         return xbmc.Input.Up()
     elif action == 'MoveLeft':
         return xbmc.Input.Left()
     elif action == 'MoveRight':
         return xbmc.Input.Right()
     elif action == 'Seek':
         try:
             percent = float(percent)
             return xbmc.Player.Seek(playerid=player[0][u'playerid'], value=percent)
         except:
             return
     elif action:
         try:
             method = 'Player.'+action
             return xbmc._request(methodname=method, params={'playerid' : player[0][u'playerid']})
         except:
             return
开发者ID:,项目名称:,代码行数:35,代码来源:

示例9: test_get_device_status_good

    def test_get_device_status_good(self):
        """ Test get_device_status happy path
        """
        from mock import MagicMock
        from jsonrpclib import Server
        device = dict(self.device)
        sh_ver = dict(self.sh_ver)

        # Arbitrary test valuse
        model = "Monkey-bot"
        timestamp = 1408034881.09

        sh_ver['modelName'] = model
        sh_ver['bootupTimestamp'] = timestamp
        response = []
        response.append(sh_ver)

        device['eapi_obj'] = Server('https://arista:[email protected]:443/command-api')
        device['eapi_obj'].runCmds = MagicMock(return_value=response)

        #response = []
        #response.append({})
        #response[0][u'interfaceStatuses'] = self.int_status

        app.get_device_status(device)
        self.assertEqual(device['modelName'], model)
        self.assertEqual(device['bootupTimestamp'], timestamp)
开发者ID:arista-eosext,项目名称:rphm,代码行数:27,代码来源:test_traps.py

示例10: add_vlans

def add_vlans():
    for switch in switches:
    	for vlanlist in vlans:
    		urlString = "http://{}:{}@{}/command-api".format(switchusername, switchpassword, switch)
    		switchReq = Server( urlString )
    		response = switchReq.runCmds( 1, ["enable", "configure", "vlan" +" "+ str(vlanlist)] )
    		print "adding vlans %s" % (vlanlist)
开发者ID:burnyd,项目名称:arista_automation_events,代码行数:7,代码来源:forloopsvlans.py

示例11: show_vlans

def show_vlans():
    for switch in switches:
        urlString = "http://{}:{}@{}/command-api".format(switchusername, switchpassword, switch)
        switchReq = Server( urlString )
        response = switchReq.runCmds( 1, ["show vlan"] )
        print "Showing the vlans on %s" % (switch)
        print json.dumps(response, indent=4)
开发者ID:burnyd,项目名称:arista_automation_events,代码行数:7,代码来源:forloopsvlans.py

示例12: push

def push(item, remote_addr, trg_queue, protocol=u'jsonrpc'):
    ''' Enqueue an FSQWorkItem at a remote queue '''
    if protocol == u'jsonrpc':
        try:
            server = Server(remote_addr, encoding=_c.FSQ_CHARSET)
            return server.enqueue(item.id, trg_queue, item.item.read())
        except Exception, e:
            raise FSQPushError(e)
开发者ID:axialmarket,项目名称:fsq,代码行数:8,代码来源:push.py

示例13: ControlPlayer

 def ControlPlayer(self, action='', percent=''):
     """ Various commands to control XBMC Player """
     self.logger.debug("Sending control to XBMC: " + action)
     xbmc = Server(self.url('/jsonrpc', True))
     player = xbmc.Player.GetActivePlayers()
     if action == 'SetMute':
         return xbmc.Application.SetMute(mute='toggle')
     elif action == 'Back':
         return xbmc.Input.Back()
     elif action == 'Down':
         return xbmc.Input.Down()
     elif action == 'Home':
         return xbmc.Input.Home()
     elif action == 'Left':
         return xbmc.Input.Left()
     elif action == 'Right':
         return xbmc.Input.Right()
     elif action == 'Select':
         return xbmc.Input.Select()
     elif action == 'Up':
         return xbmc.Input.Up()
     elif action == 'MoveLeft':
         return xbmc.Input.Left()
     elif action == 'MoveRight':
         return xbmc.Input.Right()
     elif action == 'PlayNext':
         try:
             return xbmc.Player.GoTo(playerid=player[0][u'playerid'], to='next')
         except:
             self.logger.error("Unable to control XBMC with action: " + action)
             return
     elif action == 'PlayPrev':
         try:
             return xbmc.Player.GoTo(playerid=player[0][u'playerid'], to='previous')
         except:
             self.logger.error("Unable to control XBMC with action: " + action)
             return
     elif action == 'JumpItem':
         try:
             return xbmc.Player.GoTo(playerid=player[0][u'playerid'], to=int(percent))
         except:
             self.logger.error("Unable to control XBMC with action: " + action)
             return
     elif action == 'Seek':
         try:
             percent = float(percent)
             return xbmc.Player.Seek(playerid=player[0][u'playerid'], value=percent)
         except:
             self.logger.error("Unable to control XBMC with action: " + action)
             return
     elif action:
         try:
             method = 'Player.' + action
             return xbmc._request(methodname=method, params={'playerid': player[0][u'playerid']})
         except:
             self.logger.error("Unable to control XBMC with action: " + action)
             return
开发者ID:plague85,项目名称:HTPC-Manager,代码行数:57,代码来源:xbmc.py

示例14: main

def main():
    args = parser.parse_args()
    config = get_rpc_string(os.path.expanduser('~/.namecoin/namecoin.conf'))
    rpc = Server(config)

    try:
        entry = rpc.name_filter('^%s/%s$' % (PREFIX, args.key), 0)[0]
        print(entry['value'])
    except IndexError:
        print('Key not found', file=sys.stderr)
开发者ID:kpcyrd,项目名称:nmcssh,代码行数:10,代码来源:nmcssh.py

示例15: remove_acl

def remove_acl(ip_list):
    adjacency_list = find_topology(ip_list)
    for ip in adjacency_list.keys():
        switch_cli = Server( "http://admin:[email protected]"+ip+"/command-api" )
        configure_acl_response = switch_cli.runCmds( 1, ["enable","configure terminal","no ip access-list trace",])
        for interface in adjacency_list[ip].values():
            configure_acl_interface_response = switch_cli.runCmds( 1, ["enable","configure terminal",
            "interface "+interface,
            "no ip access-group trace in",
            "end"])
开发者ID:vmware,项目名称:nsx-traceflow-pv,代码行数:10,代码来源:app.py


注:本文中的jsonrpclib.Server类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。