How to use the ltk.constants.CONF_DIR function in ltk

To help you get started, we’ve selected a few ltk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Lingotek / filesystem-connector / ltk / actions.py View on Github external
def _initialize_self(self):
        config_file_name = os.path.join(self.path, CONF_DIR, CONF_FN)
        conf_parser = configparser.ConfigParser()
        conf_parser.read(config_file_name)
        self.host = conf_parser.get('main', 'host')
        self.access_token = conf_parser.get('main', 'access_token')
        self.project_id = conf_parser.get('main', 'project_id')
        self.community_id = conf_parser.get('main', 'community_id')
        self.workflow_id = conf_parser.get('main', 'workflow_id')
        self.locale = conf_parser.get('main', 'default_locale')
        try:
            # todo this try block will stop once one of them gets an exception..
            self.project_name = conf_parser.get('main', 'project_name')
            self.download_dir = conf_parser.get('main', 'download_folder')
            self.watch_dir = conf_parser.get('main', 'watch_folder')
            watch_locales = conf_parser.get('main', 'watch_locales')
            self.watch_locales = set(watch_locales.split(','))
        except configparser.NoOptionError:
github Lingotek / filesystem-connector / python3 / ltk / actions / action_facade.py View on Github external
def _initialize_self(self):
        config_file_name = os.path.join(self.path, CONF_DIR, CONF_FN)
        conf_parser = ConfigParser()
        conf_parser.read(config_file_name)
        self.host = conf_parser.get('main', 'host')
        self.access_token = conf_parser.get('main', 'access_token')
        self.project_id = conf_parser.get('main', 'project_id')
        self.community_id = conf_parser.get('main', 'community_id')
        self.workflow_id = conf_parser.get('main', 'workflow_id')
        self.locale = conf_parser.get('main', 'default_locale')
        self.locale = self.locale.replace('_','-')
        try:
            if conf_parser.has_option('main', 'project_name'):
                self.project_name = conf_parser.get('main', 'project_name')
            if conf_parser.has_option('main', 'download_folder'):
                self.download_dir = conf_parser.get('main', 'download_folder')
            else:
                self.download_dir = None
github Lingotek / filesystem-connector / python3 / ltk / commands.py View on Github external
# if on Windows system, make directory hidden
                if os.name == 'nt':
                    logger.info("On Windows, make .ltk folder hidden")
                    # Python 2
                    # ret = ctypes.windll.kernel32.SetFileAttributesW(unicode(os.path.join(path, CONF_DIR)), HIDDEN_ATTRIBUTE)
                    # End Python 2
                    # Python 3
                    ret = ctypes.windll.kernel32.SetFileAttributesW(os.path.join(path, CONF_DIR), HIDDEN_ATTRIBUTE)
                    # End Python 3
                    if(ret != 1):   # return value of 1 signifies success
                        pass
            except IOError as e:
                print(e.errno)
                print(e)

            file_handler = logging.FileHandler(os.path.join(path, CONF_DIR, LOG_FN))

    console_handler = logging.StreamHandler(sys.stdout)
    file_handler.setLevel(API_LOG_LEVEL)
    file_handler.setFormatter(logging.Formatter('%(asctime)s  %(levelname)s: %(message)s'))
    if quiet:
        console_handler.setLevel(logging.WARNING)
    elif verbosity:
        if verbosity > 1:
            console_handler.setLevel(API_RESPONSE_LOG_LEVEL)
        else:
            console_handler.setLevel(API_LOG_LEVEL)
    else:
        console_handler.setLevel(logging.INFO)
    custom_formatter = CustomFormatter()
    console_handler.setFormatter(custom_formatter)
    logger.addHandler(file_handler)
github Lingotek / filesystem-connector / python2 / ltk / commands.py View on Github external
def init_logger(path):
    """
    Initializes logger based on path
    """
    logger.setLevel(logging.DEBUG)
    if not path:
        file_handler = logging.FileHandler(LOG_FN)
    else:
        try:
            file_handler = logging.FileHandler(os.path.join(path, CONF_DIR, LOG_FN))

            # if on Windows system, set directory properties to hidden
            if os.name == 'nt':
                try:
                    subprocess.call(["attrib", "+H", os.path.join(path, CONF_DIR)])
                except Exception as e:
                    logger.error("Error on init: "+str(e))
                # logger.info("On Windows, make .ltk folder hidden")
                # # Python 2
                ret = ctypes.windll.kernel32.SetFileAttributesW(unicode(os.path.join(path, CONF_DIR)), HIDDEN_ATTRIBUTE)
                # # End Python 2
                # # Python 3
#                 # ret = ctypes.windll.kernel32.SetFileAttributesW(os.path.join(path, CONF_DIR), HIDDEN_ATTRIBUTE)
                # # End Python 3
                # if(ret != 1):   # return value of 1 signifies success
                #     pass
github Lingotek / filesystem-connector / python2 / ltk / actions / action.py View on Github external
def is_initialized(project_path):
    ltk_path = os.path.join(project_path, CONF_DIR)
    if os.path.isdir(ltk_path) and os.path.isfile(os.path.join(ltk_path, CONF_FN)) and \
            os.stat(os.path.join(ltk_path, CONF_FN)).st_size:
        return True
    return False
github Lingotek / filesystem-connector / python3 / ltk / actions / action.py View on Github external
self.watch_locales = set()  # if specified, add these target locales to any files in the watch folder
        self.git_autocommit = None
        self.git_username = ''
        self.git_password = ''
        self.append_option = 'none'
        self.locale_folders = {}
        if not self._is_initialized():
            raise exceptions.UninitializedError("This project is not initialized. Please run init command.")
        self._initialize_self()
        self.watch = watch
        self.doc_manager = DocumentManager(self.path)
        self.folder_manager = FolderManager(self.path)
        self.timeout = timeout
        self.api = ApiCalls(self.host, self.access_token, self.watch, self.timeout)
        self.git_auto = Git_Auto(self.path)
        self.error_file_name = os.path.join(self.path, CONF_DIR, ERROR_FN)
github Lingotek / filesystem-connector / python3 / ltk / commands.py View on Github external
def init_logger(path):
    """
    Initializes logger based on path
    """
    logger.setLevel(logging.DEBUG)
    if not path:
        file_handler = logging.FileHandler(LOG_FN)
    else:
        try:
            file_handler = logging.FileHandler(os.path.join(path, CONF_DIR, LOG_FN))

            # if on Windows system, set directory properties to hidden
            if os.name == 'nt':
                try:
                    subprocess.call(["attrib", "+H", os.path.join(path, CONF_DIR)])
                except Exception as e:
                    logger.error("Error on init: "+str(e))
                # logger.info("On Windows, make .ltk folder hidden")
                # # Python 2
                # # ret = ctypes.windll.kernel32.SetFileAttributesW(unicode(os.path.join(path, CONF_DIR)), HIDDEN_ATTRIBUTE)
                # # End Python 2
                # # Python 3
                # ret = ctypes.windll.kernel32.SetFileAttributesW(os.path.join(path, CONF_DIR), HIDDEN_ATTRIBUTE)
                # # End Python 3
                # if(ret != 1):   # return value of 1 signifies success
                #     pass
github Lingotek / filesystem-connector / python2 / ltk / commands.py View on Github external
# if on Windows system, make directory hidden
                if os.name == 'nt':
                    logger.info("On Windows, make .ltk folder hidden")
                    # Python 2
                    ret = ctypes.windll.kernel32.SetFileAttributesW(unicode(os.path.join(path, CONF_DIR)), HIDDEN_ATTRIBUTE)
                    # End Python 2
                    # Python 3
#                     ret = ctypes.windll.kernel32.SetFileAttributesW(os.path.join(path, CONF_DIR), HIDDEN_ATTRIBUTE)
                    # End Python 3
                    if(ret != 1):   # return value of 1 signifies success
                        pass
            except IOError as e:
                print(e.errno)
                print(e)

            file_handler = logging.FileHandler(os.path.join(path, CONF_DIR, LOG_FN))

    console_handler = logging.StreamHandler(sys.stdout)
    file_handler.setLevel(API_LOG_LEVEL)
    file_handler.setFormatter(logging.Formatter('%(asctime)s  %(levelname)s: %(message)s'))
    if quiet:
        console_handler.setLevel(logging.WARNING)
    elif verbosity:
        if verbosity > 1:
            console_handler.setLevel(API_RESPONSE_LOG_LEVEL)
        else:
            console_handler.setLevel(API_LOG_LEVEL)
    else:
        console_handler.setLevel(logging.INFO)
    custom_formatter = CustomFormatter()
    console_handler.setFormatter(custom_formatter)
    logger.addHandler(file_handler)
github Lingotek / filesystem-connector / python3 / ltk / actions / action.py View on Github external
def is_initialized(project_path):
    ltk_path = os.path.join(project_path, CONF_DIR)
    if os.path.isdir(ltk_path) and os.path.isfile(os.path.join(ltk_path, CONF_FN)) and \
            os.stat(os.path.join(ltk_path, CONF_FN)).st_size:
        return True
    return False
github Lingotek / filesystem-connector / python3 / ltk / actions / action_facade.py View on Github external
def init_config_file(self):
        config_file_name = os.path.join(self.path, CONF_DIR, CONF_FN)
        conf_parser = ConfigParser()
        conf_parser.read(config_file_name)
        return config_file_name, conf_parser