Пример #1
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
Пример #2
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
Пример #4
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 validatePage(self):
        from lds.ReadConfig import MainFileReader as MFR
        from lds.ConfigWrapper import ConfigWrapper
        from lds.LDSUtilities import Encrypt
        rv = super(ConfirmationPage, self).validatePage()
        
        encrypt = self.field("ldsencryption")
        inex = 'internal' if self.field("ldsinternal") else 'external'
        
        buildarray = ()
        
        buildarray += ((MFR.LDSN,'key',self.field("ldsapikey")),)
        
        #proxy type = user defined
        if self.field("proxy"+WFSDataStore.PROXY_TYPE[2]):
            buildarray += ((MFR.PROXY,'type',WFSDataStore.PROXY_TYPE[2]),)
            buildarray += ((MFR.PROXY,'host',self.field("proxyhost")),)
            buildarray += ((MFR.PROXY,'port',self.field("proxyport")),)
            buildarray += ((MFR.PROXY,'auth',WFSDataStore.PROXY_AUTH[int(self.field("proxyauth"))-1]),)
            buildarray += ((MFR.PROXY,'user',self.field("proxyusr")),)
            pwd = self.field("proxypwd")
            if encrypt:
                pwd = Encrypt.ENC_PREFIX+Encrypt.secure(pwd)
            buildarray += ((MFR.PROXY,'pass',pwd),)
            
        #proxy type = system
        elif self.field("proxy"+WFSDataStore.PROXY_TYPE[1]):
            buildarray += ((MFR.PROXY,'type',WFSDataStore.PROXY_TYPE[1]),)            
            buildarray += ((MFR.PROXY,'host',''),)
            buildarray += ((MFR.PROXY,'port',''),)
            buildarray += ((MFR.PROXY,'auth',''),)
            buildarray += ((MFR.PROXY,'user',''),)
            buildarray += ((MFR.PROXY,'pass',''),)
#            if os.name == 'nt':
#                #windows
#                from lds.WinUtilities import Registry as WR
#                (_,host,port) = WR.readProxyValues()
#                buildarray += ((MFR.PROXY,'host',host),)
#                buildarray += ((MFR.PROXY,'port',port),)
#            else:
#                #unix etc
#                hp = os.environ('http_proxy')
#                rm = re.search('http://([a-zA-Z0-9_\.\-]+):(\d+)',hp)
#                buildarray += ((MFR.PROXY,'host',rm.group(1)),)
#                buildarray += ((MFR.PROXY,'port',rm.group(2)),)               
            
        #proxy type = direct
        elif self.field("proxy"+WFSDataStore.PROXY_TYPE[0]):
            buildarray += ((MFR.PROXY,'type',WFSDataStore.PROXY_TYPE[0]),)            
            buildarray += ((MFR.PROXY,'host',''),)
            buildarray += ((MFR.PROXY,'port',''),)
            buildarray += ((MFR.PROXY,'auth',''),)
            buildarray += ((MFR.PROXY,'user',''),)
            buildarray += ((MFR.PROXY,'pass',''),)

        section = self.selected[0]
        for sf in self.selectedfields:
            name = sf[0]
            value = sf[2]
            if name == 'pass' and encrypt:
                value = Encrypt.ENC_PREFIX+Encrypt.secure(value)
            buildarray += ((section,name,value),)

        buildarray += ((section,'config',inex),)
        ucfile = self.field("ldsfile")
        #ucfile = LU.standardiseUserConfigName(str(self.field("ldsfile").toString()))
        
        #save values to user config file 
        self.parent.setMFR(self.ldsfile)
        ConfigWrapper.writeUserConfigData(self.parent.getMFR(), buildarray)
        #save userconf and dest to gui prefs
        gpr = GUIPrefsReader()
        #zips with (dest,lgsel,layer,uconf...
        gpr.write(( section,'',ucfile))
        
        #pass back name of UC file for GUI dialog
        if self.ldsfile and self.parent.parent and hasattr(self.parent.parent,'controls'):
            self.parent.parent.controls.confcombo.setEditText(self.ldsfile)
            
        return rv