本文整理汇总了Python中xmlrpclib.ServerProxy.status方法的典型用法代码示例。如果您正苦于以下问题:Python ServerProxy.status方法的具体用法?Python ServerProxy.status怎么用?Python ServerProxy.status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlrpclib.ServerProxy
的用法示例。
在下文中一共展示了ServerProxy.status方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Hella
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import status [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: main
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import status [as 别名]
def main():
set_up_logging(config['logfile'])
if not am_server() and any(options.values()):
showset = ServerProxy('http://localhost:19666/')
if options['shutdown']:
os.kill(check_pid(), 15)
if options['status'] and check_pid():
logging.info("Daemon is running.")
else:
if check_pid():
return 'floamtv is already running.'
if options['daemonize']:
daemonize()
with open(pidfile, "w") as f:
f.write("%d" % os.getpid())
if os.path.exists(dbpath):
showset = load()
first = False
else:
showset = Collection()
first = True
if options['unwant']:
for show in options['unwant'].split(' '):
logging.info(showset.unwant(show))
elif options['rewant']:
for show in options['rewant'].split(' '):
logging.info(showset.rewant(show))
elif options['status']:
logging.info(showset.status(bool(options['verbose'])))
elif am_server():
atexit.register(at_exit, showset)
tasks['tvrage'] = task.LoopingCall(showset.refresh, config['sets'], first)
tasks['newzbin'] = task.LoopingCall(showset.look_on_newzbin)
tasks['tvrage'].start(60 * config['tvrage-interval'])
reactor.listenTCP(19666, server.Site(showset), interface=config['bind'])
reactor.run()
示例3: get_status_from_server
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import status [as 别名]
def get_status_from_server(self):
"""
conf_dir_list = os.listdir('/usr/etc/')
if conf_dir_list.count('hellanzb.conf') == 0:
conf_dir_list = os.listdir('/etc/')
if conf_dir_list.count('hellanzb.conf') == 0:
self.status = 'conf file not found'
self.access = 0
print self.status
return
else:
file_path = '/etc/hellanzb.conf'
self.access = 1
print 'file_path is : %s' % file_path
return
else:
file_path = '/usr/etc/hellanzb.conf'
print 'file_path is : %s' % file_path
self.access = 1
return
"""
file_path = '/etc/hellanzb.conf'
try:
execfile(file_path)
except:
self.status = 'conf file not found'
self.access = 0
#print self.status
return
# we extract the necessary variables from the configuration file
try:
server = str(getattr(Hellanzb, 'XMLRPC_SERVER'))
except:
self.status = 'no xmlrpc server configured'
self.access = 0
#print self.status
return
try:
port = str(getattr(Hellanzb, 'XMLRPC_PORT'))
except:
self.status = 'no xmlrpc port configured'
self.access = 0
#print self.status
return
try:
server_password = str(getattr(Hellanzb, 'XMLRPC_PASSWORD'))
except:
self.status = 'no xmlrpc password configured'
self.access = 0
#print self.status
return
# we build the hellanzb access url
hella_server = ServerProxy('http://' + 'hellanzb' + ':' + server_password + '@' + server + ':' + port)
# we get hellanzb status
try:
self.hella_status = hella_server.status()
except:
self.status = 'not reachable'
self.access = 0
#print self.status
return
# if we get there everything is fine
self.access = 1
示例4: send_status
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import status [as 别名]
def send_status(url):
server = ServerProxy(url)
try:
resp = server.status()
except Error, v:
resp = v
示例5: __init__
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import status [as 别名]
class Nzbget:
def __init__(self, options, session):
self.options = options
self.session = session
self.api = ServerProxy(nzbget_rpcurl)
self.prepare_session()
self.process = subprocess.Popen([nzbget_bin, '-c', nzbget_configfile, '-s', '-o', 'outputmode=log'])
self.wait_until_started()
def finalize(self):
if pytest.config.getoption("--hold"):
print('\nNZBGet is still running, press Ctrl+C to quit')
time.sleep(100000)
self.process.kill()
if not has_failures:
self.remove_tempdir()
def remove_tempdir(self):
attempt = 1
completed = False
while not completed:
try:
if os.path.exists(nzbget_maindir + '.old'):
shutil.rmtree(nzbget_maindir + '.old')
if os.path.exists(nzbget_maindir):
os.rename(nzbget_maindir, nzbget_maindir + '.old')
shutil.rmtree(nzbget_maindir + '.old')
completed = True
except Exception:
if attempt > 20:
raise
attempt += 1
time.sleep(0.2)
def prepare_session(self):
self.remove_tempdir()
os.makedirs(nzbget_maindir)
config = open(nzbget_configfile, 'w')
config.write('MainDir=' + nzbget_maindir + '\n')
config.write('DestDir=${MainDir}/complete\n')
config.write('InterDir=${MainDir}/intermediate\n')
config.write('TempDir=${MainDir}/temp\n')
config.write('QueueDir=${MainDir}/queue\n')
config.write('NzbDir=${MainDir}/nzb\n')
config.write('LogFile=${MainDir}/nzbget.log\n')
config.write('SevenZipCmd=' + sevenzip_bin + '\n')
config.write('WriteLog=append\n')
config.write('DetailTarget=log\n')
config.write('InfoTarget=log\n')
config.write('WarningTarget=log\n')
config.write('ErrorTarget=log\n')
config.write('DebugTarget=none\n')
config.write('CrashTrace=no\n')
config.write('CrashDump=yes\n')
config.write('ContinuePartial=no\n')
config.write('DirectWrite=yes\n')
config.write('ArticleCache=500\n')
config.write('WriteBuffer=1024\n')
config.write('NzbDirInterval=0\n')
config.write('FlushQueue=no\n')
config.write('WebDir=' + nzbget_srcdir + '/webui\n')
config.write('ConfigTemplate=' + nzbget_srcdir + '/nzbget.conf\n')
config.write('ControlUsername=\n')
config.write('ControlPassword=\n')
config.write('ControlIP=127.0.0.1\n')
config.write('Server1.host=127.0.0.1\n')
config.write('Server1.port=6791\n')
config.write('Server1.connections=10\n')
config.write('Server1.level=0\n')
config.write('Server2.host=127.0.0.1\n')
config.write('Server2.port=6792\n')
config.write('Server2.connections=10\n')
config.write('Server2.level=1\n')
config.write('Server2.active=no\n')
for opt in self.options:
config.write(opt + '\n')
def wait_until_started(self):
print('Waiting for nzbget to start')
stat = None
for x in range(0, 3):
try:
stat = self.api.status()
except Exception:
time.sleep(0.5)
if stat is None:
raise Exception('Could not start nzbget')
print('Started')
def append_nzb(self, nzb_name, nzb_content, unpack = None, dupekey = '', dupescore = 0, dupemode = 'FORCE', params = None):
nzbcontent64 = base64.standard_b64encode(nzb_content)
if params is None:
params = []
if unpack == True:
params.append(('*unpack:', 'yes'))
elif unpack == False:
params.append(('*unpack:', 'no'))
return self.api.append(nzb_name, nzbcontent64, 'test', 0, False, False, dupekey, dupescore, dupemode, params)
#.........这里部分代码省略.........
示例6: BuildbotController
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import status [as 别名]
class BuildbotController(object):
COMMON_OPT_FLAGS = 'c:'
COMMON_OPT_ARGS = [
'config=', 'buildmac_url=', 'buildwin_url=']
DEFAULT_CONFIG_FILE = '~/.mailpile-build-controller.cfg'
DEFAULT_PORT = 33011
def __init__(self):
self.config_file = os.path.expanduser(self.DEFAULT_CONFIG_FILE)
self.buildmac_url = None
self.buildwin_url = None
self.running = None
self.api = None
if os.path.exists(self.config_file):
self.load_config()
def load_config(self, filename=None):
with open(filename or self.config_file, 'r') as fd:
lines = [l.split('#')[0].strip()
for l in fd.read().replace("\\\n", '').splitlines()]
args = []
for line in lines:
if line:
args.append('--%s' % line.replace(' = ', '='))
return self.parse_args(args)
def parse_with_common_args(self, args, opt_flags='', opt_args=[]):
opts, args = getopt.getopt(
args,
'%s%s' % (opt_flags, self.COMMON_OPT_FLAGS),
list(opt_args) + self.COMMON_OPT_ARGS)
try:
for opt, arg in opts:
if opt in ('-c', '--config'):
self.config_file = os.path.expanduser(arg)
if not os.path.exists(self.config_file):
raise ValueError('No such file: %s' % self.config_file)
self.load_config()
elif opt in ('--buildmac_url',):
self.buildmac_url = arg
elif opt in ('--buildwin_url',):
self.buildwin_url = arg
except ValueError as e:
raise ArgumentError(e)
return opts, args
def cmd_hello(self, args):
print 'Hello: %s' % ' '.join(args)
args[:] = []
def cmd_win(self, args):
config_assert(self.buildwin_url is not None)
self.api = ServerProxy(self.buildwin_url)
self.running = None
def cmd_mac(self, args):
config_assert(self.buildmac_url is not None)
self.api = ServerProxy(self.buildmac_url)
self.running = None
def cmd_run(self, args):
config_assert(self.api is not None)
self.running = args.pop(0)
print('%s' % self.api.run(self.running, 1))
def cmd_status(self, args):
config_assert(self.api is not None)
self.running = args.pop(0)
print('%s' % self.api.status(self.running))
def cmd_wait(self, args):
config_assert(self.running is not None)
while True:
time.sleep(5)
status = self.api.status(self.running)
print('%s' % status)
if status[-1]:
break
def parse_args(self, args):
opts, args = self.parse_with_common_args(args)
while args:
command = args.pop(0)
try:
self.__getattribute__('cmd_%s' % command)(args)
except AttributeError:
raise ArgumentError('No such command: %s' % command)
return self
def run(self):
pass
def cleanup(self):
pass
#.........这里部分代码省略.........
示例7: __init__
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import status [as 别名]
class NzbGet:
def __init__(self):
config = ConfigParser.ConfigParser()
config.readfp(open('/etc/raspadmin/nzbget.conf'))
self._url=config.get("NZBGET", "url")
self._user=config.get("NZBGET", "user")
self._password=config.get("NZBGET", "password")
self._protocol=config.get("NZBGET", "protocol")
self._server=ServerProxy(self._protocol+"://"+self._user+":"+self._password+"@"+self._url)
self._start=config.get("NZBGET", "start").split(' ')
self._stop=config.get("NZBGET", "stop").split(' ')
self._tmpfiles=config.get("NZBGET", "tmpdir")
def get_tmp(self):
return self._tmpfiles
def get_format_size(self,number):
number=float(number)
extension = [ 'b', 'Kb', 'Mb','Gb' ]
for i in range(len(extension)):
if number/1024<1:
return str(round(number,2))+ " " + extension[i]
else:
number=number/1024
return str(round(number*1024,2))+" "+"Gb"
def get_status(self):
try:
result=self._server.status()
except:
return (1,None)
result['DownloadRateFormated']=self.get_format_size(result['DownloadRate'])
result['RemainingSizeLoFormated']=self.get_format_size(result['RemainingSizeMB']*1024*1024)
result['DownloadedSizeLoFormated']=self.get_format_size(result['DownloadedSizeMB']*1024*1024)
#| bug with DownloadedSizeLo that does not show the correct value???
result['AverageDownloadRateFormated']=self.get_format_size(result['AverageDownloadRate'])
return (0,result)
def get_url_queue(self):
try:
result=self._server.urlqueue()
except:
return (1,None)
return (0,result)
def get_list_groups(self):
try:
result=self._server.listgroups()
except:
return (1,None)
for i in range(len(result)):
result[i]['RemainingSizeLoFormated']=self.get_format_size(result[i]['RemainingSizeLo'])
result[i]['FileSizeLoFormated']=self.get_format_size(result[i]['FileSizeMB']*1024*1024)
result[i]['DownloadedFormated']=self.get_format_size((result[i]['FileSizeMB']-result[i]['RemainingSizeMB'])*1024*1024)
return (0,result)
def get_history(self):
try:
result=self._server.history()
except:
return (1,None)
for i in range(min(len(result),10)):
result[i]['FileSizeLoFormated']=self.get_format_size(result[i]['FileSizeMB']*1024*1024)
if result[i]['UnpackStatus']=="SUCCESS":
status="Success"
color="green"
else:
if result[i]['DeleteStatus']!='None':
status="Deleted"
color="orange"
else:
status="Failed"
color="red"
result[i]['status']=status
result[i]['color']=color
result[i]['DestDir']=result[i]['DestDir'].split('/')[-1]
if len(result)>10:
result=result[0:10]
return (0,result)
def get_post_queue(self):
try:
result=self._server.postqueue(10)
except:
return (1,None)
for i in range(len(result)):
result[i]['StageProgress']=int(result[i]['StageProgress']/10)
return (0,result)
def add_nzb(self,filename,category,addtotop):
#.........这里部分代码省略.........