How to use the maestral.config.main.CONF 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 / gui / main.py View on Github external
def _is_linked():
    """
    Checks if auth key has been saved.

    :raises: ``KeyringLocked`` if the system keyring cannot be accessed.
    """
    account_id = CONF.get("account", "account_id")
    try:
        if account_id == "":
            access_token = None
        else:
            access_token = keyring.get_password("Maestral", account_id)
        return access_token
    except KeyringLocked:
        info = "Please make sure that your keyring is unlocked and restart Maestral."
        raise KeyringLocked(info)
github SamSchott / maestral-dropbox / maestral / sync / main.py View on Github external
def excluded_status(dbx_path):
        """
        Returns 'excluded', 'partially excluded' or 'included'. This function will not
        check if the item actually exists on Dropbox.

        :param str dbx_path: Path to item on Dropbox.
        :returns: Excluded status.
        :rtype: str
        """

        dbx_path = dbx_path.lower().rstrip(osp.sep)

        excluded_items = CONF.get("main", "excluded_folders") + CONF.get("main", "excluded_files")

        if dbx_path in excluded_items:
            return "excluded"
        elif any(is_child(dbx_path, f) for f in excluded_items):
            return "partially excluded"
        else:
            return "included"
github SamSchott / maestral-dropbox / maestral / sync / client.py View on Github external
res = self.dbx.users_get_account(dbid)
        else:
            res = self.dbx.users_get_current_account()

        if not dbid:
            # save our own account info to config
            if res.account_type.is_basic():
                account_type = "basic"
            elif res.account_type.is_business():
                account_type = "business"
            elif res.account_type.is_pro():
                account_type = "pro"
            else:
                account_type = ""

            CONF.set("account", "account_id", res.account_id)
            CONF.set("account", "email", res.email)
            CONF.set("account", "display_name", res.name.display_name)
            CONF.set("account", "abbreviated_name", res.name.abbreviated_name)
            CONF.set("account", "type", account_type)

        return res
github SamSchott / maestral-dropbox / maestral / client.py View on Github external
automatically with every sync. :ivar:`rev_dict` is used to determine
        sync conflicts and detect deleted files while Maestral has not been
        running. :ivar:`rev_dict` is periodically saved to :ivar:`rev_file`.
        All keys are stored in lower case.
    :ivar rev_file: Path of local file to save :ivar:`rev_dict`. This defaults
        to '/dropbox_path/.dropbox'
    :ivar dropbox_path: Path to local Dropbox folder, as loaded from config
        file. Before changing :ivar`dropbox_path`, make sure that all syncing
        is paused. Make sure to move the local Dropbox directory before
        resuming the sync and to save the new :ivar`dropbox_path` to the
        config file.
    """

    SDK_VERSION = "2.0"

    excluded_files = CONF.get("main", "excluded_files")
    excluded_folders = CONF.get("main", "excluded_folders")
    last_cursor = CONF.get("internal", "cursor")

    dbx = None
    auth = None
    dropbox_path = ''

    notify = Notipy()
    lock = threading.RLock()

    _rev_lock = threading.Lock()

    def __init__(self):

        # get Dropbox session
        self.auth = OAuth2Session()
github SamSchott / maestral-dropbox / maestral / cli.py View on Github external
def account_info(config_name: str, running: bool):
    """Prints your Dropbox account information."""

    if _is_maestral_linked(config_name):
        from maestral.config.main import CONF
        email = CONF.get("account", "email")
        account_type = CONF.get("account", "type").capitalize()
        usage = CONF.get("account", "usage")
        path = CONF.get("main", "path")
        click.echo("")
        click.echo("Email:             {}".format(email))
        click.echo("Account-type:      {}".format(account_type))
        click.echo("Usage:             {}".format(usage))
        click.echo("Dropbox location:  '{}'".format(path))
        click.echo("")
github SamSchott / maestral-dropbox / maestral / sync / monitor.py View on Github external
def __init__(self, client, local_file_event_queue, queue_uploading, queue_downloading):

        self.client = client
        self.local_file_event_queue = local_file_event_queue
        self.queue_uploading = queue_uploading
        self.queue_downloading = queue_downloading

        # load cached properties
        self._dropbox_path = CONF.get("main", "path")
        self._excluded_files = CONF.get("main", "excluded_files")
        self._excluded_folders = CONF.get("main", "excluded_folders")
        self._rev_dict_cache = self._load_rev_dict_from_file()
github SamSchott / maestral-dropbox / maestral / client.py View on Github external
"""
        Unlinks the Dropbox account and deletes local sync information.
        """
        self.auth.unlink()

        self.rev_dict = {}
        os.remove(self.rev_file)

        self.excluded_folders = []
        CONF.set("main", "excluded_folders", [])

        CONF.set("account", "email", "")
        CONF.set("account", "usage", "")

        CONF.set("internal", "cursor", "")
        CONF.set("internal", "lastsync", None)

        logger.debug("Unliked Dropbox account")
github SamSchott / maestral-dropbox / maestral / sync / monitor.py View on Github external
def last_sync(self, last_sync):
        """Setter: last_cursor"""
        logger.debug(f"Local cursor saved: {last_sync}")
        CONF.set("internal", "lastsync", last_sync)
github SamSchott / maestral-dropbox / maestral / cli.py View on Github external
def check_for_updates():
    """Checks if updates are available by reading the cached release number from the
    config file and notifies the user."""
    from maestral import __version__
    from maestral.config.main import CONF
    from maestral.sync.utils.updates import check_version

    latest_release = CONF.get("app", "latest_release")

    has_update = check_version(__version__, latest_release, '<')

    if has_update:
        click.secho("Maestral v{0} has been released, you have v{1}. Please use your "
                    "package manager to update.".format(latest_release, __version__),
                    fg="red")
github SamSchott / maestral-dropbox / maestral / gui / setup_dialog.py View on Github external
self.mdbx = None
        self.dbx_model = None
        self.excluded_folders = []

        # resize dialog buttons
        width = self.pushButtonAuthPageCancel.width()*1.1
        for b in (self.pushButtonAuthPageLink, self.pushButtonDropboxPathUnlink,
                  self.pushButtonDropboxPathSelect, self.pushButtonFolderSelectionBack,
                  self.pushButtonFolderSelectionSelect, self.pushButtonAuthPageCancel,
                  self.pushButtonDropboxPathCalcel, self.pushButtonClose):
            b.setMinimumWidth(width)
            b.setMaximumWidth(width)

        # set up combobox
        self.dropbox_location = osp.dirname(CONF.get("main", "path")) or get_home_dir()
        relative_path = self.rel_path(self.dropbox_location)

        folder_icon = get_native_item_icon(self.dropbox_location)
        self.comboBoxDropboxPath.addItem(folder_icon, relative_path)

        self.comboBoxDropboxPath.insertSeparator(1)
        self.comboBoxDropboxPath.addItem(QtGui.QIcon(), "Other...")
        self.comboBoxDropboxPath.currentIndexChanged.connect(self.on_combobox)
        self.dropbox_folder_dialog = QtWidgets.QFileDialog(self)
        self.dropbox_folder_dialog.setAcceptMode(QtWidgets.QFileDialog.AcceptOpen)
        self.dropbox_folder_dialog.setFileMode(QtWidgets.QFileDialog.Directory)
        self.dropbox_folder_dialog.setOption(QtWidgets.QFileDialog.ShowDirsOnly, True)
        self.dropbox_folder_dialog.fileSelected.connect(self.on_new_dbx_folder)
        self.dropbox_folder_dialog.rejected.connect(
                lambda: self.comboBoxDropboxPath.setCurrentIndex(0))