Esempio n. 1
0
def read_init_file(Fname):
    File = open(Fname)
    while 1:
        line = File.readline()
        if (len(line) == 0):
            return
        wrds = string.split(line)
        if (len(wrds) > 0) and (wrds[0] == 'load'):
            Fname = figure_out_the_file(wrds[0])
            if not Fname:
                dbase.log_error('file "%s" cant be read' % Fname)
            else:
                dbase.load_dbase_file(Fname)
        elif (len(wrds) == 2):
            Param = wrds[0]
            Value = wrds[1]
            dbase.log_info('read_init_file set context "%s" "%s"' %
                           (Param, Value))
            if (',') in Value:
                W1 = string.split(Value, ',')
                ll = []
                for X in W1:
                    ll.append(makenum(X))
                dbase.set_context(Param, ll)
            elif (Value[0] in '0123456789'):
                dbase.set_context(Param, makenum(Value))
            else:
                dbase.set_context(Param, Value)
        elif (len(wrds) > 0):
            dbase.log_warning('read_init_file got "%s" . not valid.' %
                              (string.join(wrds, ' ')))
Esempio n. 2
0
def main():
    #    global CmdFile
    #    CmdFile = open_command_file()
    dbase.init()
    load_init_file()
    was_minus = False
    ind = 1
    while ind < len(sys.argv):
        Fname = sys.argv[ind]
        if Fname[0] == '-':
            was_minus = True
        if not was_minus:
            if os.path.exists(Fname):
                dbase.load_dbase_file(Fname)
            else:
                dbase.log_error('file "%s" cant be read' % Fname)
            ind += 1
        else:
            if Fname == '-do':
                ind += 1
                What = sys.argv[ind]
                use_command_wrds([What])
                ind += 1
            else:
                dbase.log_error('"%s" not known' % sys.argv[ind])
                ind += 1

    Thr = thread.start_new_thread(execute_terminal_commands, ())
    work()
Esempio n. 3
0
def load_schematics(newRoot):
    List = Glbs.details.keys()
    if newRoot in List:
        Glbs.set_context('root', newRoot)
        Glbs.graphicsChanged = True
    else:
        Fname = figure_out_the_file(newRoot)
        if Fname:
            dbase.load_dbase_file(Fname)
        else:
            dbase.log_error('file "%s" cant be read' % newRoot)
            return
Esempio n. 4
0
 def try_load_picture(self, Pic):
     if Pic in self.pictures:
         return
     Dirs = self.get_context('pics_lib')
     if type(Dirs) == types.ListType:
         for Dir in Dirs:
             Fname = '%s/%s.zpic' % (Dir, Pic)
             if os.path.exists(Fname):
                 dbase.load_dbase_file(Fname)
                 return True
     elif type(Dirs) == types.StringType:
         Fname = '%s/%s.zpic' % (Dirs, Pic)
         if os.path.exists(Fname):
             dbase.load_dbase_file(Fname)
             return True
     return False
Esempio n. 5
0
def main():
    dbase.init()
    load_init_file()
    was_minus = False
    ind = 1
    while ind < len(sys.argv):
        Fname = sys.argv[ind]
        if Fname[0] == '-':
            was_minus = True
        if not was_minus:
            Fnamex = figure_out_the_file(Fname)
            if not Fnamex:
                logs.log_error('file "%s" cant be read' % Fname)
            elif not Fnamex.endswith('.zdraw'):
                logs.log_error('file "%s" should have extension zdraw' %
                               Fnamex)
            elif os.path.exists(Fnamex):
                logs.log_info('file "%s" read' % Fnamex)
                dbase.load_dbase_file(Fnamex)
            else:
                logs.log_error('file "%s" cant be read' % Fnamex)
            ind += 1
        else:
            if Fname == '-do':
                ind += 1
                What = sys.argv[ind]
                use_command_wrds([What])
                ind += 1
            elif Fname in ['-source', '-include']:
                ind += 1
                What = sys.argv[ind]
                use_command_wrds(['include', What])
                ind += 1
            else:
                logs.log_error('"%s" not known' % sys.argv[ind])
                ind += 1


#    Thr = threading.Thread.start(execute_terminal_commands)
    thread1.start()
    work()
Esempio n. 6
0
def read_init_file(Fname):
    File = open(Fname)
    while 1:
        line = File.readline()
        if (len(line) == 0):
            return
        line = line.replace('=', ' = ')
        wrds = line.split()
        if (len(wrds) > 0) and (wrds[0] == 'load'):
            Fname = figure_out_the_file(wrds[0])
            if not Fname:
                logs.log_error('file "%s" cant be read' % Fname)
            else:
                dbase.load_dbase_file(Fname)
        elif (len(wrds) >= 2) and (wrds[0] == 'import'):
            import_command(wrds[1])
        elif (len(wrds) >= 2) and (wrds[0] == 'pics_lib'):
            Was = dbase.get_context('pics_lib')
            line2 = line.replace(',', ' ')
            wrds2 = line2.split()
            for wrd in wrds2[1:]:
                Was.append(wrd)
            dbase.set_context('pics_lib', Was)
        elif (len(wrds) == 2):
            Param = wrds[0]
            Value = wrds[1]
            #            logs.log_info('read_init_file set context "%s" "%s"'%(Param,Value))
            if (',') in Value:
                W1 = Value.split(',')
                ll = []
                for X in W1:
                    ll.append(makenum(X))
                dbase.set_context(Param, ll)
            elif (Value[0] in '0123456789'):
                dbase.set_context(Param, makenum(Value))
            else:
                dbase.set_context(Param, Value)
        elif (len(wrds) > 0):
            logs.log_warning('read_init_file got "%s" . not valid.' %
                             (' '.join(wrds)))
Esempio n. 7
0
    def try_load_picture(self, Pic):
        if Pic in self.pictures:
            return
        Dirs = self.get_context('pics_lib')
        for Extension in ['zlib', 'zpic']:
            if type(Dirs) is list:
                for Dir in Dirs:
                    Fname = '%s/%s.%s' % (Dir, Pic, Extension)
                    if os.path.exists(Fname):
                        dbase.load_dbase_file(Fname)
                        return True

            elif type(Dirs) is str:
                Fname = '%s/%s.%s' % (Dirs, Pic, Extension)
                if os.path.exists(Fname):
                    dbase.load_dbase_file(Fname)
                    return True

            Fname = '%s.%s' % (Pic, Extension)
            if os.path.exists(Fname):
                dbase.load_dbase_file(Fname)
                return True
        return False