21 logfile = settings.logfile
24 if not settings.overwrite:
25 if os.path.exists(logfile):
26 for i
in range(10000):
27 if not os.path.exists(logfile +
'.' + str(i)):
28 logfile = logfile +
'.' + str(i)
32 log = open(logfile,
'w')
42 Class to define colour format of output message
44 HEADER colour code for header
45 OKBLUE colour code for ok blue message
46 OKGREEN colour code for ok green message
47 WARNING colour code for warning message
48 FAIL colour code for fail message
49 ENDC colour code for end message
58 WARNING =
'\033[100;93m'
66 Disable colour output format
83 Enable colour output format
99 if not settings.enable_colours:
109 print a query, wait, at the end of the dots for either fail() or done()
112 string = str(string) + (60 - len(str(string))) *
'.'
113 print(string, end=
' ')
118 except BaseException:
126 open the logfile manually again after it has been closed
129 globals()[
'log'] = open(logfile,
'a')
130 query(
'Opening logfile <' + logfile +
'>')
134 query(
'Opening logfile <' + logfile +
'> and loading colours')
139 Simple announcing information debug function, in white
144 log.write(string +
'\n')
149 Most serious error announcing function, in red
153 print(bcolours.FAIL + string + bcolours.ENDC)
155 log.write(string +
'\n')
160 Prints DONE in green letters - to be used in conjunction with query() above
163 print(bcolours.OKGREEN +
'DONE' + bcolours.ENDC)
168 except BaseException:
174 Prints FAIL in red letters and follows with debug information if they were
175 passed in the list[strings] as an argument, to be used in conjunction with
179 print(bcolours.FAIL +
'FAIL' + bcolours.ENDC)
184 print(bcolours.WARNING +
'Printing debug info:\n')
187 log.write(
'Debug info:\n')
190 log.write(str(foo) +
'\n')
196 Prints a yellow warning string that is passed as the argument, moderate problem
201 print(bcolours.WARNING + string + bcolours.ENDC)
202 log.write(string +
'\n')
207 closes log after it's been opened manually
WARNING
colour code for warning message
string HEADER
colour code for header
OKBLUE
colour code for ok blue message
HEADER
colour code for header
string OKGREEN
colour code for ok green message
string WARNING
colour code for warning message
OKGREEN
colour code for ok green message
string ENDC
colour code for end message
FAIL
colour code for fail message
ENDC
colour code for end message
string FAIL
colour code for fail message
string OKBLUE
colour code for ok blue message