コード例 #1
0
    def unarchive(self, filename, project_dir, parent_dir=None, frontend=None):
        """Unpack an archive of the project.

        The archive can be untrusted (we will safely defeat attempts
        to put evil links in it, for example), but this function
        doesn't load or validate the unpacked project.

        The target directory must not exist or it's an error.

        project_dir can be None to auto-choose one.

        If parent_dir is non-None, place the project_dir in it. This is most useful
        if project_dir is None.

        Args:
            filename (str): name of a zip, tar.gz, or tar.bz2 archive file
            project_dir (str): the directory to place the project inside
            parent_dir (str): directory to place project_dir within
            frontend (Frontend): frontend instance representing current UX

        Returns:
            a ``Status``, if failed has ``errors``, on success has ``project_dir`` property.

        """
        return project_ops.unarchive(filename=filename,
                                     project_dir=project_dir,
                                     parent_dir=parent_dir,
                                     frontend=frontend)
コード例 #2
0
def unarchive_command(archive_filename, project_dir):
    """Unpack an archive of the project.

    Returns:
        exit code
    """
    status = project_ops.unarchive(archive_filename,
                                   project_dir,
                                   frontend=CliFrontend())
    if status:
        print(status.status_description)
        return 0
    else:
        console_utils.print_status_errors(status)
        return 1