/usr/share/quickly/templates/ubuntu-cli/project_root/python/__init__.py is in quickly-ubuntu-template 12.08.1-0ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | import logging
import optparse
from locale import gettext as _
from python_name import python_nameconfig
LEVELS = ( logging.ERROR,
logging.WARNING,
logging.INFO,
logging.DEBUG,
)
def main():
version = python_nameconfig.__version__
# Support for command line options.
usage = _("project_name [options]")
parser = optparse.OptionParser(version="%%prog %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'))
if __name__ == "__main__":
main()
|