Skip to content

Commit b962008

Browse files
author
Vladimir Kotal
committed
allow to break the commands cycle with return code 2
1 parent d7828c8 commit b962008

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

tools/sync/commands.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ def run(self):
7070
"""
7171
Run the sequence of commands and capture their output and return code.
7272
First command that returns code other than 0 terminates the sequence.
73+
If the command has return code 2, the sequence will be terminated
74+
however it will not be treated as error.
7375
"""
7476

7577
for command in self.commands:
@@ -81,9 +83,15 @@ def run(self):
8183
self.outputs[str(cmd)] = cmd.getoutput()
8284

8385
# If a command fails, terminate the sequence of commands.
84-
if cmd.getretcode() != 0:
85-
self.logger.debug("command {} failed, breaking".format(cmd))
86-
self.failed = True
86+
retcode = cmd.getretcode()
87+
if retcode != 0:
88+
if retcode == 2:
89+
self.logger.info("command '{}' requested break".
90+
format(cmd))
91+
else:
92+
self.logger.info("command '{}' failed with code {}, "
93+
"breaking".format(cmd, retcode))
94+
self.failed = True
8795
break
8896

8997
def check(self, ignore_errors):

tools/sync/mirror.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
if project_config.get('disabled'):
196196
logger.info("Project {} disabled, exiting".
197197
format(args.project))
198-
sys.exit(0)
198+
sys.exit(2)
199199

200200
lock = filelock.FileLock(os.path.join(tempfile.gettempdir(),
201201
args.project + "-mirror.lock"))

0 commit comments

Comments
 (0)