How to use the ltk.exceptions.ResourceNotFound 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
else:
                    for entry in response.json()['entities']:
                        id = entry['entities'][1]['properties']['id']
                        doc_name = entry['properties']['name']
                        self.rm_document(id, True, force, doc_name)
                    return
            else:
                useID = False
                matched_files = self.doc_manager.get_doc_names()
        elif not useID:
            # use current working directory as root for files instead of project root
            matched_files = get_files(file_patterns)
        else:
            matched_files = file_patterns
        if matched_files is None:
            raise exceptions.ResourceNotFound("Could not find the specified file/pattern")
        for file_name in matched_files:
            # title = os.path.basename(os.path.normpath(file_name)).split('.')[0]
            self.rm_document(file_name, useID, force)
github Lingotek / filesystem-connector / python2 / ltk / actions / action_facade.py View on Github external
for pattern in file_patterns:
                        doc = self.doc_manager.get_doc_by_prop("name",pattern)
                        if doc:
                            matched_files.append(doc['file_name'])
                else:
                    matched_files = self.get_doc_filenames_in_path(file_patterns)
            else:
                matched_files = file_patterns
            if not matched_files or len(matched_files) == 0:
                if useID:
                    raise exceptions.ResourceNotFound("No documents to remove with the specified id")
                elif removed_folder:
                    logger.info("No documents to remove")
                elif not 'all' in kwargs or not kwargs['all']:
                    raise exceptions.ResourceNotFound("No documents to remove with the specified file path")
                else:
                    raise exceptions.ResourceNotFound("No documents to remove")
            is_directory = False
            for pattern in file_patterns: # If attemping to remove any directory, don't print failure message
                basename = os.path.basename(pattern)
                if not basename or basename == "":
                    is_directory = True
            for file_name in matched_files:
                # title = os.path.basename(os.path.normpath(file_name)).split('.')[0]
                self.rm_document(self.norm_path(file_name).replace(self.path,""), useID, force)

        except Exception as e:
            # Python 2
            # End Python 2
            # Python 3
#             log_error(self.error_file_name, e)
github Lingotek / filesystem-connector / python3 / ltk / actions / action_facade.py View on Github external
doc = self.doc_manager.get_doc_by_prop("name",pattern)
                        if doc:
                            matched_files.append(doc['file_name'])
                else:
                    matched_files = self.get_doc_filenames_in_path(file_patterns)
            else:
                matched_files = file_patterns
            if not matched_files or len(matched_files) == 0:
                if useID:
                    raise exceptions.ResourceNotFound("No documents to remove with the specified id")
                elif removed_folder:
                    logger.info("No documents to remove")
                elif not 'all' in kwargs or not kwargs['all']:
                    raise exceptions.ResourceNotFound("No documents to remove with the specified file path")
                else:
                    raise exceptions.ResourceNotFound("No documents to remove")
            is_directory = False
            for pattern in file_patterns: # If attemping to remove any directory, don't print failure message
                basename = os.path.basename(pattern)
                if not basename or basename == "":
                    is_directory = True
            for file_name in matched_files:
                # title = os.path.basename(os.path.normpath(file_name)).split('.')[0]
                self.rm_document(self.norm_path(file_name).replace(self.path,""), useID, force)

        except Exception as e:
            # Python 2
            # End Python 2
            # Python 3
            log_error(self.error_file_name, e)
            # End Python 3
            if 'string indices must be integers' in str(e):
github Lingotek / filesystem-connector / python2 / ltk / actions / action_facade.py View on Github external
doc = self.doc_manager.get_doc_by_prop("name",pattern)
                        if doc:
                            matched_files.append(doc['file_name'])
                else:
                    matched_files = self.get_doc_filenames_in_path(file_patterns)
            else:
                matched_files = file_patterns
            if not matched_files or len(matched_files) == 0:
                if useID:
                    raise exceptions.ResourceNotFound("No documents to remove with the specified id")
                elif removed_folder:
                    logger.info("No documents to remove")
                elif not 'all' in kwargs or not kwargs['all']:
                    raise exceptions.ResourceNotFound("No documents to remove with the specified file path")
                else:
                    raise exceptions.ResourceNotFound("No documents to remove")
            is_directory = False
            for pattern in file_patterns: # If attemping to remove any directory, don't print failure message
                basename = os.path.basename(pattern)
                if not basename or basename == "":
                    is_directory = True
            for file_name in matched_files:
                # title = os.path.basename(os.path.normpath(file_name)).split('.')[0]
                self.rm_document(self.norm_path(file_name).replace(self.path,""), useID, force)

        except Exception as e:
            # Python 2
            # End Python 2
            # Python 3
#             log_error(self.error_file_name, e)
            # End Python 3
            if 'string indices must be integers' in str(e):
github Lingotek / filesystem-connector / python3 / ltk / actions / action_facade.py View on Github external
elif not useID:
                # use current working directory as root for files instead of project root
                if 'name' in kwargs and kwargs['name']:
                    matched_files = []

                    for pattern in file_patterns:
                        doc = self.doc_manager.get_doc_by_prop("name",pattern)
                        if doc:
                            matched_files.append(doc['file_name'])
                else:
                    matched_files = self.get_doc_filenames_in_path(file_patterns)
            else:
                matched_files = file_patterns
            if not matched_files or len(matched_files) == 0:
                if useID:
                    raise exceptions.ResourceNotFound("No documents to remove with the specified id")
                elif removed_folder:
                    logger.info("No documents to remove")
                elif not 'all' in kwargs or not kwargs['all']:
                    raise exceptions.ResourceNotFound("No documents to remove with the specified file path")
                else:
                    raise exceptions.ResourceNotFound("No documents to remove")
            is_directory = False
            for pattern in file_patterns: # If attemping to remove any directory, don't print failure message
                basename = os.path.basename(pattern)
                if not basename or basename == "":
                    is_directory = True
            for file_name in matched_files:
                # title = os.path.basename(os.path.normpath(file_name)).split('.')[0]
                self.rm_document(self.norm_path(file_name).replace(self.path,""), useID, force)

        except Exception as e:
github Lingotek / filesystem-connector / ltk / actions.py View on Github external
def display_choice(display_type, info):
    if display_type == 'community':
        input_prompt = 'Which community should this project belong to? '
    elif display_type == 'project':
        input_prompt = 'Which existing project should be used? '
    else:
        raise exceptions.ResourceNotFound("Cannot display info asked for")
    mapper = choice_mapper(info)
    choice = 'none-chosen'
    while choice not in mapper:
        choice = input(input_prompt)
        try:
            choice = int(choice)
        except ValueError:
            print("That's not a valid option!")
    for v in mapper[choice]:
        logger.info('Selected "{0}" {1}.'.format(mapper[choice][v], display_type))
        return v, mapper[choice][v]
github Lingotek / filesystem-connector / python2 / ltk / actions / action_facade.py View on Github external
def display_choice(display_type, info):
    if display_type == 'community':
        prompt_message = 'Which community should this project belong to? '
    elif display_type == 'project':
        prompt_message = 'Which existing project should be used? '
    else:
        raise exceptions.ResourceNotFound("Cannot display info asked for")
    mapper = choice_mapper(info)
    choice = 'none-chosen'
    while choice not in mapper:
        try:
            # Python 2
            choice = raw_input(prompt_message)
            # End Python 2
            # Python 3
#             choice = input(prompt_message)
            # End Python 3
        except KeyboardInterrupt:
            # Python 2
            logger.info("\nInit canceled")
            # End Python 2
            # Python 3
#             logger.error("\nInit canceled")
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