Exemplo 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)
Exemplo 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)
Exemplo 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")
Exemplo 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
Exemplo 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
Exemplo 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)
Exemplo 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
Exemplo 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
Exemplo 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
Exemplo 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
Exemplo 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
Exemplo n.º 12
0
def standard_location(type):
    warnings.warn("Use QStandardPaths.writableLocation",
                  DeprecationWarning,
                  stacklevel=2)
    return QStandardPaths.writableLocation(type)
Exemplo n.º 13
0
def standard_location(type):
    warnings.warn(
        "Use QStandardPaths.writableLocation", DeprecationWarning,
        stacklevel=2
    )
    return QStandardPaths.writableLocation(type)
Exemplo n.º 14
0
 def setUp(self) -> None:
     super().setUp()
     QStandardPaths.setTestModeEnabled(True)
     QSettings.setDefaultFormat(QSettings.IniFormat)
Exemplo n.º 15
0
 def tearDown(self) -> None:
     QStandardPaths.setTestModeEnabled(False)
     QSettings.setDefaultFormat(QSettings.NativeFormat)
     super().tearDown()
Exemplo n.º 16
0
 def standard_location(type):
     return QStandardPaths.writableLocation(type)