-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.py
More file actions
25 lines (19 loc) · 678 Bytes
/
task.py
File metadata and controls
25 lines (19 loc) · 678 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python
import argparse
import os
from datetime import datetime
def main(filename='timestamp'):
now = datetime.now()
formatted_date_time = now.strftime("%Y-%m-%d-%H-%M")
print(formatted_date_time)
script_dir = os.path.dirname(os.path.abspath(__file__))
outfile_path = os.path.join(script_dir, filename)
with open(outfile_path, "w") as file:
file.write(formatted_date_time)
file.close()
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-o", "--output", type=str,
help="name of output file")
args = parser.parse_args()
main(filename=args.output)