Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit d4a3cfe

Browse files
committed
cleaned up error exit processing - because it was not correct
1 parent b15d20c commit d4a3cfe

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

cli4/cli4.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,14 @@ def run_command(cf, method, command, params=None, content=None, files=None):
202202
if len(e) > 0:
203203
# more than one error returned by the API
204204
for x in e:
205-
sys.stderr.write('cli4: /%s - %d %s\n' % (command, x, x))
206-
sys.stderr.write('cli4: /%s - %d %s\n' % (command, int(e), e))
205+
sys.stderr.write('cli4: /%s - %d %s\n' % (command, int(x), str(x)))
206+
sys.stderr.write('cli4: /%s - %d %s\n' % (command, int(e), str(e)))
207207
raise e
208208
except CloudFlare.exceptions.CloudFlareInternalError as e:
209-
sys.stderr.write('cli4: InternalError: /%s - %d %s\n' % (command, int(e), e))
209+
sys.stderr.write('cli4: InternalError: /%s - %d %s\n' % (command, int(e), str(e)))
210210
raise e
211211
except Exception as e:
212-
sys.stderr.write('cli4: /%s - %s - api error\n' % (command, e))
212+
sys.stderr.write('cli4: /%s - %s - api error\n' % (command, str(e)))
213213
raise e
214214

215215
results.append(r)
@@ -454,16 +454,18 @@ def do_it(args):
454454
except Exception as e:
455455
sys.exit(e)
456456

457+
exit_with_error = False
457458
for command in commands:
458459
try:
459460
results = run_command(cf, method, command, params, content, files)
460461
write_results(results, output)
461462
except KeyboardInterrupt as e:
462463
sys.exit('cli4: %s - Interrupted\n' % (command))
463464
except Exception as e:
464-
if len(commands) > 1:
465-
continue
466-
sys.exit(e)
465+
exit_with_error = True
466+
467+
if exit_with_error:
468+
sys.exit(1)
467469

468470
def cli4(args):
469471
"""Cloudflare API via command line"""

0 commit comments

Comments
 (0)