-
Notifications
You must be signed in to change notification settings - Fork 1
/
FlexHelper.py
39 lines (33 loc) · 1.38 KB
/
FlexHelper.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
36
37
38
39
__author__ = 'juju'
import datetime
import time
#Post: Returns current running Operating System - Used to determine if we are using Windows or mac
def getPlatform():
return str(platform.system())
#Post: Returns current time as string so we can use it for logging
def getNow():
return str(datetime.datetime.now())
#Post: Generates a filename sufficient date string
def getNowFilename():
return str(datetime.datetime.now().strftime("%y-%m-%d-%H-%M"))
#Pre: Given a time and type of wait will wait for a given amount of time
#Post: Waited for the given amount of time and exits
def litewait(WAITTIME,TYPE):
if TYPE=="s":
log(getNow() + ": Waiting for: " + str(WAITTIME) + " seconds","runlog.log",'a')
time.sleep(WAITTIME)
if TYPE=="m":
WAITTIME=WAITTIME*60
log(getNow() + ": Waiting for: " + str(WAITTIME/60) + " minutes","runlog.log",'a')
time.sleep(WAITTIME)
if TYPE=="h":
WAITTIME=(WAITTIME*60)*60
log(getNow() + ": Waiting for: " + str((WAITTIME/60)/60) + " hours","runlog.log",'a')
time.sleep((WAITTIME*60)*60)
#Pre: Given a clear text string log it to the given FILENAMEPATH
#Post: Logs the given clear text into the filenamepath
def log(DATA,FILENAMEPATH,FILEHANDLESETTING):
file = open(FILENAMEPATH, FILEHANDLESETTING)
file.write(getNow() + ": " + DATA + '\n')
print getNow() + ": " + DATA + '\n'
file.close()