def run(self): """ Mainly, procsses sqlscripts and generates executable scripts. Later, executale scripts are feed in to dbisql for results. Maximum concurrent dbisql connections are synchronised using semaphore. """ results = [] try: sourcefile = path.join(Configuration.sourcedir, self.relpath) resultfile = path.join(Configuration.resultdir, self.relpath) output = "{0:80} {1}".format(self.relpath, "[Started]") logging.info("%s" %(output)) results = SQLManager.process(sourcefile, Configuration.resultdir, self.relpath) command = make_command(self.relpath, resultfile) with Executor.__semaphore: subprocess.call(command) if (results): (Executor.__queue).put(results) except Exception as e: logging.debug("executor thread exception: %s" %(e.args)) except: logging.debug("executor thread unexpected errro") output = "{0:80} {1}".format(self.relpath, "[Finished]") logging.info("%s" %(output))
def test_process_normal(self): file = (r'SQL/WellHeader/WellHeader.sql') rpath = str(r'SQL/WellHeader') outfile = 'WellHeader.out.sql' outpath = path.join(rpath, outfile) files = SQLManager.process(file, rpath, outfile) self.assertTrue(files) self.assertTrue(path.isfile(outpath))