Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Issue 955993006: Handle KeyboardInterrupt consistently in python scripts (Closed)

Created:
5 years, 10 months ago by Sam Clegg
Modified:
5 years, 9 months ago
Reviewers:
yosin_UTC9, M-A Ruel
CC:
chromium-reviews, cmp-cc_chromium.org, dpranke+depot_tools_chromium.org, iannucci+depot_tools_chromium.org, tfarina
Target Ref:
refs/heads/master
Project:
tools
Visibility:
Public.

Description

Handle KeyboardInterrupt consistently in python scripts Handle KeyboardInterrupt gracefully rather the printing a backtrace. Most users of these tools don't expect a backtrace when then hit Ctrl-C. Also, fix a few other inconsistencies found in the python startup code of these different scripts: - always call main function 'main' (rather than 'Main') - always return 0 from main function - if main takes args never include argv[0] Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=294250

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : #

Patch Set 4 : #

Total comments: 4

Patch Set 5 : #

Patch Set 6 : tweek test expectations #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+216 lines, -70 lines) Patch
M apply_issue.py View 1 2 3 4 1 chunk +5 lines, -1 line 0 comments Download
M chrome-update.py View 1 2 3 4 2 chunks +6 lines, -2 lines 0 comments Download
M clang_format.py View 1 2 3 4 1 chunk +6 lines, -2 lines 2 comments Download
M commit_queue.py View 1 2 3 4 1 chunk +5 lines, -1 line 0 comments Download
M drover.py View 1 2 3 4 1 chunk +5 lines, -1 line 0 comments Download
M fetch.py View 1 2 3 4 1 chunk +5 lines, -1 line 0 comments Download
M gcl.py View 1 2 3 4 1 chunk +5 lines, -1 line 0 comments Download
M gclient.py View 1 2 3 4 2 chunks +7 lines, -2 lines 0 comments Download
M git_auto_svn.py View 1 2 3 4 2 chunks +7 lines, -2 lines 0 comments Download
M git_cache.py View 1 2 3 4 1 chunk +5 lines, -1 line 0 comments Download
M git_cherry_pick_upload.py View 1 2 3 4 1 chunk +7 lines, -1 line 0 comments Download
M git_cl.py View 1 2 3 4 2 chunks +6 lines, -1 line 0 comments Download
M git_footers.py View 1 2 3 4 1 chunk +6 lines, -1 line 0 comments Download
M git_freezer.py View 1 2 3 4 1 chunk +8 lines, -3 lines 0 comments Download
M git_map.py View 1 2 3 4 2 chunks +7 lines, -4 lines 0 comments Download
M git_map_branches.py View 1 2 3 4 1 chunk +7 lines, -2 lines 0 comments Download
M git_mark_merge_base.py View 1 2 3 4 2 chunks +6 lines, -3 lines 0 comments Download
M git_nav_downstream.py View 1 2 3 4 2 chunks +5 lines, -2 lines 0 comments Download
M git_new_branch.py View 1 2 3 4 1 chunk +6 lines, -1 line 0 comments Download
M git_number.py View 1 2 3 4 1 chunk +17 lines, -16 lines 0 comments Download
M git_rebase_update.py View 1 2 3 4 2 chunks +6 lines, -2 lines 0 comments Download
M git_rename_branch.py View 1 2 3 4 1 chunk +6 lines, -1 line 0 comments Download
M git_reparent_branch.py View 1 2 3 4 1 chunk +5 lines, -1 line 0 comments Download
M git_retry.py View 1 2 3 4 1 chunk +5 lines, -1 line 0 comments Download
M git_squash_branch.py View 1 2 3 4 1 chunk +7 lines, -1 line 0 comments Download
M git_try.py View 1 2 3 4 2 chunks +10 lines, -2 lines 0 comments Download
M git_upstream_diff.py View 1 2 3 4 1 chunk +6 lines, -2 lines 0 comments Download
M gn.py View 1 2 3 4 1 chunk +5 lines, -1 line 0 comments Download
M my_activity.py View 1 2 3 4 1 chunk +5 lines, -1 line 0 comments Download
M my_reviews.py View 1 2 3 4 1 chunk +5 lines, -1 line 0 comments Download
M presubmit_support.py View 1 2 3 4 2 chunks +6 lines, -2 lines 0 comments Download
M pylint.py View 1 2 3 4 1 chunk +5 lines, -1 line 0 comments Download
M roll_dep.py View 1 2 3 4 1 chunk +5 lines, -1 line 0 comments Download
M tests/presubmit_unittest.py View 1 2 3 4 5 3 chunks +3 lines, -3 lines 0 comments Download
M upload_to_google_storage.py View 1 2 3 4 2 chunks +6 lines, -2 lines 0 comments Download

Messages

Total messages: 14 (4 generated)
Sam Clegg
I considered also having main always take args=None and never passing sys.argv[1], but this change ...
5 years, 10 months ago (2015-02-26 00:51:36 UTC) #2
M-A Ruel
Only change is could you print to sys.stderr instead? https://codereview.chromium.org/955993006/diff/60001/git_number.py File git_number.py (right): https://codereview.chromium.org/955993006/diff/60001/git_number.py#newcode278 git_number.py:278: ...
5 years, 10 months ago (2015-02-26 00:57:40 UTC) #3
Sam Clegg
Done. https://codereview.chromium.org/955993006/diff/60001/git_number.py File git_number.py (right): https://codereview.chromium.org/955993006/diff/60001/git_number.py#newcode278 git_number.py:278: except KeyboardInterrupt: On 2015/02/26 00:57:39, M-A Ruel wrote: ...
5 years, 10 months ago (2015-02-26 17:29:21 UTC) #4
M-A Ruel
lgtm, thanks!
5 years, 10 months ago (2015-02-26 17:49:22 UTC) #5
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/955993006/100001
5 years, 10 months ago (2015-02-26 18:25:26 UTC) #8
commit-bot: I haz the power
Committed patchset #6 (id:100001) as http://src.chromium.org/viewvc/chrome?view=rev&revision=294250
5 years, 10 months ago (2015-02-26 18:28:45 UTC) #9
yosin_UTC9
https://codereview.chromium.org/955993006/diff/100001/clang_format.py File clang_format.py (right): https://codereview.chromium.org/955993006/diff/100001/clang_format.py#newcode70 clang_format.py:70: sys.exit(main(sys.argv[1])) Q: Is using |argv[1]| rather than |argv[1:]| intentional? ...
5 years, 9 months ago (2015-02-28 13:11:56 UTC) #11
Sam Clegg
On 2015/02/28 13:11:56, Yosi_UTC9 wrote: > https://codereview.chromium.org/955993006/diff/100001/clang_format.py > File clang_format.py (right): > > https://codereview.chromium.org/955993006/diff/100001/clang_format.py#newcode70 > ...
5 years, 9 months ago (2015-02-28 15:33:12 UTC) #12
tfarina
https://codereview.chromium.org/955993006/diff/100001/clang_format.py File clang_format.py (right): https://codereview.chromium.org/955993006/diff/100001/clang_format.py#newcode65 clang_format.py:65: return subprocess.call([tool] + args) Looks like this broke my ...
5 years, 9 months ago (2015-02-28 18:59:27 UTC) #13
tfarina
5 years, 9 months ago (2015-02-28 19:07:06 UTC) #14
Message was sent while issue was closed.
I have a fix for that -> https://codereview.chromium.org/972453002

Powered by Google App Engine
This is Rietveld 408576698