Esempio n. 1
0
 def __init__(self, settings):
     self.settings = settings
     self.SIGNATURE = "LocalfsFileClient"
     self.ROOTPATH = settings.local_root_path
     self.CACHEPATH = settings.cache_path
     self.syncer_dbtuple = settings.syncer_dbtuple
     client_dbname = self.SIGNATURE + ".db"
     self.client_dbtuple = common.DBTuple(
         dbtype=database.ClientDB, dbname=utils.join_path(settings.instance_path, client_dbname)
     )
     database.initialize(self.client_dbtuple)
     self.probe_candidates = utils.ThreadSafeDict()
     self.check_enabled()
Esempio n. 2
0
 def __init__(self, settings):
     self.settings = settings
     self.SIGNATURE = "LocalfsFileClient"
     self.ROOTPATH = settings.local_root_path
     self.CACHEPATH = settings.cache_path
     self.syncer_dbtuple = settings.syncer_dbtuple
     client_dbname = self.SIGNATURE + '.db'
     self.client_dbtuple = common.DBTuple(dbtype=database.ClientDB,
                                          dbname=utils.join_path(
                                              settings.instance_path,
                                              client_dbname))
     database.initialize(self.client_dbtuple)
     self.probe_candidates = utils.ThreadSafeDict()
     self.check_enabled()
Esempio n. 3
0
 def __init__(self, settings):
     self.settings = settings
     self.SIGNATURE = "PithosFileClient"
     self.auth_url = settings.auth_url
     self.auth_token = settings.auth_token
     self.container = settings.container
     self.syncer_dbtuple = settings.syncer_dbtuple
     client_dbname = self.SIGNATURE+'.db'
     self.client_dbtuple = common.DBTuple(
         dbtype=database.ClientDB,
         dbname=utils.join_path(settings.instance_path, client_dbname))
     database.initialize(self.client_dbtuple)
     self.endpoint = settings.endpoint
     self.last_modification = "0000-00-00"
     self.probe_candidates = utils.ThreadSafeDict()
     self.check_enabled()
Esempio n. 4
0
 def __init__(self, settings):
     self.settings = settings
     self.SIGNATURE = "PithosFileClient"
     self.auth_url = settings.auth_url
     self.auth_token = settings.auth_token
     self.container = settings.container
     self.syncer_dbtuple = settings.syncer_dbtuple
     client_dbname = self.SIGNATURE + '.db'
     self.client_dbtuple = common.DBTuple(dbtype=database.ClientDB,
                                          dbname=utils.join_path(
                                              settings.instance_path,
                                              client_dbname))
     database.initialize(self.client_dbtuple)
     self.endpoint = settings.endpoint
     self.last_modification = "0000-00-00"
     self.probe_candidates = utils.ThreadSafeDict()
     self.check_enabled()
Esempio n. 5
0
 def __init__(self, **kwargs):
     """Setup the helper server"""
     db_name = kwargs.get('session_db',
                          os.path.join(AGKYRA_DIR, 'session.db'))
     self.session_db = common.DBTuple(dbtype=SessionDB, dbname=db_name)
     database.initialize(self.session_db)
Esempio n. 6
0
 def __init__(self, **kwargs):
     """Setup the helper server"""
     db_name = kwargs.get(
         'session_db', os.path.join(AGKYRA_DIR, 'session.db'))
     self.session_db = common.DBTuple(dbtype=SessionDB, dbname=db_name)
     database.initialize(self.session_db)
Esempio n. 7
0
    def __init__(self, auth_url, auth_token, container, local_root_path,
                 *args, **kwargs):
        check_encoding()
        auth_url = utils.to_unicode(auth_url)
        auth_token = utils.to_unicode(auth_token)
        container = utils.to_unicode(container)
        local_root_path = utils.to_unicode(local_root_path)
        self.auth_url = utils.normalize_standard_suffix(auth_url)
        self.auth_token = auth_token
        self.container = utils.normalize_standard_suffix(container)

        self.ignore_ssl = kwargs.get("ignore_ssl", False)
        if self.ignore_ssl:
            https.patch_ignore_ssl()
        elif kwargs.get('ca_certs', None):
            https.patch_with_certs(kwargs['ca_certs'])

        self.endpoint = self._get_pithos_client(
            auth_url, auth_token, container)

        container_exists = self.check_container_exists(container)

        home_dir = utils.to_unicode(os.path.expanduser('~'))
        default_settings_path = join_path(home_dir, GLOBAL_SETTINGS_NAME)
        self.settings_path = utils.to_unicode(
            kwargs.get("agkyra_path", default_settings_path))
        self.create_dir(self.settings_path, mode=stat.S_IRWXU)

        self.instances_path = join_path(self.settings_path, INSTANCES_NAME)
        self.create_dir(self.instances_path)

        self.local_root_path = utils.normalize_local_suffix(local_root_path)
        local_root_path_exists = os.path.isdir(self.local_root_path)

        self.cache_name = utils.to_unicode(
            kwargs.get("cache_name", DEFAULT_CACHE_NAME))
        self.cache_path = join_path(self.local_root_path, self.cache_name)

        self.cache_hide_name = utils.to_unicode(
            kwargs.get("cache_hide_name", DEFAULT_CACHE_HIDE_NAME))
        self.cache_hide_path = join_path(self.cache_path, self.cache_hide_name)

        self.cache_stage_name = utils.to_unicode(
            kwargs.get("cache_stage_name", DEFAULT_CACHE_STAGE_NAME))
        self.cache_stage_path = join_path(self.cache_path,
                                          self.cache_stage_name)

        self.cache_fetch_name = utils.to_unicode(
            kwargs.get("cache_fetch_name", DEFAULT_CACHE_FETCH_NAME))
        self.cache_fetch_path = join_path(self.cache_path,
                                          self.cache_fetch_name)

        self.user_id = self.endpoint.account
        self.instance = get_instance(
            [self.auth_url, self.user_id,
             self.container, self.local_root_path])
        self.instance_path = join_path(self.instances_path, self.instance)
        self.create_dir(self.instance_path)

        self.dbname = utils.to_unicode(kwargs.get("dbname", DEFAULT_DBNAME))
        self.full_dbname = join_path(self.instance_path, self.dbname)
        self.syncer_dbtuple = common.DBTuple(
            dbtype=database.SyncerDB,
            dbname=self.full_dbname)

        db_existed = os.path.isfile(self.full_dbname)
        if not db_existed:
            database.initialize(self.syncer_dbtuple)

        self.mtime_lag = 0
        self.case_insensitive = False

        if not db_existed:
            self.set_localfs_enabled(True)
            self.create_local_dirs()
            self.set_pithos_enabled(True)
            if not container_exists:
                self.mk_container(container)
        else:
            if not local_root_path_exists:
                self.set_localfs_enabled(False)
            else:
                self.create_local_dirs()
            if not container_exists:
                self.set_pithos_enabled(False)

        self.heartbeat = ThreadSafeDict()
        self.action_max_wait = kwargs.get("action_max_wait",
                                          DEFAULT_ACTION_MAX_WAIT)
        self.pithos_list_interval = kwargs.get("pithos_list_interval",
                                               DEFAULT_PITHOS_LIST_INTERVAL)

        self.connection_retry_limit = kwargs.get(
            "connection_retry_limit", DEFAULT_CONNECTION_RETRY_LIMIT)
        self.endpoint.CONNECTION_RETRY_LIMIT = self.connection_retry_limit
        self.max_alive_sync_threads = kwargs.get(
            "max_alive_sync_threads", DEFAULT_MAX_ALIVE_SYNC_THREADS)
        self.messager = Messager()
Esempio n. 8
0
    def __init__(self, auth_url, auth_token, container, local_root_path, *args,
                 **kwargs):
        check_encoding()
        auth_url = utils.to_unicode(auth_url)
        auth_token = utils.to_unicode(auth_token)
        container = utils.to_unicode(container)
        local_root_path = utils.to_unicode(local_root_path)
        self.auth_url = utils.normalize_standard_suffix(auth_url)
        self.auth_token = auth_token
        self.container = utils.normalize_standard_suffix(container)

        self.ignore_ssl = kwargs.get("ignore_ssl", False)
        if self.ignore_ssl:
            https.patch_ignore_ssl()
        elif kwargs.get('ca_certs', None):
            https.patch_with_certs(kwargs['ca_certs'])

        self.endpoint = self._get_pithos_client(auth_url, auth_token,
                                                container)

        container_exists = self.check_container_exists(container)

        home_dir = utils.to_unicode(os.path.expanduser('~'))
        default_settings_path = join_path(home_dir, GLOBAL_SETTINGS_NAME)
        self.settings_path = utils.to_unicode(
            kwargs.get("agkyra_path", default_settings_path))
        self.create_dir(self.settings_path, mode=stat.S_IRWXU)

        self.instances_path = join_path(self.settings_path, INSTANCES_NAME)
        self.create_dir(self.instances_path)

        self.local_root_path = utils.normalize_local_suffix(local_root_path)
        local_root_path_exists = os.path.isdir(self.local_root_path)

        self.cache_name = utils.to_unicode(
            kwargs.get("cache_name", DEFAULT_CACHE_NAME))
        self.cache_path = join_path(self.local_root_path, self.cache_name)

        self.cache_hide_name = utils.to_unicode(
            kwargs.get("cache_hide_name", DEFAULT_CACHE_HIDE_NAME))
        self.cache_hide_path = join_path(self.cache_path, self.cache_hide_name)

        self.cache_stage_name = utils.to_unicode(
            kwargs.get("cache_stage_name", DEFAULT_CACHE_STAGE_NAME))
        self.cache_stage_path = join_path(self.cache_path,
                                          self.cache_stage_name)

        self.cache_fetch_name = utils.to_unicode(
            kwargs.get("cache_fetch_name", DEFAULT_CACHE_FETCH_NAME))
        self.cache_fetch_path = join_path(self.cache_path,
                                          self.cache_fetch_name)

        self.user_id = self.endpoint.account
        self.instance = get_instance([
            self.auth_url, self.user_id, self.container, self.local_root_path
        ])
        self.instance_path = join_path(self.instances_path, self.instance)
        self.create_dir(self.instance_path)

        self.dbname = utils.to_unicode(kwargs.get("dbname", DEFAULT_DBNAME))
        self.full_dbname = join_path(self.instance_path, self.dbname)
        self.syncer_dbtuple = common.DBTuple(dbtype=database.SyncerDB,
                                             dbname=self.full_dbname)

        db_existed = os.path.isfile(self.full_dbname)
        if not db_existed:
            database.initialize(self.syncer_dbtuple)

        self.mtime_lag = 0
        self.case_insensitive = False

        if not db_existed:
            self.set_localfs_enabled(True)
            self.create_local_dirs()
            self.set_pithos_enabled(True)
            if not container_exists:
                self.mk_container(container)
        else:
            if not local_root_path_exists:
                self.set_localfs_enabled(False)
            else:
                self.create_local_dirs()
            if not container_exists:
                self.set_pithos_enabled(False)

        self.heartbeat = ThreadSafeDict()
        self.action_max_wait = kwargs.get("action_max_wait",
                                          DEFAULT_ACTION_MAX_WAIT)
        self.pithos_list_interval = kwargs.get("pithos_list_interval",
                                               DEFAULT_PITHOS_LIST_INTERVAL)

        self.connection_retry_limit = kwargs.get(
            "connection_retry_limit", DEFAULT_CONNECTION_RETRY_LIMIT)
        self.endpoint.CONNECTION_RETRY_LIMIT = self.connection_retry_limit
        self.max_alive_sync_threads = kwargs.get(
            "max_alive_sync_threads", DEFAULT_MAX_ALIVE_SYNC_THREADS)
        self.messager = Messager()