本文整理汇总了Python中xmlrpclib.ServerProxy.enqueuenewzbin方法的典型用法代码示例。如果您正苦于以下问题:Python ServerProxy.enqueuenewzbin方法的具体用法?Python ServerProxy.enqueuenewzbin怎么用?Python ServerProxy.enqueuenewzbin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlrpclib.ServerProxy
的用法示例。
在下文中一共展示了ServerProxy.enqueuenewzbin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Hella
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import enqueuenewzbin [as 别名]
class Hella(FooApp):
name = 'hella'
config_opts = {
'password': 'The password defined as Hellanzb.XMLRPC_PASSWORD in hellanzb.conf',
'server': 'The IP address or hostname running hellanzb',
'port': 'The port hellanzb is running on. The default is 8760',
}
def __init__(self, server=None):
FooApp.__init__(self, server)
self.hellaserver = ServerProxy('http://hellanzb:%[email protected]%s:%s/' % (self.data['password'], self.data['server'], self.data['port']))
self.data = FileStore('/tmp/apps/hella')
try:
self.cache = json.loads(self.data['cache'])
except:
self.cache = []
def send(self, msg):
response = self.hellaserver.enqueuenewzbin(int(msg['text']))
return
def run(self):
while True:
status = self.hellaserver.status()
for entry in status['log_entries']:
for key, value in entry.items():
if not value in self.cache:
self.recv('%s: %s' % (self.name, value))
self.cache.append(value)
self.data['cache'] = json.dumps(self.cache)
sleep(10)
示例2: enqueue
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import enqueuenewzbin [as 别名]
def enqueue(self, allow_probation=False):
"""
Enqueue episodes that have a Newzbin ID resolved with Hellanzb. If
allow_probation is True, don't exclude shows that are on probation.
"""
def _handle_sab(result, ep):
if 'error' in result:
logging.error("Unable to enqueue %s" % ep)
logging.error("Reason: %s" % result)
else:
logging.info("Enqueued %s" % ep)
ep.wanted = False
def _handle_sab_fail(err, ep):
logging.error("Unable to enqueue %s" % ep)
if self.newzbinid and self.wanted != 'later' or allow_probation:
if 'sab' in config['nzbclient']:
url = urlencode({'mode': 'addid',
'name': self.newzbinid,
'apikey': config['sabnzbd-apikey']})
url = "http://%s:%s/sabnzbd/api?%s" % (config['sabnzbd-host'],
config['sabnzbd-port'],
url)
attempt = getPage(url, timeout=60)
attempt.addCallback(_handle_sab, self)
attempt.addErrback(_handle_sab_fail, self)
else:
try:
hella = ServerProxy("http://hellanzb:%[email protected]%s:8760"
% (config['hellanzb-pass'], config['hellanzb-host']))
hella.enqueuenewzbin(self.newzbinid)
except:
logging.error("Unable to enqueue %s" % self)
return False
else:
logging.info("Enqueued %s" % self)
self.wanted = False