Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos.buildout
Commits
fbd5b6b1
Commit
fbd5b6b1
authored
Mar 16, 2013
by
Jim Fulton
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #89 from reinout/sys-exit-when-restarting-fix
Fix for #73: proper sys.exit code when restarting buildout
parents
4becdee2
63fb5214
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
4 deletions
+77
-4
src/zc/buildout/buildout.py
src/zc/buildout/buildout.py
+5
-2
src/zc/buildout/testing.py
src/zc/buildout/testing.py
+7
-2
src/zc/buildout/update.txt
src/zc/buildout/update.txt
+65
-0
No files found.
src/zc/buildout/buildout.py
View file @
fbd5b6b1
...
@@ -1899,7 +1899,10 @@ def main(args=None):
...
@@ -1899,7 +1899,10 @@ def main(args=None):
command
,
args
)
command
,
args
)
getattr
(
buildout
,
command
)(
args
)
getattr
(
buildout
,
command
)(
args
)
except
SystemExit
:
except
SystemExit
:
pass
logging
.
shutdown
()
# Make sure we properly propagate an exit code from a restarted
# buildout process.
raise
except
Exception
:
except
Exception
:
v
=
sys
.
exc_info
()[
1
]
v
=
sys
.
exc_info
()[
1
]
_doing
()
_doing
()
...
@@ -1920,10 +1923,10 @@ def main(args=None):
...
@@ -1920,10 +1923,10 @@ def main(args=None):
traceback
.
print_exception
(
*
exc_info
)
traceback
.
print_exception
(
*
exc_info
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
finally
:
finally
:
logging
.
shutdown
()
logging
.
shutdown
()
if
sys
.
version_info
[:
2
]
<
(
2
,
4
):
if
sys
.
version_info
[:
2
]
<
(
2
,
4
):
def
reversed
(
iterable
):
def
reversed
(
iterable
):
result
=
list
(
iterable
);
result
=
list
(
iterable
);
...
...
src/zc/buildout/testing.py
View file @
fbd5b6b1
...
@@ -107,7 +107,7 @@ def clean_up_pyc(*path):
...
@@ -107,7 +107,7 @@ def clean_up_pyc(*path):
## FIXME - check for other platforms
## FIXME - check for other platforms
MUST_CLOSE_FDS
=
not
sys
.
platform
.
startswith
(
'win'
)
MUST_CLOSE_FDS
=
not
sys
.
platform
.
startswith
(
'win'
)
def
system
(
command
,
input
=
''
):
def
system
(
command
,
input
=
''
,
with_exit_code
=
False
):
p
=
subprocess
.
Popen
(
command
,
p
=
subprocess
.
Popen
(
command
,
shell
=
True
,
shell
=
True
,
stdin
=
subprocess
.
PIPE
,
stdin
=
subprocess
.
PIPE
,
...
@@ -121,7 +121,12 @@ def system(command, input=''):
...
@@ -121,7 +121,12 @@ def system(command, input=''):
result
=
o
.
read
()
+
e
.
read
()
result
=
o
.
read
()
+
e
.
read
()
o
.
close
()
o
.
close
()
e
.
close
()
e
.
close
()
return
result
.
decode
()
output
=
result
.
decode
()
if
with_exit_code
:
# Use the with_exit_code=True parameter when you want to test the exit
# code of the command you're running.
output
+=
'EXIT CODE: %s'
%
p
.
wait
()
return
output
def
get
(
url
):
def
get
(
url
):
return
str
(
urlopen
(
url
).
read
().
decode
())
return
str
(
urlopen
(
url
).
read
().
decode
())
...
...
src/zc/buildout/update.txt
View file @
fbd5b6b1
...
@@ -234,3 +234,68 @@ directory:
...
@@ -234,3 +234,68 @@ directory:
<BLANKLINE>
<BLANKLINE>
if __name__ == '__main__':
if __name__ == '__main__':
sys.exit(zc.buildout.buildout.main())
sys.exit(zc.buildout.buildout.main())
When buildout restarts and the restarted buildout exits with an error code,
the original buildout that called the second buildout also exits with that
error code. Otherwise build scripts can erroneously detect a succesful
buildout run even if it failed.
Make a recipe that fails:
>>> mkdir(sample_buildout, 'failrecipe')
>>> write(sample_buildout, 'failrecipe', 'failrecipe.py',
... """
... import pkg_resources
... import sys
... print_ = lambda *a: sys.stdout.write(' '.join(map(str, a))+'\\n')
...
... class Recipe:
...
... def __init__(self, buildout, name, options):
... sys.exit('recipe sys-exits')
...
... def install(self):
... pass
...
... update = install
... """)
>>> write(sample_buildout, 'failrecipe', 'setup.py',
... """
... from setuptools import setup
...
... setup(
... name = "failrecipe",
... entry_points = {'zc.buildout': ['default = failrecipe:Recipe']},
... )
... """)
Let's downgrade again, triggering a restart. And use the failing recipe that
gives us a sys.exit:
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... find-links = %(new_releases)s
... index = %(new_releases)s
... parts = fail
... develop = failrecipe
...
... [versions]
... zc.buildout = < 99
... distribute = < 99
...
... [fail]
... recipe = failrecipe
... """ % dict(new_releases=new_releases))
Run the buildout:
>>> print_(system(buildout, with_exit_code=True), end='')
Upgraded:
zc.buildout version 1.4.4;
distribute version 0.6;
restarting.
Generated script '/sample-buildout/bin/buildout'.
Develop: '/sample-buildout/failrecipe'
recipe sys-exits
EXIT CODE: 1
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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