本文整理汇总了Python中xmlrpc.client.ServerProxy.version方法的典型用法代码示例。如果您正苦于以下问题:Python ServerProxy.version方法的具体用法?Python ServerProxy.version怎么用?Python ServerProxy.version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlrpc.client.ServerProxy
的用法示例。
在下文中一共展示了ServerProxy.version方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _test_xmlrpc_connection
# 需要导入模块: from xmlrpc.client import ServerProxy [as 别名]
# 或者: from xmlrpc.client.ServerProxy import version [as 别名]
def _test_xmlrpc_connection(self):
# DEPRECATED: use the erppeek wrapper instead
print('Testing %s' % self.name)
pprint(self.config)
try:
base_url = self.url + '/xmlrpc/2/'
common = ServerProxy(base_url + 'common')
user_id = common.authenticate(
self.database,
self.username,
self.password,
{}
)
models = ServerProxy(base_url + 'object')
access = models.execute_kw(
self.database,
user_id,
self.password,
'res.partner',
'check_access_rights',
['read'],
{'raise_exception': False}
)
customer_ids = models.execute_kw(
self.database,
user_id,
self.password,
'res.partner',
'search',
[[['is_company', '=', True], ['customer', '=', True]]]
)
customer_records = models.execute_kw(
self.database,
user_id,
self.password,
'res.partner',
'read',
[customer_ids]
)
print('Connection = %s', common.version())
print('User ID = %s' % user_id)
print('Access = %s' % access)
print('Number of customers = %s' % len(customer_ids))
print('Number of fields = %s' % len(customer_records[0]))
print('Success!')
except ERPPeekError as e:
print(e.__class__, e)
print('Failure!')
示例2: sendNZB
# 需要导入模块: from xmlrpc.client import ServerProxy [as 别名]
# 或者: from xmlrpc.client.ServerProxy import version [as 别名]
def sendNZB(nzb, proper=False):
"""
Sends NZB to NZBGet client
:param nzb: nzb object
:param proper: True if a Proper download, False if not.
"""
if app.NZBGET_HOST is None:
log.warning('No NZBget host found in configuration.'
' Please configure it.')
return False
addToTop = False
nzbgetprio = 0
category = app.NZBGET_CATEGORY
if nzb.series.is_anime:
category = app.NZBGET_CATEGORY_ANIME
url = 'http{}://{}:{}@{}/xmlrpc'.format(
's' if app.NZBGET_USE_HTTPS else '',
app.NZBGET_USERNAME,
app.NZBGET_PASSWORD,
app.NZBGET_HOST)
if not NZBConnection(url):
return False
nzbGetRPC = ServerProxy(url)
dupekey = ''
dupescore = 0
# if it aired recently make it high priority and generate DupeKey/Score
for cur_ep in nzb.episodes:
if dupekey == '':
if cur_ep.series.indexer == 1:
dupekey = 'Medusa-' + text_type(cur_ep.series.indexerid)
elif cur_ep.series.indexer == 2:
dupekey = 'Medusa-tvr' + text_type(cur_ep.series.indexerid)
dupekey += '-' + text_type(cur_ep.season) + '.' + text_type(cur_ep.episode)
if datetime.date.today() - cur_ep.airdate <= datetime.timedelta(days=7):
addToTop = True
nzbgetprio = app.NZBGET_PRIORITY
else:
category = app.NZBGET_CATEGORY_BACKLOG
if nzb.series.is_anime:
category = app.NZBGET_CATEGORY_ANIME_BACKLOG
if nzb.quality != Quality.UNKNOWN:
dupescore = nzb.quality * 100
if proper:
dupescore += 10
nzbcontent64 = None
if nzb.result_type == 'nzbdata':
data = nzb.extra_info[0]
nzbcontent64 = standard_b64encode(data)
log.info('Sending NZB to NZBget')
log.debug('URL: {}', url)
try:
# Find out if nzbget supports priority (Version 9.0+),
# old versions beginning with a 0.x will use the old command
nzbget_version_str = nzbGetRPC.version()
nzbget_version = try_int(
nzbget_version_str[:nzbget_version_str.find('.')]
)
if nzbget_version == 0:
if nzbcontent64:
nzbget_result = nzbGetRPC.append(
nzb.name + '.nzb',
category,
addToTop,
nzbcontent64
)
else:
if nzb.result_type == 'nzb':
if not nzb.provider.login():
return False
# TODO: Check if this needs exception handling
data = nzb.provider.session(nzb.url).content
if data is None:
return False
nzbcontent64 = standard_b64encode(data)
nzbget_result = nzbGetRPC.append(
nzb.name + '.nzb',
category,
addToTop,
nzbcontent64
)
elif nzbget_version == 12:
if nzbcontent64 is not None:
nzbget_result = nzbGetRPC.append(
nzb.name + '.nzb', category, nzbgetprio, False,
nzbcontent64, False, dupekey, dupescore, 'score'
)
else:
#.........这里部分代码省略.........