-
Notifications
You must be signed in to change notification settings - Fork 4
/
aiida_utils.py
executable file
·35 lines (27 loc) · 1001 Bytes
/
aiida_utils.py
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
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
import os,sys
from subprocess import check_output
from datetime import datetime as datetime
def create_READMEtxt(directory=False,add=False):
''' wiretes a README.txt file '''
if directory == False:
directory = os.getcwd()
# get sha
curr_folder = os.path.dirname(os.path.abspath(__file__))
pwd = os.getcwd()
os.chdir(curr_folder)
sha = check_output(["git","rev-parse","master"]).decode('utf-8')
os.chdir(pwd)
# get time
time_now = datetime.now()
# name of RADME
filepath = directory+'/README_'+time_now.strftime("%Y-%m-%d_%H:%M")+'.txt'
# write README.txt
strout=os.path.basename(sys.argv[0])+" "+" ".join(sys.argv[1:])
with open(filepath, "w") as text_file:
text_file.write("# using https://gitlab.com/daniel.marchand/aiida-alloy\n")
text_file.write("# used sha: "+sha) #+"\n")
text_file.write("\n")
text_file.write(strout+"\n")
print('written ',filepath)
return