diff options
author | bnewbold <bnewbold@robocracy.org> | 2011-06-26 14:50:51 -0400 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2011-06-26 14:50:51 -0400 |
commit | aeb73eaf4b377a55b5850b051a906d26f1bc8b43 (patch) | |
tree | d23e251df04dda93e2340a86814901ba071ef7c4 /code/templates/script.py | |
parent | ee59c4c14866b4dc555a530b9c557a481f56c02c (diff) | |
download | openwrt-repro-aeb73eaf4b377a55b5850b051a906d26f1bc8b43.tar.gz openwrt-repro-aeb73eaf4b377a55b5850b051a906d26f1bc8b43.zip |
new templates
Diffstat (limited to 'code/templates/script.py')
-rwxr-xr-x | code/templates/script.py | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/code/templates/script.py b/code/templates/script.py new file mode 100755 index 0000000..dccf20e --- /dev/null +++ b/code/templates/script.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +""" +SYNOPSIS + + TODO helloworld [-h,--help] [-v,--verbose] [--version] + +DESCRIPTION + + TODO This describes how to use this script. This docstring + will be printed by the script if there is an error or + if the user requests help (-h or --help). + +EXAMPLES + + TODO: Show some examples of how to use this script. + +EXIT STATUS + + TODO: List exit codes + +AUTHOR + + TODO: Name <name@example.org> + +LICENSE + + This script is in the public domain, free from copyrights or restrictions. + +VERSION + + $Id$ +""" + +import sys, os, traceback, optparse +import time +import re +#from pexpect import run, spawn + +def main (): + + global options, args + # TODO: Do something more interesting here... + print 'Hello world!' + +if __name__ == '__main__': + try: + start_time = time.time() + parser = optparse.OptionParser(formatter=optparse.TitledHelpFormatter(), usage=globals()['__doc__'], version='$Id$') + parser.add_option ('-v', '--verbose', action='store_true', default=False, help='verbose output') + (options, args) = parser.parse_args() + #if len(args) < 1: + # parser.error ('missing argument') + if options.verbose: print time.asctime() + main() + if options.verbose: print time.asctime() + if options.verbose: print 'TOTAL TIME IN MINUTES:', + if options.verbose: print (time.time() - start_time) / 60.0 + sys.exit(0) + except KeyboardInterrupt, e: # Ctrl-C + raise e + except SystemExit, e: # sys.exit() + raise e + except Exception, e: + print 'ERROR, UNEXPECTED EXCEPTION' + print str(e) + traceback.print_exc() + os._exit(1) |