How to use the maestral.config.base.get_conf_path function in maestral

To help you get started, we’ve selected a few maestral examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SamSchott / maestral-dropbox / maestral / config / user.py View on Github external
def filename(self):
        """Create a .ini filename. This .ini files stores the global preferences.
        """
        if self.subfolder is None:
            config_file = osp.join(get_home_dir(), '.%s.ini' % self.name)
            return config_file
        else:
            folder = get_conf_path(self.subfolder)
            # Save defaults in a "defaults" dir of .spyder2 to not pollute it
            if 'defaults' in self.name:
                folder = osp.join(folder, 'defaults')
                if not osp.isdir(folder):
                    os.mkdir(folder)
            config_file = osp.join(folder, '%s.ini' % self.name)
            return config_file
github SamSchott / maestral-dropbox / maestral / sync / utils / appdirs.py View on Github external
def get_cache_path(subfolder=None, filename=None, create=True):
    """
    Returns the default cache path for the platform. This will be:

        - macOS: "~/Library/Application Support/SUBFOLDER/FILENAME"
        - Linux: "$XDG_CACHE_HOME/SUBFOLDER/FILENAME"
        - fallback: "~/.cache/SUBFOLDER/FILENAME"

    :param str subfolder: The subfolder for the app.
    :param str filename: The filename to append for the app.
    :param bool create: If ``True``, the folder "" will be created on-demand.
    """
    if platform.system() == "Darwin":
        return get_conf_path(subfolder, filename, create)
    else:
        return get_log_path(subfolder, filename, create)
github SamSchott / maestral-dropbox / maestral / cli.py View on Github external
def list_configs():
    """Lists all maestral configs"""
    from maestral.config.base import get_conf_path
    configs = []
    for file in os.listdir(get_conf_path("maestral")):
        if file.endswith(".ini"):
            configs.append(os.path.splitext(os.path.basename(file))[0])

    return configs
github SamSchott / maestral-dropbox / maestral / cli.py View on Github external
def config_remove(name: str):
    """Remove a Maestral configuration."""
    if name not in list_configs():
        click.echo("Configuration '{}' could not be found.".format(name))
    else:
        from maestral.config.base import get_conf_path
        for file in os.listdir(get_conf_path("maestral")):
            if file.startswith(name):
                os.unlink(os.path.join(get_conf_path("maestral"), file))
        click.echo("Deleted configuration '{}'.".format(name))
github SamSchott / maestral-dropbox / maestral / config / user.py View on Github external
def filename(self):
        """Create a .ini filename. This .ini files stores the global preferences.
        """
        if self.subfolder is None:
            config_file = osp.join(get_home_dir(), '.%s.ini' % self.name)
            return config_file
        else:
            folder = get_conf_path(self.subfolder)
            # Save defaults in a "defaults" dir of .spyder2 to not pollute it
            if 'defaults' in self.name:
                folder = osp.join(folder, 'defaults')
                if not osp.isdir(folder):
                    os.mkdir(folder)
            config_file = osp.join(folder, '%s.ini' % self.name)
            return config_file
github SamSchott / maestral-dropbox / maestral / sync / oauth.py View on Github external
import keyring.backends.OS_X
    keyring.set_keyring(keyring.backends.OS_X.Keyring())
else:
    # get preferred keyring backends for platform, excluding the chainer backend
    all_keyrings = keyring.backend.get_all_keyring()
    preferred_kreyrings = [k for k in all_keyrings if not isinstance(k, keyring.backends.chainer.ChainerBackend)]

    keyring.set_keyring(max(preferred_kreyrings, key=lambda x: x.priority))


class OAuth2Session(object):
    """
    OAuth2Session provides OAuth2 login and token store.
    """

    TOKEN_FILE = osp.join(get_conf_path(SUBFOLDER), "o2_store.txt")  # before v0.2.0
    oAuth2FlowResult = None

    Success = 0
    InvalidToken = 1
    ConnectionFailed = 2

    def __init__(self):

        self.account_id = CONF.get("account", "account_id")
        self.access_token = ""

    def load_token(self):
        """
        Check if auth key has been saved.

        :raises: ``KeyringLocked`` if the system keyring cannot be accessed.
github SamSchott / maestral-dropbox / maestral / sync / utils / appdirs.py View on Github external
def get_autostart_path(filename=None, create=True):
    """
    Returns the default cache path for the platform. This will be:

        - macOS: "~/Library/LaunchAgents/FILENAME"
        - Linux: "$XDG_CONFIG_HOME/autostart/FILENAME"
        - fallback: "~/.config/autostart/FILENAME"

    :param str filename: The filename to append for the app.
    :param bool create: If ``True``, the folder "" will be created on-demand.
    """
    if platform.system() == "Darwin":
        autostart_path = osp.join(get_home_dir(), "Library", "LaunchAgents")
    else:
        autostart_path = get_conf_path("autostart", create=create)

    # attach filename
    if filename:
        autostart_path = osp.join(autostart_path, filename)

    return autostart_path
github SamSchott / maestral-dropbox / maestral / cli.py View on Github external
def config_remove(name: str):
    """Remove a Maestral configuration."""
    if name not in list_configs():
        click.echo("Configuration '{}' could not be found.".format(name))
    else:
        from maestral.config.base import get_conf_path
        for file in os.listdir(get_conf_path("maestral")):
            if file.startswith(name):
                os.unlink(os.path.join(get_conf_path("maestral"), file))
        click.echo("Deleted configuration '{}'.".format(name))