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


Python ServerProxy.enqueuenewzbin方法代码示例

本文整理汇总了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)
开发者ID:JeremyGrosser,项目名称:foobox,代码行数:33,代码来源:hella.py

示例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
开发者ID:floam,项目名称:floamtv,代码行数:47,代码来源:floamtv.py


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