本文整理汇总了Python中backend.Backend.post_job方法的典型用法代码示例。如果您正苦于以下问题:Python Backend.post_job方法的具体用法?Python Backend.post_job怎么用?Python Backend.post_job使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backend.Backend
的用法示例。
在下文中一共展示了Backend.post_job方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Scheduler
# 需要导入模块: from backend import Backend [as 别名]
# 或者: from backend.Backend import post_job [as 别名]
class Scheduler(object):
# structure = {
# 'type': IS(*TYPE.values_both_types()),
# 'state': IS(*STATE.values_both_types()),
# 'jobInfo': dict,
# accountId, bundleId, storeCountry, appType{appstore,cydia}
# 'worker': Worker,
# 'device': Device,
# 'date_added': float
# }
@classmethod
def _default_runjob(cls):
return {
'type':'run_app',
'state':'pending',
'jobInfo': {
'appType':'AppStoreApp'
},
}
def __init__(self, backendUrl):
self.backend = Backend(backendUrl)
def schedule_job(self, jobDict):
job = Scheduler._default_runjob()
job = dict_merge(job, jobDict)
jobId = self.backend.post_job(job)
return jobId
def schedule_bundleId(self, bundleId, worker=None, device=None, account=None, country=None, executionStrategy=None):
jobDict = {
'jobInfo': {
'bundleId':bundleId
}
}
if worker:
jobDict['worker'] = worker
if device:
jobDict['device'] = device
if account:
jobDict['jobInfo']['accountId'] = account
if country:
jobDict['jobInfo']['storeCountry'] = country
if executionStrategy:
jobDict['jobInfo']['executionStrategy'] = executionStrategy
return self.schedule_job(jobDict)
def schedule_appId(self, appId, account=None, country=None, executionStrategy=None):
url = 'http://itunes.apple.com/lookup?id=%s' % appId
r = requests.get(url)
if r.status_code != 200:
logging.error("Requests to %s failed: %s", (url, r.text))
return False
resDict = json.loads(r.text)
results = resDict['results']
if len(results) != 1:
logger.error("No app with id %s found", (appId))
return False
return self.schedule_bundleId(results[0]['bundleId'], account=account, country=country, executionStrategy=None)
def schedule_itunes(self, url, account=None, country=None, executionStrategy=None):
logger.info('Adding apps from iTunes (%s)' % url)
r = requests.get(url)
if r.status_code != 200:
logging.error("Requests to %s failed: %s", (url, r.text))
return False
resDict = json.loads(r.text)
entries = resDict['feed']['entry']
result = True
for entry in entries:
if not self.schedule_bundleId(entry['id']['attributes']['im:bundleId'], account=account, country=country, executionStrategy=None):
result = False
return result
示例2: Scheduler
# 需要导入模块: from backend import Backend [as 别名]
# 或者: from backend.Backend import post_job [as 别名]
class Scheduler(object):
# structure = {
# 'type': IS(*TYPE.values_both_types()),
# 'state': IS(*STATE.values_both_types()),
# 'jobInfo': dict,
# accountId, bundleId, storeCountry, appType{appstore,cydia}
# 'worker': Worker,
# 'device': Device,
# 'date_added': float
# }
@classmethod
def _default_runjob(cls):
return {
'type':'run_app',
'state':'pending',
'jobInfo': {
'appType':'AppStoreApp'
},
}
@classmethod
def _default_dioscopejob(cls):
return {
'type':'dioscope',
'state':'pending',
'jobInfo': {
'appType':'AppStoreApp'
}
}
def __init__(self, backendUrl):
self.backend = Backend(backendUrl)
def schedule_job(self, jobDict, type='run'):
if type == 'dioscope':
job = Scheduler._default_dioscopejob()
else:
job = Scheduler._default_runjob()
job = dict_merge(job, jobDict)
jobId = self.backend.post_job(job)
return jobId
def schedule_bundleId(self, bundleId, worker=None, device=None, account=None, country=None, executionStrategy=None, type='run'):
jobDict = {
'jobInfo': {
'bundleId':bundleId
}
}
if worker:
jobDict['worker'] = worker
if device:
jobDict['device'] = device
if account:
jobDict['jobInfo']['accountId'] = account
if country:
jobDict['jobInfo']['storeCountry'] = country
if executionStrategy:
jobDict['jobInfo']['executionStrategy'] = executionStrategy
return self.schedule_job(jobDict, type)
def schedule_appId(self, appId, account=None, country=None, executionStrategy=None):
url = 'http://itunes.apple.com/lookup?id=%s' % appId
r = requests.get(url)
if r.status_code != 200:
logging.error("Requests to %s failed: %s", (url, r.text))
return False
resDict = json.loads(r.text)
results = resDict['results']
if len(results) != 1:
logger.error("No app with id %s found", (appId))
return False
return self.schedule_bundleId(results[0]['bundleId'], account=account, country=country, executionStrategy=None)
def schedule_itunes(self, url, account=None, country=None, executionStrategy=None):
logger.info('Adding apps from iTunes (%s)' % url)
r = requests.get(url)
if r.status_code != 200:
logging.error("Requests to %s failed: %s", (url, r.text))
return False
resDict = json.loads(r.text)
entries = resDict['feed']['entry']
result = True
for entry in entries:
if not self.schedule_bundleId(entry['id']['attributes']['im:bundleId'], account=account, country=country, executionStrategy=None):
result = False
return result
def schedule_dioscope_new(self, host, index, account=None, country=None, executionStrategy=None):
es = Elasticsearch([host])
result = es.search(index=index, doc_type="app", fields="bundleId.untouched,currentVersionReleaseDate,version", size=1000)
apps = result['hits']['hits']
count = 0
#.........这里部分代码省略.........