def main(benchmarks, name, tsp, cores, timeout, sequential, prio_conflicts, debug, verbose, official): if not name: name = f"pc={'T' if prio_conflicts else 'F'}," \ f"ord={'T' if sequential else 'F'}" if not sequential: name = f"tsp={tsp}," + name if official: name += ' (TU)' def prepped_solver(problem: Problem) -> List: return solver(problem, { "tsp": tsp.lower(), "pc": prio_conflicts, "ord": sequential }) api_key = open("api_key.txt", "r").read().strip() benchmark = MapfwBenchmarker(api_key, benchmarks, "A*+OD+ID", name, debug, prepped_solver, cores=cores, timeout=timeout) logger.start(info=debug, debug=verbose) benchmark.run() logger.stop()
def run(): props = config.get_properties("config.yml") env.timezone_name = props['env']['timezone'] logger.start() logger.log("Loaded properties: \n{}", pprint.pformat(props)) task_scheduler = scheduler.Scheduler(int(props['workers'])) for camera in props['cameras']: task_scheduler.add_task(_save_camera_snapshot, camera, props) task_scheduler.start(int(props['time_period_sec']))
def inv_cipher(data, key, N_k): r = 0 rounds = get_rounds(N_k) data = create_state_block(data) logger.input(r, data) key_sch = key[-4:] logger.k_sch(r, key_sch) addRoundKey(data, key_sch) for r in range(rounds-2, 0, -1): logger.start(rounds-r-1, data) inv_shiftRows(data) logger.shift_row(rounds-r-1, data) inv_subBytes(data) logger.sub_byte(rounds-r-1, data) key_sch = key[4*(r):4*(r+1)] logger.k_sch(rounds-r-1, key_sch) addRoundKey(data, key_sch) logger.ik_add(rounds-r-1, data) inv_mixColumns(data) logger.start(rounds-r, data) inv_subBytes(data) logger.sub_byte(rounds-r, data) inv_shiftRows(data) logger.shift_row(rounds-r, data) key_sch = key[0:4] logger.k_sch(rounds-r, key_sch) addRoundKey(data, key_sch) logger.output(rounds-r, data) return convert_block_to_stream(data)
def cipher(data, key, N_k): r = 0 rounds = get_rounds(N_k) data = create_state_block(data) logger.input(r, data) key_sch = key[0:4] logger.k_sch(r, key_sch) addRoundKey(data, key_sch) for r in range(1, rounds - 1): logger.start(r, data) subBytes(data) logger.sub_byte(r, data) shiftRows(data) logger.shift_row(r, data) mixColumns(data) logger.mix_column(r, data) key_sch = key[4 * r:4 * (r + 1)] logger.k_sch(r, key_sch) addRoundKey(data, key_sch) r += 1 logger.start(r, data) subBytes(data) logger.sub_byte(r, data) shiftRows(data) logger.shift_row(r, data) key_sch = key[-4:] logger.k_sch(r, key_sch) addRoundKey(data, key_sch) logger.output(r, data) return convert_block_to_stream(data)
def logstart(logfile=None, logdir=None): ''' Initialise file and console loggers. * logdir: The directory where the timestamped log file will be saved. * logfile: If `logdir` is not specified, log to this file. :return: The log file path. ''' logfile = log.start(logfile, logdir) log.divider() if logfile: log.info("Started logger. Logging to file: '%s'" % logfile) else: log.info("Started logger. A log file or log directory was not specified.") return logfile
Waktu : {} """ post_text = post_text.format(event.judul.encode('utf8'), event.link.encode('utf8'), event.waktu_event) post_text = post_text.strip() return post_text def crawl(): newUpdate = scraper.checkWebUpdate() if (newUpdate == 1): logger.printlogstat("New Update : On Web") elif (newUpdate == 0): logger.printlogstat("No update") return 0 # global variable post = "Payung Teduh" if __name__ == "__main__": logger.start() analize() debug() crawl() ret = initialize_post() if (ret == 0): unittest.main() logger.finish()
Library.args = library.options.parser.parse_args(sys.argv[1:]) log.debug("Parsed command line: {!s}".format(library.args)) log_level = logging.getLevelName(library.args.loglevel.upper()) if library.args.logfile == 'daddyvision.log': log_file = '{}.log'.format(__pgmname__) else: log_file = os.path.expanduser(library.args.logfile) # If an absolute path is not specified, use the default directory. if not os.path.isabs(log_file): log_file = os.path.join(logger.LogDir, __pgmname__, log_file) logger.start(log_file, log_level, timed=True) if len(library.args.library) == 0: msg = 'Missing Scan Starting Point (Input Directory), Using Default: {}'.format(library.settings.NewSeriesDir) log.info(msg) library.args.library = [library.settings.NewSeriesDir] for _lib_path in library.args.library: if os.path.exists(_lib_path): try: library.renameSeries(_lib_path) except: an_error = traceback.format_exc() log.error(traceback.format_exception_only(type(an_error), an_error)[-1]) else: log.error('Skipping Rename: Unable to find File/Directory: {}'.format(_lib_path))
except sqlite3.IntegrityError, e: raise DuplicateRecord except sqlite3.Error, e: raise UnexpectedErrorOccured("File Information Insert: {} {}".format(e, file_details)) return file_id if __name__ == '__main__': logger.initialize() log.trace("MAIN: -------------------------------------------------") library = DownloadDatabase() Library.args = library.options.parser.parse_args(sys.argv[1:]) log.debug("Parsed command line: {!s}".format(library.args)) log_level = logging.getLevelName(library.args.loglevel.upper()) if library.args.logfile == 'daddyvision.log': log_file = '{}.log'.format(__pgmname__) else: log_file = os.path.expanduser(library.args.logfile) # If an absolute path is not specified, use the default directory. if not os.path.isabs(log_file): log_file = os.path.join(logger.LogDir, log_file) logger.start(log_file, log_level, timed=False) library.ScanSeriesLibrary()
if os.path.exists(USERPATH_FILE): IS_PORTABLE = False USER_PATH = get_first_textfile_line(USERPATH_FILE) os.makedirs(USER_PATH, exist_ok=True) else: IS_PORTABLE = True USER_PATH = PROG_PATH # Get program version VERSION = get_first_textfile_line(os.path.join(PATH, "VERSION")) # Setup dual logging/printing LOG_PATH = os.path.join(USER_PATH, LOG_TITLE) import logger logger.start(LOG_PATH) # Start printing output def datetime_str(): now = datetime.now() return now.strftime("%d/%m/%Y %H:%M:%S") print("---------------- BEGIN LOG", datetime_str(), "----------------") print("LPHK - LaunchPad HotKey - A Novation Launchpad Macro Scripting System") print("Version:", VERSION) print("Platform:", PLATFORM.capitalize()) print("Is compiled executable:", IS_EXE) print("Is portable:", IS_PORTABLE) print("Operating path:", PATH)
self.db.commit() self.db.close() if __name__ == '__main__': logger.initialize() library = CleanDatabase() args = library.options.parser.parse_args(sys.argv[1:]) log.debug("Parsed command line: {!s}".format(args)) log_level = logging.getLevelName(args.loglevel.upper()) if args.logfile == 'daddyvision.log': log_file = '{}.log'.format(__pgmname__) else: log_file = os.path.expanduser(args.logfile) # If an absolute path is not specified, use the default directory. if not os.path.isabs(log_file): log_file = os.path.join(logger.LogDir, log_file) logger.start(log_file, log_level, timed=True) if len(args.library) < 1: log.warn('No pathname supplied for rename: Using default: {}'.format(library.settings.NewMoviesDir)) args.library = library.settings.NewMoviesDir library.cleanDatabase()
File_Count, Files_Deleted, Files_Updated)) self.db.commit() log.info('Complete: Files Checked: %5s Number Deleted: %s' % (Files_Processed, Files_Deleted)) if __name__ == '__main__': logger.initialize() log.trace("MAIN: -------------------------------------------------") library = CleanDatabase() Library.args = library.options.parser.parse_args(sys.argv[1:]) log.debug("Parsed command line: {!s}".format(library.args)) log_level = logging.getLevelName(library.args.loglevel.upper()) if library.args.logfile == 'daddyvision.log': log_file = '{}.log'.format(__pgmname__) else: log_file = os.path.expanduser(library.args.logfile) # If an absolute path is not specified, use the default directory. if not os.path.isabs(log_file): log_file = os.path.join(logger.LogDir, log_file) logger.start(log_file, log_level, timed=False) library.ScanFileEntries() library.ScanDownloadEntries()
Library.args = library.options.parser.parse_args(sys.argv[1:]) log.debug("Parsed command line: {!s}".format(library.args)) log_level = logging.getLevelName(library.args.loglevel.upper()) if library.args.logfile == 'daddyvision.log': log_file = '{}.log'.format(__pgmname__) else: log_file = os.path.expanduser(library.args.logfile) # If an absolute path is not specified, use the default directory. if not os.path.isabs(log_file): log_file = os.path.join(logger.LogDir, log_file) logger.start(log_file, log_level, timed=False, errorlog=library.args.errorlog) myrequest = {} if len(library.args.library) > 0: for pathname in library.args.library: print pathname if os.path.exists(pathname): myrequest = parser.getFileDetails(pathname) if library.args.series_name: myrequest['SeriesName'] = library.args.series_name if library.args.season: myrequest['SeasonNum'] = library.args.season if library.args.epno: myrequest['EpisodeNums'] = library.args.epno else:
import os from datetime import datetime from datetime import timedelta from PyQt5.QtWidgets import (QTabWidget, QMessageBox, QComboBox, QGraphicsScene, QGraphicsView, QDateEdit, QTimeEdit, QDialog, QLineEdit, QFrame, QLabel, QSlider, QGridLayout, QPushButton, QVBoxLayout, QHBoxLayout, QApplication, QWidget, QGroupBox, QScrollArea, QSizePolicy) from PyQt5.QtCore import (QTimer, Qt, QDate, QDateTime, QTime) import uuid import time from win10toast import ToastNotifier from typing import List logger.start("log.txt") logger.save_create("save_files.txt") user_tasks = user_backend.TaskCollection() notifier = ToastNotifier() # the main gui area class App(QWidget): #initialize all of the variables and call gui functions def __init__(self): super(App, self).__init__() self.setWindowTitle('to due') self.setGeometry(300, 200, 600, 600) self.create_task_area() self.vertical_layout = QVBoxLayout(self)
+ str(finallyException.message.lower()) + ".") # Prints the traceback traceback.print_exc() print(Fore.RESET) sys.exit(1) ######################################## # MAIN PROGRAM # ######################################## if __name__ == '__main__': checks.check_root() # Function to check the user checks.check_platform( ) # Checks if the component is run on GNU/Linux platform checks.check_raspberrypi( ) # Checks if the component is run on a Raspberry Pi checks.check_network( ) # Checks if the Raspberry Pi is connected to the network checks.check_concurrency( ) # Checks if the component is or not already running logfile = system.create_logger_dir( ) # Creates the directory for logging file logger.start(logfile) # Starts the logger arguments = checks.menu( ) # Checks the options entered by the user when running the component constants(arguments) # Declares all the constants main(arguments) # Main function
def on_error(self, status) : print(status) auth = OAuthHandler(ckey,csecret) auth.set_access_token(atoken,asecret) try: twitterStream = Stream(auth,twitterListener()) msg = " initiated run" try: if sys.argv[1] == "cron": msg = "cron" + msg init_by = 'cron' else: msg = "user" + msg init_by = 'user' except Exception: msg = "user" + msg init_by = 'user' print(msg) logger.start(msg) twitterStream.filter(track=term_set) except KeyboardInterrupt: print("["+init_by+"] Caught KeyboardInterrupt :: Total # : G["+ str(int_german)+"]-R["+str(int_russian)+"] | E["+str(interesting_count-1-int_german-int_russian)+"] / T["+str(count))+"]" logger.end("["+init_by+"] Caught KeyboardInterrupt :: Total # : G["+ str(int_german)+"]-R["+str(int_russian)+"] | E["+str(interesting_count-1-int_german-int_russian)+"] / T["+str(count))+"]" sys.exit(0)
Library.args = library.options.parser.parse_args(sys.argv[1:]) log.debug("Parsed command line: {!s}".format(library.args)) log_level = logging.getLevelName(library.args.loglevel.upper()) if library.args.logfile == "daddyvision.log": log_file = "{}.log".format(__pgmname__) else: log_file = os.path.expanduser(library.args.logfile) # If an absolute path is not specified, use the default directory. if not os.path.isabs(log_file): log_file = os.path.join(logger.LogDir, log_file) logger.start(log_file, log_level, timed=False, errorlog=library.args.errorlog) myrequest = {} if len(library.args.library) > 0: for pathname in library.args.library: print pathname if os.path.exists(pathname): myrequest = parser.getFileDetails(pathname) if library.args.series_name: myrequest["SeriesName"] = library.args.series_name if library.args.season: myrequest["SeasonNum"] = library.args.season if library.args.epno: myrequest["EpisodeNums"] = library.args.epno else: myrequest["SeriesName"] = pathname