Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Konstantin A
tower
Commits
c5dd51bf
Commit
c5dd51bf
authored
Feb 23, 2018
by
Aleksey Shirokih
Browse files
Simplify code
parent
ed8c22fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
tower/api/pull.py
View file @
c5dd51bf
...
...
@@ -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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment