-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSignature.py
35 lines (34 loc) · 1013 Bytes
/
Signature.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
import os,sys,subprocess
SIGNATURE_FILE=os.path.expanduser("~/.mutt/sig")
FORTUNE_COMMAND="fortune -n 200 -s wisdom"
def delete_previous():
fp = open(SIGNATURE_FILE,"r")
lines = fp.readlines()
fp.close()
fp = open(SIGNATURE_FILE,"w")
for line in lines:
if line.startswith('\"\"'):
break
fp.write(line)
fp.close()
def add_quote():
if sys.version[0]=='3':
x=subprocess.getstatusoutput(FORTUNE_COMMAND)
if sys.version[0]=='2':
x=[0]+[subprocess.check_output(FORTUNE_COMMAND.split())[:-1]]
if x[0]==0:
delete_previous()
fp = open(SIGNATURE_FILE,"a")
fp.writelines("\"\" "+x[1]+" \"\"")
fp.close()
print_signature()
else:
print("Some problem with the fortune program ,, see if it is installed")
exit(-1)
def print_signature():
fp = open(SIGNATURE_FILE,"r")
lines=fp.readlines()
fp.close()
print(''.join(lines))
if __name__=='__main__':
add_quote()