Commit 2b583c6d authored by root martinif's avatar root martinif
Browse files

add option outfile

parent 0f13cdc5
Pipeline #135 canceled with stages
......@@ -56,31 +56,40 @@ def do_export(user, password):
def print_usage():
print('wer-streamt-es-fetcher.py: -u|--user EMAIL -p|--password PASSWORD')
print('Usage: wer-streamt-es-fetcher.py: -u|--user EMAIL -p|--password PASSWORD -o|--outfile FILE')
def main(argv):
try:
opts, args = getopt.getopt(argv, "u:p:", ["user=", "password="])
opts, args = getopt.getopt(argv, "u:p:o:", ["user=", "password=", "outfile="])
user = None
password = None
outfilename = None
for opt, arg in opts:
if opt in ("-u", "--user"):
user = arg
elif opt in ("-p", "--password"):
password = arg
elif opt in ("-o", "--outfile"):
outfilename = arg
if user and password:
result_json = do_export(user, password)
print(result_json)
if outfilename:
with open(outfilename, 'w') as f:
print(result_json, file=f)
else:
print(result_json)
else:
print_usage()
exit(3)
print(sys.argv)
exit(2)
except getopt.GetoptError:
print_usage()
print(sys.argv)
exit(3)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment