Skip to content

Commit

Permalink
Merge pull request GafferHQ#5605 from johnhaddon/arnoldAuth
Browse files Browse the repository at this point in the history
CI : Authenticate for Arnold downloads
  • Loading branch information
ericmehl authored Jan 2, 2024
2 parents 151b585 + b867026 commit 4777134
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ jobs:
f.write( 'ARNOLD_ROOT=%s\n' % arnoldRoot )
env:
PYTHONUTF8: 1
ARNOLD_DOWNLOAD_USER: ${{ secrets.ARNOLD_DOWNLOAD_USER }}
ARNOLD_DOWNLOAD_PASSWORD: ${{ secrets.ARNOLD_DOWNLOAD_PASSWORD }}
shell: python

- name: Build Docs and Package
Expand Down
33 changes: 21 additions & 12 deletions .github/workflows/main/installArnold.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,12 @@
import sys
import argparse
import os
import pathlib
import shutil
import subprocess
import urllib
import urllib.request
import zipfile

if sys.version_info[0] < 3 :
from urllib import urlretrieve
else:
from urllib.request import urlretrieve

platform = { "darwin" : "darwin", "win32" : "windows" }.get( sys.platform, "linux" )
format = { "win32" : "zip" }.get( sys.platform, "tgz" )

Expand All @@ -65,15 +62,27 @@

url="https://forgithubci.solidangle.com/arnold/{}".format( archive )

installDir = os.path.join( "arnoldRoot", args.version )
os.makedirs( installDir )
os.chdir( installDir )
installDir = pathlib.Path.cwd() / "arnoldRoot" / args.version
installDir.mkdir( parents = True, exist_ok = True )
archiveFile = installDir / archive

print( "Downloading Arnold \"{}\"".format( url ) )
archiveFile, headers = urlretrieve( url )

authHandler = urllib.request.HTTPBasicAuthHandler()
authHandler.add_password(
realm = None,
uri = url,
user = os.environ["ARNOLD_DOWNLOAD_USER"],
passwd = os.environ["ARNOLD_DOWNLOAD_PASSWORD"]
)

urllib.request.install_opener( urllib.request.build_opener( authHandler ) )
with urllib.request.urlopen( url ) as inFile :
with open( archiveFile, "wb" ) as outFile :
shutil.copyfileobj( inFile, outFile )

if format == "tgz" :
subprocess.check_call( [ "tar", "-xzf", archiveFile ] )
subprocess.check_call( [ "tar", "-xzf", archiveFile, "-C", installDir ] )
elif format == "zip":
with zipfile.ZipFile( archiveFile ) as f :
f.extractall()
f.extractall( path = installDir )

0 comments on commit 4777134

Please sign in to comment.