]> code.communitydata.science - covid19.git/blobdiff - wikipedia/scripts/fetch_enwiki_daily_views.py
updated to just write a single log file for each day
[covid19.git] / wikipedia / scripts / fetch_enwiki_daily_views.py
index 7015a3b5a2ac03fa4ec1bf5ce4ee06d2958f8a4e..829343de318c9aaf906350d2ad57880482547ce8 100755 (executable)
@@ -26,7 +26,7 @@ def parse_args():
     parser.add_argument('-o', '--output_folder', help='Where to save output', default="wikipedia/data", type=str)
     parser.add_argument('-i', '--article_file', help='File listing article names', default="wikipedia/resources/enwp_wikiproject_covid19_articles.txt", type=str)
     parser.add_argument('-d', '--query_date', help='Date if not yesterday, in YYYYMMDD format.', type=str)
-    parser.add_argument('-L', '--logging_level', help='Logging level. Options are debug, info, warning, error, critical. Default: info.', default='info', type=str), 
+    parser.add_argument('-L', '--logging_level', help='Logging level. Options are debug, info, warning, error, critical. Default: info.', default='info', type=digobs.get_loglevel), 
     parser.add_argument('-W', '--logging_destination', help='Logging destination file. (default: standard error)', type=str), 
     args = parser.parse_args()
     return(args)
@@ -45,14 +45,11 @@ def main():
         yesterday = datetime.datetime.today() - datetime.timedelta(days=1)
         query_date = yesterday.strftime("%Y%m%d")
 
-    #handle -L
-    loglevel = digobs.get_loglevel(args.logging_level)
-
     #handle -W
     if args.logging_destination:
-        logging.basicConfig(filename=args.logging_destination, filemode='a', level=loglevel)
+        logging.basicConfig(filename=args.logging_destination, filemode='a', level=args.logging_level)
     else:
-        logging.basicConfig(level=loglevel)
+        logging.basicConfig(level=args.logging_level)
 
     export_time = str(datetime.datetime.now())
     export_date = datetime.datetime.today().strftime("%Y%m%d")

Community Data Science Collective || Want to submit a patch?