Add command lin eparameter --debug.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 4 Jul 2018 18:41:36 +0000 (20:41 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 4 Jul 2018 18:41:36 +0000 (20:41 +0200)
owm.py

diff --git a/owm.py b/owm.py
index 323ab9d6417635fa8877dc0ee95cafd68110f1d8..c57b2422b24550b012bd415458048e99357f2a6a 100755 (executable)
--- a/owm.py
+++ b/owm.py
@@ -15,8 +15,6 @@ import datetime
 import math
 from seeparklib.openweathermap import openweathermap_json
 
-debug = False
-
 
 def fromtimestamp(timestamp, format):
     return datetime.datetime.fromtimestamp(timestamp).strftime(format)
@@ -74,7 +72,7 @@ def write_csv(csv_file, weather_data):
         ])
 
 
-def main(configfile):
+def main(configfile, debug):
     config = configparser.ConfigParser()
     config.read(configfile)
     apikey = config.get('openweathermap', 'apikey')
@@ -99,5 +97,6 @@ if __name__ == '__main__':
     default_config_file = os.path.expanduser('~/seewasser.ini')
     parser = argparse.ArgumentParser(description='Get OpenWeathermap data')
     parser.add_argument('--config', default=default_config_file, help='configuration file')
+    parser.add_argument('--debug', action='store_true', default=False, help='print debug information')
     args = parser.parse_args()
-    main(args.config)
+    main(args.config, args.debug)