Removed update content files (#7497)

This commit is contained in:
Blyron 2024-04-24 15:07:09 +02:00 committed by GitHub
parent 50e55e38d5
commit f0db576510
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 0 additions and 255 deletions

View File

@ -1,76 +0,0 @@
@echo off
rem ============================================================================
rem -- Set up environment ------------------------------------------------------
rem ============================================================================
set SCRIPT_DIR=%~dp0
set CONTENT_FOLDER=%SCRIPT_DIR%Unreal/CarlaUnreal/Content/Carla
set VERSION_FILE=%CONTENT_FOLDER%/.version
set CONTENT_VERSIONS=%SCRIPT_DIR%/Util/ContentVersions.txt
rem ============================================================================
rem -- Get the last version to download ----------------------------------------
rem ============================================================================
if not exist "%CONTENT_FOLDER%" mkdir "%CONTENT_FOLDER%"
for /F "delims=" %%a in (%CONTENT_VERSIONS%) do (
set "lastLine=%%a"
)
set CONTENT_ID=%lastLine:~-16,16%
set CONTENT_LINK=http://carla-assets.s3.amazonaws.com/%CONTENT_ID%.tar.gz
if "%CONTENT_ID:~0,2%"=="20" (
set CONTENT_FILE=%CONTENT_FOLDER%/%CONTENT_ID%.tar.gz
set CONTENT_FILE_TAR=%CONTENT_FOLDER%/%CONTENT_ID%.tar
echo %CONTENT_ID%
echo %CONTENT_LINK%
) else (
echo Error reading the latest version from ContentVersions.txt, check last line of file %CONTENT_VERSIONS%'
goto error_download
)
rem ============================================================================
rem -- Download the content ----------------------------------------------------
rem ============================================================================
echo Downloading "%CONTENT_LINK%"...
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%CONTENT_LINK%', '%CONTENT_FILE%')"
if %errorlevel% neq 0 goto error_download
echo %FILE_N% Extracting content from "%CONTENT_FILE%", this can take a while...
if exist "%ProgramW6432%/7-Zip/7z.exe" (
"%ProgramW6432%/7-Zip/7z.exe" x "%CONTENT_FILE%" -o"%CONTENT_FOLDER%" -y
if %errorlevel% neq 0 goto error_download
echo Deleting %CONTENT_FILE:/=\%
del %CONTENT_FILE:/=\%
"%ProgramW6432%/7-Zip/7z.exe" x "%CONTENT_FILE_TAR%" -o"%CONTENT_FOLDER%" -y
if %errorlevel% neq 0 goto error_download
echo Deleting %CONTENT_FILE_TAR:/=\%
del %CONTENT_FILE_TAR:/=\%
) else (
powershell -Command "Expand-Archive '%CONTENT_FILE%' -DestinationPath '%CONTENT_FOLDER%'"
if %errorlevel% neq 0 goto error_download
del %CONTENT_FILE%
)
goto success
:success
echo.
echo %FILE_N% Content has been successfully installed in "%CONTENT_FOLDER%"!
goto good_exit
:error_download
goto bad_exit
:good_exit
echo %FILE_N% Exiting...
endlocal
exit /b 0
:bad_exit
if exist "%CONTENT_FILE%" rd /s /q "%CONTENT_FOLDER%"
echo %FILE_N% Exiting with error...
endlocal
exit /b %errorlevel%

View File

@ -1,78 +0,0 @@
from argparse import ArgumentParser
from tarfile import TarFile
from pathlib import Path
import requests
import shutil
import json
WORKSPACE_PATH = Path(__file__).parent.resolve()
CONTENT_PARENT_PATH = WORKSPACE_PATH / 'Unreal' / 'CarlaUnreal' / 'Content'
INTERMEDIATE_FILE_PATH = CONTENT_PARENT_PATH / f'Carla.tar.gz'
CONTENT_PATH = CONTENT_PARENT_PATH / 'Carla'
CONTENT_VERSION_FILE_PATH = WORKSPACE_PATH / 'Util' / 'ContentVersions.json'
if CONTENT_PATH.exists():
print(f'"{CONTENT_PATH}" already exists.')
exit(-1)
arg_parser = ArgumentParser(description = __doc__)
arg_parser.add_argument(
'--content-version',
default = None,
type = str,
help = 'Version of the Carla UE Content to download.')
arg_parser.add_argument(
'--display-progress',
default = False,
type = bool,
help = 'Whether to display download progress.')
ARGV = arg_parser.parse_args()
CONTENT_VERSION = ARGV.content_version
DISPLAY_PROGRESS = ARGV.display_progress
print ('Creating UE content directories.')
CONTENT_PARENT_PATH.mkdir(exist_ok = True)
CONTENT_PATH.mkdir(exist_ok = True)
print ('Reading UE content version URLs.')
content_version_map = None
with open(CONTENT_VERSION_FILE_PATH, 'r') as file:
content_version_map = json.load(file)
assert content_version_map != None
assert type(content_version_map) is dict
if CONTENT_VERSION is None:
CONTENT_VERSION = content_version_map['latest']
assert CONTENT_VERSION in content_version_map
print(f'No content version was specified, using "latest" ({CONTENT_VERSION}).')
VERSION_INFO = content_version_map[CONTENT_VERSION]
IDENTIFIER = VERSION_INFO['id']
STORAGE_KIND = VERSION_INFO['type']
url = None
if STORAGE_KIND == 'google-drive':
url = f'https://drive.google.com/open?id={IDENTIFIER}'
elif STORAGE_KIND == 'aws':
url = f'http://carla-assets.s3.amazonaws.com/{IDENTIFIER}.tar.gz'
assert url != None
print(f'Downloading "{url}".')
try:
# TODO: This may not be optimal for our case:
with requests.Session() as session:
with session.get(url, stream = True) as result:
with open(INTERMEDIATE_FILE_PATH, 'wb') as file:
shutil.copyfileobj(result.raw, file)
except:
print('Failed to download Carla UE content.')
exit(-1)
finally:
if INTERMEDIATE_FILE_PATH.exists():
assert INTERMEDIATE_FILE_PATH.is_file()
print('Extracting CARLA content.')
TarFile.open(INTERMEDIATE_FILE_PATH).extractall(CONTENT_PATH)
INTERMEDIATE_FILE_PATH.unlink()
print('Done.')

101
Update.sh
View File

@ -1,101 +0,0 @@
#! /bin/bash
################################################################################
# Updates CARLA content.
################################################################################
set -e
DOC_STRING="Update CARLA content to the latest version, to be run after 'git pull'."
USAGE_STRING="Usage: $0 [-h|--help] [-s|--skip-download]"
# ==============================================================================
# -- Parse arguments -----------------------------------------------------------
# ==============================================================================
SKIP_DOWNLOAD=false
OPTS=`getopt -o hs --long help,skip-download -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2 ; fi
eval set -- "$OPTS"
while true; do
case "$1" in
-s | --skip-download )
SKIP_DOWNLOAD=true;
shift ;;
-h | --help )
echo "$DOC_STRING"
echo "$USAGE_STRING"
exit 1
;;
* )
break ;;
esac
done
# ==============================================================================
# -- Set up environment --------------------------------------------------------
# ==============================================================================
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd "$SCRIPT_DIR" >/dev/null
CONTENT_FOLDER="${SCRIPT_DIR}/Unreal/CarlaUnreal/Content/Carla"
CONTENT_ID=$(tac $SCRIPT_DIR/Util/ContentVersions.txt | egrep -m 1 . | rev | cut -d' ' -f1 | rev)
CONTENT_LINK=http://carla-assets.s3.amazonaws.com/${CONTENT_ID}.tar.gz
VERSION_FILE="${CONTENT_FOLDER}/.version"
function download_content {
if [[ -d "$CONTENT_FOLDER" ]]; then
echo "Backing up existing Content..."
mv -v "$CONTENT_FOLDER" "${CONTENT_FOLDER}_$(date +%Y%m%d%H%M%S)"
fi
mkdir -p "$CONTENT_FOLDER"
mkdir -p Content
if hash aria2c 2>/dev/null; then
echo -e "${CONTENT_LINK}\n\tout=Content.tar.gz" > .aria2c.input
aria2c -j16 -x16 --input-file=.aria2c.input
rm -f .aria2c.input
else
wget -c ${CONTENT_LINK} -O Content.tar.gz
fi
tar -xvzf Content.tar.gz -C Content
rm Content.tar.gz
mv Content/* "$CONTENT_FOLDER"
rm -rf Content
echo "$CONTENT_ID" > "$VERSION_FILE"
echo "Content updated successfully."
}
# ==============================================================================
# -- Download Content if necessary ---------------------------------------------
# ==============================================================================
if $SKIP_DOWNLOAD ; then
echo "Skipping 'Content' update. Please manually download the package from"
echo
echo " ${CONTENT_LINK}"
echo
echo "and extract it under Unreal/CarlaUnreal/Content/Carla."
exit 0
fi
if [[ -d "$CONTENT_FOLDER/.git" ]]; then
echo "Using git version of 'Content', skipping update."
elif [[ -f "$CONTENT_FOLDER/.version" ]]; then
if [ "$CONTENT_ID" == `cat $VERSION_FILE` ]; then
echo "Content is up-to-date."
else
download_content
fi
else
download_content
fi
popd >/dev/null