Esempio n. 1
0
    def __init__(self, arg, command=None):

        full_name, self.path, self.base_name, extension = utils.translate_name(
            arg)

        MultIteratorParser.__init__(self, open(f"{self.base_name}.spg"))
        if command is not None:
            self.command = command

        self.command, ext = os.path.splitext(self.command)

        if not utils.check_params.consistency(self.command, self):
            utils.newline_msg("ERR",
                              "simulation configuration is not consistent.")
            sys.exit(1)

        self.input_configuration = utils.read_input_configuration(
            f"{self.command}.input")

        self.default_parameters = utils.SPGSettings()

        for k, v in self.input_configuration.items():

            if v.var_type != "str":
                self.default_parameters[k] = eval(f"{v.var_type}({v.default})")
            else:
                self.default_parameters[k] = v.default

        self.stdout_configuration = utils.read_output_configuration(
            self.command)
Esempio n. 2
0
    def __init__(self, db_name, timeout=5):
        full_name, self.path, self.base_name, extension = utils.translate_name(
            db_name)

        self.db_name = "%s/%s.spgql" % (self.path, self.base_name)
        sim_name = "%s/%s.spg" % (self.path, self.base_name)

        MultIteratorParser.__init__(self, open(sim_name))
        #   print self.data
        # self.path, foo = os.path.split( os.path.abspath(db_name) )
        # self.base_name, foo = os.path.splitext( foo )
        #    print  check_params.consistency(self.command, self)
        if not check_params.consistency(self.command, self):
            utils.newline_msg("ERR",
                              "simulation configuration is not consistent.")
            sys.exit(1)

        all_outputs = check_params.read_output_configuration(self.command)

        self.stdout_contents = dict()
        for k in all_outputs:
            table = k.output_table
            if table not in self.stdout_contents.leys():
                self.stdout_contents[table] = k

        self.connection = sql.connect(self.db_name,
                                      timeout=timeout,
                                      check_same_thread=False)
        self.cursor = self.connection.cursor()
Esempio n. 3
0
 def __init__(self, stream=None, db_name = "results.sqlite", timeout = 5):
     MultIteratorParser.__init__(self, stream)
 #    print  check_params.consistency(self.command, self)
     if not check_params.consistency(self.command, self):
         utils.newline_msg("ERR","parameters.dat file is not consistent.")
         sys.exit(1)
     self.stdout_contents = check_params.contents_in_output(self.command)
             
     self.connection =  sql.connect(db_name, timeout = timeout)
     self.cursor = self.connection.cursor()
Esempio n. 4
0
    def __init__(self, db_name , timeout = 5):
        full_name, self.path, self.base_name, extension = utils.translate_name( db_name )

        self.db_name = "%s/%s.spgql"%(self.path, self.base_name)
        sim_name = "%s/%s.spg"%(self.path, self.base_name)

        MultIteratorParser.__init__(self, open(sim_name) )
        # self.path, foo = os.path.split( os.path.abspath(db_name) )
        # self.base_name, foo = os.path.splitext( foo )
    #    print  check_params.consistency(self.command, self)
        if not check_params.consistency(self.command, self):
            utils.newline_msg("ERR","simulation configuration is not consistent.")
            sys.exit(1)

        self.stdout_contents = check_params.contents_in_output(self.command)
                
        self.connection =  sql.connect(self.db_name, timeout = timeout, check_same_thread = False)
        self.cursor = self.connection.cursor()
Esempio n. 5
0
    def __getitem__(self, name):
        """ the values of the multiterator are supposed to be accessed
      only by the operator[] (or by the returned value of next()
      """
        #      print name, self.names
        #      if name == "id":
        #          return self.current_iteration_id

        assert name in self.input_configuration.keys(
        ), "the requested variable '%s' was not found in the multiterator" % name
        ret = MultIteratorParser.__getitem__(self, name)
        #      print(ret, self.input_configuration[name])

        if self.input_configuration[name].var_type != 'str':
            #          print(self.input_configuration[name].var_type)
            ret = eval(f"{self.input_configuration[name].var_type}({ret})")
        return ret