本文整理汇总了Python中models.Actor.get_dbid方法的典型用法代码示例。如果您正苦于以下问题:Python Actor.get_dbid方法的具体用法?Python Actor.get_dbid怎么用?Python Actor.get_dbid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Actor
的用法示例。
在下文中一共展示了Actor.get_dbid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: put
# 需要导入模块: from models import Actor [as 别名]
# 或者: from models.Actor import get_dbid [as 别名]
def put(self, actor_id):
dbid = Actor.get_dbid(g.tenant, actor_id)
try:
actor = Actor.from_db(actors_store[dbid])
except KeyError:
raise APIException(
"actor not found: {}'".format(actor_id), 404)
previous_image = actor.image
args = self.validate_put(actor)
args['tenant'] = g.tenant
update_image = False
if args['image'] == previous_image:
args['status'] = actor.status
else:
update_image = True
args['status'] = SUBMITTED
args['api_server'] = g.api_server
args['owner'] = g.user
actor = Actor(**args)
actors_store[actor.db_id] = actor.to_db()
if update_image:
ch = CommandChannel()
ch.put_cmd(actor_id=actor.db_id, image=actor.image, tenant=args['tenant'])
# return ok(result={'update_image': str(update_image)},
# msg="Actor updated successfully.")
return ok(result=actor.display(),
msg="Actor updated successfully.")
示例2: get
# 需要导入模块: from models import Actor [as 别名]
# 或者: from models.Actor import get_dbid [as 别名]
def get(self, actor_id, execution_id):
def get_hypermedia(actor, exc):
return {'_links': {'self': '{}/actors/v2/{}/executions/{}/logs'.format(actor.api_server, actor.id, exc.id),
'owner': '{}/profiles/v2/{}'.format(actor.api_server, actor.owner),
'execution': '{}/actors/v2/{}/executions/{}'.format(actor.api_server, actor.id, exc.id)},
}
dbid = Actor.get_dbid(g.tenant, actor_id)
try:
actor = Actor.from_db(actors_store[dbid])
except KeyError:
raise APIException(
"actor not found: {}'".format(actor_id), 404)
try:
excs = executions_store[dbid]
except KeyError:
raise APIException("No executions found for actor {}.".format(actor_id))
try:
exc = Execution.from_db(excs[execution_id])
except KeyError:
raise APIException("Execution not found {}.".format(execution_id))
try:
logs = logs_store[execution_id]
except KeyError:
logs = ""
result={'logs': logs}
result.update(get_hypermedia(actor, exc))
return ok(result, msg="Logs retrieved successfully.")
示例3: delete
# 需要导入模块: from models import Actor [as 别名]
# 或者: from models.Actor import get_dbid [as 别名]
def delete(self, actor_id, ch_name):
id = Actor.get_dbid(g.tenant, actor_id)
try:
worker = Worker.get_worker(id, ch_name)
except WorkerException as e:
raise APIException(e.msg, 404)
shutdown_worker(ch_name)
return ok(result=None, msg="Worker scheduled to be stopped.")
示例4: post
# 需要导入模块: from models import Actor [as 别名]
# 或者: from models.Actor import get_dbid [as 别名]
def post(self, actor_id):
id = Actor.get_dbid(g.tenant, actor_id)
try:
actor = Actor.from_db(actors_store[id])
except KeyError:
raise APIException(
"actor not found: {}'".format(actor_id), 404)
args = self.validate_post()
Execution.add_execution(id, args)
return ok(result=actor.display(), msg="Actor execution added successfully.")