def setup_class(self): self.project_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(self.project_dir) import config self.settings = config.CONFIG() self.settings.DEBUGGING = True import unlogger self.logging = unlogger.UnmanicLogger.__call__() self.logging.setup_logger(self.settings) self.logger = self.logging.get_logger() self.ffmpeg = FFMPEGHandle(self.settings, self.logging)
def main(): global threads global RUN_THREADS # Read settings settings = config.CONFIG() # Create our data queues data_queues = { "scheduledtasks": queue.Queue(), "inotifytasks": queue.Queue(), "progress_reports": queue.Queue(), "logging": unmanic_logging } # Clear cache directory common.clean_files_in_dir(settings.CACHE_PATH) # Setup job queue job_queue = JobQueue(settings, data_queues) # Setup post-processor thread start_post_processor(data_queues, settings, job_queue) # Start the worker threads worker_handle = start_workers(data_queues, settings, job_queue) # Start new thread to handle messages from service start_handler(data_queues, settings, job_queue) # Start new thread to run the web UI start_ui_server(data_queues, settings, worker_handle) # Start scheduled thread start_library_scanner_manager(data_queues, settings) # Start inotify watch manager start_inotify_watch_manager(data_queues, settings) # Watch for the term signal signal.signal(signal.SIGTERM, sig_handle) while RUN_THREADS: signal.pause() # Received term signal. Stop everything main_logger.info("Stopping all threads") for thread in threads: main_logger.info("Sending thread {} abort signal".format( thread['name'])) thread['thread'].stop() main_logger.info("Waiting for thread {} to stop".format( thread['name'])) thread['thread'].join() main_logger.info("Exit Unmanic")
def main(): # Read settings settings = config.CONFIG(main_logger) # Apply settings to logging unmanic_logging.setup_logger(settings) # Create our data queues data_queues = { "scheduledtasks": queue.Queue(), "inotifytasks": queue.Queue(), "progress_reports": queue.Queue(), "logging": unmanic_logging } # Clear cache directory common.clean_files_in_dir(settings.CACHE_PATH) # Setup job queue job_queue = JobQueue(settings, data_queues) # Setup post-processor thread start_post_processor(data_queues, settings, job_queue) # Start the worker threads worker_handle = start_workers(data_queues, settings, job_queue) # Start new thread to handle messages from service start_handler(data_queues, settings, job_queue) # Start new thread to run the web UI start_ui_server(data_queues, settings, worker_handle) # start scheduled thread start_library_scanner_manager(data_queues, settings) # start inotify watch manager notifier = start_inotify_watch_manager(data_queues, settings) notifier.loop() while True: time.sleep(5) # stop everything main_logger.info("Stopping all processes") scheduler.abort_flag.set() handler.abort_flag.set() scheduler.join() handler.join() main_logger.info("Exit")
def setup_class(self): """ Setup the class state for pytest. :return: """ self.project_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # sys.path.append(self.project_dir) unmanic_logging = unlogger.UnmanicLogger.__call__(False) unmanic_logging.get_logger() # import config import config self.settings = config.CONFIG() self.settings.DEBUGGING = True self.ffmpeg = ffmpeg.FFMPEGHandle(self.settings)
def setup_class(self): self.project_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) import config from lib import unlogger self.settings = config.CONFIG() self.settings.DEBUGGING = True self.logging = unlogger.UnmanicLogger.__call__() self.logging.setup_logger(self.settings) self.logger = self.logging.get_logger() # Create our test queues self.data_queues = { "progress_reports": queue.Queue(), "logging": self.logging } self.task_queue = queue.Queue(maxsize=1) self.complete_queue = queue.Queue()
def setup_class(self): """ Setup the class state for pytest :return: """ self.project_dir = os.path.dirname( os.path.dirname(os.path.abspath(__file__))) # sys.path.append(self.project_dir) self.logging = unlogger.UnmanicLogger.__call__(False) self.logging.get_logger() # import config import config self.settings = config.CONFIG() self.settings.DEBUGGING = True # Create our test queues self.data_queues = { "progress_reports": queue.Queue(), "logging": self.logging } self.task_queue = queue.Queue(maxsize=1) self.complete_queue = queue.Queue()
import asyncio from aiocache import Cache from databases import Database import config from files_app.models import init_db Settings = config.CONFIG() cache = Cache() def setup_database(db_config): db = Database(db_config) asyncio.get_event_loop().run_until_complete(init_db(db)) return db db = setup_database(Settings.get_db_config())
# This file is executed on every boot (including wake-boot from deepsleep) import esp import network import webrepl esp.osdebug(None) # wifi connect wlan = network.WLAN(network.STA_IF) wlan.active(True) try: # read config import config import app app.cfg = config.CONFIG() wlan.config(dhcp_hostname=app.cfg.hostname) wlan.connect(app.cfg.ssid, app.cfg.pwd) except: wlan.connect('WG', 'voytek66') webrepl.start()
import pytest from io import StringIO from main import * import asyncio from files_app.models import File from pytest_mock import mocker import time from files_app.routes import * import setup import config Settings = config.CONFIG(test=True) @pytest.yield_fixture async def app(mocker): app = Sanic(__name__) from files_app.routes import bp app.blueprint(bp) yield app @pytest.fixture def test_cli(loop, app, sanic_client): return loop.run_until_complete(sanic_client(app)) async def test_files_returns_200(test_cli):
import tensorflow as tf import databatch import define import numpy as np import config import pickle import os os.environ["PYTHONUNBUFFERED"] = "1" os.environ["CUDA_VISIBLE_DEVICES"] = "0" CFG = config.CONFIG() CFG.Print() def init_w(s, name=None): return tf.Variable(tf.truncated_normal(shape=s, stddev=0.1), name=name) def init_b(s, name=None): return tf.Variable(tf.constant(0.1, shape=s), name=name) def conv2d(x, W, strides=[1, 1, 1, 1], downsize=False, name=None): if downsize: strides = [1, 4, 1, 1] return tf.nn.conv2d(x, W, strides=strides, padding="SAME", name=name) def res_block(input, input_channel_num, output_channel_num, name,
about.set_name(creditos.Info.name) about.set_authors(creditos.Info.authors) about.set_documenters(creditos.Info.documenters) about.set_artists(creditos.Info.artists) about.set_translator_credits(creditos.Info.translator) about.set_version(creditos.Info.version) about.set_comments(creditos.Info.description) about.set_copyright(creditos.Info.copyright) about.set_website(creditos.Info.website) about.set_license(creditos.Info.license) about.set_wrap_license(True) about.run() about.destroy() if string==_("Config"): print " menu de congifuracion" conf=config.CONFIG() conf.show() #~ def carga_tooltip(self): #~ ruta=os.path.abspath(os.path.dirname(__file__)) #~ ff=open(ruta + "/tooltips.xml","r") #~ t=ff.readlines() #~ for a in range(len(t)): #~ cad_aux=t[a].strip("\n") #~ if cad_aux=="<tool>": #~ self.tooltip[t[a+1].strip("\n")]=t[a+2].strip("\n") def carga_dicc(self): """ funcion para cargar los componentes bloques, los valores del gtk.notebook estan determinados por el nombre del archivo, leyendo el archivo saco el valor
def main(inputfile, outputfile, configfile=''): torspath = os.path.dirname(os.path.realpath(sys.argv[0])) if configfile == '': configfile = torspath + os.path.sep + 'configfile.txt' args = config.ARGS(inputfile) Config = config.CONFIG(configfile, outputfile) paths = Config.path_dic() paths['torsscan'] = torspath sys.path.insert(0, es.get_paths(paths, 'bin')) sys.path.insert(0, es.get_paths(paths, 'qtc')) sys.path.insert(0, es.get_paths(paths, 'torsscan')) log.info(random_cute_animal()) ##### Build and Run EStokTP ###### #################################### global io, ob import obtools as ob import iotools as io import tctools as tc import shutil symnums = [] samps = None if args.restart < 8: index = 0 if "Opt" in args.jobs and args.restart < 1: alljobs = args.jobs args.jobs = ["Opt"] es.run_level0(args, paths) args.restart = 1 args.jobs = alljobs if "1dTau" in args.jobs and args.restart < 4: logging.info("========\nBEGIN LEVEL 1 and 1DHR\n========\n") alljobs = args.jobs negvals = True attempt = 0 while (negvals and attempt < 3): attempt += 1 args.jobs = ["Opt_1", "1dTau"] negvals = False if attempt == 1 and args.restart == 3: pass else: stoichs, symnums = es.build_files(args, paths) es.execute(paths, args.nodes[0]) if io.check_file('output/estoktp.out'): shutil.copy('output/estoktp.out', 'output/estoktp_l1.out') args.restart = 3 for i in range(len(args.reacs)): lowene = 0.0 lowenefile = None if io.check_file('me_files/reac' + str(i + 1) + '_hr.me'): hr = io.read_file('me_files/reac' + str(i + 1) + '_hr.me') hr = hr.split('Rotor') startkey = 'Potential' for j, rotor in enumerate(hr[1:]): pot = rotor.split(startkey)[1] pot = pot.splitlines()[1] for k, ene in enumerate(pot.split()): if float(ene) - lowene < -0.1: lowene = float(ene) lowenefile = 'hr_geoms/geom_isp' + str( i + 1).zfill(2) + '_hr' + str( j + 1).zfill(2) + '_hpt' + str( k + 1).zfill(2) + '.xyz' if lowenefile: xyz = io.read_file(lowenefile) logging.info(xyz) slabel = ob.get_slabel(ob.get_mol(xyz)) if slabel.split('_m')[0] == ob.get_slabel( args.reacs[i]).split('_m')[0]: negvals = True if io.check_file('data/ts.dat') and i == 0: if 'isomerization' in args.reactype.lower(): tsfile = io.read_file('data/ts.dat') ijk = tsfile.split('ji ki')[1].split()[:3] ijk.append( tsfile.split('ireact2')[1].split('\n') [1].split()[-1]) xyz = xyz.splitlines() xyz[int(ijk[0]) + 1] = '2 ' + xyz[int(ijk[0]) + 1] xyz[int(ijk[1]) + 1] = '3 ' + xyz[int(ijk[1]) + 1] xyz[int(ijk[2]) + 1] = '4 ' + xyz[int(ijk[2]) + 1] xyz[int(ijk[3]) + 1] = '1 ' + xyz[int(ijk[3]) + 1] xyz = '\n'.join(xyz) else: ijk = io.read_file('data/ts.dat').split( 'ksite')[1].split()[:3] xyz = xyz.splitlines() xyz[int(ijk[0]) + 1] = '2 ' + xyz[int(ijk[0]) + 1] xyz[int(ijk[1]) + 1] = '1 ' + xyz[int(ijk[1]) + 1] xyz[int(ijk[2]) + 1] = '3 ' + xyz[int(ijk[2]) + 1] xyz = '\n'.join(xyz) slabel = ob.get_smiles_filename( ob.get_slabel(args.reacs[i])) io.mkdir('geomdir') io.write_file(xyz, 'geomdir/' + slabel + '.xyz') args.restart = 1 args.XYZ = 'geomdir' args.xyzstart = '0' log.warning( 'Lower configuration found in 1dTau. Restarting at Level1. Saved geometry to {}' .format(slabel + '.xyz')) else: log.warning( 'Lower configuration found in 1dTau. But has different smiles: {} vs. {}' .format(slabel, ob.get_slabel(args.reacs[i]))) for l in range(len(args.prods)): lowene = 0. lowenefile = None if io.check_file('me_files/prod' + str(l + 1) + '_hr.me'): hr = io.read_file('me_files/prod' + str(l + 1) + '_hr.me') hr = hr.split('Rotor') startkey = 'Potential' for j, rotor in enumerate(hr[1:]): pot = rotor.split(startkey)[1] pot = pot.splitlines()[1] for k, ene in enumerate(pot.split()): if float(ene) - lowene < -0.1: lowene = float(ene) lowenefile = 'hr_geoms/geom_isp' + str( i + l + 2).zfill(2) + '_hr' + str( j + 1).zfill(2) + '_hpt' + str( k + 1).zfill(2) + '.xyz' if lowenefile: xyz = io.read_file(lowenefile) slabel = ob.get_slabel(ob.get_mol(xyz)) if slabel.split('_m')[0] == ob.get_slabel( args.prods[l]).split('_m')[0]: negvals = True slabel = ob.get_smiles_filename( ob.get_slabel(args.prods[l])) io.mkdir('geomdir') io.write_file(xyz, 'geomdir/' + slabel + '.xyz') args.restart = 1 args.XYZ = 'geomdir' args.xyzstart = '0' log.warning( 'Lower configuration found in 1dTau. Restarting at Level1. Saved geometry to {}' .format(slabel + '.xyz')) else: log.warning( 'Lower configuration found in 1dTau. But has different smiles: {} vs. {}' .format(slabel, ob.get_slabel(args.prods[l]))) if args.reactype.lower() in [ 'addition', 'abstraction', 'isomerization', 'addition_well', 'isomerization_well' ]: lowene = 0. lowenefile = None if io.check_file('me_files/ts_hr.me'): hr = io.read_file('me_files/ts_hr.me') hr = hr.split('Rotor') startkey = 'Potential' for j, rotor in enumerate(hr[1:]): pot = rotor.split(startkey)[1] pot = pot.splitlines()[1] for k, ene in enumerate(pot.split()): if float(ene) - lowene < -0.1: lowene = float(ene) lowenefile = 'hr_geoms/geom_isp00_hr' + str( j + 1).zfill(2) + '_hpt' + str( k + 1).zfill(2) + '.xyz' if lowenefile: xyz = io.read_file(lowenefile) negvals = True io.mkdir('geomdir') io.write_file(xyz, 'geomdir/ts.xyz') args.restart = 1 args.XYZ = 'geomdir' args.xyzstart = '0' log.warning( 'Lower configuration found in 1dTau. Restarting at Level1. Saved geometry to ts.xyz' ) if args.wellp and args.wellp.lower() != 'false': lowene = 0. lowenefile = None if io.check_file('me_files/wellp_hr.me'): hr = io.read_file('me_files/wellp_hr.me') hr = hr.split('Rotor') startkey = 'Potential' for j, rotor in enumerate(hr[1:]): pot = rotor.split(startkey)[1] pot = pot.splitlines()[1] for k, ene in enumerate(pot.split()): if float(ene) - lowene < -0.1: lowene = float(ene) lowenefile = 'hr_geoms/geom_isp06_hr' + str( j + 1).zfill(2) + '_hpt' + str( k + 1).zfill(2) + '.xyz' if lowenefile: xyz = io.read_file(lowenefile) negvals = True io.mkdir('geomdir') io.write_file(xyz, 'geomdir/wellp.xyz') args.restart = 1 args.XYZ = 'geomdir' args.xyzstart = '0' log.warning( 'Lower configuration found in 1dTau. Restarting at Level1. Saved geometry to wellp.xyz' ) if args.wellr and args.wellr.lower() != 'false': lowene = 0. lowenefile = None if io.check_file('me_files/wellr_hr.me'): hr = io.read_file('me_files/wellr_hr.me') hr = hr.split('Rotor') startkey = 'Potential' for j, rotor in enumerate(hr[1:]): pot = rotor.split(startkey)[1] pot = pot.splitlines()[1] for k, ene in enumerate(pot.split()): if float(ene) - lowene < -0.1: lowene = float(ene) lowenefile = 'hr_geoms/geom_isp05_hr' + str( j + 1).zfill(2) + '_hpt' + str( k + 1).zfill(2) + '.xyz' if lowenefile: xyz = io.read_file(lowenefile) negvals = True io.mkdir('geomdir') io.write_file(xyz, 'geomdir/wellr.xyz') args.restart = 1 args.XYZ = 'geomdir' args.xyzstart = '0' log.warning( 'Lower configuration found in 1dTau. Restarting at Level1. Saved geometry to wellr.xyz' ) args.jobs = alljobs elif "Opt_1" in args.jobs and args.restart < 2: log.info("========\nBEGIN LEVEL 1\n========\n") alljobs = args.jobs args.jobs = ["Opt_1"] stoichs, symnums = es.build_files(args, paths) es.execute(paths, args.nodes[0]) if io.check_file('output/estoktp.out'): shutil.copy('output/estoktp.out', 'output/estoktp_l1.out') args.jobs = alljobs args.restart = 2 if args.anharm.lower() != 'false' and 'd' not in args.nodes[0]: import thermo log.info("========\nBEGIN VPT2\n========\n") optlevel, anlevel = thermo.get_anlevel(args.anharm, args.meths) for n, reac in enumerate(args.reacs): typ = 'reac' natom = ob.get_natom(reac) if natom > 2: mult = ob.get_mult(reac) if io.check_file('me_files/' + typ + str(n + 1) + '_fr.me'): if not 'Anh' in io.read_file('me_files/' + typ + str(n + 1) + '_fr.me'): anfr, fr1, anx, fr2, fr3, _ = thermo.get_anharm( typ, str(n + 1), natom, args.nodes[0], anlevel, args.anovrwrt, reac, optlevel.split('/'), paths) lines = io.read_file('me_files/' + typ + str(n + 1) + '_fr.me') io.write_file( lines, 'me_files/' + typ + str(n + 1) + '_harm.me') lines = fr1 + fr2.split( 'End' )[0] + fr3 + '\n !************************************\n' io.write_file( lines, 'me_files/' + typ + str(n + 1) + '_fr.me') for n, prod in enumerate(args.prods): typ = 'prod' natom = ob.get_natom(prod) if natom > 2: mult = ob.get_mult(prod) if io.check_file('me_files/' + typ + str(n + 1) + '_fr.me'): if not 'Anh' in io.read_file('me_files/' + typ + str(n + 1) + '_fr.me'): anfr, fr1, anx, fr2, fr3, _ = thermo.get_anharm( typ, str(n + 1), natom, args.nodes[0], anlevel, args.anovrwrt, prod, optlevel.split('/'), paths) lines = io.read_file('me_files/' + typ + str(n + 1) + '_fr.me') io.write_file( lines, 'me_files/' + typ + str(n + 1) + '_harm.me') lines = fr1 + fr2.split( 'End' )[0] + fr3 + '\n !************************************\n' io.write_file( lines, 'me_files/' + typ + str(n + 1) + '_fr.me') if args.reactype and io.check_file('geoms/tsgta_l1.xyz'): typ = 'ts' mol = io.read_file('geoms/tsgta_l1.xyz') ts = ob.get_mol(mol) natom = ob.get_natom(ts) mult = ob.get_mult(ts) if io.check_file('me_files/ts_fr.me'): if not 'Anh' in io.read_file('me_files/ts_fr.me'): anfr, fr1, anx, fr2, fr3, _ = thermo.get_anharm( typ, str(n + 1), natom, args.nodes[0], anlevel, args.anovrwrt, 'ts', optlevel.split('/'), paths) lines = io.read_file('me_files/' + typ + '_fr.me') io.write_file(lines, 'me_files/' + typ + '_harm.me') lines = fr1 + fr2.split( 'End' )[0] + fr3 + '\n End\n !************************************\n' io.write_file(lines, 'me_files/' + typ + '_fr.me') log.info("========\nBEGIN MDHR, HL\n========\n") if 'kTP' in args.jobs: alljobs = args.jobs args.jobs = [] for job in alljobs: if job != 'kTP': args.jobs.append(job) stoichs, symnums = es.build_files(args, paths) es.execute(paths, args.nodes[0]) if io.check_file('me_files/ts_en.me'): tsen = float(io.read_file('me_files/ts_en.me')) tsen += float(io.read_file('me_files/ts_zpe.me')) reacen = 0 proden = 0 for i, reac in enumerate(args.reacs): if io.check_file('me_files/reac{}_en.me'.format(i + 1)): reacen += float( io.read_file('me_files/reac{}_en.me'.format(i + 1))) reacen += float( io.read_file('me_files/reac{}_zpe.me'.format(i + 1))) if args.reactype.lower( ) == 'addition_well' or args.reactype.lower( ) == 'isomerization_well': if io.check_file('me_files/wellp_en.me'): proden += float(io.read_file('me_files/wellp_en.me')) proden += float(io.read_file('me_files/wellp_zpe.me')) else: for i, prod in enumerate(args.prods): if io.check_file('me_files/prod{}_en.me'.format(i + 1)): proden += float( io.read_file( 'me_files/prod{}_en.me'.format(i + 1))) proden += float( io.read_file( 'me_files/prod{}_zpe.me'.format(i + 1))) if tsen <= reacen or tsen <= proden: log.info('Well Depth is negative. NoTunnel is turned on') if args.esoptions: args.esoptions += ',NoTunnel' else: args.esoptions = 'NoTunnel' log.info("========\nBEGIN kTP\n========\n") args.jobs = alljobs restart = 7 stoichs, symnums = es.build_files(args, paths) es.execute(paths, args.nodes[0]) else: stoichs, symnums = es.build_files(args, paths) es.execute(paths, args.nodes[0]) if ("1dTau" in args.jobs or 'MdTau' in args.jobs): for i in range(len(args.reacs)): es.check_hrs(i + 1, 'reac') for i in range(len(args.prods)): es.check_hrs(i + 1, 'prod') es.me_file_abs_path() if args.restart == 10: io.execute([paths['bin'] + os.path.sep + 'mess', 'me_ktp.inp']) if args.reactype and io.check_file('rate.out'): import me_parser #initialize the class in which to store the results data = me_parser.paper() data.reactions = [] # set some constants, depending upon whether the rate coefficients are to be used for CHEMKIN or something else. data.T0 = 1.0 data.R = 1.987 # cal/mol-K. Note that PLOG formalism requires Ea in cal/mol-K! data.N_avo = 6.0221415E23 #convert bimolecular rate coefficients from cm^3/sec to cm^3/mol/s # set the minimum and maximum temperature #data.Tmin = 600.0 #data.Tmax = 1200.0 # read me.out file from the command line me_dot_out = 'rate.out' if io.check_file(me_dot_out): lines = io.read_file(me_dot_out, True) if len(lines) < 2: log.info('rate.out is empty') ## copy new plog executable to the path of the source file #path = os.path.abspath(os.path.dirname(me_dot_out)) # #command = 'cp /home/elliott/bin/dsarrfit.x_cfg ' + path #log.info( command) #os.system(command) # parse results for the temperature, pressure, and names of channels me_parser.get_temp_pres(data, lines) # parse results for the pdep rate constants me_parser.get_pdep_k(data, lines) # fit the results to PLOG expressions me_parser.fit_pdep( data, nonlin_fit=False ) #replace <True> with <False> if you don't want to use the nonlinear solver (not recommended) # print the resulting PLOG expressions to file me_parser.print_plog(data, me_dot_out) # plot the results: dashed line = single PLOG, solid line = double PLOG #me_parser.plot_reactant(data, me_dot_out, show_plot=False, save_plot=True) ####### Parse results ######### ######################################## import results rs = results.RESULTS(args, paths) args.hlen = rs.get_hlen() args.optlevel = rs.optlevel args.enlevel = rs.enlevel args.taulevel = rs.taulevel if args.parseall.lower() == 'true' or args.alltherm.lower() == 'true': rs.get_results() ####### Build and run thermo ######### ######################################## import thermo rs.thermo = False if args.alltherm.lower() == 'true': rs.thermo = True args.symnums = symnums rs.dH0, rs.dH298, rs.hfbases, rs.anfreqs, rs.anxmat = thermo.run( args, paths, rs.d) if args.parseall.lower() == 'true': rs.get_thermo_results() return