示例#1
0
 def _deregister(self,name):
     fn = LU.standardiseDriverNames(name)
     #sync/rel the DS
     #self.register[fn]['ep'].closeDS()#DS should already have closed
     self.register[fn]['ep'] = None
     self.register[fn]['type'] = None
     self.register[fn]['uri'] = None
     del self.register[fn]
示例#2
0
 def _deregister(self, name):
     fn = LU.standardiseDriverNames(name)
     #sync/rel the DS
     #self.register[fn]['ep'].closeDS()#DS should already have closed
     self.register[fn]['ep'] = None
     self.register[fn]['type'] = None
     self.register[fn]['uri'] = None
     del self.register[fn]
示例#3
0
 def _initSection(self, section):
     checksec = LU.standardiseDriverNames(section)
     if checksec:
         self.cp.add_section(checksec)
         return True
     elif section == self.PREFS_SEC:
         self.cp.add_section(section)
         return True
     return False
示例#4
0
 def _initSection(self,section):
     checksec = LU.standardiseDriverNames(section)
     if checksec:
         self.cp.add_section(checksec)
         return True
     elif section == self.PREFS_SEC:
         self.cp.add_section(section)
         return True
     return False
示例#5
0
 def closeEndPoint(self, name):
     '''Closes the DS is a named EP or delete the EP completely if not needed'''
     fn = LU.standardiseDriverNames(name)
     #<HACK6>. Bypass DS closing for FileGDB connections
     if fn == 'FileGDB': return
     #</HACK6>
     if self.register.has_key(fn):
         self._disconnect(fn)
         if self.register[fn]['rc'] == 0:
             self._deregister(fn)
示例#6
0
 def closeEndPoint(self,name):
     '''Closes the DS is a named EP or delete the EP completely if not needed'''
     fn = LU.standardiseDriverNames(name)
     #<HACK6>. Bypass DS closing for FileGDB connections
     if fn=='FileGDB': return
     #</HACK6>
     if self.register.has_key(fn):
         self._disconnect(fn)
         if self.register[fn]['rc'] == 0:
             self._deregister(fn)
示例#7
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()
示例#8
0
 def openEndPoint(self,name,uri=None,req=None):
     #print 'GEP',name,uri,req
     '''Gets a named EP incrementing a refcount or registers a new one as needed'''
     fn = LU.standardiseDriverNames(name)
     #if fn+uri exist AND fn is valid AND (fn not prev registered OR the saved URI != uri) 
     if (fn and uri)\
     and (fn in DataStore.DRIVER_NAMES.values() or fn == WFSDataStore.DRIVER_NAME) \
     and (not self.register.has_key(fn) or self.register[fn]['uri']!=uri):
         self._register(fn,uri)
         self._connect(fn, req)
     elif fn in self.register: 
         self._connect(fn,req)
     else:
         raise EndpointConnectionException('Register Entry {} has not been initialised.'.format(fn))
     return self.register[fn]['ep']
示例#9
0
 def openEndPoint(self, name, uri=None, req=None):
     #print 'GEP',name,uri,req
     '''Gets a named EP incrementing a refcount or registers a new one as needed'''
     fn = LU.standardiseDriverNames(name)
     #if fn+uri exist AND fn is valid AND (fn not prev registered OR the saved URI != uri)
     if (fn and uri)\
     and (fn in DataStore.DRIVER_NAMES.values() or fn == WFSDataStore.DRIVER_NAME) \
     and (not self.register.has_key(fn) or self.register[fn]['uri']!=uri):
         self._register(fn, uri)
         self._connect(fn, req)
     elif fn in self.register:
         self._connect(fn, req)
     else:
         raise EndpointConnectionException(
             'Register Entry {} has not been initialised.'.format(fn))
     return self.register[fn]['ep']
示例#10
0
    if len(args)==0:
        print __doc__
        sys.exit(0)
    else: 
        #since we're not breaking the switch the last arg read will be the DST used
        pn = None
        for arg in args:
            if arg.lower() in ("init", "initialise", "initalize"):
                ldslog.info("Initialisation of configuration files/tables requested. Implies FULL rebuild")
                tp.setInitConfig()
            elif arg in ("clean"):
                ldslog.info("Cleaning named layer")
                tp.setCleanConfig()
            else:
                #if we dont have init/clean the only other arg must be output type
                pn = LDSUtilities.standardiseDriverNames(arg)
                
        if pn is None:
            print __doc__
            raise InputMisconfigurationException("Unrecognised command; output type (pg,ms,slite,fgdb) declaration required")
            

    #aggregation point for common LDS errors
    mm = '*** Complete *** '
    try:
        reg = DatasourceRegister()
        sep = reg.openEndPoint('WFS',uc)
        dep = reg.openEndPoint(pn,uc)
        reg.setupLayerConfig(tp,sep,dep, tp.getInitConfig())
        tp.setSRC(sep)
        tp.setDST(dep)
示例#11
0
 def updateGUIValues(self,readlist):
     '''Fill dialog values from provided list'''
     #TODO. Remove circular references when setCurrentIndex() triggers do###Changed()
     #Read user input
     rdest,self.rlgval,ruconf,repsg,rfd,rtd = readlist
     
     #--------------------------------------------------------------------
     
     #Destination Menu
     selecteddest = LU.standardiseDriverNames(rdest)
     if selecteddest not in self.destlist:
         self.destlist = self.getConfiguredDestinations()
         self.destcombo.addItem(selecteddest)
     destindex = self.destlist.index(selecteddest) if selecteddest else 0
     
     if self.destcombo.currentIndex() != destindex:
         self.destcombo.setCurrentIndex(destindex)
     
     #InitButton
     self.initbutton.setText('Layer Select')
     
     #Config File
     confindex = 0
     if LU.assessNone(ruconf):
         ruconf = ruconf.split('.')[0]
         if ruconf not in self.cflist:
             self.cflist += [ruconf,]
             self.confcombo.addItem(ruconf)
         confindex = self.cflist.index(ruconf)
         
     if self.confcombo.currentIndex() != confindex:
         self.confcombo.setCurrentIndex(confindex)
     #self.confEdit.setText(ruconf if LU.assessNone(ruconf) else '')
     
     #Layer/Group Selection
     self.updateLGValues(ruconf,self.rlgval,rdest)
     lgindex = None
     if LU.assessNone(self.rlgval):
         #index of list value
         lgindex = self.parent.confconn.getLayerGroupIndex(self.rlgval,col=1)
         
     if LU.assessNone(lgindex):
         #advance by 1 for sep
         lgindex += 1 if lgindex>self.sepindex else 0 
     else:
         #using the separator index sets the combo to blank
         lgindex = self.sepindex
     if self.lgcombo.currentIndex() != lgindex:
         self.lgcombo.setCurrentIndex(lgindex)
     #self.doLGEditUpdate()
     
     #EPSG
     #                                user > layerconf
     #useepsg = LU.precedence(repsg, lce.epsg if lce else None, None)
     epsgindex = [i[0] for i in self.nzlsr+[(None,None)]+self.rowsr].index(repsg)
     if self.epsgcombo.currentIndex() != epsgindex:
         self.epsgcombo.setCurrentIndex(epsgindex)
         
     #epsgedit = self.epsgcombo.lineEdit()
     #epsgedit.setText([e[1] for e in self.nzlsr+self.rowsr if e[0]==repsg][0])
     
     #epsgedit.setText([e for e in self.nzlsr+self.rowsr if re.match('^\s*(\d+).*',e).group(1)==repsg][0])
     
     #To/From Dates
     if LU.assessNone(rfd):
         self.fromdateedit.setDate(QDate(int(rfd[0:4]),int(rfd[5:7]),int(rfd[8:10])))
     else:
         early = DataStore.EARLIEST_INIT_DATE
         self.fromdateedit.setDate(QDate(int(early[0:4]),int(early[5:7]),int(early[8:10])))
         
     if LU.assessNone(rtd):
         self.todateedit.setDate(QDate(int(rtd[0:4]),int(rtd[5:7]),int(rtd[8:10]))) 
     else:
         today = DataStore.getCurrent()
         self.todateedit.setDate(QDate(int(today[0:4]),int(today[5:7]),int(today[8:10])))
示例#12
0
 def updateGUIValues(self,readlist):
     '''Fill dialog values from provided list'''
     #TODO. Remove circular references when setCurrentIndex() triggers do###Changed()
     #Read user input
     rdest,self.rlgval,ruconf,repsg,rfd,rtd = readlist
     
     #--------------------------------------------------------------------
     
     #Destination Menu
     selecteddest = LU.standardiseDriverNames(rdest)
     if selecteddest not in self.destlist:
         self.destlist = self.getConfiguredDestinations()
         self.destcombo.addItem(selecteddest)
     destindex = self.destlist.index(selecteddest) if selecteddest else 0
     
     if self.destcombo.currentIndex() != destindex:
         self.destcombo.setCurrentIndex(destindex)
     
     #InitButton
     self.initbutton.setText('Layer Select')
     
     #Config File
     confindex = 0
     if LU.assessNone(ruconf):
         ruconf = ruconf.split('.')[0]
         if ruconf not in self.cflist:
             self.cflist += [ruconf,]
             self.confcombo.addItem(ruconf)
         confindex = self.cflist.index(ruconf)
         
     if self.confcombo.currentIndex() != confindex:
         self.confcombo.setCurrentIndex(confindex)
     #self.confEdit.setText(ruconf if LU.assessNone(ruconf) else '')
     
     #Layer/Group Selection
     self.updateLGValues(ruconf,self.rlgval,rdest)
     lgindex = None
     if LU.assessNone(self.rlgval):
         #index of list value
         lgindex = self.parent.confconn.getLayerGroupIndex(self.rlgval,col=1)
         
     if LU.assessNone(lgindex):
         #advance by 1 for sep
         lgindex += 1 if lgindex>self.sepindex else 0 
     else:
         #using the separator index sets the combo to blank
         lgindex = self.sepindex
     if self.lgcombo.currentIndex() != lgindex:
         self.lgcombo.setCurrentIndex(lgindex)
     #self.doLGEditUpdate()
     
     #EPSG
     #                                user > layerconf
     #useepsg = LU.precedence(repsg, lce.epsg if lce else None, None)
     epsgindex = [i[0] for i in self.nzlsr+[(None,None)]+self.rowsr].index(repsg)
     if self.epsgcombo.currentIndex() != epsgindex:
         self.epsgcombo.setCurrentIndex(epsgindex)
         
     #epsgedit = self.epsgcombo.lineEdit()
     #epsgedit.setText([e[1] for e in self.nzlsr+self.rowsr if e[0]==repsg][0])
     
     #epsgedit.setText([e for e in self.nzlsr+self.rowsr if re.match('^\s*(\d+).*',e).group(1)==repsg][0])
     
     #To/From Dates
     if LU.assessNone(rfd):
         self.fromdateedit.setDate(QDate(int(rfd[0:4]),int(rfd[5:7]),int(rfd[8:10])))
     else:
         early = DataStore.EARLIEST_INIT_DATE
         self.fromdateedit.setDate(QDate(int(early[0:4]),int(early[5:7]),int(early[8:10])))
         
     if LU.assessNone(rtd):
         self.todateedit.setDate(QDate(int(rtd[0:4]),int(rtd[5:7]),int(rtd[8:10]))) 
     else:
         today = DataStore.getCurrent()
         self.todateedit.setDate(QDate(int(today[0:4]),int(today[5:7]),int(today[8:10])))