Esempio n. 1
0
 def __init__(self, file_path):#, store_id=None):
     """
     constructor
     """
     path_list = str(file_path).split("/")[:-2]
     logging_path = unicode("/").join(path_list)
     self.__log = LogHelper.get_store_logger(logging_path, logging.INFO)
     
     #if store_id is not None:
     #    self.__create_file_structure(file_path, store_id)
     self.__settings = QSettings(file_path, QSettings.IniFormat)
     self.__settings.setIniCodec(TsConstants.DEFAULT_ENCODING)
     if self.__settings.iniCodec() is None:
         self.__log.info("no such encoding: " + TsConstants.DEFAULT_ENCODING)
     self.__path = file_path
Esempio n. 2
0
    def __init__(self, file_path):  #, store_id=None):
        """
        constructor
        """
        path_list = str(file_path).split("/")[:-2]
        logging_path = unicode("/").join(path_list)
        self.__log = LogHelper.get_store_logger(logging_path, logging.INFO)

        #if store_id is not None:
        #    self.__create_file_structure(file_path, store_id)
        self.__settings = QSettings(file_path, QSettings.IniFormat)
        self.__settings.setIniCodec(TsConstants.DEFAULT_ENCODING)
        if self.__settings.iniCodec() is None:
            self.__log.info("no such encoding: " +
                            TsConstants.DEFAULT_ENCODING)
        self.__path = file_path
Esempio n. 3
0
    def __init_store(self):
        """
        initializes the store paths, config reader, file system watcher without instantiation of a new object
        """
        self.__name = self.__path.split("/")[-1]
        self.__parent_path = self.__path[:len(self.__path)-len(self.__name)]
        self.__tags_file_path = self.__path + "/" + self.__tags_file_name
        self.__sync_tags_file_path = self.__path + "/" + TsConstants.DEFAULT_STORE_CONFIG_DIR + "/" + self.__sync_tags_file_name
        self.__config_path = self.__path + "/" + self.__config_file_name
        self.__vocabulary_path = self.__path + "/" + self.__vocabulary_file_name #TsConstants.STORE_CONFIG_DIR + "/" + TsConstants.STORE_VOCABULARY_FILENAME
        self.__watcher_path = self.__path + "/" + self.__storage_dir_name
        self.__navigation_path = self.__path + "/" + self.__navigation_dir_name
        self.__describing_nav_path = self.__path + "/" + self.__describing_nav_dir_name
        self.__categorising_nav_path = self.__path + "/" + self.__categorising_nav_dir_name
        config_file_name = unicode(self.__config_path.split("/")[-1])
        self.__temp_progress_path = unicode(self.__config_path[:len(self.__config_path)-len(config_file_name)-1])
        
        self.__tag_wrapper = TagWrapper(self.__tags_file_path)
        self.__sync_tag_wrapper = TagWrapper(self.__sync_tags_file_path)
        
        ## update store id to avoid inconsistency
        config_wrapper = ConfigWrapper(self.__path + "/" + self.__config_file_name)#self.__tags_file_name)
        config_wrapper.set_store_id(self.__id)
        self.__vocabulary_wrapper = VocabularyWrapper(self.__vocabulary_path)
        self.connect(self.__vocabulary_wrapper, QtCore.SIGNAL("changed"), self.__handle_vocabulary_changed)
        self.__store_config_wrapper = ConfigWrapper(self.__config_path)
        self.connect(self.__store_config_wrapper, QtCore.SIGNAL("changed()"), self.__handle_store_config_changed)
        
        if len(self.__name) == 0:
            self.__name = self.__path[:self.__path.rfind("/")]
        
        if not self.__is_android_store():
            # no activity is required on android tag stores
            self.__watcher.addPath(self.__parent_path)
            self.__watcher.addPath(self.__watcher_path)
        
        ## all necessary files and dirs should have been created now - so init the logger
        self.__log = LogHelper.get_store_logger(self.__path, logging.INFO) 
        self.__log.info("parent_path: '%s'" % self.__name)

        ## handle offline changes
        self.__handle_unfinished_operation()
        self.__handle_file_expiry()
        self.__handle_file_changes(self.__watcher_path)