예제 #1
0
    def networkResource(self):
        '''
        Get the network resource location from the registry.
        '''
        regConfig = RegistryConfig()
        networkResReg = regConfig.read([NETWORK_DOC_RESOURCE])

        if len(networkResReg) == 0:
            networkLocation = "C:/"
        else:
            networkLocation = networkResReg[NETWORK_DOC_RESOURCE]

        return networkLocation
예제 #2
0
    def _composerTemplatesPath(self):
        """
        Reads the path of composer templates in the registry.
        """
        regConfig = RegistryConfig()
        keyName = "ComposerTemplates"

        valueCollection = regConfig.read([keyName])

        if len(valueCollection) == 0:
            return None

        else:
            return valueCollection[keyName]
예제 #3
0
def initLookups():
    '''
    Loads the initial lookup values into the STDM database.
    First check if there is a flag in the registry for asserting whether the lookup values have been initialized.
    If False or the key does not exist then initialize then set key to True
    '''                
    regConfig = RegistryConfig()            
    lookupReg = regConfig.read([DATABASE_LOOKUP])
    
    if len(lookupReg) == 0 :
        loadLookups()  
    else:
        lookupState = lookupReg[DATABASE_LOOKUP].lower()  
        if lookupState == "false":loadLookups()            
예제 #4
0
    def _composerOutputPath(self):
        """
        Returns the directory name of the composer output directory.
        """
        regConfig = RegistryConfig()
        keyName = "ComposerOutputs"

        valueCollection = regConfig.read([keyName])

        if len(valueCollection) == 0:
            return None

        else:
            return valueCollection[keyName]
예제 #5
0
def loadLookups():
    for k,v in stdm_lookups.iteritems():
            modelName = k
            Values = v
            model = globals()[modelName]
            modelInstance = model()
            queryObj = modelInstance.queryObject()
            
            #Ensure item does not exist before being inserted
            for lk in v:
                #Convert QString to Python string
                lk = unicode(lk)
                lkObj = queryObj.filter(model.name == lk).first()
                if lkObj == None:
                    lkInst = model()                
                    lkInst.name = lk
                    lkInst.save()  
    
    #Update registry
    regConfig = RegistryConfig()            
    regConfig.write({DATABASE_LOOKUP:str(True)})  
예제 #6
0
def documentTemplates():
    """
    Return a dictionary of document names and their corresponding absolute file paths.
    """
    docTemplates = OrderedDict()

    regConfig = RegistryConfig()
    keyName = "ComposerTemplates"

    pathConfig = regConfig.read([keyName])

    if len(pathConfig) > 0:
        templateDir = pathConfig[keyName]

        pathDir = QDir(templateDir)
        pathDir.setNameFilters(["*.sdt"])
        docFileInfos = pathDir.entryInfoList(QDir.Files, QDir.Name)

        for df in docFileInfos:
            docTemplates[df.completeBaseName()] = df.absoluteFilePath()

    return docTemplates
예제 #7
0
 def __init__(self):
     self.dbHost = "Host"
     self.dbPort = "Port"
     self.dbName = "Database"
     self.regConfig = RegistryConfig()