示例#1
0
    def buildIndex(self):
        '''Builds an index creation string for a new full replicate in PG format'''
        tableonly = self.dst_info.ascii_name.split('.')[-1]
        ALLOW_TABLE_INDEX_CREATION = True
        #SpatiaLite doesnt have a unique constraint but since we're using a pk might a well declare it as such
        if ALLOW_TABLE_INDEX_CREATION and LDSUtilities.assessNone(
                self.dst_info.pkey):
            #spatialite won't do post create constraint additions (could to a re-create?)
            cmd = 'CREATE INDEX {0}_{1}_PK ON {0}({1})'.format(
                tableonly, self.dst_info.pkey)
            try:
                self.executeSQL(cmd)
                ldslog.info("Index = {}({}). Execute = {}".format(
                    tableonly, self.dst_info.pkey, cmd))
            except RuntimeError as rte:
                if re.search('already exists', str(rte)):
                    ldslog.warn(rte)
                else:
                    raise

        #Unless we select SPATIAL_INDEX=no as a Layer option this should never be needed
        #because gcol is also used to determine whether a layer is spatial still do this check
        if LDSUtilities.assessNone(self.dst_info.geocolumn):
            #untested and unlikely to work
            cmd = "CREATE INDEX {0}_{1}_SK ON {0}({1})".format(
                self.dst_info.ascii_name, self.dst_info.geocolumn)
            try:
                self.executeSQL(cmd)
                ldslog.info("Index = {}({}). Execute = {}.".format(
                    tableonly, self.dst_info.geocolumn, cmd))
            except RuntimeError as rte:
                if re.search('already exists', str(rte)):
                    ldslog.warn(rte)
                else:
                    raise
 def buildIndex(self):
     '''Builds an index creation string for a new full replicate'''
     tableonly = self.dst_info.ascii_name.split('.')[-1]
     
     if LU.assessNone(self.dst_info.pkey):
         cmd = 'ALTER TABLE {0} ADD CONSTRAINT {1}_{2}_PK UNIQUE({2})'.format(self.dst_info.ascii_name,tableonly,self.dst_info.pkey)
         try:
             self.executeSQL(cmd)
             ldslog.info("Index = {}({}). Execute = {}".format(tableonly,self.dst_info.pkey,cmd))
         except RuntimeError as rte:
             if re.search('already exists', str(rte)): 
                 ldslog.warn(rte)
             else:
                 raise        
             
     if LU.assessNone(self.dst_info.geocolumn):
         cmd = 'CREATE SPATIAL INDEX {1}_{2}_GK ON {0}({2})'.format(self.dst_info.ascii_name,tableonly,self.dst_info.geocolumn)
         cmd += ' WITH (BOUNDING_BOX = (XMIN = {0},YMIN = {1},XMAX = {2},YMAX = {3}))'.format(self.BBOX['XMIN'],self.BBOX['YMIN'],self.BBOX['XMAX'],self.BBOX['YMAX'])
         #cmd = 'CREATE SPATIAL INDEX ON {}'.format(tableonly)
         try:
             self.executeSQL(cmd)
             ldslog.info("Index = {}({}). Execute = {}".format(tableonly,self.dst_info.geocolumn,cmd))
         except RuntimeError as rte:
             if re.search('already exists', str(rte)): 
                 ldslog.warn(rte)
             else:
                 raise
示例#3
0
 def buildIndex(self):
     '''Builds an index creation string for a new full replicate in PG format'''
     tableonly = self.dst_info.ascii_name.split('.')[-1]
     
     if LDSUtilities.assessNone(self.dst_info.pkey):
         cmd = 'ALTER TABLE {0} ADD CONSTRAINT {1}_{2}_PK UNIQUE({2})'.format(self.dst_info.ascii_name,tableonly,self.dst_info.pkey)
         try:
             self.executeSQL(cmd)
             ldslog.info("Index = {}({}). Execute = {}".format(tableonly,self.dst_info.pkey,cmd))
         except RuntimeError as rte:
             if re.search('already exists', str(rte)): 
                 ldslog.warn(rte)
             else:
                 raise
                     
     #If a spatial index has already been created don't try to create another one
     if self.SPATIAL_INDEX == 'OFF' and LDSUtilities.assessNone(self.dst_info.geocolumn):
         cmd = 'CREATE INDEX {1}_{2}_GK ON {0} USING GIST({2})'.format(self.dst_info.ascii_name,tableonly,self.dst_info.geocolumn)
         try:
             self.executeSQL(cmd)
             ldslog.info("Index = {}({}). Execute = {}".format(tableonly,self.dst_info.geocolumn,cmd))
         except RuntimeError as rte:
             if re.search('already exists', str(rte)): 
                 ldslog.warn(rte)
             else:
                 raise
示例#4
0
 def buildIndex(self):
     '''Builds an index creation string for a new full replicate in PG format'''
     tableonly = self.dst_info.ascii_name.split('.')[-1]
     ALLOW_CONSTRAINT_CREATION=False
     #SpatiaLite doesnt have a unique constraint but since we're using a pk might a well declare it as such
     if ALLOW_CONSTRAINT_CREATION and LDSUtilities.assessNone(self.dst_info.pkey):
         #spatialite won't do post create constraint additions (could to a re-create?)
         cmd = 'ALTER TABLE {0} ADD PRIMARY KEY {1}_{2}_PK ({2})'.format(self.dst_info.ascii_name,tableonly,self.dst_info.pkey)
         try:
             self.executeSQL(cmd)
             ldslog.info("Index = {}({}). Execute = {}".format(tableonly,self.dst_info.pkey,cmd))
         except RuntimeError as rte:
             if re.search('already exists', str(rte)): 
                 ldslog.warn(rte)
             else:
                 raise        
     
     #Unless we select SPATIAL_INDEX=no as a Layer option this should never be needed
     #because gcol is also used to determine whether a layer is spatial still do this check   
     if LDSUtilities.assessNone(self.dst_info.geocolumn) and 'SPATIAL_INDEX=NO' in [opt.replace(' ','').upper() for opt in self.sl_local_opts]:
         cmd = "SELECT CreateSpatialIndex('{}','{}')".format(self.dst_info.ascii_name,self.DEFAULT_GCOL)
         try:
             self.executeSQL(cmd)
             ldslog.info("Index = {}({}). Execute = {}. NB Cannot override Geo-Column Name.".format(tableonly,self.DEFAULT_GCOL,cmd))
         except RuntimeError as rte:
             if re.search('already exists', str(rte)): 
                 ldslog.warn(rte)
             else:
                 raise
示例#5
0
 def buildIndex(self):
     '''Builds an index creation string for a new full replicate in PG format'''
     tableonly = self.dst_info.ascii_name.split('.')[-1]
     ALLOW_TABLE_INDEX_CREATION=True
     #SpatiaLite doesnt have a unique constraint but since we're using a pk might a well declare it as such
     if ALLOW_TABLE_INDEX_CREATION and LDSUtilities.assessNone(self.dst_info.pkey):
         #spatialite won't do post create constraint additions (could to a re-create?)
         cmd = 'CREATE INDEX {0}_{1}_PK ON {0}({1})'.format(tableonly,self.dst_info.pkey)
         try:
             self.executeSQL(cmd)
             ldslog.info("Index = {}({}). Execute = {}".format(tableonly,self.dst_info.pkey,cmd))
         except RuntimeError as rte:
             if re.search('already exists', str(rte)): 
                 ldslog.warn(rte)
             else:
                 raise        
     
     #Unless we select SPATIAL_INDEX=no as a Layer option this should never be needed
     #because gcol is also used to determine whether a layer is spatial still do this check   
     if LDSUtilities.assessNone(self.dst_info.geocolumn):
         #untested and unlikely to work
         cmd = "CREATE INDEX {0}_{1}_SK ON {0}({1})".format(self.dst_info.ascii_name,self.dst_info.geocolumn)
         try:
             self.executeSQL(cmd)
             ldslog.info("Index = {}({}). Execute = {}.".format(tableonly,self.dst_info.geocolumn,cmd))
         except RuntimeError as rte:
             if re.search('already exists', str(rte)): 
                 ldslog.warn(rte)
             else:
                 raise
示例#6
0
 def readLayerProperty(self, layer, key):
     try:
         if isinstance(layer, tuple) or isinstance(layer, list):
             value = ()
             for l in layer:
                 value += (LU.assessNone(self.cp.get(l, key)), )
         else:
             value = LU.assessNone(self.cp.get(layer, key))
     except:
         '''return a default value otherwise none which would also be a default for some keys'''
         #the logic here may be a bit suss, if the property is blank return none but if there is an error assume a default is needed?
         return {'pkey': 'ID', 'name': layer, 'geocolumn': 'SHAPE'}.get(key)
     return value
示例#7
0
 def readLayerProperty(self,layer,key):
     try:
         if isinstance(layer,tuple) or isinstance(layer,list):
             value = () 
             for l in layer:
                 value += (LU.assessNone(self.cp.get(l, key)),)
         else:
             value = LU.assessNone(self.cp.get(layer, key))
     except:
         '''return a default value otherwise none which would also be a default for some keys'''
         #the logic here may be a bit suss, if the property is blank return none but if there is an error assume a default is needed?
         return {'pkey':'ID','name':layer,'geocolumn':'SHAPE'}.get(key)
     return value
 def writeKeysToLayerConfig(self, ckey):
     '''Add custom key to the selection_model list of layers (assumes required av->sl transfer completed) not just the transferring entry'''
     layerlist = [ll[0] for ll in self.selection_model.mdata]
     replacementlist = ()
     dep = self.parent.confconn.reg.openEndPoint(
         self.parent.confconn.destname, self.parent.confconn.uconf)
     #print 'opened dep=',dep,'reg=',self.parent.confconn.reg#DEBUG
     self.parent.confconn.reg.setupLayerConfig(self.parent.confconn.tp,
                                               None,
                                               dep,
                                               initlc=False)
     #categorylist = [f.encode('utf8').strip() for f in dep.getLayerConf().readLayerProperty(layerlist, 'category') if f]
     categorylist = [
         LU.assessNone(f) for f in dep.getLayerConf().readLayerProperty(
             layerlist, 'category')
     ]
     for cat in categorylist:
         replacementlist += ((cat if ckey in cat.split(',') else cat + ',' +
                              ckey) if cat else ckey, )
     #print '>>> writing this replacementlist to LC',replacementlist
     dep.getLayerConf().writeLayerProperty(layerlist, 'category',
                                           replacementlist)
     #new keyword written so re-read complete (LC) and update assigned keys list
     self.parent.confconn.setupCompleteLayerList(dep, refresh=True)
     self.parent.confconn.setupAssignedLayerList()
     self.parent.confconn.buildLayerGroupList()
     #self.refreshLayers(dep,customkey)
     #print 'closing dep=',dep,'reg=',self.parent.confconn.reg#DEBUG
     self.parent.confconn.reg.closeEndPoint(self.parent.confconn.destname)
     dep = None
 def closeEvent(self, event):
     '''Intercept close event to signal parent to update status'''
     self.parent.controls.setStatus(self.parent.controls.STATUS.IDLE,
                                    'Done')
     #return last group selection
     #lastgroup = LU.recode(self.page.keywordcombo.lineEdit().text().toUtf8().data())
     lastgroup = LU.recode(
         LQ.readWidgetText(self.page.keywordcombo.lineEdit().text()))
     #self.parent.controls.gpr.writeline('lgvalue',lastgroup)
     if LU.assessNone(lastgroup):
         dep = self.parent.confconn.reg.openEndPoint(
             self.parent.confconn.destname, self.parent.confconn.uconf)
         #sep = self.parent.confconn.reg.openEndPoint('WFS',self.parent.confconn.uconf)
         self.parent.confconn.reg.setupLayerConfig(self.parent.confconn.tp,
                                                   None, dep)
         self.parent.confconn.setupCompleteLayerList(dep)
         self.parent.confconn.setupAssignedLayerList()
         self.parent.confconn.buildLayerGroupList()
         lgindex = self.parent.confconn.getLayerGroupIndex(lastgroup, col=1)
         self.parent.controls.refreshLGCombo()
         #current index wont be available in parent if this is the init run
         self.parent.controls.lgcombo.setCurrentIndex(
             lgindex if lgindex else 0)
         #self.parent.confconn.reg.closeEndPoint('WFS')
         self.parent.confconn.reg.closeEndPoint(
             self.parent.confconn.destname)
         sep, dep = None, None
示例#10
0
    def fetchLayerInfo(cls, url, ver=None, proxy=None):
        '''Non-GDAL static method for fetching LDS layer ID's using etree parser.'''
        res = []
        content = None
        wfs_ns = cls.NS['wfs20'] if re.match('^2', ver) else cls.NS['wfs11']
        ftxp = "//{0}FeatureType".format(wfs_ns)
        nmxp = "./{0}Name".format(wfs_ns)
        ttxp = "./{0}Title".format(wfs_ns)
        kyxp = "./{0}Keywords/{0}Keyword".format(cls.NS['ows'])

        try:
            if not LDSUtilities.assessNone(proxy):
                install_opener(build_opener(ProxyHandler(proxy)))
            #content = urlopen(url)#bug in lxml doesnt close url/files using parse method
            with closing(urlopen(url)) as content:
                tree = etree.parse(content)
                for ft in tree.findall(ftxp):
                    name = ft.find(nmxp).text  #.encode('utf8')
                    title = ft.find(ttxp).text  #.encode('utf8')
                    #keys = [x.text.encode('utf8') for x in ft.findall(kyxp)]
                    keys = [x.text for x in ft.findall(kyxp)]

                    res += ((name, title, keys), )

        except XMLSyntaxError as xe:
            ldslog.error('Error parsing URL;' + str(url) + ' ERR;' + str(xe))

        return res
示例#11
0
 def fetchLayerInfo(cls,url,ver=None,proxy=None):
     '''Non-GDAL static method for fetching LDS layer ID's using etree parser.'''
     res = []
     content = None
     wfs_ns = cls.NS['wfs20'] if re.match('^2',ver) else cls.NS['wfs11']
     ftxp = "//{0}FeatureType".format(wfs_ns)
     nmxp = "./{0}Name".format(wfs_ns)
     ttxp = "./{0}Title".format(wfs_ns)
     kyxp = "./{0}Keywords/{0}Keyword".format(cls.NS['ows'])
     
     try:            
         if not LDSUtilities.assessNone(proxy): install_opener(build_opener(ProxyHandler(proxy)))
         #content = urlopen(url)#bug in lxml doesnt close url/files using parse method
         with closing(urlopen(url)) as content:
             tree = etree.parse(content)
             for ft in tree.findall(ftxp):
                 name = ft.find(nmxp).text#.encode('utf8')
                 title = ft.find(ttxp).text#.encode('utf8')
                 #keys = [x.text.encode('utf8') for x in ft.findall(kyxp)]
                 keys = [x.text for x in ft.findall(kyxp)]
                 
                 res += ((name,title,keys),)
             
     except XMLSyntaxError as xe:
         ldslog.error('Error parsing URL;'+str(url)+' ERR;'+str(xe))
         
     return res
示例#12
0
 def writesecline(self,section,field,value):
     try:            
         self.cp.set(section,field,value if LU.assessNone(value) else '')
         with codecs.open(self.fn, 'w','utf-8') as configfile:
             self.cp.write(configfile)
         ldslog.debug(str(section)+':'+str(field)+'='+str(value))                                                                                        
     except Exception as e:
         ldslog.warn('Problem writing GUI prefs. {} - sfv={}'.format(e,(section,field,value)))
示例#13
0
 def checkKeyword(self,ktext):
     '''Checks keyword isn't null and isn't part of the LDS supplied keywords'''
     if LU.assessNone(ktext) is None:
         QMessageBox.about(self, "Keyword Required","Please enter a Keyword to assign Layer(s) to")
         return False
     if ktext in self.confconn_link.reserved:
         QMessageBox.about(self, "Reserved Keyword","'{}' is a reserved keyword, please select again".format(ktext))
         return False
     return True
示例#14
0
    def readMainProperty(self,driver,key):
        try:
            return LU.assessNone(self.cp.get(driver, key))
#             if LU.assessNone(value) is None:
#                 return None
        except:
            '''return a default value otherwise none which would also be a default for some keys'''
            ldslog.warn("Cannot find requested driver/key in {}; self.cp.get('{}','{}') combo".format(self.filename[self.filename.rfind('/'):],driver,key))
        return None
示例#15
0
 def writesecline(self, section, field, value):
     try:
         self.cp.set(section, field, value if LU.assessNone(value) else '')
         with codecs.open(self.fn, 'w', 'utf-8') as configfile:
             self.cp.write(configfile)
         ldslog.debug(str(section) + ':' + str(field) + '=' + str(value))
     except Exception as e:
         ldslog.warn('Problem writing GUI prefs. {} - sfv={}'.format(
             e, (section, field, value)))
示例#16
0
 def readParameters(self):
     '''Read values out of dialogs'''
     destination = LU.assessNone(str(self.destlist[self.destcombo.currentIndex()]))
     #lgindex = self.parent.confconn.getLayerGroupIndex(self.lgcombo.currentText().toUtf8().data())
     lgindex = self.parent.confconn.getLayerGroupIndex(LQ.readWidgetText(self.lgcombo.currentText()))
     #NB need to test for None explicitly since zero is a valid index
     lgval = self.parent.confconn.lglist[lgindex][1] if LU.assessNone(lgindex) else None       
     #uconf = LU.standardiseUserConfigName(str(self.confcombo.lineEdit().text()))
     #uconf = str(self.confcombo.lineEdit().text())
     uconf = str(self.cflist[self.confcombo.currentIndex()])
     ee = self.epsgenable.isChecked()
     epsg = None if ee is False else re.match('^\s*(\d+).*',str(self.epsgcombo.lineEdit().text())).group(1)
     fe = self.fromdateenable.isChecked()
     te = self.todateenable.isChecked()
     fd = None if fe is False else str(self.fromdateedit.date().toString('yyyy-MM-dd'))
     td = None if te is False else str(self.todateedit.date().toString('yyyy-MM-dd'))
     
     return destination,lgval,uconf,epsg,fe,te,fd,td
示例#17
0
 def readParameters(self):
     '''Read values out of dialogs'''
     destination = LU.assessNone(str(self.destlist[self.destcombo.currentIndex()]))
     #lgindex = self.parent.confconn.getLayerGroupIndex(self.lgcombo.currentText().toUtf8().data())
     lgindex = self.parent.confconn.getLayerGroupIndex(LQ.readWidgetText(self.lgcombo.currentText()))
     #NB need to test for None explicitly since zero is a valid index
     lgval = self.parent.confconn.lglist[lgindex][1] if LU.assessNone(lgindex) else None       
     #uconf = LU.standardiseUserConfigName(str(self.confcombo.lineEdit().text()))
     #uconf = str(self.confcombo.lineEdit().text())
     uconf = str(self.cflist[self.confcombo.currentIndex()])
     ee = self.epsgenable.isChecked()
     epsg = None if ee is False else re.match('^\s*(\d+).*',str(self.epsgcombo.lineEdit().text())).group(1)
     fe = self.fromdateenable.isChecked()
     te = self.todateenable.isChecked()
     fd = None if fe is False else str(self.fromdateedit.date().toString('yyyy-MM-dd'))
     td = None if te is False else str(self.todateedit.date().toString('yyyy-MM-dd'))
     
     return destination,lgval,uconf,epsg,fe,te,fd,td
示例#18
0
    def readMainProperty(self, driver, key):
        try:
            return LU.assessNone(self.cp.get(driver, key))
#             if LU.assessNone(value) is None:
#                 return None
        except:
            '''return a default value otherwise none which would also be a default for some keys'''
            ldslog.warn(
                "Cannot find requested driver/key in {}; self.cp.get('{}','{}') combo"
                .format(self.filename[self.filename.rfind('/'):], driver, key))
        return None
示例#19
0
 def _commonURI(self,layer):
     '''Refers to common connection instance for reading or writing'''
     if hasattr(self,'conn_str') and self.conn_str:
         return self.validateConnStr(self.conn_str)
     #can't put schema in quotes, causes error but without quotes tables get created in public anyway, still need schema.table syntax
     if LDSUtilities.assessNone(self.pwd):
         if self.pwd.startswith(Encrypt.ENC_PREFIX):
             pwd = " password='******'".format(Encrypt.unSecure(self.pwd))
         else:
             pwd = " password='******'".format(self.pwd)
     else:
         pwd = ""
     
     sch = " active_schema={}".format(self.schema) if LDSUtilities.assessNone(self.schema) else ""
     usr = "******".format(self.usr) if LDSUtilities.assessNone(self.usr) else ""
     hst = " host='{}'".format(self.host) if LDSUtilities.assessNone(self.host) else ""
     prt = " port='{}'".format(self.port) if LDSUtilities.assessNone(self.port) else ""
     uri = "PG:dbname='{}'".format(self.dbname)+hst+prt+usr+pwd+sch
     ldslog.debug(uri)
     return uri
 def _commonURI(self,layer):
     '''Refers to common connection instance for example in a DB where it doesn't matter whether your reading or writing'''
     if hasattr(self,'conn_str') and self.conn_str:
         return self.validateConnStr(self.conn_str)
     #return "MSSQL:server={};database={};trusted_connection={};".format(self.server, self.dbname, self.trust)
     if LU.assessNone(self.pwd):
         if self.pwd.startswith(Encrypt.ENC_PREFIX):
             pwd = ";PWD={}".format(Encrypt.unSecure(self.pwd))
         else:
             pwd = ";PWD={}".format(self.pwd)
     else:
         pwd = ""
         
     sstr = ";Schema={}".format(self.schema) if LU.assessNone(self.schema) else ""
     usr = "******".format(self.usr) if LU.assessNone(self.usr) else ""
     drv = ";Driver='{}'".format(self.odbc) if LU.assessNone(self.odbc) else ""
     tcn = ";trusted_connection={}".format(self.trust) if LU.assessNone(self.trust) else ""
     uri = "MSSQL:server={};database={}".format(self.server, self.dbname, self.odbc)+usr+pwd+drv+sstr+tcn
     ldslog.debug(uri)
     return uri
示例#21
0
    def __init__(self,parent,lg=None,ep=None,fd=None,td=None,sc=None,dc=None,cq=None,uc=None):

        self.name = 'TP{}'.format(datetime.utcnow().strftime('%y%m%d%H%M%S'))
        self.parent = parent
        self.CLEANCONF = None
        self.INITCONF = None
        
        self.src = None
        self.dst = None 
        self.lnl = None
        self.partitionlayers = None
        self.partitionsize = None
        self.sixtyfourlayers = None
        self.prefetchsize = None
        
        self.layer = None
        self.layer_total = 0
        self.layer_count = 0
        
        #only do a config file rebuild if requested
        self.clearInitConfig()
        self.clearCleanConfig()
            
        self.setEPSG(ep)
        self.setFromDate(fd)
        self.setToDate(td)

        #splitting out group/layer and lgname
        self.lgval = None
        if LU.assessNone(lg):
            self.setLayerGroupValue(lg)
            
        self.source_str = None
        if LU.assessNone(sc):
            self.parseSourceConfig(sc)
        
        self.destination_str = LU.assessNone(dc)
        self.cql = LU.assessNone(cq)
        
        self.setUserConf(uc)
 def checkKeyword(self, ktext):
     '''Checks keyword isn't null and isn't part of the LDS supplied keywords'''
     if LU.assessNone(ktext) is None:
         QMessageBox.about(self, "Keyword Required",
                           "Please enter a Keyword to assign Layer(s) to")
         return False
     if ktext in self.confconn_link.reserved:
         QMessageBox.about(
             self, "Reserved Keyword",
             "'{}' is a reserved keyword, please select again".format(
                 ktext))
         return False
     return True
    def buildIndex(self):
        '''Builds an index creation string for a new full replicate in PG format'''
        tableonly = self.dst_info.ascii_name.split('.')[-1]
        ALLOW_CONSTRAINT_CREATION = False
        #SpatiaLite doesnt have a unique constraint but since we're using a pk might a well declare it as such
        if ALLOW_CONSTRAINT_CREATION and LDSUtilities.assessNone(
                self.dst_info.pkey):
            #spatialite won't do post create constraint additions (could to a re-create?)
            cmd = 'ALTER TABLE {0} ADD PRIMARY KEY {1}_{2}_PK ({2})'.format(
                self.dst_info.ascii_name, tableonly, self.dst_info.pkey)
            try:
                self.executeSQL(cmd)
                ldslog.info("Index = {}({}). Execute = {}".format(
                    tableonly, self.dst_info.pkey, cmd))
            except RuntimeError as rte:
                if re.search('already exists', str(rte)):
                    ldslog.warn(rte)
                else:
                    raise

        #Unless we select SPATIAL_INDEX=no as a Layer option this should never be needed
        #because gcol is also used to determine whether a layer is spatial still do this check
        if LDSUtilities.assessNone(
                self.dst_info.geocolumn) and 'SPATIAL_INDEX=NO' in [
                    opt.replace(' ', '').upper() for opt in self.sl_local_opts
                ]:
            cmd = "SELECT CreateSpatialIndex('{}','{}')".format(
                self.dst_info.ascii_name, self.DEFAULT_GCOL)
            try:
                self.executeSQL(cmd)
                ldslog.info(
                    "Index = {}({}). Execute = {}. NB Cannot override Geo-Column Name."
                    .format(tableonly, self.DEFAULT_GCOL, cmd))
            except RuntimeError as rte:
                if re.search('already exists', str(rte)):
                    ldslog.warn(rte)
                else:
                    raise
示例#24
0
 def getLayerGroupIndex(self,dispval,col=2):
     '''Finds a matching group/layer entry from its displayed name'''
     #0=lorg,1=value,2=display 
     compval = LU.recode(dispval)
     if not LU.assessNone(compval):
         ldslog.warn('No attempt made to find index for empty group/layer request, "{}"'.format(compval))
         return None# or 0?
         
     try:
         #print 'lgl',[type(i[1]) for i in self.lglist],'\ncv',type(compval)
         index = [i[col] for i in self.lglist].index(compval)
     except ValueError as ve:
         ldslog.warn(u'Cannot find an index in column {} for the requested group/layer, "{}", from {} layers. Returning None index'.format(col,compval,len(self.lglist)))
         index = None
     return index
示例#25
0
 def runLayerConfigAction(self):
     '''Arg-less action to open a new layer config dialog'''        
     dest,lgval,uconf,_,_,_,_,_ = self.controls.readParameters()
     
     if not LU.assessNone(dest):
         self.controls.setStatus(self.controls.STATUS.IDLE,'Cannot open Layer-Config without defined Destination')
         return
         
     if self.confconn is None:
         #build a new confconn
         self.confconn = ConfigConnector(uconf,lgval,dest)
     else:
         #if any parameters have changed, re-initialise
         self.confconn.initConnections(uconf,lgval,dest)
         
     self.runLayerConfigDialog()
示例#26
0
 def runLayerConfigAction(self):
     '''Arg-less action to open a new layer config dialog'''        
     dest,lgval,uconf,_,_,_,_,_ = self.controls.readParameters()
     
     if not LU.assessNone(dest):
         self.controls.setStatus(self.controls.STATUS.IDLE,'Cannot open Layer-Config without defined Destination')
         return
         
     if self.confconn is None:
         #build a new confconn
         self.confconn = ConfigConnector(uconf,lgval,dest)
     else:
         #if any parameters have changed, re-initialise
         self.confconn.initConnections(uconf,lgval,dest)
         
     self.runLayerConfigDialog()
示例#27
0
    def getConfigOptions(self):
        '''Pass up getConfigOptions call'''

        #system, read from env/reg

        proxyconfigoptions = []
        #(type, host, port, auth, usr, pwd) = self.PP

        type2 = LDSUtilities.assessNone(self.PP['TYPE'])
        if type2 == self.PROXY_TYPE[1]:
            if LDSUtilities.assessNone(self.PP['HOST']):
                hp = 'GDAL_HTTP_PROXY=' + str(self.PP['HOST'])
                if LDSUtilities.assessNone(self.PP['PORT']):
                    hp += ':' + str(self.PP['PORT'])
                proxyconfigoptions += [hp]
                #if no h/p no point doing u/p
                proxyconfigoptions += ['GDAL_HTTP_PROXYUSERPWD= : ']

        if type2 == self.PROXY_TYPE[2]:
            #user difined, expect all fields filled
            if LDSUtilities.assessNone(self.PP['HOST']):
                hp = 'GDAL_HTTP_PROXY=' + str(self.PP['HOST'])
                if LDSUtilities.assessNone(self.PP['PORT']):
                    hp += ':' + str(self.PP['PORT'])
                proxyconfigoptions += [hp]
            if LDSUtilities.assessNone(self.PP['USR']):
                up = 'GDAL_HTTP_PROXYUSERPWD=' + str(self.PP['USR'])
                if LDSUtilities.assessNone(self.PP['PWD']):
                    if self.PP['PWD'].startswith(Encrypt.ENC_PREFIX):
                        up += ":" + str(Encrypt.unSecure(self.PP['PWD']))
                    else:
                        up += ":" + str(self.PP['PWD'])
                proxyconfigoptions += [up]
                #NB do we also need to set GDAL_HTTP_USERPWD?
            if LDSUtilities.assessNone(self.PP['AUTH']):
                proxyconfigoptions += [
                    'GDAL_PROXY_AUTH=' + str(self.PP['AUTH'])
                ]
                #NB do we also need to set GDAL_HTTP_AUTH?

        return super(WFSDataStore,
                     self).getConfigOptions() + proxyconfigoptions
示例#28
0
 def readLayerProperty(self,pkey,field):
     '''Single property reader'''
     plist = ()
     layer = self.lcfname.ds.GetLayer(self.lcfname.LDS_CONFIG_TABLE)###fname -> lcfname
     layer.ResetReading()
     #HACK Win7
     layer.GetFeatureCount()
     if isinstance(pkey,tuple) or isinstance(pkey,list):
         for p in pkey:
             f = self.lcfname._findMatchingFeature(layer, 'id', p)###fname -> lcfname
             #plist += ('' if f is None else f.GetField(field).encode('utf8'),)
             plist += ('' if f is None else LU.recode(f.GetField(field)),)
         return plist
     else:
         feat = self.lcfname._findMatchingFeature(layer, 'id', pkey)
         if feat is None:
             return None
         prop = feat.GetField(field)
     return LU.recode(prop) if LU.assessNone(prop) else None#.encode('utf8')
示例#29
0
    def getLayerGroupIndex(self, dispval, col=2):
        '''Finds a matching group/layer entry from its displayed name'''
        #0=lorg,1=value,2=display
        compval = LU.recode(dispval)
        if not LU.assessNone(compval):
            ldslog.warn(
                'No attempt made to find index for empty group/layer request, "{}"'
                .format(compval))
            return None  # or 0?

        try:
            #print 'lgl',[type(i[1]) for i in self.lglist],'\ncv',type(compval)
            index = [i[col] for i in self.lglist].index(compval)
        except ValueError as ve:
            ldslog.warn(
                u'Cannot find an index in column {} for the requested group/layer, "{}", from {} layers. Returning None index'
                .format(col, compval, len(self.lglist)))
            index = None
        return index
示例#30
0
    def getConfigOptions(self):
        '''Pass up getConfigOptions call'''
        
        #system, read from env/reg

        proxyconfigoptions = []
        #(type, host, port, auth, usr, pwd) = self.PP
        
        type2 = LDSUtilities.assessNone(self.PP['TYPE'])
        if type2 == self.PROXY_TYPE[1]:
            if LDSUtilities.assessNone(self.PP['HOST']):
                hp = 'GDAL_HTTP_PROXY='+str(self.PP['HOST'])
                if LDSUtilities.assessNone(self.PP['PORT']):
                    hp += ':'+str(self.PP['PORT'])
                proxyconfigoptions += [hp] 
                #if no h/p no point doing u/p
                proxyconfigoptions += ['GDAL_HTTP_PROXYUSERPWD= : '] 
                
        
        if type2 == self.PROXY_TYPE[2]:
            #user difined, expect all fields filled
            if LDSUtilities.assessNone(self.PP['HOST']):
                hp = 'GDAL_HTTP_PROXY='+str(self.PP['HOST'])
                if LDSUtilities.assessNone(self.PP['PORT']):
                    hp += ':'+str(self.PP['PORT'])
                proxyconfigoptions += [hp] 
            if LDSUtilities.assessNone(self.PP['USR']):
                up = 'GDAL_HTTP_PROXYUSERPWD='+str(self.PP['USR'])
                if LDSUtilities.assessNone(self.PP['PWD']):
                    if self.PP['PWD'].startswith(Encrypt.ENC_PREFIX):
                        up += ":"+str(Encrypt.unSecure(self.PP['PWD']))
                    else:
                        up += ":"+str(self.PP['PWD'])
                proxyconfigoptions += [up]
                #NB do we also need to set GDAL_HTTP_USERPWD?
            if LDSUtilities.assessNone(self.PP['AUTH']):
                proxyconfigoptions += ['GDAL_PROXY_AUTH='+str(self.PP['AUTH'])]
                #NB do we also need to set GDAL_HTTP_AUTH?   
            
        return super(WFSDataStore,self).getConfigOptions()+proxyconfigoptions
 def getLayerOptions(self,layer_id):
     '''Get MS options for GEO_NAME'''
     #GEOM_TYPE, OVERWRITE, LAUNDER, PRECISION, DIM={2,3}, GEOM_NAME, SCHEMA, SRID
     
     local_opts = ['MARS Connection=TRUE']
     gc = self.layerconf.readLayerProperty(layer_id,'geocolumn')
     if gc:
         local_opts += ['GEOM_NAME='+gc]
         
     schema = self.confwrap.readDSProperty(self.DRIVER_NAME,'schema')
     if schema is None:
         schema = self.schema
     if LU.assessNone(schema) and LU.containsOnlyAlphaNumeric(schema):
         local_opts += ['SCHEMA='+schema]
         
     srid = self.layerconf.readLayerProperty(layer_id,'epsg')
     if srid:
         local_opts += ['SRID='+srid]
     
     return super(MSSQLSpatialDataStore,self).getLayerOptions(layer_id) + local_opts
示例#32
0
 def write(self,rlist):
     self.dvalue = rlist[0]
     
     if self.cp.has_section(self.PREFS_SEC):
         self.cp.set(self.PREFS_SEC,self.dselect,self.dvalue)
     else:
         self.cp.add_section(self.PREFS_SEC)
         self.cp.set(self.PREFS_SEC,self.dselect,self.dvalue)
         
     for pr in zip(self.plist,rlist[1:]):
         if not self.cp.has_section(self.dvalue):
             self.cp.add_section(self.dvalue)
         try:
             if LU.assessNone(pr[1]):         
                 self.cp.set(self.dvalue,pr[0],pr[1])
                 ldslog.debug(self.dvalue+':'+pr[0]+'='+pr[1])                                                                                        
         except Exception as e:
             ldslog.warn('Problem writing GUI prefs. '+str(e))
     with codecs.open(self.fn, 'w','utf-8') as configfile:
         self.cp.write(configfile)
示例#33
0
    def write(self, rlist):
        self.dvalue = rlist[0]

        if self.cp.has_section(self.PREFS_SEC):
            self.cp.set(self.PREFS_SEC, self.dselect, self.dvalue)
        else:
            self.cp.add_section(self.PREFS_SEC)
            self.cp.set(self.PREFS_SEC, self.dselect, self.dvalue)

        for pr in zip(self.plist, rlist[1:]):
            if not self.cp.has_section(self.dvalue):
                self.cp.add_section(self.dvalue)
            try:
                if LU.assessNone(pr[1]):
                    self.cp.set(self.dvalue, pr[0], pr[1])
                    ldslog.debug(self.dvalue + ':' + pr[0] + '=' + pr[1])
            except Exception as e:
                ldslog.warn('Problem writing GUI prefs. ' + str(e))
        with codecs.open(self.fn, 'w', 'utf-8') as configfile:
            self.cp.write(configfile)
示例#34
0
 def doLGComboChanged(self):
     '''Read the layer/group value and change epsg to layer or gpr match'''
     #get a matching LG entry and test whether its a layer or group
     #lgi = self.parent.confconn.getLayerGroupIndex(self.lgcombo.currentText().toUtf8().data())
     lgi = self.parent.confconn.getLayerGroupIndex(LQ.readWidgetText(self.lgcombo.currentText()))
     #lgi can be none if we init a new group, in which case we use the GPR value
     if lgi:
         lge = self.parent.confconn.lglist[lgi]
         lce = self.getLCE(lge[1]) if lge[0]==LORG.LAYER else None
     else:
         lce = None
     
     #look for filled layer conf epsg OR use prefs stored in gpr
     if lce and LU.assessNone(lce.epsg):
         epsgval = lce.epsg
     else:
         rdest = str(self.destlist[self.destcombo.currentIndex()])
         _,_,epsgval,_,_ = self.gprParameters(rdest)
     epsgindex = [i[0] for i in self.nzlsr+[(0,0)]+self.rowsr].index(epsgval)
     if self.epsgcombo.currentIndex() != epsgindex:
         self.epsgcombo.setCurrentIndex(int(epsgindex))
示例#35
0
 def doLGComboChanged(self):
     '''Read the layer/group value and change epsg to layer or gpr match'''
     #get a matching LG entry and test whether its a layer or group
     #lgi = self.parent.confconn.getLayerGroupIndex(self.lgcombo.currentText().toUtf8().data())
     lgi = self.parent.confconn.getLayerGroupIndex(LQ.readWidgetText(self.lgcombo.currentText()))
     #lgi can be none if we init a new group, in which case we use the GPR value
     if lgi:
         lge = self.parent.confconn.lglist[lgi]
         lce = self.getLCE(lge[1]) if lge[0]==LORG.LAYER else None
     else:
         lce = None
     
     #look for filled layer conf epsg OR use prefs stored in gpr
     if lce and LU.assessNone(lce.epsg):
         epsgval = lce.epsg
     else:
         rdest = str(self.destlist[self.destcombo.currentIndex()])
         _,_,epsgval,_,_ = self.gprParameters(rdest)
     epsgindex = [i[0] for i in self.nzlsr+[(0,0)]+self.rowsr].index(epsgval)
     if self.epsgcombo.currentIndex() != epsgindex:
         self.epsgcombo.setCurrentIndex(int(epsgindex))
示例#36
0
 def writeKeysToLayerConfig(self, ckey):
     '''Add custom key to the selection_model list of layers (assumes required av->sl transfer completed) not just the transferring entry'''
     layerlist = [ll[0] for ll in self.selection_model.mdata]
     replacementlist = ()
     dep = self.parent.confconn.reg.openEndPoint(self.parent.confconn.destname,self.parent.confconn.uconf)
     #print 'opened dep=',dep,'reg=',self.parent.confconn.reg#DEBUG
     self.parent.confconn.reg.setupLayerConfig(self.parent.confconn.tp,None,dep,initlc=False)
     #categorylist = [f.encode('utf8').strip() for f in dep.getLayerConf().readLayerProperty(layerlist, 'category') if f]
     categorylist = [LU.assessNone(f) for f in dep.getLayerConf().readLayerProperty(layerlist, 'category')]
     for cat in categorylist:
         replacementlist += ( (cat if ckey in cat.split(',') else cat+','+ckey) if cat else ckey, )
     #print '>>> writing this replacementlist to LC',replacementlist
     dep.getLayerConf().writeLayerProperty(layerlist, 'category', replacementlist)
     #new keyword written so re-read complete (LC) and update assigned keys list
     self.parent.confconn.setupCompleteLayerList(dep,refresh=True)
     self.parent.confconn.setupAssignedLayerList()
     self.parent.confconn.buildLayerGroupList()
     #self.refreshLayers(dep,customkey)
     #print 'closing dep=',dep,'reg=',self.parent.confconn.reg#DEBUG
     self.parent.confconn.reg.closeEndPoint(self.parent.confconn.destname)        
     dep = None
示例#37
0
 def closeEvent(self,event):
     '''Intercept close event to signal parent to update status'''
     self.parent.controls.setStatus(self.parent.controls.STATUS.IDLE,'Done')
     #return last group selection
     #lastgroup = LU.recode(self.page.keywordcombo.lineEdit().text().toUtf8().data())
     lastgroup = LU.recode(LQ.readWidgetText(self.page.keywordcombo.lineEdit().text()))
     #self.parent.controls.gpr.writeline('lgvalue',lastgroup)
     if LU.assessNone(lastgroup):
         dep = self.parent.confconn.reg.openEndPoint(self.parent.confconn.destname,self.parent.confconn.uconf)
         #sep = self.parent.confconn.reg.openEndPoint('WFS',self.parent.confconn.uconf)
         self.parent.confconn.reg.setupLayerConfig(self.parent.confconn.tp,None,dep)
         self.parent.confconn.setupCompleteLayerList(dep)
         self.parent.confconn.setupAssignedLayerList()
         self.parent.confconn.buildLayerGroupList()
         lgindex = self.parent.confconn.getLayerGroupIndex(lastgroup,col=1)
         self.parent.controls.refreshLGCombo()
         #current index wont be available in parent if this is the init run
         self.parent.controls.lgcombo.setCurrentIndex(lgindex if lgindex else 0)
         #self.parent.confconn.reg.closeEndPoint('WFS')
         self.parent.confconn.reg.closeEndPoint(self.parent.confconn.destname)
         sep,dep = None,None
示例#38
0
 def readLayerProperty(self, pkey, field):
     '''Single property reader'''
     plist = ()
     layer = self.lcfname.ds.GetLayer(
         self.lcfname.LDS_CONFIG_TABLE)  ###fname -> lcfname
     layer.ResetReading()
     #HACK Win7
     layer.GetFeatureCount()
     if isinstance(pkey, tuple) or isinstance(pkey, list):
         for p in pkey:
             f = self.lcfname._findMatchingFeature(layer, 'id',
                                                   p)  ###fname -> lcfname
             #plist += ('' if f is None else f.GetField(field).encode('utf8'),)
             plist += ('' if f is None else LU.recode(f.GetField(field)), )
         return plist
     else:
         feat = self.lcfname._findMatchingFeature(layer, 'id', pkey)
         if feat is None:
             return None
         prop = feat.GetField(field)
     return LU.recode(prop) if LU.assessNone(
         prop) else None  #.encode('utf8')
示例#39
0
 def read(self):
     '''Read stored DS value and return this and its matching params'''
     try:
         with codecs.open(self.fn, 'r', 'utf-8') as cf:
             self.cp.readfp(cf)
         self.dvalue = self.cp.get(self.PREFS_SEC, self.dselect)
         if LU.assessNone(self.dvalue) is None:
             return (None, ) * (len(self.plist) + 1)
     except NoSectionError as nse:
         #if no sec init sec and opt and ret nones
         ldslog.warn('Error getting GUI prefs section :: ' + str(nse))
         if not self._initSection(self.PREFS_SEC):
             raise
         self._initOption(self.PREFS_SEC, self.dselect)
         return (None, ) * (len(self.plist) + 1)
     except NoOptionError as noe:
         #if no opt init opt and ret nones
         ldslog.warn('Error getting GUI prefs :: ' + str(noe))
         if not self._initOption(self.PREFS_SEC, self.dselect):
             raise
         return (None, ) * (len(self.plist) + 1)
     #if dval is okay ret it and res of a read of that sec
     return (self.dvalue, ) + self.readsec(self.dvalue)
示例#40
0
 def read(self):
     '''Read stored DS value and return this and its matching params'''
     try:
         with codecs.open(self.fn, 'r','utf-8') as cf:
             self.cp.readfp(cf)
         self.dvalue = self.cp.get(self.PREFS_SEC, self.dselect) 
         if LU.assessNone(self.dvalue) is None:
             return (None,)*(len(self.plist)+1)
     except NoSectionError as nse:
         #if no sec init sec and opt and ret nones
         ldslog.warn('Error getting GUI prefs section :: '+str(nse))
         if not self._initSection(self.PREFS_SEC):
             raise
         self._initOption(self.PREFS_SEC,self.dselect)
         return (None,)*(len(self.plist)+1)
     except NoOptionError as noe:
         #if no opt init opt and ret nones
         ldslog.warn('Error getting GUI prefs :: '+str(noe))
         if not self._initOption(self.PREFS_SEC,self.dselect):
             raise
         return (None,)*(len(self.plist)+1)
     #if dval is okay ret it and res of a read of that sec
     return (self.dvalue,)+self.readsec(self.dvalue)
示例#41
0
 def deleteForgotten(self, alist, flt='v_\w{8}_wxs_\w{4}'):
     '''Removes keywords with the format v_########_wxs_#### since these are probably not user generated and 
     because they're used as temporary keys and will eventually be forgotten by LDS. Also removes text Nones'''
     #HACK
     return set(
         [a for a in alist if LU.assessNone(a) and not re.search(flt, a)])
示例#42
0
 def _readSingleLayerProperty(self, layer, key):
     return LU.assessNone(self.cp.get(layer, key))
    def __init__(self, parent=None,key=None):
        super(ProxyConfigPage, self).__init__(parent)
        
        self.parent = parent 
        self.key = key
        
        try:
            (pxytype,pxyhost,pxyport,pxyauth,pxyusr,pxypwd) = self.parent.mfr.readProxyConfig()
        except:
            (pxytype,pxyhost,pxyport,pxyauth,pxyusr,pxypwd) = (None,)*6
            
        #if we use enums for pxy types
        #pxytype = [a[0] for a in WFSDataStore.PROXY_TYPE.reverse.items() if a[1]==pxytype][0]

            
        self.setTitle(self.parent.plist.get(self.key)[1]+' Configuration Options')
        self.setSubTitle('Enter the hostname/ip-address, port number and authentication details of your HTTP proxy')

        QToolTip.setFont(QFont('SansSerif', 10))
        
        #labels
        directlabel = QLabel('Direct Connection')
        systemlabel = QLabel('Use System Proxy settings')
        proxylabel = QLabel('Configure Proxy')
        
        hostLabel = QLabel('Proxy Host')
        portLabel = QLabel('Proxy Port')
        authLabel = QLabel('Authentication')
        usrLabel = QLabel('Username')
        pwdLabel = QLabel('Password')
        
        
        #radio buttons
        self.directradio = QRadioButton()
        self.systemradio = QRadioButton()
        self.usrdefradio = QRadioButton()
        
        
        #edit boxes
        self.hostEdit = QLineEdit(pxyhost)
        self.hostEdit.setToolTip('Enter Proxy host (IP Address or hostname)')
        self.portEdit = QLineEdit(pxyport)
        self.portEdit.setToolTip('Enter Proxy port')
        
        #dropdown
        self.authSelect = QComboBox()
        self.authSelect.addItem('')
        self.authSelect.setToolTip('Select appropriate proxy authentication mechanism')
        self.authSelect.addItems(WFSDataStore.PROXY_AUTH)
        self.authSelect.setCurrentIndex(0 if LU.assessNone(pxyauth) is None else WFSDataStore.PROXY_AUTH.index(pxyauth))
        
        self.usrEdit = QLineEdit(pxyusr)
        self.usrEdit.setToolTip('Enter your proxy username (if required)')
        self.pwdEdit = QLineEdit('')#pxypwd
        self.usrEdit.setToolTip('Enter your proxy password (if required)')
        self.pwdEdit.setEchoMode(QLineEdit.Password)
        
        self.portEdit.setValidator(QRegExpValidator(QRegExp("\d{1,5}"), self))
        
        self.registerField(self.key+"host",self.hostEdit)
        self.registerField(self.key+"port",self.portEdit)
        self.registerField(self.key+"auth",self.authSelect,"currentIndex")
        self.registerField(self.key+"usr",self.usrEdit)
        self.registerField(self.key+"pwd",self.pwdEdit)
        
        self.registerField(self.key+WFSDataStore.PROXY_TYPE[0],self.directradio)
        self.registerField(self.key+WFSDataStore.PROXY_TYPE[1],self.systemradio)
        self.registerField(self.key+WFSDataStore.PROXY_TYPE[2],self.usrdefradio)

        #grid
        grid1 = QGridLayout()
        grid1.setSpacing(10)
        
        grid2 = QGridLayout()
        grid2.setSpacing(10)
        
        #layout
        hbox = QHBoxLayout()
        grid1.addWidget(self.directradio,1,0)
        grid1.addWidget(directlabel,1,1)
        grid1.addWidget(self.systemradio,2,0)
        grid1.addWidget(systemlabel,2,1)
        grid1.addWidget(self.usrdefradio,3,0)
        grid1.addWidget(proxylabel,3,1)
        hbox.addLayout(grid1)
        hbox.addStretch(1)
        
        
        self.gbox = QGroupBox('Proxy Configuration')

        #dsu
        subs = False
        if pxytype == WFSDataStore.PROXY_TYPE[1]:
            #system
            self.systemradio.setChecked(True)
        elif pxytype == WFSDataStore.PROXY_TYPE[2]:
            #user_defined
            self.usrdefradio.setChecked(True)
            subs = True
        else:
            #direct (default)
            self.directradio.setChecked(True)
            
        self.setUserDefined(subs)
        
        self.directradio.clicked.connect(self.disableUserDefined)
        self.systemradio.clicked.connect(self.disableUserDefined)
        self.usrdefradio.clicked.connect(self.enableUserDefined)
        
        grid2.addWidget(hostLabel, 1, 0)
        grid2.addWidget(self.hostEdit, 1, 2)
        
        grid2.addWidget(portLabel, 2, 0)
        grid2.addWidget(self.portEdit, 2, 2)
        
        grid2.addWidget(authLabel, 3, 0)
        grid2.addWidget(self.authSelect, 3, 2)
        
        grid2.addWidget(usrLabel, 4, 0)
        grid2.addWidget(self.usrEdit, 4, 2)
        
        grid2.addWidget(pwdLabel, 5, 0)
        grid2.addWidget(self.pwdEdit, 5, 2)
             
        self.gbox.setLayout(grid2)
        
        #layout    
        vbox = QVBoxLayout()
        vbox.addLayout(hbox)
        vbox.insertWidget(1,self.gbox)
        self.setLayout(vbox)  
    def __init__(self,parent=None,key=None):
        super(PostgreSQLConfigPage, self).__init__(parent)
        
        self.parent = parent 
        self.key = key
        
        try:
            (pghost,pgport,pgdbname,pgschema,pgusr,pgpwd,pgover,pgconfig,pgepsg,pgcql) = self.parent.mfr.readPostgreSQLConfig()
        except:
            (pghost,pgport,pgdbname,pgschema,pgusr,pgpwd,pgover,pgconfig,pgepsg,pgcql) = (None,)*10
        
        self.setTitle('PostgreSQL/PostGIS Configuration Options')
        self.setSubTitle('Enter the hostname/ip-address, port number, name and schema of your PostgreSQL server instance.')
     
        QToolTip.setFont(QFont('SansSerif', 10))
              
        #labels
        hostLabel = QLabel('PostgreSQL Host')
        portLabel = QLabel('PostgreSQL Port')
        dbnameLabel = QLabel('PostgreSQL DB Name')
        schemaLabel = QLabel('PostgreSQL DB Schema')
        usrLabel = QLabel('Username')
        pwdLabel = QLabel('Password')
        
        #edit boxes
        self.hostEdit = QLineEdit(pghost)
        self.hostEdit.setToolTip('Enter the name of your PostgreSQL host/IP-address')
        self.portEdit = QLineEdit('5432' if LU.assessNone(pgport) is None else pgport)
        self.portEdit.setToolTip('Enter the PostgreSQL listen port')
        self.dbnameEdit = QLineEdit(pgdbname)
        self.dbnameEdit.setToolTip('Enter the name of the PostgreSQL DB to connect with')
        self.schemaEdit = QLineEdit(pgschema)
        self.schemaEdit.setToolTip('Set the database schema here')
        self.usrEdit = QLineEdit(pgusr)
        self.usrEdit.setToolTip('Name of PostgreSQL account/user')
        self.pwdEdit = QLineEdit('')#pgpwd
        self.pwdEdit.setToolTip('Enter PostgreSQL account password')
        self.pwdEdit.setEchoMode(QLineEdit.Password)
        
        self.portEdit.setValidator(QRegExpValidator(QRegExp("\d{1,5}"), self))
        
        
        self.registerField(self.key+"host",self.hostEdit)
        self.registerField(self.key+"port",self.portEdit)
        self.registerField(self.key+"dbname",self.dbnameEdit)
        self.registerField(self.key+"schema",self.schemaEdit)
        self.registerField(self.key+"usr",self.usrEdit)
        self.registerField(self.key+"pwd",self.pwdEdit)

        #grid
        grid = QGridLayout()
        grid.setSpacing(10)
        
        #layout
        grid.addWidget(hostLabel, 1, 0)
        grid.addWidget(self.hostEdit, 1, 2)
        
        grid.addWidget(portLabel, 2, 0)
        grid.addWidget(self.portEdit, 2, 2)
        
        grid.addWidget(dbnameLabel, 3, 0)
        grid.addWidget(self.dbnameEdit, 3, 2)
        
        grid.addWidget(schemaLabel, 4, 0)
        grid.addWidget(self.schemaEdit, 4, 2)
        
        grid.addWidget(usrLabel, 5, 0)
        grid.addWidget(self.usrEdit, 5, 2)
        
        grid.addWidget(pwdLabel, 6, 0)
        grid.addWidget(self.pwdEdit, 6, 2)
              
        #layout                
        self.setLayout(grid)  
示例#45
0
    def __init__(self, parent=None):
        super(LayerSelectionPage, self).__init__(parent)
        self.parent = parent
        
        #convenience link
        self.confconn_link = self.parent.parent.confconn
        
        #flag top prevent read read action on keyword delete. New logic makes this redundant
        #self.keywordbypass = False

        QToolTip.setFont(QFont('SansSerif', 10))
        
        #label
        filterlabel = QLabel('Filter')
        availablelabel = QLabel('Available Layers')
        selectionlabel = QLabel('Layer Selections')
        keywordlabel = QLabel('Keyword')
        explainlabel = QLabel("Edit Group assignments using this dialog or to simply initialise the Layer-Config just click 'Finish'")
        
        #selection buttons
        chooseallbutton = QPushButton('>>')
        chooseallbutton.setFixedWidth(self.XFER_BW)
        chooseallbutton.clicked.connect(self.doChooseAllClickAction)
        
        choosebutton = QPushButton('>')
        choosebutton.setFixedWidth(self.XFER_BW)
        choosebutton.clicked.connect(self.doChooseClickAction)
        
        rejectbutton = QPushButton('<')
        rejectbutton.setFixedWidth(self.XFER_BW)
        rejectbutton.clicked.connect(self.doRejectClickAction)
        
        rejectallbutton = QPushButton('<<')
        rejectallbutton.setFixedWidth(self.XFER_BW)
        rejectallbutton.clicked.connect(self.doRejectAllClickAction)
        
        #operation buttons        
        finishbutton = QPushButton('Finish')
        finishbutton.setToolTip('Finish and Close layer selection dialog')
        finishbutton.clicked.connect(self.parent.close)
        
        resetbutton = QPushButton('Reset')
        resetbutton.font()
        resetbutton.setToolTip('Read Layer from LDS GetCapabilities request. Overwrites current Layer Config')       
        resetbutton.clicked.connect(self.doResetClickAction)
        
        self.available_sfpm = LDSSFPAvailableModel(self)
        self.selection_sfpm = LDSSFPSelectionModel(self)
        
        self.available_sfpm.setSourceModel(self.parent.available_model)
        self.selection_sfpm.setSourceModel(self.parent.selection_model)
        
        #textedits
        filteredit = QLineEdit('')
        filteredit.setToolTip('Filter Available-Layers pane (filter operates across Name and Title fields and accepts Regex expressions)')       
        filteredit.textChanged.connect(self.available_sfpm.setActiveFilter)
        
        self.keywordcombo = QComboBox()
        self.keywordcombo.setToolTip('Select or Add a unique identifier to be saved in layer config (keyword)')
        self.keywordcombo.addItems(list(self.confconn_link.assigned))
        self.keywordcombo.setEditable(True)
        self.keywordcombo.activated.connect(self.doKeyComboChangeAction)
        
        lgindex = self.confconn_link.getLayerGroupIndex(self.confconn_link.lgval,col=1)
        lgentry = self.confconn_link.lglist[lgindex] if LU.assessNone(lgindex) else None
        #keywordedit = self.keywordcombo.lineEdit().text().toUtf8().data().decode('utf8')# for writing
        #if no entry or layer indicated then blank 
        self.keywordcombo.lineEdit().setText('' if lgentry is None or lgentry[0]==LORG.LAYER else lgentry[1])#self.confconn_link.lgval)#TODO. group only
        
        #header
        headmodel = QStandardItemModel()
        headmodel.setHorizontalHeaderLabels([i[2] for i in self.colparams][:self.parent.available_model.columnCount()])
        
        headview1 = QHeaderView(Qt.Horizontal)
        headview1.setModel(headmodel)
        headview1.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) 
        
        headview2 = QHeaderView(Qt.Horizontal)
        headview2.setModel(headmodel)
        headview2.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)            

        #table
        self.available = QTableView()
        self.available.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.available.setSelectionMode(QAbstractItemView.MultiSelection)       
        
        self.selection = QTableView()
        self.selection.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.selection.setSelectionMode(QAbstractItemView.MultiSelection)
        
        #interesting, must set model after selection attributes but before headers else row selections/headers don't work properly
        self.available.setModel(self.available_sfpm)
        self.selection.setModel(self.selection_sfpm)
        
        self.available.setSortingEnabled(True)
        self.available.setHorizontalHeader(headview1)
        
        self.selection.setSortingEnabled(True)
        self.selection.setHorizontalHeader(headview2)

        for cp in self.colparams:
            self.available.setColumnWidth(cp[0],cp[1])
            self.selection.setColumnWidth(cp[0],cp[1])

        self.available.verticalHeader().setVisible(False)
        self.available.horizontalHeader().setVisible(True)
        
        self.selection.verticalHeader().setVisible(False)
        self.selection.horizontalHeader().setVisible(True)
        
        
        #layout  
        vbox00 = QVBoxLayout()
        vbox00.addWidget(availablelabel)
        vbox00.addWidget(self.available)
        
        vbox01 = QVBoxLayout()
        vbox01.addWidget(chooseallbutton)
        vbox01.addWidget(choosebutton)
        vbox01.addWidget(rejectbutton)
        vbox01.addWidget(rejectallbutton)
        
        vbox02 = QVBoxLayout()
        vbox02.addWidget(selectionlabel)
        vbox02.addWidget(self.selection)

        
        vbox10 = QVBoxLayout()
        vbox10.addWidget(filterlabel)
        vbox10.addWidget(filteredit)
        
        hbox12 = QHBoxLayout()
        hbox12.addWidget(keywordlabel)
        hbox12.addStretch(1)
        #hbox12.addWidget(inspbutton)
        #hbox12.addWidget(addbutton)
        #hbox12.addWidget(delbutton)
        
        vbox12 = QVBoxLayout()
        vbox12.addLayout(hbox12)
        vbox12.addWidget(self.keywordcombo)
                
        #00|01|02
        #10|11|12
        grid0 = QGridLayout()
        grid0.addLayout(vbox00,1,0)
        grid0.addLayout(vbox01,1,1)
        grid0.addLayout(vbox02,1,2)
        grid0.addLayout(vbox10,0,0)
        grid0.addLayout(vbox12,0,2)
        
        
        hbox2 = QHBoxLayout()
        hbox2.addWidget(resetbutton)
        hbox2.addStretch(1)
        hbox2.addWidget(explainlabel)
        hbox2.addWidget(finishbutton)
        #gbox1.setLayout(hbox2)
        
        
        
        vbox3 = QVBoxLayout()
        vbox3.addLayout(grid0)
        #vbox3.addLayout(hbox3)
        #vbox3.addWidget(line0)
        vbox3.addLayout(hbox2)
        
        self.setLayout(vbox3)
示例#46
0
 def gprParameters(self,rdest):
     '''Zip default and GPR values'''
     return [x if LU.assessNone(x) else y for x,y in zip(self.parent.gpr.readsec(rdest),self.parent.DEF_RVALS[1:])]
示例#47
0
 def gprParameters(self,rdest):
     '''Zip default and GPR values'''
     return [x if LU.assessNone(x) else y for x,y in zip(self.parent.gpr.readsec(rdest),self.parent.DEF_RVALS[1:])]
示例#48
0
 def updateFromGPR(self):
     '''Read GPR file for changes or init'''
     if not self.gpr: 
         self.gpr = GUIPrefsReader()
     return [x if LU.assessNone(x) else y for x,y in zip(self.gpr.read(),self.DEF_RVALS)]
示例#49
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])))
示例#50
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])))
    def __init__(self, parent=None):
        super(LayerSelectionPage, self).__init__(parent)
        self.parent = parent

        #convenience link
        self.confconn_link = self.parent.parent.confconn

        #flag top prevent read read action on keyword delete. New logic makes this redundant
        #self.keywordbypass = False

        QToolTip.setFont(QFont('SansSerif', 10))

        #label
        filterlabel = QLabel('Filter')
        availablelabel = QLabel('Available Layers')
        selectionlabel = QLabel('Layer Selections')
        keywordlabel = QLabel('Keyword')
        explainlabel = QLabel(
            "Edit Group assignments using this dialog or to simply initialise the Layer-Config just click 'Finish'"
        )

        #selection buttons
        chooseallbutton = QPushButton('>>')
        chooseallbutton.setFixedWidth(self.XFER_BW)
        chooseallbutton.clicked.connect(self.doChooseAllClickAction)

        choosebutton = QPushButton('>')
        choosebutton.setFixedWidth(self.XFER_BW)
        choosebutton.clicked.connect(self.doChooseClickAction)

        rejectbutton = QPushButton('<')
        rejectbutton.setFixedWidth(self.XFER_BW)
        rejectbutton.clicked.connect(self.doRejectClickAction)

        rejectallbutton = QPushButton('<<')
        rejectallbutton.setFixedWidth(self.XFER_BW)
        rejectallbutton.clicked.connect(self.doRejectAllClickAction)

        #operation buttons
        finishbutton = QPushButton('Finish')
        finishbutton.setToolTip('Finish and Close layer selection dialog')
        finishbutton.clicked.connect(self.parent.close)

        resetbutton = QPushButton('Reset')
        resetbutton.font()
        resetbutton.setToolTip(
            'Read Layer from LDS GetCapabilities request. Overwrites current Layer Config'
        )
        resetbutton.clicked.connect(self.doResetClickAction)

        self.available_sfpm = LDSSFPAvailableModel(self)
        self.selection_sfpm = LDSSFPSelectionModel(self)

        self.available_sfpm.setSourceModel(self.parent.available_model)
        self.selection_sfpm.setSourceModel(self.parent.selection_model)

        #textedits
        filteredit = QLineEdit('')
        filteredit.setToolTip(
            'Filter Available-Layers pane (filter operates across Name and Title fields and accepts Regex expressions)'
        )
        filteredit.textChanged.connect(self.available_sfpm.setActiveFilter)

        self.keywordcombo = QComboBox()
        self.keywordcombo.setToolTip(
            'Select or Add a unique identifier to be saved in layer config (keyword)'
        )
        self.keywordcombo.addItems(list(self.confconn_link.assigned))
        self.keywordcombo.setEditable(True)
        self.keywordcombo.activated.connect(self.doKeyComboChangeAction)

        lgindex = self.confconn_link.getLayerGroupIndex(
            self.confconn_link.lgval, col=1)
        lgentry = self.confconn_link.lglist[lgindex] if LU.assessNone(
            lgindex) else None
        #keywordedit = self.keywordcombo.lineEdit().text().toUtf8().data().decode('utf8')# for writing
        #if no entry or layer indicated then blank
        self.keywordcombo.lineEdit().setText(
            '' if lgentry is None or lgentry[0] == LORG.LAYER else
            lgentry[1])  #self.confconn_link.lgval)#TODO. group only

        #header
        headmodel = QStandardItemModel()
        headmodel.setHorizontalHeaderLabels([
            i[2] for i in self.colparams
        ][:self.parent.available_model.columnCount()])

        headview1 = QHeaderView(Qt.Horizontal)
        headview1.setModel(headmodel)
        headview1.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)

        headview2 = QHeaderView(Qt.Horizontal)
        headview2.setModel(headmodel)
        headview2.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)

        #table
        self.available = QTableView()
        self.available.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.available.setSelectionMode(QAbstractItemView.MultiSelection)

        self.selection = QTableView()
        self.selection.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.selection.setSelectionMode(QAbstractItemView.MultiSelection)

        #interesting, must set model after selection attributes but before headers else row selections/headers don't work properly
        self.available.setModel(self.available_sfpm)
        self.selection.setModel(self.selection_sfpm)

        self.available.setSortingEnabled(True)
        self.available.setHorizontalHeader(headview1)

        self.selection.setSortingEnabled(True)
        self.selection.setHorizontalHeader(headview2)

        for cp in self.colparams:
            self.available.setColumnWidth(cp[0], cp[1])
            self.selection.setColumnWidth(cp[0], cp[1])

        self.available.verticalHeader().setVisible(False)
        self.available.horizontalHeader().setVisible(True)

        self.selection.verticalHeader().setVisible(False)
        self.selection.horizontalHeader().setVisible(True)

        #layout
        vbox00 = QVBoxLayout()
        vbox00.addWidget(availablelabel)
        vbox00.addWidget(self.available)

        vbox01 = QVBoxLayout()
        vbox01.addWidget(chooseallbutton)
        vbox01.addWidget(choosebutton)
        vbox01.addWidget(rejectbutton)
        vbox01.addWidget(rejectallbutton)

        vbox02 = QVBoxLayout()
        vbox02.addWidget(selectionlabel)
        vbox02.addWidget(self.selection)

        vbox10 = QVBoxLayout()
        vbox10.addWidget(filterlabel)
        vbox10.addWidget(filteredit)

        hbox12 = QHBoxLayout()
        hbox12.addWidget(keywordlabel)
        hbox12.addStretch(1)
        #hbox12.addWidget(inspbutton)
        #hbox12.addWidget(addbutton)
        #hbox12.addWidget(delbutton)

        vbox12 = QVBoxLayout()
        vbox12.addLayout(hbox12)
        vbox12.addWidget(self.keywordcombo)

        #00|01|02
        #10|11|12
        grid0 = QGridLayout()
        grid0.addLayout(vbox00, 1, 0)
        grid0.addLayout(vbox01, 1, 1)
        grid0.addLayout(vbox02, 1, 2)
        grid0.addLayout(vbox10, 0, 0)
        grid0.addLayout(vbox12, 0, 2)

        hbox2 = QHBoxLayout()
        hbox2.addWidget(resetbutton)
        hbox2.addStretch(1)
        hbox2.addWidget(explainlabel)
        hbox2.addWidget(finishbutton)
        #gbox1.setLayout(hbox2)

        vbox3 = QVBoxLayout()
        vbox3.addLayout(grid0)
        #vbox3.addLayout(hbox3)
        #vbox3.addWidget(line0)
        vbox3.addLayout(hbox2)

        self.setLayout(vbox3)
示例#52
0
    def readLayerParameters(self, id):
        #def readLayerSchemaConfig(self,layer):
        '''Full Layer config reader. Returns the config values for the whole layer or makes sensible guesses for defaults'''
        from LDSUtilities import LayerConfEntry
        #
        #        try:
        #            defn = self.cp.get(layer, 'sql')
        #            #if the user has gone to the trouble of defining their own schema in SQL just return that
        #            return (defn,None,None,None,None,None,None,None,None)
        #        except:
        #            pass
        '''optional but one way to record the type and name of a column is to save a string tuple (name,type) and parse this at build time'''
        try:
            pkey = self.cp.get(id, 'pkey')
        except NoOptionError:
            ldslog.warn(
                "LayerSchema: No Primary Key Column defined, default to 'ID'")
            pkey = 'ID'
        '''names are/can-be stored so we can reverse search by layer name'''
        try:
            name = self.cp.get(id, 'name')
        except NoOptionError:
            ldslog.warn(
                "LayerSchema: No Name saved in config for this layer, returning ID"
            )
            name = id

        if name is None:
            name = id
        '''names are/can-be stored so we can reverse search by layer name'''
        try:
            group = LU.assessNone(self.cp.get(id, 'category'))
        except NoOptionError:
            ldslog.warn("Group List: No Groups defined for this layer")
            group = None

        if not group:
            pass

        try:
            gcol = self.cp.get(id, 'geocolumn')
        except NoOptionError:
            ldslog.warn(
                "LayerSchema: No Geo Column defined, default to 'SHAPE'")
            gcol = 'SHAPE'

        #i dont think we need this anymore using the new logic, if gcol->spatial, if pkey->unique


#        try:
#            index = self.cp.get(layer, 'index')
#        except NoOptionError:
#            ldslog.warn("LayerSchema: No Index Column/Specification defined, default to None")
#            index = None

        try:
            epsg = self.cp.get(id, 'epsg')
        except NoOptionError:
            #print "No Projection Transformation defined"#don't really need to state the default occurance
            epsg = None

        try:
            lmod = self.cp.get(id, 'lastmodified')
        except NoOptionError:
            ldslog.warn(
                "LayerSchema: No Last-Modified date recorded, successful update will write current time here"
            )
            lmod = None

        try:
            disc = self.cp.get(id, 'discard')
        except NoOptionError:
            disc = None

        try:
            cql = self.cp.get(id, 'cql')
        except NoOptionError:
            cql = None

        return LayerConfEntry(id, pkey, name, group, gcol, epsg, lmod, disc,
                              cql)
示例#53
0
    def readLayerParameters(self,id):
    #def readLayerSchemaConfig(self,layer):
        '''Full Layer config reader. Returns the config values for the whole layer or makes sensible guesses for defaults'''
        from LDSUtilities import LayerConfEntry
#        
#        try:
#            defn = self.cp.get(layer, 'sql')
#            #if the user has gone to the trouble of defining their own schema in SQL just return that
#            return (defn,None,None,None,None,None,None,None,None)
#        except:
#            pass
            
        '''optional but one way to record the type and name of a column is to save a string tuple (name,type) and parse this at build time'''
        try:
            pkey = self.cp.get(id, 'pkey')
        except NoOptionError:
            ldslog.warn("LayerSchema: No Primary Key Column defined, default to 'ID'")
            pkey = 'ID'
            
        '''names are/can-be stored so we can reverse search by layer name'''
        try:
            name = self.cp.get(id, 'name')
        except NoOptionError:
            ldslog.warn("LayerSchema: No Name saved in config for this layer, returning ID")
            name = id
            
        if name is None:
            name = id
            
        '''names are/can-be stored so we can reverse search by layer name'''
        try:
            group = LU.assessNone(self.cp.get(id, 'category'))
        except NoOptionError:
            ldslog.warn("Group List: No Groups defined for this layer")
            group = None
        
        if not group:
            pass     
            
        try:
            gcol = self.cp.get(id, 'geocolumn')
        except NoOptionError:
            ldslog.warn("LayerSchema: No Geo Column defined, default to 'SHAPE'")
            gcol = 'SHAPE'
        
        #i dont think we need this anymore using the new logic, if gcol->spatial, if pkey->unique    
#        try:
#            index = self.cp.get(layer, 'index')
#        except NoOptionError:
#            ldslog.warn("LayerSchema: No Index Column/Specification defined, default to None")
#            index = None
            
        try:
            epsg = self.cp.get(id, 'epsg')
        except NoOptionError:
            #print "No Projection Transformation defined"#don't really need to state the default occurance
            epsg = None
            
        try:
            lmod = self.cp.get(id, 'lastmodified')
        except NoOptionError:
            ldslog.warn("LayerSchema: No Last-Modified date recorded, successful update will write current time here")
            lmod = None
            
        try:
            disc = self.cp.get(id, 'discard')
        except NoOptionError:
            disc = None 
            
        try:
            cql = self.cp.get(id, 'cql')
        except NoOptionError:
            cql = None
            
        return LayerConfEntry(id,pkey,name,group,gcol,epsg,lmod,disc,cql)