Example #1
0
    def beginLog(self, file_name=''):
        if file_name == '':
            file_name = self.__name

        self.__log_name = file_name + '.log'

        if not os.path.exists(self.__log_path):
            os.makedirs(self.__log_path)

        UI.openLog(self.__log_path + '/' + self.__log_name)
        UI.logTitle('INITIALIZING SCRIPT ' + self.__name)

        if self.__headline != '':
            UI.log('HEADLINE', *self.__headline)

        if self.__purpose != '':
            UI.log('PURPOSE', *self.__purpose)

        self.__start = datetime.now()
        UI.log('BEGIN LOG', 'Start time: ' + str(self.__start).split('.')[0])
Example #2
0
    def endLog(self):
        self.__end = datetime.now()
        self.__duration = self.__end - self.__start
        UI.log('END LOG', 'End time: ' + str(self.__end).split('.')[0],
               'Duration: ' + str(self.__duration))
        UI.logTitle(UI.test_result)
        UI.closeLog()

        if os.path.exists(self.__log_path + '/PASS - ' + self.__log_name):
            os.remove(self.__log_path + '/PASS - ' + self.__log_name)

        if os.path.exists(self.__log_path + '/FAIL - ' + self.__log_name):
            os.remove(self.__log_path + '/FAIL - ' + self.__log_name)

        if os.path.exists(self.__log_path + '/CHECK - ' + self.__log_name):
            os.remove(self.__log_path + '/CHECK - ' + self.__log_name)

        if os.path.exists(self.__log_path + '/EXCEPTION - ' + self.__log_name):
            os.remove(self.__log_path + '/EXCEPTION - ' + self.__log_name)

        shutil.copyfile(
            self.__log_path + '/' + self.__log_name,
            self.__log_path + '/' + UI.test_result + ' - ' + self.__log_name)