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


Python Server._request方法代码示例

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


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

示例1: xbmcControlPlayer

# 需要导入模块: from jsonrpclib import Server [as 别名]
# 或者: from jsonrpclib.Server import _request [as 别名]
def xbmcControlPlayer(action):
    server = Server(xbmcMakeUrl() + '/jsonrpc')
    if action == 'SetMute':
        method = 'Application.SetMute'
        data = server._request(methodname=method, params=['toggle'])
    elif action == 'MoveLeft':
        method = 'Player.MoveLeft'
        data = server._request(methodname=method, params={'playerid' : 1, 'value' : 'smallbackward'})
    elif action == 'MoveRight':
        method = 'Player.MoveRight'
        data = server._request(methodname=method, params={'playerid' : 1, 'value' : 'smallforward'})
    else:
        method = 'Player.' + action
        data = server._request(methodname=method, params={'playerid' : 1})
    return dumps(data)
开发者ID:Saladpact,项目名称:HTPC-Manager,代码行数:17,代码来源:xbmc.py

示例2: ControlPlayer

# 需要导入模块: from jsonrpclib import Server [as 别名]
# 或者: from jsonrpclib.Server import _request [as 别名]
 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:,项目名称:,代码行数:37,代码来源:

示例3: ControlPlayer

# 需要导入模块: from jsonrpclib import Server [as 别名]
# 或者: from jsonrpclib.Server import _request [as 别名]
 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,代码行数:59,代码来源:xbmc.py


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