예제 #1
0
 def __init__(self, path, addr, port):
     self.logger = DropboxLogManager.get_logger(self)
     self.path = path
     self.addr = addr
     self.port = port
     self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self.offset = 0
예제 #2
0
 def __init__(self, path, addr, port):
     self.logger = DropboxLogManager.get_logger(self)
     self.path = path
     self.addr = addr
     self.port = port
     self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self.offset = 0
예제 #3
0
 def __init__(self, path, client, overwrite=False):
     self.logger = DropboxLogManager.get_logger(self)
     self.path = path
     self.client = client
     self.upload_id = None
     self.expected_offset = 0
     self.overwrite = overwrite
     self.expires = None
예제 #4
0
 def __init__(self, dropbox_client):
     self.logger = DropboxLogManager.get_logger(self)
     # dropbox api client
     self.client = dropbox_client
     # cache init
     self.cache = CacheManager.get_cache('MetadataCache')
     self.cache.get_entry('/')
     # downloader
     self.download_manager = DropboxDownloadManager(dropbox_client)
예제 #5
0
 def __init__(self, dropbox_client):
     self.logger = DropboxLogManager.get_logger(self)
     # dropbox api client
     self.client = dropbox_client
     # cache init
     self.cache = CacheManager.get_cache('MetadataCache')
     self.cache.get_entry('/')
     # downloader
     self.download_manager = DropboxDownloadManager(dropbox_client)
예제 #6
0
 def __init__(self, dbclient):
     self.logger = DropboxLogManager.get_logger(self)
     self.dbclient = dbclient
     server_sock, client_sock = socket.socketpair(socket.AF_UNIX, socket.SOCK_DGRAM)
     self.control_sock = ControlSocket(client_sock)
     self.mcache = CacheManager.get_cache('MetadataCache')
     self.downloads = dict()
     self.next_fd = 0
     self.server = DropboxDownloadServer(self.dbclient, ControlSocket(server_sock))
     self.server.start()
예제 #7
0
def main():
    config_file = os.path.join(os.getenv('HOME'), '.dropboxfuse')
    log = DropboxLogManager()
    client = DropboxClient(config_file)
    CacheManager.set_cache('MetadataCache', MetadataCache(client))
    download_manager = DropboxDownloadManager(client)
    print download_file(download_manager, '/hello.txt')

    del download_manager
    del client
    del log
예제 #8
0
 def __init__(self, path):
     self.logger = DropboxLogManager.get_logger(self)
     self.path = path
     if os.path.isfile(path):
         try:
             fp = open(self.path, 'rb')
             config = json.load(fp)
         except:
             self.logger.warn('config file %s could not be read, using defaults')
             config = dict()
     else:
         config = dict()
     super(DropboxConfiguration, self).__init__(config)
    def __init__(self, dbclient, control_sock):
        self.logger = DropboxLogManager.get_logger(self)
        self.dbclient = dbclient
        self.control_sock = control_sock
        self.dcache = DataCache(self.dbclient)
        self.streams = list()

        # for poll()
        self.output_fds = dict()
        self.input_fds = dict()
        self.poller = select.poll()
        self._register_input_fd(self.control_sock)

        super(DropboxDownloadServer, self).__init__()
예제 #10
0
 def __init__(self, path):
     self.logger = DropboxLogManager.get_logger(self)
     self.path = path
     if os.path.isfile(path):
         try:
             fp = open(self.path, 'rb')
             config = json.load(fp)
         except:
             self.logger.warn(
                 'config file %s could not be read, using defaults')
             config = dict()
     else:
         config = dict()
     super(DropboxConfiguration, self).__init__(config)
예제 #11
0
    def __init__(self, dbclient, control_sock):
        self.logger = DropboxLogManager.get_logger(self)
        self.dbclient = dbclient
        self.control_sock = control_sock
        self.dcache = DataCache(self.dbclient)
        self.streams = list()

        # for poll()
        self.output_fds = dict()
        self.input_fds = dict()
        self.poller = select.poll()
        self._register_input_fd(self.control_sock)

        super(DropboxDownloadServer, self).__init__()
예제 #12
0
def main():
    default_path = os.path.join(os.getenv('HOME'), '.dropboxfuse')
    parser = argparse.ArgumentParser()
    parser.add_argument('-m', '--mount-point', type=str, required=True)
    parser.add_argument('-c',
                        '--config',
                        type=str,
                        default=default_path,
                        required=False)
    parser.add_argument('-k',
                        '--app-key',
                        type=str,
                        default=None,
                        required=False)
    parser.add_argument('-s',
                        '--app-secret',
                        type=str,
                        default=None,
                        required=False)
    parser.add_argument('-a',
                        '--access-token',
                        type=str,
                        default=None,
                        required=False)

    options = parser.parse_args()
    log_manager = DropboxLogManager()
    dropbox_client = DropboxClient(options.config, options.app_key,
                                   options.app_secret, options.access_token)
    CacheManager.set_cache('MetadataCache', MetadataCache(dropbox_client))
    CacheManager.set_cache('DataCache', DataCache(dropbox_client))
    dropbox_fuse = DropboxFuse(dropbox_client)
    try:
        dbfuse = fuse.FUSE(dropbox_fuse,
                           options.mount_point,
                           foreground=True,
                           nothreads=True,
                           allow_other=True)
    except Exception as e:
        print str(e)
        raise
    finally:
        del dropbox_fuse
        del dropbox_client
        del log_manager
    return 0
예제 #13
0
 def __init__(self, path, dcache_entry):
     self.logger = DropboxLogManager.get_logger(self)
     self.path = path
     self.dcache_entry = dcache_entry
     self.server_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self.server_sock.bind(('127.0.0.1', 0))
     # NOTE: backlog is set to 1
     # in order to allow the following `hack`
     # the socket is created, binded and listen(1)
     # the the addr, port is passed to the client process
     # the client will try to connect() and will be catched by the backlog
     # then we (our process) will hit accept() and finish the handshake
     self.server_sock.listen(1)
     self.client_sock = None
     self.client_addr = None
     self.client_pos = 0
     self.logger.info('created stream (%d) for %s', id(self), os.path.basename(self.path))
     super(DownloadStream, self).__init__()
예제 #14
0
 def __init__(self, path, dcache_entry):
     self.logger = DropboxLogManager.get_logger(self)
     self.path = path
     self.dcache_entry = dcache_entry
     self.server_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self.server_sock.bind(('127.0.0.1', 0))
     # NOTE: backlog is set to 1
     # in order to allow the following `hack`
     # the socket is created, binded and listen(1)
     # the the addr, port is passed to the client process
     # the client will try to connect() and will be catched by the backlog
     # then we (our process) will hit accept() and finish the handshake
     self.server_sock.listen(1)
     self.client_sock = None
     self.client_addr = None
     self.client_pos = 0
     self.logger.info('created stream (%d) for %s', id(self),
                      os.path.basename(self.path))
     super(DownloadStream, self).__init__()
예제 #15
0
    def __init__(self,
                 config,
                 app_key=None,
                 app_secret=None,
                 access_token=None):
        self.logger = DropboxLogManager.get_logger(self)
        self.config = DropboxConfiguration(config)
        if not ('app_key' in self.config and 'app_secret' in self.config):
            if app_key is None or app_secret is None:
                msg = 'app_secret AND app_secret needs to be valid'
                self.logger.error(msg)
                raise Exception(msg)
            self.config['app_key'] = app_key
            self.config['app_secret'] = app_secret

        if not ('access_token' in self.config and 'user_id' in self.config):
            ret = DropboxClient.get_access_token(self.config['app_key'],
                                                 self.config['app_secret'])
            access_token, user_id = ret
            self.config['access_token'] = access_token
            self.config['user_id'] = user_id

        self.config.commit()
        super(DropboxClient, self).__init__(self.config['access_token'])
예제 #16
0
 def __init__(self, path, client):
     self.logger = DropboxLogManager.get_logger(self)
     self.path = path
     self.client = client
     self._dirty = False
     self._is_cached = False
예제 #17
0
 def __init__(self, client):
     self.logger = DropboxLogManager.get_logger(self)
     self.cache = dict()
     self.client = client