Esempio n. 1
0
    def _initResourcePaths(self):
        resourcePaths = []
        resourcePaths.append(path.dirname(__file__))

        resourcePaths.extend(QStandardPaths.standardLocations(
            QStandardPaths.AppLocalDataLocation))

        # For when we're running from the dev tree
        resourcePaths.append(path.abspath(path.curdir))
        resourcePaths.append(path.join(path.abspath(path.curdir), 'resources'))
        resourcePaths.append(path.join(path.abspath(path.curdir), 'doc'))

        return resourcePaths
Esempio n. 2
0
    def init(self):
        from .MainApplication import MainApplication
        appDir = QCoreApplication.applicationDirPath()
        self._paths[self.AppData].extend(
            QStandardPaths.standardLocations(QStandardPaths.AppDataLocation))
        self._paths[self.Plugins].append(pathjoin(appDir, 'plugins'))
        for location in self._paths[self.AppData]:
            self.initAssertIn(location)
        if MainApplication.isTestModeEnabled():
            self._paths[self.Config].append(
                pathjoin(QDir().tempPath(), '%s-test' % const.APPNAME))
        else:
            self._paths[self.Config].append(
                QStandardPaths.writableLocation(
                    QStandardPaths.AppConfigLocation))

        self._paths[self.Profiles].append(
            pathjoin(self._paths[self.Config][0], 'profiles'))
        # We also allow to load data from Config path
        self.initAssertIn(self._paths[self.Config][0])

        # if PLUGIN_PATH is set, only load plugins from there
        pluginPath = environ.get('PLUGIN_PATH', '')
        if pluginPath:
            self._paths[self.Plugins] = [
                pluginPath,
            ]

        self._tmpdir = QTemporaryDir()
        self._paths[self.Temp].append(self._tmpdir.path())
        if not self._tmpdir.isValid():
            print('Failed to create temporary directory %s' %
                  self._tmpdir.path(),
                  file=stderr)

        self._paths[self.Cache].append(
            QStandardPaths.writableLocation(QStandardPaths.CacheLocation))