Added --stdout option
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Sat, 26 May 2012 11:39:06 +0000 (11:39 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Sat, 26 May 2012 11:39:06 +0000 (11:39 +0000)
members.py

index 9f800b5152477fe4b841fd9e43b210f18fc3c880..0fbaa79e0193eaf49ced8d843d7749e9ed41724e 100755 (executable)
@@ -292,6 +292,9 @@ if __name__ == '__main__':
     parser.add_option('--dry-run',
         action='store_true', dest='dryrun', default=False,
         help="don't store result in archives.")
+    parser.add_option('--stdout',
+        action='store_true', dest='stdout', default=False,
+        help="Print result on stdout rather that in results.log")
     options, args = parser.parse_args()
 
     if options.debug:
@@ -307,8 +310,11 @@ if __name__ == '__main__':
     else:
         BASE_DIRECTORY = os.path.join(HOME, options.directory)
 
-    result_filename = os.path.join(BASE_DIRECTORY, 'results.log')
-    logging.basicConfig(filename=result_filename, level=loglevel, format='%(asctime)s %(levelname)s %(message)s', datefmt='%Y-%m-%d %H:%M:%S %Z')
+    if options.stdout:
+        logging.basicConfig(level=loglevel, format='%(asctime)s %(levelname)s %(message)s', datefmt='%Y-%m-%d %H:%M:%S %Z')
+    else:
+        result_filename = os.path.join(BASE_DIRECTORY, 'results.log')
+        logging.basicConfig(filename=result_filename, level=loglevel, format='%(asctime)s %(levelname)s %(message)s', datefmt='%Y-%m-%d %H:%M:%S %Z')
 
     read_config(BASE_DIRECTORY)
 
@@ -326,7 +332,8 @@ if __name__ == '__main__':
         oldmembers = eval(f.read())
     
     if options.new_archive_filename:
-        newf = open(options.new_archive_filename, mode='r', encoding='utf8')
+        new_archive_filename = os.path.join(BASE_DIRECTORY, options.new_archive_filename)
+        newf = open(new_archive_filename, mode='r', encoding='utf8')
         newmembers = eval(newf.read())
     else:
         newmembers = members_fetch(options.alliance)