예제 #1
0
 def mtime(self):
     if self.exists():
         metadata = self._dropboxc.files_get_metadata(self.dropbox_file())
         epochTime = metadata.server_modified.timestamp()
         return epochTime
     else:
         raise DropboxFileException(
             "The file does not seem to exist remotely: %s" %
             self.dropbox_file())
예제 #2
0
    def __init__(self, *args, **kwargs):
        super(RemoteProvider, self).__init__(*args, **kwargs)

        self._dropboxc = dropbox.Dropbox(*args, **kwargs)
        try:
            self._dropboxc.users_get_current_account()
        except dropbox.exceptions.AuthError as err:
            DropboxFileException(
                "ERROR: Invalid Dropbox OAuth access token; try re-generating an access token from the app console on the web."
            )
예제 #3
0
    def download(self, make_dest_dirs=True):
        if self.exists():
            # if the destination path does not exist, make it
            if make_dest_dirs:
                os.makedirs(os.path.dirname(self.file()), exist_ok=True)

            self._dropboxc.files_download_to_file(self.file(),
                                                  self.remote_file())
        else:
            raise DropboxFileException(
                "The file does not seem to exist remotely: %s" %
                self.remote_file())
예제 #4
0
    def _download(self, make_dest_dirs=True):
        if self.exists():
            # if the destination path does not exist, make it
            if make_dest_dirs:
                os.makedirs(os.path.dirname(self.local_file()), exist_ok=True)

            self._dropboxc.files_download_to_file(self.local_file(),
                                                  self.dropbox_file())
            os_sync()  # ensure flush to disk
        else:
            raise DropboxFileException(
                "The file does not seem to exist remotely: %s" %
                self.dropbox_file())
예제 #5
0
    def __init__(self, *args, keep_local=False, provider=None, **kwargs):
        super(RemoteObject, self).__init__(
            *args, keep_local=keep_local, provider=provider, **kwargs
        )

        if provider:
            self._dropboxc = provider.remote_interface()
        else:
            self._dropboxc = dropbox.Dropbox(*args, **kwargs)
            try:
                self._dropboxc.users_get_current_account()
            except dropbox.exceptions.AuthError as err:
                DropboxFileException(
                    "ERROR: Invalid Dropbox OAuth access token; try re-generating an access token from the app console on the web."
                )