Commit c5dd51bf authored by Aleksey Shirokih's avatar Aleksey Shirokih
Browse files

Simplify code

parent ed8c22fb
......@@ -102,24 +102,23 @@ class PullAPI(API):
env = job.environment
status = True
log = []
try:
unpack_url(Link(env.playbook_link), env.playbook_path)
except KeyboardInterrupt:
raise
except Exception as e:
logger.error("Pull error: %s", e)
status = False
try:
for role in Role.select().where(Role.environment == env, Role.is_enabled == True): # noqa
unpack_url(Link(role.link), role.role_path)
except KeyboardInterrupt:
raise
except Exception as e:
logger.error("Roles pull error: %s", e)
status = False
to_pull = [(env.playbook_link, env.playbook_path)]
for role in Role.select().where(Role.environment == env, Role.is_enabled == True): # noqa
to_pull.append((role.link, role.role_path))
for line in reversed(to_pull):
self.pull(line[0], line[1])
with db.atomic():
job.complete_ts = datetime.datetime.now()
job.status = status
job.log = "\n".join(log)
job.save()
@staticmethod
def pull(link, path):
try:
unpack_url(Link(link), path)
except KeyboardInterrupt:
raise
except Exception as e:
logger.error("Pull error: %s", e)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment