示例#1
0
    def getScratchDirPath(self):
        """Get the scratch preference if available, otherwise return
        None

        Note: this reads from file on each load; this not be efficient

        >>> a = Environment()
        >>> post = a.getScratchDirPath()
        """
        fp = drawer.getPrefsPath()
        if not os.path.exists(fp):
            return None
        prefDict = getXmlPrefDict(fp)
        try:
            fpScratch = prefDict['athena']['fpScratchDir']
        except:  # catch all
            fpScratch = ''
        if not os.path.exists(fpScratch) or not os.path.isdir(fpScratch):
            self.printWarn(
                'scratch directory preference set to a non-directory: %s' %
                fpScratch)
            fpScratch = ''  # do not pass forward
        # final return
        if fpScratch == '':
            return None
        else:
            return fpScratch
示例#2
0
    def getScratchDirPath(self):
        """Get the scratch preference if available, otherwise return
        None

        Note: this reads from file on each load; this not be efficient

        >>> a = Environment()
        >>> post = a.getScratchDirPath()
        """
        fp = drawer.getPrefsPath()
        if not os.path.exists(fp):
            return None
        prefDict = getXmlPrefDict(fp)
        try:
            fpScratch = prefDict['athena']['fpScratchDir']
        except: # catch all
            fpScratch = ''
        if not os.path.exists(fpScratch) or not os.path.isdir(fpScratch): 
            self.printWarn('scratch directory preference set to a non-directory: %s' % fpScratch)
            fpScratch = '' # do not pass forward        
        # final return
        if fpScratch == '':
            return None
        else:
            return fpScratch
示例#3
0
    def debugStat(self):
        """Get the debug preference if available, otherwise zero
        only do this once

        >>> a = Environment()
        >>> post = a.debugStat()
        """
        fp = drawer.getPrefsPath()
        if not os.path.exists(fp):
            return 0
        prefDict = getXmlPrefDict(fp)
        # if fp is not found, this should return a default
        try:
            return int(prefDict['athena']['debug'])
        except:  # catch all: this cannot crash
            return 0
示例#4
0
    def debugStat(self):
        """Get the debug preference if available, otherwise zero
        only do this once

        >>> a = Environment()
        >>> post = a.debugStat()
        """
        fp = drawer.getPrefsPath()
        if not os.path.exists(fp):
            return 0
        prefDict = getXmlPrefDict(fp)
        # if fp is not found, this should return a default
        try:
            return int(prefDict['athena']['debug'])
        except: # catch all: this cannot crash
            return 0