Ejemplo n.º 1
0
def request(doc_name, path, locales, to_delete, due_date, workflow):
    """ Add targets to document(s) to start translation; defaults to the entire project. If no locales are specified, Filesystem Connector
        will look for target watch locales set in ltk config. Use ltk list -l to see possible locales. """
    try:
        action = actions.Action(os.getcwd())
        init_logger(action.path)
        if locales and isinstance(locales,str):
            locales = [locales]

        doc_name = remove_powershell_formatting(doc_name)
        path = remove_powershell_formatting(path)

        action.target_action(doc_name, path, locales, to_delete, due_date, workflow)
    except (UninitializedError, ResourceNotFound, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
Ejemplo n.º 2
0
def request(doc_name, path, locales, to_cancel, to_delete, due_date, workflow):
    """ Add targets to document(s) to start translation; defaults to the entire project. If no locales are specified, Filesystem Connector
        will look for target watch locales set in ltk config. Use ltk list -l to see possible locales. """
    try:
        action = request_action.RequestAction(os.getcwd(), doc_name, path, locales, to_cancel, to_delete, due_date, workflow)
        init_logger(action.path)
        if locales and isinstance(locales,str):
            locales = [locales]

        doc_name = remove_powershell_formatting(doc_name)
        path = remove_powershell_formatting(path)

        action.target_action()
    except (UninitializedError, ResourceNotFound, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
Ejemplo n.º 3
0
def add(file_names, **kwargs):
    """ Add files and folders for upload to Lingotek.  Fileglobs (e.g. *.txt) can be used to add all matching files and/or folders. Added folders will automatically add the new files added or created inside of them.  """
    try:
        action = actions.Action(os.getcwd())
        init_logger(action.path)

        file_names = remove_powershell_formatting(file_names)

        for f in kwargs:
            if kwargs[f]:
                temp = remove_powershell_formatting(kwargs[f])
                kwargs[f] = temp

        action.add_action(file_names, **kwargs)
    except (UninitializedError, RequestFailedError, ResourceNotFound, AlreadyExistsError) as e:
        print_log(e)
        logger.error(e)
        return
Ejemplo n.º 4
0
def mv(source_path, destination_path):
    """
    Moves specified local doc to a specified destination directory, moving both the file itself and file location stores in the local database.
    If SOURCE_PATH is a directory, all added files in the directory will be moved.
    """
    try:
        # action = actions.Action(os.getcwd())
        action = ImportAction(os.getcwd())
        init_logger(action.path)

        source_path = remove_powershell_formatting(source_path)
        print("Source path " + str(source_path))
        destination_path = remove_powershell_formatting(destination_path)
        print("Destination path "+str(destination_path))

        action.mv_action(source_path, destination_path)
    except(UninitializedError, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
Ejemplo n.º 5
0
def mv(source_path, destination_path):
    """
    Moves specified local doc to a specified destination directory, moving both the file itself and file location stored in the local database.
    If SOURCE_PATH is a directory, all added files in the directory will be moved.
    """
    try:
        # action = actions.Action(os.getcwd())
        add = add_action.AddAction(os.getcwd())
        action = move_action.MoveAction(add, os.getcwd())
        init_logger(action.path)

        source_path = remove_powershell_formatting(source_path)
        #print("Source path " + str(source_path))
        destination_path = remove_powershell_formatting(destination_path)
        #print("Destination path "+str(destination_path))

        action.mv_action(source_path, destination_path)
    except(UninitializedError, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
Ejemplo n.º 6
0
def add(file_names, **kwargs):
    #""" Add files and folders for upload to Lingotek.  Fileglobs (e.g. *.txt) can be used to add all matching files and/or folders. Added folders will automatically add the new files added or created inside of them. """
    """ Add files and folders for upload to Lingotek.  Fileglobs (e.g. *.txt) can be used to add all matching files and/or folders. Added folders will automatically add the new files added or created inside of them.
    
    Metadata can be added by launching the metadata wizard with the -m flag or by using flags for specific metadata.  The metadata flags are --author_email, --author_name, --business_division, --business_unit, --campaign_id, --campaign_rating, --channel, --contact_email, --contact_name, --content_description, --content_type, --domain, --external_application_id, --external_document_id, --external_style_id, --job_id, --purchase_order, --reference_url, --region, --require_review, --category_id, and --note """
    try:
        action = add_action.AddAction(os.getcwd())
        init_logger(action.path)

        file_names = remove_powershell_formatting(file_names)

        for f in kwargs:
            if kwargs[f]:
                temp = remove_powershell_formatting(kwargs[f])
                kwargs[f] = temp

        action.add_action(file_names, **kwargs)
    except (UninitializedError, RequestFailedError, ResourceNotFound, AlreadyExistsError) as e:
        print_log(e)
        logger.error(e)
        return
Ejemplo n.º 7
0
def config(**kwargs):
    """ View or change local configuration """
    try:
        action = actions.Action(os.getcwd())
        init_logger(action.path)
        for f in kwargs:
            if kwargs[f]:
                temp = remove_powershell_formatting(kwargs[f])
                kwargs[f] = temp
        action.config_action(**kwargs)
    except (UninitializedError, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
Ejemplo n.º 8
0
def config(**kwargs):
    """ View or change local configuration """
    try:
        action = config_action.ConfigAction(os.getcwd())
        init_logger(action.path)
        for f in kwargs:
            if kwargs[f]:
                temp = remove_powershell_formatting(kwargs[f])
                kwargs[f] = temp
        action.config_action(**kwargs)
    except (UninitializedError, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
Ejemplo n.º 9
0
def status(**kwargs):
    """ Gets the status of a specific document or all documents """
    try:
        action = status_action.StatusAction(os.getcwd())
        init_logger(action.path)

        for f in kwargs:
            if kwargs[f]:
                temp = remove_powershell_formatting(kwargs[f])
                kwargs[f] = temp

        action.get_status(**kwargs)
    except (UninitializedError, ResourceNotFound) as e:
        print_log(e)
        logger.error(e)
        return
Ejemplo n.º 10
0
def status(**kwargs):
    """ Gets the status of a specific document or all documents """
    try:
        action = actions.Action(os.getcwd())
        init_logger(action.path)

        for f in kwargs:
            if kwargs[f]:
                temp = remove_powershell_formatting(kwargs[f])
                kwargs[f] = temp


        action.status_action(**kwargs)
    except (UninitializedError, ResourceNotFound) as e:
        print_log(e)
        logger.error(e)
        return
Ejemplo n.º 11
0
def clean(force, dis_all, file_paths):
    """
    Cleans up the associations between local documents and documents in Lingotek.
    By default, checks that local documents and remote documents match up.
    Enter file or directory names to remove local associations of specific files or directories.
    """
    try:
        action = actions.Action(os.getcwd())
        init_logger(action.path)

        if len(file_paths) > 0:
            file_paths = remove_powershell_formatting(file_paths)

        action.clean_action(force, dis_all, file_paths)
    except (UninitializedError, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
Ejemplo n.º 12
0
def clean(force, dis_all, file_paths):
    """
    Cleans up the associations between local documents and documents in Lingotek.
    By default, removes documents from local tracking that have been cancelled or no longer exist locally or in the Lingotek Cloud.
    Enter file or directory names to cancel those documents and remove local associations of specific files or directories.
    """
    try:
        action = clean_action.CleanAction(os.getcwd())
        init_logger(action.path)

        if len(file_paths) > 0:
            file_paths = remove_powershell_formatting(file_paths)

        action.clean_action(force, dis_all, file_paths)
    except (UninitializedError, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
Ejemplo n.º 13
0
def rm(file_names, **kwargs):
    """
    Disassociates local doc(s) from Lingotek Cloud and removes them from the project by cancelling them.  If the remote copy should be deleted, use the -r flag.
    """
    try:
        action = rm_action.RmAction(os.getcwd())
        init_logger(action.path)
        if not file_names and not (('all' in kwargs and kwargs['all']) or ('local' in kwargs and kwargs['local'])):
            logger.info("Usage: ltk rm [OPTIONS] FILE_NAMES...")
            return

        if len(file_names) > 0:
            file_names = remove_powershell_formatting(file_names)

        action.rm_action(file_names, **kwargs)
    except (UninitializedError, ResourceNotFound, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
Ejemplo n.º 14
0
def rm(file_names, **kwargs):
    """
    Disassociates local doc(s) from Lingotek Cloud and deletes the remote copy.
    If the remote copy should be kept, please use ltk clean.
    """
    try:
        action = actions.Action(os.getcwd())
        init_logger(action.path)
        if not file_names and not ('all' in kwargs and kwargs['all']):
            logger.info("Usage: ltk rm [OPTIONS] FILE_NAMES...")
            return

        if len(file_names) > 0:
            file_names = remove_powershell_formatting(file_names)

        action.rm_action(file_names, **kwargs)
    except (UninitializedError, ResourceNotFound, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
Ejemplo n.º 15
0
def clone(folders, copy_root):
    """
    Copies the folder structure of added folders or specified folders
    for each target locale as specified in config.
    Folders are added to the locale folder specified if one has been specified,
    or by default a new folder will be created with the name of the locale. If
    only one root folder is being cloned, then the locale folder is used
    (instead of creating a new folder inside of the locale folder).
    """
    try:
        action = actions.Action(os.getcwd())
        init_logger(action.path)
        if isinstance(folders,str):
            folders = [folders]

        if len(folders) > 0:
            folders = remove_powershell_formatting(folders)

        action.clone_action(folders, copy_root)
    except (UninitializedError, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
Ejemplo n.º 16
0
def import_command(import_all, force, path):
    """
    Import documents from Lingotek Cloud, by default downloading to the project's root folder
    """
    # todo import should show all documents
    # add a force option so can import all force -- overwrites all existing documents without prompting
    # check if doc id
    # if exist, prompt for overwrite
    # else automatically re-name
    # possibly have to patch title in Lingotek Cloud?
    try:
        # action = actions.Action(os.getcwd())
        action = ImportAction(os.getcwd())
        init_logger(action.path)

        if path != None:
            path = remove_powershell_formatting(path)

        action.import_action(import_all, force, path)
    except(UninitializedError, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
Ejemplo n.º 17
0
def import_command(import_all, force, path, track, no_cancel):
    """
    Import documents from Lingotek Cloud, by default downloading to the project's root folder
    """
    # todo import should show all documents
    # add a force option so can import all force -- overwrites all existing documents without prompting
    # check if doc id
    # if exist, prompt for overwrite
    # else automatically re-name
    # possibly have to patch title in Lingotek Cloud?
    try:
        # action = actions.Action(os.getcwd())
        action = import_action.ImportAction(os.getcwd())
        init_logger(action.path)

        if path != None:
            path = remove_powershell_formatting(path)

        action.import_action(import_all, force, path, track, no_cancel)
    except(UninitializedError, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return
Ejemplo n.º 18
0
def clone(folders, copy_root):
    """
    Copies the folder structure of added folders or specified folders
    for each target locale as specified in config.
    Folders are added to the locale folder specified if one has been specified,
    or by default a new folder will be created with the name of the locale. If
    only one root folder is being cloned, then the locale folder is used
    (instead of creating a new folder inside of the locale folder).
    """
    try:
        action = clone_action.CloneAction(os.getcwd())
        init_logger(action.path)
        if isinstance(folders,str):
            folders = [folders]

        if len(folders) > 0:
            folders = remove_powershell_formatting(folders)

        action.clone_action(folders, copy_root)
    except (UninitializedError, RequestFailedError) as e:
        print_log(e)
        logger.error(e)
        return