-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f350ec
commit 6f1e069
Showing
4 changed files
with
706 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,5 @@ target/ | |
FoundationPlist.py | ||
|
||
# Go junk | ||
bin/ | ||
vendor/ | ||
report_broken_client/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/python | ||
|
||
import subprocess | ||
import optparse | ||
import time | ||
|
||
def get_options(): | ||
"""Return commandline options.""" | ||
usage = "%prog [options]" | ||
option_parser = optparse.OptionParser(usage=usage) | ||
option_parser.add_option( | ||
"--delay", default=0, type=int, | ||
help="Delay running for between 0 and N seconds.") | ||
option_parser.add_option( | ||
"--path", default='/usr/local/sal/bin/sal-submit', type=str, | ||
help="Path to script to run") | ||
# We have no arguments, so don't store the results. | ||
opts, _ = option_parser.parse_args() | ||
return opts | ||
|
||
def random_delay(delay): | ||
if delay == 0: | ||
print 'No delay set' | ||
return | ||
randomized_delay = random.randrange(0, delay) | ||
print "Delaying run by %s seconds" % randomized_delay | ||
time.sleep(randomized_delay) | ||
|
||
def execute_path(path): | ||
path_stat = os.stat(path) | ||
if not path_stat.st_mode & stat.S_IWOTH: | ||
try: | ||
subprocess.call([path], stdin=None) | ||
except (OSError, subprocess.CalledProcessError): | ||
print "'{}' had errors during execution!".format(path) | ||
else: | ||
print "'{}' is not executable or has bad permissions".format(path) | ||
|
||
def main(): | ||
opts = get_options() | ||
path = opts.path | ||
delay = opts.delay | ||
|
||
if delay > 0: | ||
random_delay(delay) | ||
|
||
execute_path(path) | ||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.