Exemplo n.º 1
0
    def launch_process(self, configuration_filename):
        os.chdir(self.path)

        if self.create_tree():
            dir_n = utils.generate_string(self.values, self.variables, joining_string = "/")
            if not os.path.exists(dir_n): 
                os.makedirs(dir_n)
            os.chdir(dir_n)

#      configuration_filename = "input_%s_%d.dat"%(self.db_name, self.current_run_id)
        fconf = open(configuration_filename,"w")
        for k in self.values.keys():
            print >> fconf, k, utils.replace_in_string(self.values[k], self.values) 
        fconf.close()

        cmd = "%s/%s -i %s"%(BINARY_PATH, self.command, configuration_filename )
        proc = Popen(cmd, shell = True, stdin = PIPE, stdout = PIPE, stderr = PIPE )
#     poll = proc.poll()
#      while poll is None:
#           time.sleep(1)
#       utils.newline_msg( "SLP", "%s -- %s -- %s"%(cmd,self.path,poll))
            
#            poll = proc.poll()
        
#        print self.command,  self.path, self.db_name,  configuration_filename  , self.values, <$$$$$$$
#        print self.current_run_id, self.current_variables_id, self.entities, configuration_filename
        self.return_code = proc.wait()
    #    print self.return_code 
        self.output = [i.strip() for i in proc.stdout.readline().split()]
        self.stderr = "\n".join([i.strip() for i in proc.stderr.readline().split()])
#        self.return_code = 0
#        self.output = ""
        os.remove(configuration_filename)
Exemplo n.º 2
0
    def launch_process(self):
#        pwd = os.path.abspath(".")
   #     if self.directory_vars or self.create_trees():
   #         dir = utils.generate_string(self.values,self.directory_vars, joining_string = "/")
   #         if not os.path.exists(dir): os.makedirs(dir)
    #        os.chdir(dir)
        configuration_filename = "input_%.8d.dat"%(self.current_valuesset_id)
        fconf = open(configuration_filename,"w")
        
        for k in self.values.keys():
            print >> fconf, k, utils.replace_in_string(self.values[k], self.values) 
        fconf.close()
Exemplo n.º 3
0
    def launch_process(self):
        pwd = os.path.abspath(".")
        if self.create_trees():
            
            dir = utils.generate_string(self.values,self.directory_vars, joining_string = "/")
            if not os.path.exists(dir): os.makedirs(dir)
            os.chdir(dir)
        configuration_filename = "input_%.8d.dat"%(self.current_run_id)
        output_filename = "output_%.8d.dat"%(self.current_run_id)
        print configuration_filename
        fconf = open(configuration_filename,"w")        
        for k in self.values.keys():
            print >> fconf, k, utils.replace_in_string(self.values[k], self.values) 
        fconf.close()
        
        cmd = "%s/%s -i %s > %s"%(BINARY_PATH, self.command, configuration_filename, output_filename )
        os.system(cmd)
        ret_code = 0
#        proc = Popen(cmd, shell = True, stdin = PIPE, stdout = PIPE, stderr = PIPE )
#        proc.wait()
 #       ret_code = proc.returncode
        output = [i.strip() for i in open(output_filename).readline().split()]
        os.remove(configuration_filename)
        os.remove(output_filename)
        if self.directory_vars:
            os.chdir(pwd)
#        if ret_code == 0:
            
        all_d = [self.current_valuesset_id]
        all_d.extend( output )
#            print self.output_column, all_d
        cc = 'INSERT INTO results (values_set_id, %s) VALUES (%s) '%( ", ".join(self.output_column) , ", ".join([str(i) for i in all_d]) )
        flog = open(self.full_name.replace("sqlite", "log"), "aw") 
        print >> flog, "%.8d: %s --> %s"%(self.current_valuesset_id, self.values, output)

        try:
            self.execute_query( cc )
            self.execute_query( 'UPDATE run_status SET status ="D" WHERE id = %d'%self.current_run_id )           
        except:
            self.execute_query( 'UPDATE run_status SET status ="E" WHERE id = %d'%self.current_run_id )