示例#1
0
 def file_map(local_file):
     """Upload local file to remote location and calculate remote name"""
     tmpfile = RemoteTempfile(directory=True)
     local_path = find_included_file(local_file.path, local_file.context)
     put(local_path=local_path, remote_path=tmpfile.name)
     remote_files.append(tmpfile)
     return join(tmpfile.name, basename(local_path))
示例#2
0
def check_command_file(cmd_file):
    """Helper tool to writing complex virt-* command files

    Read the given command file, attempt to perform all file inclusions and
    emdebbed script execution and yeild the resulting composit command file

    :param str cmd_file: The command file to check
    """
    ast = tuple(perform_ast_includes(file_to_ast(expanduser(cmd_file))))
    for used_file in ast_to_used_files(ast):
        used_file_path = find_included_file(used_file.path, used_file.context)
        if not exists(used_file_path):
            abort('File "{0}" included from "{1}" line {2} not found!'.format(
                used_file.path, used_file.context.file, used_file.context.line
            ))
    for item in ast:
        puts(ast_item_to_string(item))
def test_find_included_file(given, inc_ctx, expected):
    result = find_included_file(given, inc_ctx)
    assert expected == result