def updateLastTrigger(iteration, intervalIndex): config = configparser.ConfigParser() config.read(getAbsPath('./config/config.ini')) config["MODE1 : Intervals"]["LastTrigger"] = str([iteration, intervalIndex]) with open(getAbsPath('./config/config.ini'), 'w') as f: config.write(f)
def updateExercise(name): config = configparser.ConfigParser() config.read(getAbsPath('./config/config.ini')) param = ast.literal_eval(config["EXERCISES"][name]) newParam = str((param[0], str(param[1]), param[2] + 1)) config["EXERCISES"][name] = newParam with open(getAbsPath('./config/config.ini'), 'w') as f: config.write(f)
def preProcessingFunc(): numOfArgs = len(sys.argv) mainScriptPath = sys.argv[0] try: inputFilePath = sys.argv[numOfArgs - 1] except IndexError: raise RuntimeError('No file with models provided!') utils.setParamsFromArgs(sys.argv[1:(numOfArgs - 1)]) state.set('mainScriptPath', utils.getAbsPath(mainScriptPath)) state.set('inputFilePath', utils.getAbsPath(inputFilePath)) state.set('outputFilePath', utils.computeClassFilePath()) utils.printTitle('Pre-processing of given file is about to begin.') tempDirPath = utils.createTempDirectory(mainScriptPath) state.set('tempDirPath', tempDirPath) if (not state.get('prenamedComponents')): nameComponentsInput = None while (nameComponentsInput != 'y' and nameComponentsInput != 'n'): nameComponentsInput = input( 'Would you like to ' + 'name the components for more human-readable class hypotheses? ' + '(y/n) ').lower() print() state.set('nameComponents', nameComponentsInput == 'y') clustersMap = preProcessing.parseInputFile() state.set('clusters', clustersMap) utils.initClusterWeights() utils.printTitle('Pre-processing of file complete!') while not len(state.get('relevantPatterns')): setRelevantPatterns() labels = utils.getAllLabelsFromUser() labelExamplesPaths = utils.createLabelExampleFiles(labels) state.set('labels', labels) state.set('labelExamplesPaths', labelExamplesPaths) utils.initUserLabelCounters() utils.setDefaultQuery() utils.printTitle('Thank you, classification process will now begin.')
def getExerciseByName(name): config = configparser.ConfigParser() config.read(getAbsPath('./config/config.ini')) if name in config.options("EXERCISES"): return ast.literal_eval(config["EXERCISES"][name]) else: return False
def getInputsConfig(): config = configparser.ConfigParser() config.read(getAbsPath('./config/config.ini')) keyboard = config["INPUTS"].getboolean("block_keyboard") mouse = config["INPUTS"].getboolean("block_mouse") return (keyboard, mouse)
def getLastTrigger(): config = configparser.ConfigParser() config.read(getAbsPath('./config/config.ini')) try : # [iteration, intervalTime] return ast.literal_eval(config["MODE1 : Intervals"]["LastTrigger"]) except: return None
def getServerConfig(): config = configparser.ConfigParser() config.read(getAbsPath('./config/config.ini')) if "PORT" in config.options("EXERCISES"): return int(config["SERVER"]["PORT"]) else: print("Switching to default ports : 5000") return 5000
def getBasicInfo(): config = configparser.ConfigParser() config.read(getAbsPath('./config/config.ini')) MODE = int(config["WORKOUT"]["MODE"]) EXERCISES_MODE = int(config["WORKOUT"]["randomize_sequence"]) EXERCISES_SELECTED = ast.literal_eval(config["WORKOUT"]["EXERCIsES_SELECTED"]) NUMBER_TO_PICK_PER_SESSION = int(config["WORKOUT"]["exercises_per_session"]) INFO = [MODE, EXERCISES_MODE, EXERCISES_SELECTED, NUMBER_TO_PICK_PER_SESSION] if MODE == 0: # INFO = [MODE, EXERCISES_MODE, EXERCISES_SELECTED, NUMBER_TO_PICK_PER_SESSION, TIMER] INFO.append(int(config["MODE0 : Repeat"]["TIMER"])) elif MODE == 1: # INFO = [MODE, EXERCISES_MODE, EXERCISES_SELECTED, NUMBER_TO_PICK_PER_SESSION, HOURS, MAXIMUM_NUMBER_OF_SESSIONS_PER_INTERVAL, RECUPERATION_TIME_SECONDS] INFO.append(ast.literal_eval(config["MODE1 : Intervals"]["HOURS"])) INFO.append(int(config["MODE1 : Intervals"]["MAXIMUM_NUMBER_OF_SESSIONS_PER_INTERVAL"])) INFO.append(int(config["MODE1 : Intervals"]["recuperation_time_between_sessions_in_seconds"])) return INFO
def __init__(self, MODE, VALUE, MODE_EXERCISES, EXERCISES): self.MODE = MODE if self.MODE == 0: self.menu_options = ( ("Mode : Repeat", None, self._openConfig), ("Every : " + str(VALUE) + "s", None, self._openConfig), ("Sequence's type : " + ((MODE_EXERCISES == 1) and "Randomized" or "Ordered"), None, self._openConfig), ("Exercises loaded : " + str(EXERCISES), None, self._openConfig), ("Reload", None, self._reload)) elif self.MODE == 1: self.menu_options = ( ("Mode : Intervals", None, self._openConfig), ("Hours : " + str(VALUE[0]), None, self._openConfig), ("Number of sessions per interval: " + str(VALUE[1]), None, self._openConfig), ("Time between two sessions : " + str(VALUE[2]) + "s", None, self._openConfig), ("Sequence's type : " + ((MODE_EXERCISES == 1) and "Randomized" or "Ordered"), None, self._openConfig), ("Exercises loaded : " + str(EXERCISES), None, self._openConfig), ("Reload", None, self._reload)) self.icon = getAbsPath("./config/icon.ico") self.name = "Workout Starter Pack" self.tray = SysTrayIcon(self.icon, self.name, self.menu_options , on_quit=self.quitTray)
def _openConfig(self): config = getAbsPath("./config/config.ini") os.startfile(config)
def notify(title, message, duration = 10, threaded=True): toaster = ToastNotifier() toaster.show_toast(title, message, duration=duration, icon_path=getAbsPath("./config/icon.ico"), threaded=threaded)