aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorJon Bernard <bernardj@gmail.com>2010-09-18 12:28:31 -0400
committerJon Bernard <bernardj@gmail.com>2010-09-18 12:28:31 -0400
commit9458b75cd770e13668c13e9bbe006afd0a9c9891 (patch)
treef56d83c33c3f6c9fca1b0f4d36ab651a750f1893 /bin
downloadpepseq-9458b75cd770e13668c13e9bbe006afd0a9c9891.zip
Initial commit
Diffstat (limited to 'bin')
-rwxr-xr-xbin/pepseq60
1 files changed, 60 insertions, 0 deletions
diff --git a/bin/pepseq b/bin/pepseq
new file mode 100755
index 0000000..ef824fc
--- /dev/null
+++ b/bin/pepseq
@@ -0,0 +1,60 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import gettext
+import logging
+import optparse
+import os
+import sys
+
+import gettext
+from gettext import gettext as _
+gettext.textdomain('pepseq')
+
+# Add project root directory (enable symlink, and trunk execution).
+PROJECT_ROOT_DIRECTORY = os.path.abspath(
+ os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))))
+
+if (os.path.exists(os.path.join(PROJECT_ROOT_DIRECTORY, 'pepseq'))
+ and PROJECT_ROOT_DIRECTORY not in sys.path):
+ sys.path.insert(0, PROJECT_ROOT_DIRECTORY)
+ os.putenv('PYTHONPATH', PROJECT_ROOT_DIRECTORY) # for subprocesses
+
+from pepseq import pepseqconfig
+
+LEVELS = ( logging.ERROR,
+ logging.WARNING,
+ logging.INFO,
+ logging.DEBUG,
+ )
+
+if __name__ == "__main__":
+
+ version = pepseqconfig.__pepseq_data_directory__
+ # Support for command line options.
+ usage = _("pepseq [options]")
+ parser = optparse.OptionParser(version="pepseq %s" % version, usage=usage)
+ parser.add_option('-d', '--debug', dest='debug_mode', action='store_true',
+ help=_('Print the maximum debugging info (implies -vv)'))
+ parser.add_option('-v', '--verbose', dest='logging_level', action='count',
+ help=_('set error_level output to warning, info, and then debug'))
+ # exemple of silly CLI option
+ parser.add_option("-f", "--foo", action="store", dest="foo",
+ help=_("foo should be assigned to bar"))
+ parser.set_defaults(logging_level=0, foo=None)
+ (options, args) = parser.parse_args()
+
+ # set the verbosity
+ if options.debug_mode:
+ options.logging_level = 3
+ logging.basicConfig(level=LEVELS[options.logging_level], format='%(asctime)s %(levelname)s %(message)s')
+
+
+ # this is the easter egg (:
+ if options.foo == 'bar':
+ logging.warning(_('easter egg found'))
+ print(_("Schweet"))
+
+ # Run your cli application there.
+ print _("I'm launched and my args are: %s") % (" ".join(args))
+ logging.debug(_('end of prog'))