def __init__(self, input_dir, output_dir, **kwargs):
        # Get keyword arguments.
        server_address = kwargs.get(str('server_address'), '')
        remote_path = kwargs.get(str('remote_path'), '')
        username = kwargs.get(str('username'), '')
        scp_exe = kwargs.get(str('scp_executable'), '/usr/bin/scp')

        # Check for required arguments.
        if len(server_address) == 0:
            sys.exit('No server_address passed')
        if len(remote_path) == 0:
            sys.exit('No remote_path passed')
        if len(username) == 0:
            sys.exit('No username passed')

        # Check for required external executable.
        if not os.path.isfile(scp_exe):
            sys.exit('scp not found at "%s"' % scp_exe)

        # Process files and directories.
        for item_name in os.listdir(input_dir):
            item_path = os.path.join(input_dir, item_name)
            self.upload_files(item_path, scp_exe, username, server_address, remote_path)

        # Up to this point our Task has no output. Which means the next Task has no input to work with.
        # So we're re-using the previous Task's output, by passing it down.
        pass_input_to_output(input_dir, output_dir)
    def __init__(self, input_dir, output_dir, **kwargs):
        # Get keyword arguments.
        directory = kwargs.get(str('directory'), '')
        create = kwargs.get(str('create_directory'), False)
        overwrite = kwargs.get(str('overwrite_existing'), False)

        # Check required argument.
        if len(directory) > 0:
            directory = os.path.expanduser(directory)
            self.check_target_directory(directory, create)
        else:
            sys.exit('No directory passed to copy to')

        # Process files and directories.
        for item_name in os.listdir(input_dir):
            item_path = os.path.join(input_dir, item_name)

            if os.path.isfile(item_path):
                copy_file(item_path, os.path.join(directory, item_name), overwrite)

            elif os.path.isdir(item_path):
                copy_tree(item_path, os.path.join(directory, item_name), overwrite)

        # Up to this point our Task has no output. Which means the next Task has no input to work with.
        # So we're re-using the previous Task's output, by passing it down.
        pass_input_to_output(input_dir, output_dir)
    def __init__(self, input_dir, output_dir, **kwargs):
        # Get keyword arguments.
        patterns = kwargs.get(str('patterns'), [])
        directories = kwargs.get(str('directories'), [])
        ignore_case = kwargs.get(str('ignore_case'), True)
        overwrite = kwargs.get(str('overwrite_existing'), False)
        create = kwargs.get(str('create_directory'), False)

        # Check required arguments.
        if len(patterns) == 0:
            sys.exit('No patterns passed')
        elif len(directories) == 0:
            sys.exit('No directories passed')
        elif len(patterns) != len(directories):
            sys.exit('Different number of patterns and directories passed')

        # Process files and directories.
        compiled_patterns = self.compile_patterns(patterns, ignore_case)
        for item_name in os.listdir(input_dir):
            item_path = os.path.join(input_dir, item_name)
            self.match_and_copy(item_path, compiled_patterns, directories,
                                overwrite, create)

        # Up to this point our Task has no output. Which means the next Task has no input to work with.
        # So we're re-using the previous Task's output, by passing it down.
        pass_input_to_output(input_dir, output_dir)
Exemple #4
0
 def __init__(self, input_dir, output_dir, **kwargs):
     # Check if there are files or folders in the input_dir.
     if len(os.listdir(input_dir)) == 0:
         sys.exit(
             'No files or folders in input_dir. The previous Task wrote nothing to its output_dir.'
         )
     else:
         # Up to this point our Task has no output. Which means the next Task has no input to work with.
         # So we're re-using the previous Task's output, by passing it down.
         pass_input_to_output(input_dir, output_dir)
    def __init__(self, input_dir, output_dir, **kwargs):
        # Get keyword arguments.
        app_name = kwargs.get(str('app_name'), '')

        # Check for required arguments.
        if len(app_name) == 0:
            sys.exit('No app_name passed')

        # Process files and directories.
        for item_name in os.listdir(input_dir):
            item_path = os.path.join(input_dir, item_name)
            self.open_file(item_path, app_name)

        # Up to this point our Task has no output. Which means the next Task has no input to work with.
        # So we're re-using the previous Task's output, by passing it down.
        pass_input_to_output(input_dir, output_dir)
    def __init__(self, input_dir, output_dir, **kwargs):
        # Get keyword arguments.
        delete_to_trash = kwargs.get(str('delete_to_trash'), True)

        # Process files and directories.
        original_paths = get_original_paths(output_dir)

        for original_path in original_paths:
            if os.path.isfile(original_path):
                self.delete_file(delete_to_trash, original_path)

            elif os.path.isdir(original_path):
                self.delete_tree(delete_to_trash, original_path)

        # Up to this point our Task has no output. Which means the next Task has no input to work with.
        # So we're re-using the previous Task's output, by passing it down.
        pass_input_to_output(input_dir, output_dir)
Exemple #7
0
def test_pass_input_to_output(tmpdir):
    input_dir = tmpdir.join('0')
    os.makedirs('%s' % input_dir)

    shutil.copyfile('%s' % files_dir.join('pg5903.epub'),
                    '%s' % input_dir.join('pg5903.epub'))

    input_sub_dir = input_dir.join('foo')
    os.makedirs('%s' % input_sub_dir)

    output_dir = tmpdir.join('1')
    os.makedirs('%s' % output_dir)

    pass_input_to_output(input_dir='%s' % input_dir,
                         output_dir='%s' % output_dir)

    assert output_dir.join('pg5903.epub').check() is True
    assert output_dir.join('foo').check() is True
Exemple #8
0
    def __init__(self, input_dir, output_dir, **kwargs):
        # Get keyword arguments.
        overwrite = kwargs.get(str('overwrite_existing'), False)
        fallback_path = kwargs.get(str('fallback_path'), '')

        original_paths = get_original_paths(output_dir)
        parent_path = self.get_parent_path(original_paths, fallback_path)

        # Process files and directories.
        for item_name in os.listdir(input_dir):
            item_path = os.path.join(input_dir, item_name)

            if os.path.isfile(item_path):
                copy_file(item_path, os.path.join(parent_path, item_name),
                          overwrite)

            elif os.path.isdir(item_path):
                copy_tree(item_path, os.path.join(parent_path, item_name),
                          overwrite)

        # Up to this point our Task has no output. Which means the next Task has no input to work with.
        # So we're re-using the previous Task's output, by passing it down.
        pass_input_to_output(input_dir, output_dir)