def displayHelp(): text = "Usage :\n\tpython main.py [options] dataFolder\n\n" text += "Options:\n" text += "\t-d\t\t\t\t\tDebug mode.\n" text += "\t-o X\t\t\t\tSet X as xml output file.\n" text += "\t--maxiterations X\tSet X as the maximum number of iterations.\n" text += "\t-t X\t\t\t\tSet the numerical tolerance for the convergence to X.\n" text += "\t-f X\t\t\t\tSet X as the operation folder\n" text += "\t-l\t\t\t\t\tPerform linear AC optimal power flows.\n" text += "\t--cplex\t\t\t\tUse the CPLEX solver." tools.log(text,options.LOG,options.PRINT_TO_SCREEN)
def main(argv): # Read instance folder if len(argv) < 1 : displayHelp() sys.exit(2) folderPath=argv[-1] if argv[-1].endswith(("/","\\")) else argv[-1]+"/" if not os.path.exists(folderPath): raise Exception('Folder \"%s\" does not exists.' % folderPath) outputSolutionFile="data.xml" # Parse options maximumIterations=20 convergenceTolerance=None try: opts, args = getopt.getopt(argv[0:-1],"dlm:o:t:f:",["im=","gamma=","maxiterations=","operationfolder=","cplex"]) except getopt.GetoptError as err: tools.log(err) displayHelp() sys.exit(2) for opt, arg in opts: if opt in ["-o"]: outputSolutionFile = arg elif opt in ["-l"]: options.OPF_METHOD = "linearOpf" elif opt in ["-d"]: options.DEBUG = True elif opt in ["--maxiterations"]: maximumIterations = max(1,int(arg)) elif opt in ["-t"]: convergenceTolerance = float(arg) elif opt in ["-f","--operationfolder"]: options.FOLDER = arg elif opt in ["--cplex"]: options.SOLVER = 'cplex' # Log file options.log=outputSolutionFile+".log" # Create and launch system lockFile='lock.lock' if options.COPY: # If copy mode, the lock file is specific to the operation folder. lockFile='%s.lock'%(options.FOLDER) with tools.fileLock(lockFile): tools.cleanLog(options.LOG) system=System(dataFolder=folderPath,maximumIterations=maximumIterations,outputSolutionFile=outputSolutionFile,convergenceTolerance=convergenceTolerance) tools.log(system.run(),options.LOG,options.PRINT_TO_SCREEN)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Launch the main windows of TeXos """ from gi.repository import Gtk # Add the "src" directory to the python path from sys import path as PYTHONPATH from os import getcwd, path PYTHONPATH.append(path.join(getcwd(),"src")) # -- from src import gui from src import tools if __name__ == '__main__': if tools.ACTIVE_LOG: tools.init_log() tools.log("Starting TeXos",tools.LOG_MAIN) window = gui.WindowTeXos () window.show_all() Gtk.main()