browser/dashboard: use appdirs, closes #438

This commit is contained in:
Robert Jördens 2016-07-18 16:50:27 +02:00
parent 340d65fec7
commit bb706c1fe2
3 changed files with 17 additions and 10 deletions

View File

@ -10,7 +10,8 @@ from PyQt5 import QtCore, QtGui, QtWidgets
from quamash import QEventLoop
from artiq import __artiq_dir__ as artiq_dir
from artiq.tools import verbosity_args, atexit_register_coroutine
from artiq.tools import (verbosity_args, atexit_register_coroutine,
get_user_config_dir)
from artiq.gui import state, applets, models, log
from artiq.browser import datasets, files, experiments
@ -19,10 +20,7 @@ logger = logging.getLogger(__name__)
def get_argparser():
if os.name == "nt":
default_db_file = os.path.expanduser("~\\artiq_browser.pyon")
else:
default_db_file = os.path.expanduser("~/.artiq_browser.pyon")
default_db_file = os.path.join(get_user_config_dir(), "artiq_browser.pyon")
parser = argparse.ArgumentParser(description="ARTIQ Browser")
parser.add_argument("--db-file", default=default_db_file,

View File

@ -10,7 +10,8 @@ from PyQt5 import QtCore, QtGui, QtWidgets
from quamash import QEventLoop
from artiq import __artiq_dir__ as artiq_dir, __version__ as artiq_version
from artiq.tools import *
from artiq.tools import (atexit_register_coroutine, verbosity_args,
get_user_config_dir)
from artiq.protocols.pc_rpc import AsyncioClient
from artiq.protocols.broadcast import Receiver
from artiq.gui.models import ModelSubscriber
@ -20,10 +21,8 @@ from artiq.dashboard import (experiments, shortcuts, explorer,
def get_argparser():
if os.name == "nt":
default_db_file = os.path.expanduser("~\\artiq_dashboard.pyon")
else:
default_db_file = os.path.expanduser("~/.artiq_dashboard.pyon")
default_db_file = os.path.join(get_user_config_dir(),
"artiq_dashboard.pyon")
parser = argparse.ArgumentParser(description="ARTIQ Dashboard")
parser.add_argument(

View File

@ -14,6 +14,9 @@ import numpy as np
from artiq.language.environment import is_experiment
from artiq.protocols import pyon
from artiq.appdirs import user_config_dir
from artiq._version import get_versions
artiq_version = get_versions()['version']
__all__ = ["parse_arguments", "elide", "short_format", "file_import",
@ -243,3 +246,10 @@ def get_windows_drives():
drives.append(letter)
bitmask >>= 1
return drives
def get_user_config_dir():
major = artiq_version.split(".")[0]
dir = user_config_dir("artiq", "m-labs", major)
os.makedirs(dir, exist_ok=True)
return dir