diff options
author | Luis Lozano <llozano@chromium.org> | 2015-12-15 13:49:30 -0800 |
---|---|---|
committer | Luis Lozano <llozano@chromium.org> | 2015-12-16 17:36:06 +0000 |
commit | f2a3ef46f75d2196a93d3ed27f4d1fcf22b54fbe (patch) | |
tree | 185d243c7eed7c7a0db6f0e640746cadc1479ea9 /sheriff_rotation.py | |
parent | 2a66f70fef907c1cb15229cb58e5129cb620ac98 (diff) | |
download | toolchain-utils-f2a3ef46f75d2196a93d3ed27f4d1fcf22b54fbe.tar.gz |
Run pyformat on all the toolchain-utils files.
This gets rid of a lot of lint issues.
Ran by doing this:
for f in *.py; do echo -n "$f " ; if [ -x $f ]; then pyformat -i
--remove_trailing_comma --yapf --force_quote_type=double $f ; else
pyformat -i --remove_shebang --remove_trailing_comma --yapf
--force_quote_type=double $f ; fi ; done
BUG=chromium:567921
TEST=Ran simple crosperf run.
Change-Id: I59778835fdaa5f706d2e1765924389f9e97433d1
Reviewed-on: https://chrome-internal-review.googlesource.com/242031
Reviewed-by: Luis Lozano <llozano@chromium.org>
Commit-Queue: Luis Lozano <llozano@chromium.org>
Tested-by: Luis Lozano <llozano@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@google.com>
Diffstat (limited to 'sheriff_rotation.py')
-rwxr-xr-x | sheriff_rotation.py | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/sheriff_rotation.py b/sheriff_rotation.py index 64c655f5..718bdb26 100755 --- a/sheriff_rotation.py +++ b/sheriff_rotation.py @@ -1,13 +1,12 @@ #!/usr/bin/python # # Copyright 2010 Google Inc. All Rights Reserved. - """Script to build the ChromeOS toolchain. This script sets up the toolchain if you give it the gcctools directory. """ -__author__ = "asharif@google.com (Ahmad Sharif)" +__author__ = 'asharif@google.com (Ahmad Sharif)' import datetime import os @@ -18,9 +17,10 @@ from utils import email_sender class SheriffHandler(object): - SHERIFF_FILE = os.path.join(constants.CROSTC_WORKSPACE, "sheriffs.txt") - SUBJECT = "You (%s) are the sheriff for the week: %s - %s" - BODY = "Please see instructions here: https://sites.google.com/a/google.com/chromeos-toolchain-team-home2/home/sheriff-s-corner/sheriff-duties" + SHERIFF_FILE = os.path.join(constants.CROSTC_WORKSPACE, 'sheriffs.txt') + SUBJECT = 'You (%s) are the sheriff for the week: %s - %s' + BODY = ('Please see instructions here: ' + 'https://sites.google.com/a/google.com/chromeos-toolchain-team-home2/home/sheriff-s-corner/sheriff-duties') def GetWeekInfo(self, day=datetime.datetime.today()): """Return week_start, week_end.""" @@ -28,14 +28,14 @@ class SheriffHandler(object): epoch = datetime.datetime.utcfromtimestamp(0) delta_since_epoch = day - epoch - abs_days = abs(delta_since_epoch.days) - 2 # To get it to start from Sat. + abs_days = abs(delta_since_epoch.days) - 2 # To get it to start from Sat. weeks_since_epoch = abs_days / 7 day_of_week = abs_days % 7 week_begin = day - datetime.timedelta(days=day_of_week) week_end = day + datetime.timedelta(days=(6 - day_of_week)) - strftime_format = "%A, %B %d %Y" + strftime_format = '%A, %B %d %Y' return (week_begin.strftime(strftime_format), week_end.strftime(strftime_format)) @@ -46,14 +46,14 @@ class SheriffHandler(object): def ReadSheriffsAsList(self): """Return the sheriff file contents.""" - contents = "" - with open(self.SHERIFF_FILE, "r") as f: + contents = '' + with open(self.SHERIFF_FILE, 'r') as f: contents = f.read() return contents.splitlines() def WriteSheriffsAsList(self, to_write): - with open(self.SHERIFF_FILE, "w") as f: - f.write("\n".join(to_write)) + with open(self.SHERIFF_FILE, 'w') as f: + f.write('\n'.join(to_write)) def GetRotatedSheriffs(self, num_rotations=1): """Return the sheriff file contents.""" @@ -61,8 +61,8 @@ class SheriffHandler(object): new_sheriff_list = [] num_rotations = num_rotations % len(sheriff_list) - new_sheriff_list = (sheriff_list[num_rotations:] + - sheriff_list[:num_rotations]) + new_sheriff_list = ( + sheriff_list[num_rotations:] + sheriff_list[:num_rotations]) return new_sheriff_list def Email(self): @@ -74,26 +74,26 @@ class SheriffHandler(object): subject, self.BODY, email_from=os.path.basename(__file__), - email_cc=["c-compiler-chrome"]) + email_cc=['c-compiler-chrome']) def Main(argv): parser = optparse.OptionParser() - parser.add_option("-e", - "--email", - dest="email", - action="store_true", - help="Email the sheriff.") - parser.add_option("-r", - "--rotate", - dest="rotate", - help="Print sheriffs after n rotations.") - parser.add_option("-w", - "--write", - dest="write", - action="store_true", + parser.add_option('-e', + '--email', + dest='email', + action='store_true', + help='Email the sheriff.') + parser.add_option('-r', + '--rotate', + dest='rotate', + help='Print sheriffs after n rotations.') + parser.add_option('-w', + '--write', + dest='write', + action='store_true', default=False, - help="Wrote rotated contents to the sheriff file.") + help='Wrote rotated contents to the sheriff file.') options, _ = parser.parse_args(argv) @@ -102,22 +102,23 @@ def Main(argv): current_sheriff = sheriff_handler.GetCurrentSheriff() week_start, week_end = sheriff_handler.GetWeekInfo() - print "Current sheriff: %s (%s - %s)" % (current_sheriff, week_start, week_end) + print 'Current sheriff: %s (%s - %s)' % (current_sheriff, week_start, + week_end) if options.email: sheriff_handler.Email() if options.rotate: rotated_sheriffs = sheriff_handler.GetRotatedSheriffs(int(options.rotate)) - print "Rotated sheriffs (after %s rotations)" % options.rotate - print "\n".join(rotated_sheriffs) + print 'Rotated sheriffs (after %s rotations)' % options.rotate + print '\n'.join(rotated_sheriffs) if options.write: sheriff_handler.WriteSheriffsAsList(rotated_sheriffs) - print "Rotated sheriffs written to file." + print 'Rotated sheriffs written to file.' return 0 -if __name__ == "__main__": +if __name__ == '__main__': retval = Main(sys.argv) sys.exit(retval) |