14 logfile = settings.logfile
17 if not settings.overwrite:
18 if os.path.exists(logfile):
19 for i
in range(10000):
20 if not os.path.exists(logfile +
'.' + str(i)):
21 logfile = logfile +
'.' + str(i)
25 log = open(logfile,
'w')
35 Class to define colour format of output message
37 HEADER colour code for header
38 OKBLUE colour code for ok blue message
39 OKGREEN colour code for ok green message
40 WARNING colour code for warning message
41 FAIL colour code for fail message
42 ENDC colour code for end message
51 WARNING =
'\033[100;93m'
59 Disable colour output format
76 Enable colour output format
92 if not settings.enable_colours:
102 print a query, wait, at the end of the dots for either fail() or done()
105 string = str(string) + (60 - len(str(string))) *
'.'
106 print(string, end=
' ')
111 except BaseException:
119 open the logfile manually again after it has been closed
122 globals()[
'log'] = open(logfile,
'a')
123 query(
'Opening logfile <' + logfile +
'>')
127 query(
'Opening logfile <' + logfile +
'> and loading colours')
132 Simple announcing information debug function, in white
137 log.write(string +
'\n')
142 Most serious error announcing function, in red
146 print(bcolours.FAIL + string + bcolours.ENDC)
148 log.write(string +
'\n')
153 Prints DONE in green letters - to be used in conjunction with query() above
156 print(bcolours.OKGREEN +
'DONE' + bcolours.ENDC)
161 except BaseException:
167 Prints FAIL in red letters and follows with debug information if they were
168 passed in the list[strings] as an argument, to be used in conjunction with
172 print(bcolours.FAIL +
'FAIL' + bcolours.ENDC)
177 print(bcolours.WARNING +
'Printing debug info:\n')
180 log.write(
'Debug info:\n')
183 log.write(str(foo) +
'\n')
189 Prints a yellow warning string that is passed as the argument, moderate problem
194 print(bcolours.WARNING + string + bcolours.ENDC)
195 log.write(string +
'\n')
200 closes log after it's been opened manually