How to use the ltk.actions.Action 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 / tests / test_actions / test_init.py View on Github external
def test_init_api(self):
        create_config()
        action = actions.Action(os.getcwd())
        assert action.api
        action.close()
        cleanup()
github Lingotek / filesystem-connector / tests / test_actions / test_init.py View on Github external
def test_init_doc_manager(self):
        create_config()
        action = actions.Action(os.getcwd())
        assert action.doc_manager
        action.close()
        cleanup()
github Lingotek / filesystem-connector / tests / test_actions / test_init.py View on Github external
def test_init_host(self):
        create_config()
        action = actions.Action(os.getcwd())
        print (action.host)
        action.close()
        cleanup()
github Lingotek / filesystem-connector / ltk / commands.py View on Github external
def request(doc_name, locales, to_delete, due_date, workflow):
    """ Add targets to document(s) to start translation; defaults to the entire project. Use ltk list -l to see possible locales """
    try:
        action = actions.Action(os.getcwd())
        init_logger(action.path)
        action.target_action(doc_name, locales, to_delete, due_date, workflow)
    except (UninitializedError, ResourceNotFound, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
github Lingotek / filesystem-connector / ltk / commands.py View on Github external
def add(file_names, **kwargs):
    """ Adds content. Could be one or more files specified by a Unix shell pattern """
    try:
        action = actions.Action(os.getcwd())
        init_logger(action.path)
        action.add_action(file_names, **kwargs)
    except (UninitializedError, RequestFailedError, ResourceNotFound, AlreadyExistsError) as e:
        print_log(e)
        logger.error(e)
        return
github Lingotek / filesystem-connector / ltk / commands.py View on Github external
def push():
    """ Sends updated content to Lingotek for documents that have been added """
    try:
        action = actions.Action(os.getcwd())
        init_logger(action.path)
        action.push_action()
    except UninitializedError as e:
        print_log(e)
        logger.error(e)
        return
github Lingotek / filesystem-connector / ltk / commands.py View on Github external
def status(**kwargs):
    """ Gets the status of a specific document or all documents """
    try:
        action = actions.Action(os.getcwd())
        init_logger(action.path)
        action.status_action(**kwargs)
    except (UninitializedError, ResourceNotFound) as e:
        print_log(e)
        logger.error(e)
        return
github Lingotek / filesystem-connector / ltk / commands.py View on Github external
def list_ids(id_type):
    """ Shows docs, workflows, locales, or formats """
    try:
        action = actions.Action(os.getcwd())
        init_logger(action.path)
        if id_type == 'workflow':
            action.list_workflow_action()
        elif id_type == 'locale':
            action.list_locale_action()
        elif id_type == 'format':
            action.list_format_action()
        elif id_type == 'filter':
            action.list_filter_action()
        elif id_type == 'remote':
            action.list_remote_action()
        else:
            action.list_ids_action()

    except (UninitializedError, RequestFailedError) as e:
        print_log(e)
github Lingotek / filesystem-connector / ltk / watch.py View on Github external
def is_hidden_file(file_path):
    # todo more robust checking for OSX files that doesn't start with '.'
    name = os.path.basename(os.path.abspath(file_path))
    return name and (name.startswith('.') or has_hidden_attribute(file_path) or name == "4913")

def has_hidden_attribute(file_path):
    """ Detects if a file has hidden attributes """
    try:
        attrs = ctypes.windll.kernel32.GetFileAttributesW(unicode(file_path))
        assert attrs != -1
        result = bool(attrs & 2)
    except (AttributeError, AssertionError):
        result = False
    return result

class WatchAction(Action):
    # def __init__(self, path, remote=False):
    def __init__(self, path):
        Action.__init__(self, path)
        self.observer = Observer()  # watchdog observer that will watch the files
        self.handler = WatchHandler()
        self.handler.on_modified = self._on_modified
        self.handler.on_created = self._on_created
        self.handler.on_moved = self._on_moved
        self.watch_queue = []  # not much slower than deque unless expecting 100+ items
        self.locale_delimiter = None
        self.ignore_ext = []  # file types to ignore as specified by the user
        self.detected_locales = {}  # dict to keep track of detected locales
        # if remote:  # poll lingotek cloud periodically if this option enabled
        # self.remote_thread = threading.Thread(target=self.poll_remote(), args=())
        # self.remote_thread.daemon = True
        # self.remote_thread.start()
github Lingotek / filesystem-connector / ltk / watch.py View on Github external
def __init__(self, path):
        Action.__init__(self, path)
        self.observer = Observer()  # watchdog observer that will watch the files
        self.handler = WatchHandler()
        self.handler.on_modified = self._on_modified
        self.handler.on_created = self._on_created
        self.handler.on_moved = self._on_moved
        self.watch_queue = []  # not much slower than deque unless expecting 100+ items
        self.locale_delimiter = None
        self.ignore_ext = []  # file types to ignore as specified by the user
        self.detected_locales = {}  # dict to keep track of detected locales
        # if remote:  # poll lingotek cloud periodically if this option enabled