def setupMainAndUserConfig(self, inituserconfig):
     '''Sets up a reader to the main configuration file or alternatively, a user specified config file.
     Userconfig is not mean't to replace mainconfig, just overwrite the parts the user has decided to customise'''
     #self.userconfig = None
     self.userconfig = MainFileReader(
         LDSUtilities.standardiseUserConfigName(inituserconfig),
         False) if inituserconfig else None
     self.mainconfig = MainFileReader()
Example #2
0
    def __init__(self, cfpath=None, use_defaults=True):
        '''
        Constructor
        '''

        from lds.DataStore import DataStore
        self.driverconfig = {i: () for i in DataStore.DRIVER_NAMES}

        self.use_defaults = use_defaults
        #if we dont give the constructor a file path is uses the template file which will fill in any default values missed in the user conf
        #but if cpath is requested and doesn't exist we initialise it, otherwise you end up trying to overwrite the template
        if cfpath is None:
            self.filename = LU.standardiseUserConfigName(self.DEFAULT_MF)
        else:
            #Standardise since there is no guarantee cfpath is going to be in the reqd format to start with (since its a user entry)
            self.filename = LU.standardiseUserConfigName(cfpath)

        self.cp = None
        self.initMainFile()
        self.fn = re.search('(.+)\.conf',
                            os.path.basename(self.filename)).group(1)
Example #3
0
    def __init__(self,cfpath=None,use_defaults=True):
        '''
        Constructor
        '''
        
        from lds.DataStore import DataStore
        self.driverconfig = {i:() for i in DataStore.DRIVER_NAMES}
            
        self.use_defaults = use_defaults
        #if we dont give the constructor a file path is uses the template file which will fill in any default values missed in the user conf
        #but if cpath is requested and doesn't exist we initialise it, otherwise you end up trying to overwrite the template
        if cfpath is None:
            self.filename = LU.standardiseUserConfigName(self.DEFAULT_MF)
        else:
            #Standardise since there is no guarantee cfpath is going to be in the reqd format to start with (since its a user entry)
            self.filename = LU.standardiseUserConfigName(cfpath)

        
        self.cp = None
        self.initMainFile()
        self.fn = re.search('(.+)\.conf',os.path.basename(self.filename)).group(1)
Example #4
0
    def runReplicationScript(self,clean=False):
        '''Run the layer/group repliction script'''
        destination,lgval,uconf,epsg,fe,te,fd,td = self.readParameters()
        uconf_path = LU.standardiseUserConfigName(uconf)
        destination_path = LU.standardiseLayerConfigName(destination)
        destination_driver = LU.standardiseDriverNames(destination)

        if not os.path.exists(uconf_path):
            self.userConfMessage(uconf_path)
            return
        elif not MainFileReader(uconf_path).hasSection(destination_driver):
            self.userConfMessage(uconf_path,destination_driver)
            return
        #-----------------------------------------------------
        #'destname','layer','uconf','group','epsg','fd','td','int'
     
        self.parent.gpr.write((destination_driver,lgval,uconf,epsg,fd,td))        
        ldslog.info(u'dest={0}, lg={1}, conf={2}, epsg={3}'.format(destination_driver,lgval,uconf,epsg))
        ldslog.info('fd={0}, td={1}, fe={2}, te={3}'.format(fd,td,fe,te))
        lgindex = self.parent.confconn.getLayerGroupIndex(lgval,col=1)
        #lorg = self.parent.confconn.lglist[lgindex][0]
        #----------don't need lorg in TP anymore but it is useful for sorting/counting groups
        #self.parent.confconn.tp.setLayerOrGroup(lorg)
        self.parent.confconn.tp.setLayerGroupValue(lgval)
        if self.fromdateenable.isChecked(): self.parent.confconn.tp.setFromDate(fd)
        if self.todateenable.isChecked(): self.parent.confconn.tp.setToDate(td)
        self.parent.confconn.tp.setUserConf(uconf)
        if self.epsgenable: self.parent.confconn.tp.setEPSG(epsg)
        
        #because clean state persists in TP
        if clean:
            self.parent.confconn.tp.setCleanConfig()
        else:
            self.parent.confconn.tp.clearCleanConfig()
        #(re)initialise the data source since uconf may have changed
        #>>#self.parent.confconn.tp.src = self.parent.confconn.initSourceWrapper()
        #--------------------------
        ###ep = self.parent.confconn.reg.openEndPoint(self.parent.confconn.destname,self.parent.confconn.uconf)
        
        ###self.parent.confconn.reg.closeEndPoint(self.parent.confconn.destname)
        ###ep = None
        #Open ProcessRunner and run with TP(proc)/self(gui) instances
        #HACK temp add of dest_drv to PR call
        try:
            #TODO. Test for valid LC first
            self.tpr = ProcessRunner(self,destination_driver)
        except Exception as e:
            ldslog.error('Cannot create ProcessRunner {}. NB Possible missing Layer Config {}'.format(str(e),destination_path))
            self.layerConfMessage(destination_path)
            return
        #If PR has been successfully created we must vave a valid dst    
        ldslog.debug('TRPstart')
        self.tpr.start()
Example #5
0
 def launchUCEditor(self, checked=None):
     '''User Config Editor launch'''
     fn = LU.standardiseUserConfigName(str(self.controls.cflist[self.controls.confcombo.currentIndex()]))
     prefs = LDSPrefsEditor(fn,self)
     prefs.setWindowTitle('LDS Preferences Editor (User Config)')
     prefs.show()    
Example #6
0
 def setupMainAndUserConfig(self,inituserconfig):
     '''Sets up a reader to the main configuration file or alternatively, a user specified config file.
     Userconfig is not mean't to replace mainconfig, just overwrite the parts the user has decided to customise'''
     #self.userconfig = None
     self.userconfig = MainFileReader(LDSUtilities.standardiseUserConfigName(inituserconfig),False) if inituserconfig else None
     self.mainconfig = MainFileReader()
Example #7
0
 def launchUCEditor(self, checked=None):
     '''User Config Editor launch'''
     fn = LU.standardiseUserConfigName(str(self.controls.cflist[self.controls.confcombo.currentIndex()]))
     prefs = LDSPrefsEditor(fn,self)
     prefs.setWindowTitle('LDS Preferences Editor (User Config)')
     prefs.show()