Esempio n. 1
0
 def tearDownClass(cls):
     gc.collect()
     cls.app.setApplicationName(cls.__appname)
     cls.app.setOrganizationDomain(cls.__appdomain)
     cls.app = None
     super(QCoreAppTestCase, cls).tearDownClass()
     QStandardPaths.setTestModeEnabled(False)
Esempio n. 2
0
 def tearDownClass(cls):
     gc.collect()
     cls.app.setApplicationName(cls.__appname)
     cls.app.setOrganizationDomain(cls.__appdomain)
     cls.app.sendPostedEvents(None, 0)
     # Keep app instance alive between tests with PyQt5 5.14.0 and later
     if PYQT_VERSION <= 0x050e00:
         cls.app = None
     super(QCoreAppTestCase, cls).tearDownClass()
     QStandardPaths.setTestModeEnabled(False)
Esempio n. 3
0
 def setUpClass(cls):
     super(QCoreAppTestCase, cls).setUpClass()
     QStandardPaths.setTestModeEnabled(True)
     app = cls._AppClass.instance()
     if app is None:
         app = cls._AppClass([])
     cls.app = app
     cls.__appname = cls.app.applicationName()
     cls.__appdomain = cls.app.organizationDomain()
     cls.app.setApplicationName("orangecanvas.testing")
     cls.app.setOrganizationDomain("biolab.si")
Esempio n. 4
0
def _session(cachedir=None):
    # type: (...) -> requests.Session
    """
    Return a requests.Session instance

    Parameters
    ----------
    cachedir : Optional[str]
        HTTP cache location.

    Returns
    -------
    session : requests.Session
    """
    import cachecontrol.caches
    if cachedir is None:
        cachedir = QStandardPaths.writableLocation(QStandardPaths.CacheLocation)
        cachedir = os.path.join(cachedir, "networkcache", "requests")
    session = requests.Session()
    session = cachecontrol.CacheControl(
        session,
        cache=cachecontrol.caches.FileCache(
            directory=cachedir
        )
    )
    return session
Esempio n. 5
0
def _session(cachedir=None):
    # type: (...) -> requests.Session
    """
    Return a requests.Session instance

    Parameters
    ----------
    cachedir : Optional[str]
        HTTP cache location.

    Returns
    -------
    session : requests.Session
    """
    import cachecontrol.caches
    if cachedir is None:
        cachedir = QStandardPaths.writableLocation(QStandardPaths.CacheLocation)
        cachedir = os.path.join(cachedir, "networkcache", "requests")
    session = requests.Session()
    session = cachecontrol.CacheControl(
        session,
        cache=cachecontrol.caches.FileCache(
            directory=cachedir
        )
    )
    return session
Esempio n. 6
0
def data_dir_base():
    """
    Return the platform dependent generic application directory.

    This is usually

        - on windows: "%USERPROFILE%\\AppData\\Local\\"
        - on OSX:  "~/Library/Application Support/"
        - other: "~/.local/share/
    """
    return QStandardPaths.writableLocation(QStandardPaths.GenericDataLocation)
Esempio n. 7
0
def cache_dir():
    """
    Return the application cache directory. If the directory path
    does not yet exists then create it.
    """
    init()
    cachedir = QStandardPaths.writableLocation(QStandardPaths.CacheLocation)
    version = QCoreApplication.applicationVersion()
    cachedir = os.path.join(cachedir, version)
    if not os.path.exists(cachedir):
        os.makedirs(cachedir)
    return cachedir
Esempio n. 8
0
def cache_dir():
    """
    Return the application cache directory. If the directory path
    does not yet exists then create it.
    """
    init()
    cachedir = QStandardPaths.writableLocation(QStandardPaths.CacheLocation)
    version = QCoreApplication.applicationVersion()
    cachedir = os.path.join(cachedir, version)
    if not os.path.exists(cachedir):
        os.makedirs(cachedir)
    return cachedir
Esempio n. 9
0
def data_dir():
    """
    Return the application data directory. If the directory path
    does not yet exists then create it.
    """
    init()
    datadir = QStandardPaths.writableLocation(QStandardPaths.DataLocation)
    version = QCoreApplication.applicationVersion()
    datadir = os.path.join(datadir, version)
    if not os.path.isdir(datadir):
        try:
            os.makedirs(datadir, exist_ok=True)
        except OSError:
            pass
    return datadir
Esempio n. 10
0
def data_dir():
    """
    Return the application data directory. If the directory path
    does not yet exists then create it.
    """
    init()
    datadir = QStandardPaths.writableLocation(QStandardPaths.DataLocation)
    version = QCoreApplication.applicationVersion()
    datadir = os.path.join(datadir, version)
    if not os.path.isdir(datadir):
        try:
            os.makedirs(datadir, exist_ok=True)
        except OSError:
            pass
    return datadir
Esempio n. 11
0
def cache_dir():
    """Return the application cache directory. If the directory path
    does not yet exists then create it.
    """
    warnings.warn(f"'{__name__}.cache_dir' is deprecated.",
                  DeprecationWarning,
                  stacklevel=2)
    base = QStandardPaths.writableLocation(QStandardPaths.GenericCacheLocation)
    name = QCoreApplication.applicationName()
    version = QCoreApplication.applicationVersion()
    if not name:
        name = "Orange"
    if not version:
        version = "0.0.0"
    path = os.path.join(base, name, version)
    try:
        os.makedirs(path, exist_ok=True)
    except OSError:
        pass
    return path
Esempio n. 12
0
def standard_location(type):
    warnings.warn("Use QStandardPaths.writableLocation",
                  DeprecationWarning,
                  stacklevel=2)
    return QStandardPaths.writableLocation(type)
Esempio n. 13
0
def standard_location(type):
    warnings.warn(
        "Use QStandardPaths.writableLocation", DeprecationWarning,
        stacklevel=2
    )
    return QStandardPaths.writableLocation(type)
Esempio n. 14
0
 def setUp(self) -> None:
     super().setUp()
     QStandardPaths.setTestModeEnabled(True)
     QSettings.setDefaultFormat(QSettings.IniFormat)
Esempio n. 15
0
 def tearDown(self) -> None:
     QStandardPaths.setTestModeEnabled(False)
     QSettings.setDefaultFormat(QSettings.NativeFormat)
     super().tearDown()
Esempio n. 16
0
 def standard_location(type):
     return QStandardPaths.writableLocation(type)