aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-05-01 22:35:15 +0200
committerGuido Günther <agx@sigxcpu.org>2011-05-01 22:35:15 +0200
commitadd935ff05e960de47ee8ecccbdc1e48cdd0219d (patch)
treeb432f1bf4c23ab21109421a8379fe278c30cc338
parenta2a2aac10c248cc3a7467ca4bbe51bcc5478fdd0 (diff)
Add option parser
se we can enable debugging by default
-rwxr-xr-xsrc/prepaid-manager-applet.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/prepaid-manager-applet.py b/src/prepaid-manager-applet.py
index 66f3609..77de3ed 100755
--- a/src/prepaid-manager-applet.py
+++ b/src/prepaid-manager-applet.py
@@ -27,6 +27,7 @@ from gi.repository import Gtk
import locale
import logging
import os
+import sys
import time
import ppm
@@ -635,8 +636,18 @@ def setup_schemas():
os.environ["GSETTINGS_SCHEMA_DIR"] = "data"
-def main():
- logging.basicConfig(level=logging.DEBUG,
+def main(args):
+ parser = glib.option.OptionParser()
+ parser.add_option("--debug", "-d", action="store_true", dest="debug",
+ help="enable debugging", default=False)
+ options, args = parser.parse_args()
+
+ if options.debug:
+ log_level = logging.DEBUG
+ else:
+ log_level = logging.INFO
+
+ logging.basicConfig(level=log_level,
format='ppm: %(levelname)s: %(message)s')
setup_schemas()
@@ -651,7 +662,7 @@ def main():
if __name__ == "__main__":
try:
- main()
+ main(sys.argv)
except KeyboardInterrupt:
logging.debug("Received KeyboardInterrupt. Exiting application.")
except SystemExit: