Esempio n. 1
0
 def __init__(self, application, path, retag_mode, verbose):
     QtCore.QObject.__init__(self)
     
     self.LOG_LEVEL = logging.INFO
     if verbose:
         self.LOG_LEVEL = logging.DEBUG
     
     self.__log = LogHelper.get_app_logger(self.LOG_LEVEL)
     
     ## create a config object to get the registered store paths
     self.__main_config = ConfigWrapper(TsConstants.CONFIG_PATH)
     
     if self.__main_config is None:
         self.__log.info("No config file found for the given path")
         self.__handle_retag_error()
     else:
         self.__store_path = PathHelper.resolve_store_path(path, self.__main_config.get_store_path_list())
     
     self.__item_name = PathHelper.get_item_name_from_path(path)
     
     ## create the object
     self.__retag_widget = ReTagController(application, self.__store_path, self.__item_name, True, verbose_mode)
     ## connect to the signal(s)
     self.connect(self.__retag_widget, QtCore.SIGNAL("retag_cancel"), self.__handle_retag_cancel)
     self.connect(self.__retag_widget, QtCore.SIGNAL("retag_error"), self.__handle_retag_error)
     self.connect(self.__retag_widget, QtCore.SIGNAL("retag_success"), self.__handle_retag_success)
     ## start the retagging
     self.__retag_widget.start()
Esempio n. 2
0
    def resolve_store_path(path_to_be_resolved, store_path_list):
        """
        provide a absolute or an relative path to an item.
        this method returns the path to the containing store
        
        a list with all configured stores must be passed in order to identify the appropriate store
        
        RETURNS found resolved store_path
        
        RETURNS NONE if there is no appropriate store configured for the given path
        """
        LOG = LogHelper.get_app_logger(logging.INFO)
        
        if path_to_be_resolved is None or path_to_be_resolved == "":
            LOG.error("there is no path given")
            return None
        if store_path_list is None or len(store_path_list) == 0:
            LOG.error("there is no store list given")
            return None
            
        absolute_path = os.path.abspath(path_to_be_resolved)
        
        for store_path in store_path_list:
            store_path = os.path.abspath(store_path)
            if absolute_path.find(store_path) > -1:
                return store_path
        
        return None 

## end     
Esempio n. 3
0
    def __init__(self, application, path, retag_mode, verbose):
        QtCore.QObject.__init__(self)

        self.LOG_LEVEL = logging.INFO
        if verbose:
            self.LOG_LEVEL = logging.DEBUG

        self.__log = LogHelper.get_app_logger(self.LOG_LEVEL)

        ## create a config object to get the registered store paths
        self.__main_config = ConfigWrapper(TsConstants.CONFIG_PATH)

        if self.__main_config is None:
            self.__log.info("No config file found for the given path")
            self.__handle_retag_error()
        else:
            self.__store_path = PathHelper.resolve_store_path(path, self.__main_config.get_store_path_list())

        self.__item_name = PathHelper.get_item_name_from_path(path)

        ## create the object
        self.__retag_widget = ReTagController(application, self.__store_path, self.__item_name, True, verbose_mode)
        ## connect to the signal(s)
        self.connect(self.__retag_widget, QtCore.SIGNAL("retag_cancel"), self.__handle_retag_cancel)
        self.connect(self.__retag_widget, QtCore.SIGNAL("retag_error"), self.__handle_retag_error)
        self.connect(self.__retag_widget, QtCore.SIGNAL("retag_success"), self.__handle_retag_success)
        ## start the retagging
        self.__retag_widget.start()
Esempio n. 4
0
    def __init__(self, application, source_store, target_store, auto_sync,
                 verbose):
        QtCore.QObject.__init__(self)

        self.LOG_LEVEL = logging.INFO
        if verbose:
            self.LOG_LEVEL = logging.DEBUG

        self.__log = LogHelper.get_app_logger(self.LOG_LEVEL)

        ## create a config object to get the registered store paths
        self.__main_config = ConfigWrapper(TsConstants.CONFIG_PATH)

        ## create the object
        self.__sync_widget = SyncController(application, source_store,
                                            target_store, auto_sync,
                                            verbose_mode)

        ## connect to the signal(s)
        self.connect(self.__sync_widget, QtCore.SIGNAL("sync_cancel"),
                     self.__handle_sync_cancel)
        self.connect(self.__sync_widget, QtCore.SIGNAL("sync_error"),
                     self.__handle_sync_error)
        self.connect(self.__sync_widget, QtCore.SIGNAL("sync_success"),
                     self.__handle_sync_success)

        ## start the sync controller
        self.__sync_widget.start()
Esempio n. 5
0
    def __init__(self, application, store_path, item_name, retag_mode=True, verbose=False):
        QtCore.QObject.__init__(self)

        self.__log = None
        self.__main_config = None
        self.__store_config = None
        self.__tag_dialog = None
        self.__store = None

        self.__retag_mode = retag_mode

        self.__no_store_found = False

        self.__item_name = unicode(item_name)
        self.__store_path = store_path

        # the main application which has the translator installed
        self.__application = application

        self.LOG_LEVEL = logging.INFO
        if verbose:
            self.LOG_LEVEL = logging.DEBUG

        self.STORE_CONFIG_DIR = TsConstants.DEFAULT_STORE_CONFIG_DIR
        self.STORE_CONFIG_FILE_NAME = TsConstants.DEFAULT_STORE_CONFIG_FILENAME
        self.STORE_TAGS_FILE_NAME = TsConstants.DEFAULT_STORE_TAGS_FILENAME
        self.STORE_VOCABULARY_FILE_NAME = TsConstants.DEFAULT_STORE_VOCABULARY_FILENAME

        locale = unicode(QtCore.QLocale.system().name())[0:2]
        self.__translator = QtCore.QTranslator()
        if self.__translator.load("ts_" + locale + ".qm", "tsresources/"):
            self.__application.installTranslator(self.__translator)

        # get dir names for all available languages
        self.CURRENT_LANGUAGE = self.trUtf8("en")
        self.STORE_STORAGE_DIRS = []
        self.STORE_DESCRIBING_NAV_DIRS = []
        self.STORE_CATEGORIZING_NAV_DIRS = []
        self.STORE_EXPIRED_DIRS = []
        self.STORE_NAVIGATION_DIRS = []
        self.SUPPORTED_LANGUAGES = TsConstants.DEFAULT_SUPPORTED_LANGUAGES
        self.MAX_CLOUD_TAGS = TsConstants.DEFAULT_MAX_CLOUD_TAGS
        self.__store_dict = {}

        for lang in self.SUPPORTED_LANGUAGES:
            self.change_language(lang)
            self.STORE_NAVIGATION_DIRS.append(self.trUtf8("navigation"))
            self.STORE_STORAGE_DIRS.append(self.trUtf8("storage"))  # self.STORE_STORAGE_DIR_EN))
            self.STORE_DESCRIBING_NAV_DIRS.append(
                self.trUtf8("descriptions")
            )  # self.STORE_DESCRIBING_NAVIGATION_DIR_EN))
            self.STORE_CATEGORIZING_NAV_DIRS.append(
                self.trUtf8("categories")
            )  # self.STORE_CATEGORIZING_NAVIGATION_DIR_EN))
            self.STORE_EXPIRED_DIRS.append(self.trUtf8("expired_items"))  # STORE_EXPIRED_DIR_EN))
        ## reset language
        self.change_language(self.CURRENT_LANGUAGE)

        self.__log = LogHelper.get_app_logger(self.LOG_LEVEL)
Esempio n. 6
0
    def __init__(self, application, store_path, item_name, retag_mode = True, verbose = False):
        QtCore.QObject.__init__(self)
        
        self.__log = None
        self.__main_config = None
        self.__store_config = None
        self.__tag_dialog = None
        self.__store = None
        
        self.__retag_mode = retag_mode
        
        self.__no_store_found = False

        self.__item_name = unicode(item_name)
        self.__store_path = store_path

        # the main application which has the translator installed
        self.__application = application

        self.LOG_LEVEL = logging.INFO
        if verbose:
            self.LOG_LEVEL = logging.DEBUG
            

        self.STORE_CONFIG_DIR = TsConstants.DEFAULT_STORE_CONFIG_DIR
        self.STORE_CONFIG_FILE_NAME = TsConstants.DEFAULT_STORE_CONFIG_FILENAME
        self.STORE_TAGS_FILE_NAME = TsConstants.DEFAULT_STORE_TAGS_FILENAME
        self.STORE_VOCABULARY_FILE_NAME = TsConstants.DEFAULT_STORE_VOCABULARY_FILENAME
        
        locale = unicode(QtCore.QLocale.system().name())[0:2]
        self.__translator = QtCore.QTranslator()
        if self.__translator.load("ts_" + locale + ".qm", "tsresources/"):
            self.__application.installTranslator(self.__translator)

        #get dir names for all available languages
        self.CURRENT_LANGUAGE = self.trUtf8("en")
        self.STORE_STORAGE_DIRS = []
        self.STORE_DESCRIBING_NAV_DIRS = []
        self.STORE_CATEGORIZING_NAV_DIRS = []
        self.STORE_EXPIRED_DIRS = []
        self.STORE_NAVIGATION_DIRS = []
        self.SUPPORTED_LANGUAGES = TsConstants.DEFAULT_SUPPORTED_LANGUAGES
        self.MAX_CLOUD_TAGS = TsConstants.DEFAULT_MAX_CLOUD_TAGS
        self.__store_dict = {}
        
        for lang in self.SUPPORTED_LANGUAGES: 
            self.change_language(lang)
            self.STORE_NAVIGATION_DIRS.append(self.trUtf8("navigation")) 
            self.STORE_STORAGE_DIRS.append(self.trUtf8("storage"))#self.STORE_STORAGE_DIR_EN))  
            self.STORE_DESCRIBING_NAV_DIRS.append(self.trUtf8("descriptions"))#self.STORE_DESCRIBING_NAVIGATION_DIR_EN))  
            self.STORE_CATEGORIZING_NAV_DIRS.append(self.trUtf8("categories"))#self.STORE_CATEGORIZING_NAVIGATION_DIR_EN)) 
            self.STORE_EXPIRED_DIRS.append(self.trUtf8("expired_items"))#STORE_EXPIRED_DIR_EN)) 
        ## reset language 
        self.change_language(self.CURRENT_LANGUAGE)
        
        self.__log = LogHelper.get_app_logger(self.LOG_LEVEL)
Esempio n. 7
0
    def __init__(self, application, verbose):
        QtCore.QObject.__init__(self)

        self.__log = None
        self.__main_config = None
        self.__admin_dialog = None
        self.__retag_dialog = None
        self.__verbose_mode = verbose
        # the main application which has the translator installed
        self.__application = application

        self.LOG_LEVEL = logging.INFO
        if verbose:
            self.LOG_LEVEL = logging.DEBUG

        self.STORE_CONFIG_DIR = TsConstants.DEFAULT_STORE_CONFIG_DIR
        self.STORE_CONFIG_FILE_NAME = TsConstants.DEFAULT_STORE_CONFIG_FILENAME
        self.STORE_TAGS_FILE_NAME = TsConstants.DEFAULT_STORE_TAGS_FILENAME
        self.STORE_VOCABULARY_FILE_NAME = TsConstants.DEFAULT_STORE_VOCABULARY_FILENAME

        self.__system_locale = unicode(QtCore.QLocale.system().name())[0:2]
        self.__translator = QtCore.QTranslator()
        if self.__translator.load("ts_" + self.__system_locale + ".qm",
                                  "tsresources/"):
            self.__application.installTranslator(self.__translator)
        # "en" is automatically translated to the current language e.g. en -> de
        self.CURRENT_LANGUAGE = self.__get_locale_language()
        #dir names for all available languages
        self.STORE_STORAGE_DIRS = []
        self.STORE_DESCRIBING_NAV_DIRS = []
        self.STORE_CATEGORIZING_NAV_DIRS = []
        self.STORE_EXPIRED_DIRS = []
        self.STORE_NAVIGATION_DIRS = []
        self.SUPPORTED_LANGUAGES = TsConstants.DEFAULT_SUPPORTED_LANGUAGES
        self.__store_dict = {}

        # catch all "possible" dir-names
        for lang in self.SUPPORTED_LANGUAGES:
            self.change_language(lang)
            self.STORE_STORAGE_DIRS.append(
                self.trUtf8("storage"))  #self.STORE_STORAGE_DIR_EN))
            self.STORE_DESCRIBING_NAV_DIRS.append(self.trUtf8(
                "descriptions"))  #self.STORE_DESCRIBING_NAVIGATION_DIR_EN))
            self.STORE_CATEGORIZING_NAV_DIRS.append(self.trUtf8(
                "categories"))  #self.STORE_CATEGORIZING_NAVIGATION_DIR_EN))
            self.STORE_EXPIRED_DIRS.append(
                self.trUtf8("expired_items"))  #STORE_EXPIRED_DIR_EN))
            self.STORE_NAVIGATION_DIRS.append(self.trUtf8("navigation"))

        self.__log = LogHelper.get_app_logger(self.LOG_LEVEL)
        self.__init_configuration()
Esempio n. 8
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. 9
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. 10
0
    def __init__(self, application, verbose):
        QtCore.QObject.__init__(self)
        
        self.__log = None
        self.__main_config = None
        self.__admin_dialog = None
        self.__retag_dialog = None
        self.__verbose_mode = verbose
        # the main application which has the translator installed
        self.__application = application

        self.LOG_LEVEL = logging.INFO
        if verbose:
            self.LOG_LEVEL = logging.DEBUG
            

        self.STORE_CONFIG_DIR = TsConstants.DEFAULT_STORE_CONFIG_DIR
        self.STORE_CONFIG_FILE_NAME = TsConstants.DEFAULT_STORE_CONFIG_FILENAME
        self.STORE_TAGS_FILE_NAME = TsConstants.DEFAULT_STORE_TAGS_FILENAME
        self.STORE_VOCABULARY_FILE_NAME = TsConstants.DEFAULT_STORE_VOCABULARY_FILENAME
        
        self.__system_locale = unicode(QtCore.QLocale.system().name())[0:2]
        self.__translator = QtCore.QTranslator()
        if self.__translator.load("ts_" + self.__system_locale + ".qm", "tsresources/"):
            self.__application.installTranslator(self.__translator)
        # "en" is automatically translated to the current language e.g. en -> de
        self.CURRENT_LANGUAGE = self.__get_locale_language()
        #dir names for all available languages
        self.STORE_STORAGE_DIRS = []
        self.STORE_DESCRIBING_NAV_DIRS = []
        self.STORE_CATEGORIZING_NAV_DIRS = []
        self.STORE_EXPIRED_DIRS = []
        self.STORE_NAVIGATION_DIRS = []
        self.SUPPORTED_LANGUAGES = TsConstants.DEFAULT_SUPPORTED_LANGUAGES
        self.__store_dict = {}
        
        # catch all "possible" dir-names
        for lang in self.SUPPORTED_LANGUAGES: 
            self.change_language(lang) 
            self.STORE_STORAGE_DIRS.append(self.trUtf8("storage"))#self.STORE_STORAGE_DIR_EN))  
            self.STORE_DESCRIBING_NAV_DIRS.append(self.trUtf8("descriptions"))#self.STORE_DESCRIBING_NAVIGATION_DIR_EN))  
            self.STORE_CATEGORIZING_NAV_DIRS.append(self.trUtf8("categories"))#self.STORE_CATEGORIZING_NAVIGATION_DIR_EN)) 
            self.STORE_EXPIRED_DIRS.append(self.trUtf8("expired_items"))#STORE_EXPIRED_DIR_EN))
            self.STORE_NAVIGATION_DIRS.append(self.trUtf8("navigation")) 
        
        self.__log = LogHelper.get_app_logger(self.LOG_LEVEL)
        self.__init_configuration()
Esempio n. 11
0
    def get_item_name_from_path(path):
        """
        returns the name of the substring after the most right slash
        """
        LOG = LogHelper.get_app_logger(logging.INFO)

        if path is None or path == "":
            LOG.error("there is no path given")
            return None
        
        item_name = os.path.split(path)[1]
        print item_name
        if item_name is None or item_name == "":
            LOG.error("there is no item name given: %s" % path)
            return None
        
        return item_name
Esempio n. 12
0
    def pid_exists(pid):
        """
        check if the given pid number is an currently running process
        """
        LOG = LogHelper.get_app_logger(logging.INFO)

        if pid != None and pid == "android":
            # android serialization workaround
            return True

        if sys.platform[:3] == "win":

            # check if process exists
            hProc = None
            try:
                hProc = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, int(pid))
            except Exception:
                LOG.info("exception while quering")
                return False
            finally:
                if hProc != None:
                    # close handle the process exist
                    LOG.info("process exists %s handle ", pid)
                    win32api.CloseHandle(hProc)
                    return True
                else:
                    LOG.info("process failed to get handle")
                    return False

        try:
            # the second parameter is the signal code
            # If sig is 0, then no signal is sent, but error checking is still performed.
            # if "os.kill" throws no exception, the process exists
            os.kill(int(pid), 0)
            # if no exception is thrown kill the current process
            return True
        except OSError, e:
            # the process with the provided pid does not exist enymore
            # so an exception is thrown
            # ESRCH means "no such process"
            print errno.ESRCH
            if e.errno == errno.ESRCH:
                return False
            else:
                raise
Esempio n. 13
0
    def pid_exists(pid):
        """
        check if the given pid number is an currently running process
        """
        LOG = LogHelper.get_app_logger(logging.INFO)

        if pid != None and pid == "android":
            # android serialization workaround
            return True

        if sys.platform[:3] == "win":

            # check if process exists
            hProc = None
            try:
                hProc = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, int(pid))
            except Exception:
                LOG.info("exception while quering")
                return False
            finally:
                if hProc != None:
                    # close handle the process exist
                    LOG.info("process exists %s handle ", pid)
                    win32api.CloseHandle(hProc)
                    return True
                else:
                    LOG.info("process failed to get handle")
                    return False
            
        try:
            # the second parameter is the signal code
            # If sig is 0, then no signal is sent, but error checking is still performed.
            # if "os.kill" throws no exception, the process exists
            os.kill(int(pid), 0)
            # if no exception is thrown kill the current process
            return True 
        except OSError, e:
            # the process with the provided pid does not exist enymore
            # so an exception is thrown
            # ESRCH means "no such process"
            print errno.ESRCH 
            if e.errno == errno.ESRCH:
                return False
            else:
                raise
Esempio n. 14
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)
Esempio n. 15
0
 def __init__(self, application, source_store, target_store, auto_sync, verbose):
     QtCore.QObject.__init__(self)
     
     self.LOG_LEVEL = logging.INFO
     if verbose:
         self.LOG_LEVEL = logging.DEBUG
     
     self.__log = LogHelper.get_app_logger(self.LOG_LEVEL)
     
     ## create a config object to get the registered store paths
     self.__main_config = ConfigWrapper(TsConstants.CONFIG_PATH)
     
     ## create the object
     self.__sync_widget = SyncController(application, source_store, target_store, auto_sync, verbose_mode)
     
     ## connect to the signal(s)
     self.connect(self.__sync_widget, QtCore.SIGNAL("sync_cancel"), self.__handle_sync_cancel)
     self.connect(self.__sync_widget, QtCore.SIGNAL("sync_error"), self.__handle_sync_error)
     self.connect(self.__sync_widget, QtCore.SIGNAL("sync_success"), self.__handle_sync_success)
     
     ## start the sync controller
     self.__sync_widget.start()
Esempio n. 16
0
    def __init__(self, application, parent=None, verbose=False, dryrun=False):
        """ 
        initializes the configuration. This method is called every time the config file changes
        """
        
        QtCore.QObject.__init__(self)
        
        self.__application = application
        
        self.__admin_widget = None
        
        self.DRY_RUN = dryrun        
        ## initialize localization
        self.__system_locale = unicode(QtCore.QLocale.system().name())[0:2]
        self.__translator = QtCore.QTranslator()
        if self.__translator.load("ts_" + self.__system_locale + ".qm", "tsresources/"):
            self.__application.installTranslator(self.__translator)
        # "en" is automatically translated to the current language e.g. en -> de
        self.CURRENT_LANGUAGE = self.trUtf8("en")
        self.SUPPORTED_LANGUAGES = TsConstants.DEFAULT_SUPPORTED_LANGUAGES
        
        ## global settings/defaults (only used if reading config file failed or invalid!)
        self.STORE_CONFIG_DIR = TsConstants.DEFAULT_STORE_CONFIG_DIR
        self.STORE_CONFIG_FILE_NAME = TsConstants.DEFAULT_STORE_CONFIG_FILENAME
        self.STORE_TAGS_FILE_NAME = TsConstants.DEFAULT_STORE_TAGS_FILENAME
        self.STORE_VOCABULARY_FILE_NAME = TsConstants.DEFAULT_STORE_VOCABULARY_FILENAME

        #get dir names for all available languages
        store_current_language = self.CURRENT_LANGUAGE 
        self.STORE_STORAGE_DIRS = []
        self.STORE_DESCRIBING_NAV_DIRS = []
        self.STORE_CATEGORIZING_NAV_DIRS = []
        self.STORE_EXPIRED_DIRS = []
        self.STORE_NAVIGATION_DIRS = []

        for lang in self.SUPPORTED_LANGUAGES: 
            self.change_language(lang)
            self.STORE_NAVIGATION_DIRS.append(self.trUtf8("navigation")) 
            self.STORE_STORAGE_DIRS.append(self.trUtf8("storage"))#self.STORE_STORAGE_DIR_EN))  
            self.STORE_DESCRIBING_NAV_DIRS.append(self.trUtf8("descriptions"))#self.STORE_DESCRIBING_NAVIGATION_DIR_EN))  
            self.STORE_CATEGORIZING_NAV_DIRS.append(self.trUtf8("categories"))#self.STORE_CATEGORIZING_NAVIGATION_DIR_EN)) 
            self.STORE_EXPIRED_DIRS.append(self.trUtf8("expired_items"))#STORE_EXPIRED_DIR_EN)) 
        ## reset language 
        self.change_language(store_current_language) 
     
        self.EXPIRY_PREFIX = TsConstants.DEFAULT_EXPIRY_PREFIX
        self.TAG_SEPERATOR = TsConstants.DEFAULT_TAG_SEPARATOR
        self.NUM_RECENT_TAGS = TsConstants.DEFAULT_RECENT_TAGS
        self.NUM_POPULAR_TAGS = TsConstants.DEFAULT_POPULAR_TAGS
        self.MAX_TAGS = TsConstants.DEFAULT_MAX_TAGS
        self.MAX_CLOUD_TAGS = TsConstants.DEFAULT_MAX_CLOUD_TAGS
        self.STORES = []
        ## dict for dialogs identified by their store id
        self.DIALOGS = {}
        
        ## init configurations
        self.__app_config_wrapper = None
        self.__log = None
        
        self.LOG_LEVEL = logging.INFO
        if verbose:
            self.LOG_LEVEL = logging.DEBUG
            
        self.__log = LogHelper.get_app_logger(self.LOG_LEVEL)
        self.__log.info("starting tagstore watcher")
        
        self.__init_configurations()
Esempio n. 17
0
    def __init__(self, application, source_store_path, target_store_path, auto_sync, verbose = False):
        """
        initialize the controller
        """
        QtCore.QObject.__init__(self)
        
        # init components
        self.__application = application
        self.__source_store_path = source_store_path
        self.__target_store_path = target_store_path
        self.__auto_sync = auto_sync

        self.__main_config = None
        self.__store_config = None
        self.__source_store = None
        self.__target_store = None
        self.__sync_dialog = None
        self.__conflict_file_list = None
        self.__source_items = None
        self.__target_items = None
        self.__target_sync_items = None
        
        
        # default values
        self.STORE_CONFIG_DIR = TsConstants.DEFAULT_STORE_CONFIG_DIR
        self.STORE_CONFIG_FILE_NAME = TsConstants.DEFAULT_STORE_CONFIG_FILENAME
        self.STORE_TAGS_FILE_NAME = TsConstants.DEFAULT_STORE_TAGS_FILENAME
        self.STORE_VOCABULARY_FILE_NAME = TsConstants.DEFAULT_STORE_VOCABULARY_FILENAME
        self.STORE_SYNC_FILE_NAME = TsConstants.DEFAULT_STORE_SYNC_TAGS_FILENAME
        
        # load translators
        locale = unicode(QtCore.QLocale.system().name())[0:2]
        self.__translator = QtCore.QTranslator()
        if self.__translator.load("ts_" + locale + ".qm", "tsresources/"):
            self.__application.installTranslator(self.__translator)

        #get dir names for all available languages
        self.CURRENT_LANGUAGE = self.trUtf8("en")
        self.STORE_STORAGE_DIRS = []
        self.STORE_DESCRIBING_NAV_DIRS = []
        self.STORE_CATEGORIZING_NAV_DIRS = []
        self.STORE_EXPIRED_DIRS = []
        self.STORE_NAVIGATION_DIRS = []
        self.SUPPORTED_LANGUAGES = TsConstants.DEFAULT_SUPPORTED_LANGUAGES
        self.__store_dict = {}
        
        for lang in self.SUPPORTED_LANGUAGES: 
            self.change_language(lang)
            self.STORE_NAVIGATION_DIRS.append(self.trUtf8("navigation")) 
            self.STORE_STORAGE_DIRS.append(self.trUtf8("storage"))#self.STORE_STORAGE_DIR_EN))  
            self.STORE_DESCRIBING_NAV_DIRS.append(self.trUtf8("descriptions"))#self.STORE_DESCRIBING_NAVIGATION_DIR_EN))  
            self.STORE_CATEGORIZING_NAV_DIRS.append(self.trUtf8("categories"))#self.STORE_CATEGORIZING_NAVIGATION_DIR_EN)) 
            self.STORE_EXPIRED_DIRS.append(self.trUtf8("expired_items"))#STORE_EXPIRED_DIR_EN)) 
            
        ## reset language 
        self.change_language(self.CURRENT_LANGUAGE)
            
        # init logger component
        self.LOG_LEVEL = logging.INFO
        if verbose:
            self.LOG_LEVEL = logging.DEBUG 
        
        # get logger
        self.__log = LogHelper.get_app_logger(self.LOG_LEVEL)
Esempio n. 18
0
    def __init__(self,
                 application,
                 source_store_path,
                 target_store_path,
                 auto_sync,
                 verbose=False):
        """
        initialize the controller
        """
        QtCore.QObject.__init__(self)

        # init components
        self.__application = application
        self.__source_store_path = source_store_path
        self.__target_store_path = target_store_path
        self.__auto_sync = auto_sync

        self.__main_config = None
        self.__store_config = None
        self.__source_store = None
        self.__target_store = None
        self.__sync_dialog = None
        self.__conflict_file_list = None
        self.__source_items = None
        self.__target_items = None
        self.__target_sync_items = None

        # default values
        self.STORE_CONFIG_DIR = TsConstants.DEFAULT_STORE_CONFIG_DIR
        self.STORE_CONFIG_FILE_NAME = TsConstants.DEFAULT_STORE_CONFIG_FILENAME
        self.STORE_TAGS_FILE_NAME = TsConstants.DEFAULT_STORE_TAGS_FILENAME
        self.STORE_VOCABULARY_FILE_NAME = TsConstants.DEFAULT_STORE_VOCABULARY_FILENAME
        self.STORE_SYNC_FILE_NAME = TsConstants.DEFAULT_STORE_SYNC_TAGS_FILENAME

        # load translators
        locale = unicode(QtCore.QLocale.system().name())[0:2]
        self.__translator = QtCore.QTranslator()
        if self.__translator.load("ts_" + locale + ".qm", "tsresources/"):
            self.__application.installTranslator(self.__translator)

        #get dir names for all available languages
        self.CURRENT_LANGUAGE = self.trUtf8("en")
        self.STORE_STORAGE_DIRS = []
        self.STORE_DESCRIBING_NAV_DIRS = []
        self.STORE_CATEGORIZING_NAV_DIRS = []
        self.STORE_EXPIRED_DIRS = []
        self.STORE_NAVIGATION_DIRS = []
        self.SUPPORTED_LANGUAGES = TsConstants.DEFAULT_SUPPORTED_LANGUAGES
        self.__store_dict = {}

        for lang in self.SUPPORTED_LANGUAGES:
            self.change_language(lang)
            self.STORE_NAVIGATION_DIRS.append(self.trUtf8("navigation"))
            self.STORE_STORAGE_DIRS.append(
                self.trUtf8("storage"))  #self.STORE_STORAGE_DIR_EN))
            self.STORE_DESCRIBING_NAV_DIRS.append(self.trUtf8(
                "descriptions"))  #self.STORE_DESCRIBING_NAVIGATION_DIR_EN))
            self.STORE_CATEGORIZING_NAV_DIRS.append(self.trUtf8(
                "categories"))  #self.STORE_CATEGORIZING_NAVIGATION_DIR_EN))
            self.STORE_EXPIRED_DIRS.append(
                self.trUtf8("expired_items"))  #STORE_EXPIRED_DIR_EN))

        ## reset language
        self.change_language(self.CURRENT_LANGUAGE)

        # init logger component
        self.LOG_LEVEL = logging.INFO
        if verbose:
            self.LOG_LEVEL = logging.DEBUG

        # get logger
        self.__log = LogHelper.get_app_logger(self.LOG_LEVEL)