| 1 |
# This module will make a logfile with the username of the person who ran the
|
| 2 |
# main program and the date. It will take the path as an argument. It will also
|
| 3 |
# stay open until the main program sends the close command. Ideally, it will
|
| 4 |
# keep appending to the same file for 1 month. after that month is over it will
|
| 5 |
# backup that file and make a new month log file.
|
| 6 |
# Eborges
|
| 7 |
# 1.01.01
|
| 8 |
|
| 9 |
from time import asctime
|
| 10 |
from getpass import getuser
|
| 11 |
import os, sys
|
| 12 |
def log_file_header(path):
|
| 13 |
global log
|
| 14 |
now = asctime() + '\n'
|
| 15 |
username = getuser() + '\n'
|
| 16 |
month = now[4:7]
|
| 17 |
path = path + month + ".txt"
|
| 18 |
log=open(path,'a')
|
| 19 |
log.write('\n')
|
| 20 |
log.write(now)
|
| 21 |
log.write(username)
|
| 22 |
log.close()
|
| 23 |
return path
|
| 24 |
|
| 25 |
def main():
|
| 26 |
path = "c:\\"
|
| 27 |
print path #remove after finished
|
| 28 |
log_file_header(path)
|
| 29 |
argum = sys.argv[1]
|
| 30 |
print argum #remove after finished
|
| 31 |
#sys.stdout = open("U:\Nov.txt",'a')
|
| 32 |
print "%s"%(log_file_header(path)) #remove after finished
|
| 33 |
os.system("%s >>%s"%(argum,log_file_header(path)))
|
| 34 |
print "Process complete"
|
| 35 |
#log.close()
|
| 36 |
if __name__ == "__main__":
|
| 37 |
main()
|