diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..486a232 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.zip filter=lfs diff=lfs merge=lfs -text diff --git a/.gitmodules b/.gitmodules index b15e2f8..f14b821 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,3 +19,6 @@ [submodule "volume/git/cgwire-gazu"] path = volume/git/cgwire-gazu url = https://github.com/cgwire/gazu.git +[submodule "volume/git/avalon-config"] + path = volume/git/avalon-config + url = https://github.com/getavalon/config.git diff --git a/README.md b/README.md index ca4de48..cd37adb 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,20 @@ Click on any of the below problems for potential causes and solutions. + +
+ 3. Open File - Security Warning +
+ If running terminal.bat pops up this dialog: +
+ +
+ You need to tell Windows that the virtual machine running Docker is trusted. +
+ See https://superuser.com/questions/44503/how-do-i-tell-windows-7-to-trust-a-particular-network-location +
+ +
Can't find your problem? Submit a [bug report](../../issues) diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..bd003ce --- /dev/null +++ b/start.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +docker run --name avalon-files -d --rm \ + -p 445:445 \ + avalon/files \ + -s "Avalon;/avalon;yes;yes;yes;all;none;all" \ + -u "avalon;default" +docker run --name avalon-database -d --rm \ + -v avalon-database:/data/db \ + -p 27017:27017 \ + avalon/database +docker run --name avalon-tracker -d --rm \ + -v avalon-tracker:/var/lib/postgresql \ + -v avalon-tracker:/opt/zou/zou/thumbnails \ + -p 80:80 \ + avalon/tracker diff --git a/volume/avalon.bat b/volume/avalon.bat index f1200e0..5b7f730 100644 --- a/volume/avalon.bat +++ b/volume/avalon.bat @@ -1,4 +1,2 @@ @echo off - -set AVALON_MONGO=mongodb://192.168.99.100:27017 -%~dp0bin\windows\python36\python.exe %~dp0avalon_cli.py %* +call %~dp0/terminal.bat python %~dp0avalon_cli.py %* diff --git a/volume/avalon_cli.py b/volume/avalon_cli.py index 0d569eb..01bec4f 100644 --- a/volume/avalon_cli.py +++ b/volume/avalon_cli.py @@ -38,22 +38,31 @@ import os import sys +import json +import time import shutil +import zipfile +import logging +import datetime import tempfile import platform -import contextlib import subprocess -import json -import time -import datetime -import zipfile +import contextlib import pymongo from bson import json_util + REPO_DIR = os.path.dirname(os.path.abspath(__file__)) +GIT_DIR = os.path.join(REPO_DIR, "git") +HOME_DIR = os.path.expanduser("~/.avalon") AVALON_DEBUG = bool(os.getenv("AVALON_DEBUG")) +log = logging.getLogger("avalon") + +if AVALON_DEBUG: + log.setLevel(logging.DEBUG) + init = """\ from avalon import api, shell api.install(shell) @@ -87,15 +96,89 @@ def _check_pyqt5(): sys.exit(1) +def _firsttime(): + """Avalon was run for the first time + + ~/.avalon + /bin + /examples + /pythonpath + + """ + + # This function is the one creating the home directory, + # if it existed then it should have been deleted prior + # to running this. + assert not os.path.exists(HOME_DIR), "This is a bug" + + # 1. Copy Python + osname = ( + "windows" if os.name == "nt" else + "linux" if os.name == "posix" else + "osx" + ) + + # Sources + dirname = os.path.dirname(__file__) + zipname = os.path.join(dirname, "bin", osname + ".zip") + gitdir = os.path.join(dirname, "git") + examplesdir = os.path.join(gitdir, "avalon-examples", "projects") + pythondir = os.path.join(dirname, "bin", "pythonpath") + + # Destinations + dst_bindir = os.path.join(HOME_DIR, "bin") + dst_examplesdir = os.path.join(HOME_DIR, "examples") + dst_pythondir = os.path.join(HOME_DIR, "pythonpath") + + if os.path.isfile(zipname): + with zipfile.ZipFile(zipname) as f: + uncompress_size = sum( + (file.file_size for file in f.infolist()) + ) + + extracted_size = 0 + for file in f.infolist(): + extracted_size += file.file_size + progress = extracted_size * 90 / uncompress_size + sys.stdout.write( + "\rInitialising.. %d%%" + % progress + ) + f.extract(file, path=dst_bindir) + + else: + print("No binaries provided for your OS, '%s'" % os.name) + print("See https://getavalon.github.io/2.0/guides/ for help") + + # Store cross-platform Python dependencies + sys.stdout.write("\rInitialising.. 90%") + shutil.copytree(pythondir, dst_pythondir) + + # Store examples + sys.stdout.write("\rInitialising.. 95%") + shutil.copytree(examplesdir, dst_examplesdir) + + sys.stdout.write("\rInitialising.. 100%") + sys.stdout.write("\n") + print("All done, continuing..") + log.debug("Done") + + def _install(root=None): # Enable overriding from local environment - for dependency, name in (("PYBLISH_BASE", "pyblish-base"), - ("PYBLISH_QML", "pyblish-qml"), - ("AVALON_CORE", "avalon-core"), - ("AVALON_LAUNCHER", "avalon-launcher"), - ("AVALON_EXAMPLES", "avalon-examples")): - if dependency not in os.environ: - os.environ[dependency] = os.path.join(REPO_DIR, "git", name) + environ = { + "PYBLISH_BASE": os.path.join(GIT_DIR, "pyblish-base"), + "PYBLISH_QML": os.path.join(GIT_DIR, "pyblish-qml"), + "AVALON_CORE": os.path.join(GIT_DIR, "avalon-core"), + "AVALON_LAUNCHER": os.path.join(GIT_DIR, "avalon-launcher"), + "AVALON_EXAMPLES": os.path.join(HOME_DIR, "examples"), + } + + for key, value in environ.items(): + if key in os.environ: + continue + + os.environ[key] = value os.environ["PATH"] = os.pathsep.join([ # Expose "avalon", overriding existing @@ -130,7 +213,7 @@ def _install(root=None): if "AVALON_CONFIG" not in os.environ: os.environ["AVALON_CONFIG"] = "polly" os.environ["PYTHONPATH"] += os.pathsep + os.path.join( - REPO_DIR, "git", "mindbender-config") + GIT_DIR, "mindbender-config") if root is not None: os.environ["AVALON_PROJECTS"] = root @@ -319,9 +402,15 @@ def main(): parser.add_argument("--restore", help="Restore a project or a folder or projects.") parser.add_argument("--drop", help="Delete database") + parser.add_argument("--firsttime", + action="store_true", + help="Run first-time setup for Avalon") kwargs, args = parser.parse_known_args() + if kwargs.firsttime: + return _firsttime() + _install(root=kwargs.root) cd = os.path.dirname(os.path.abspath(__file__)) diff --git a/volume/bin/linux/maya2017 b/volume/bin/linux/maya2017 index 11ba075..75fedea 100644 --- a/volume/bin/linux/maya2017 +++ b/volume/bin/linux/maya2017 @@ -1,2 +1,2 @@ #!/usr/bin/env bash -/usr/autodesk/maya2015/bin/maya \ No newline at end of file +/usr/autodesk/maya2017/bin/maya \ No newline at end of file diff --git a/volume/bin/windows.zip b/volume/bin/windows.zip new file mode 100644 index 0000000..e73095a --- /dev/null +++ b/volume/bin/windows.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:da5e2fb0cc8b638dda0cb5d85b2af1d7713eda4efd341c668487699afd6dfa36 +size 91881056 diff --git a/volume/git/avalon-config b/volume/git/avalon-config new file mode 160000 index 0000000..2448de4 --- /dev/null +++ b/volume/git/avalon-config @@ -0,0 +1 @@ +Subproject commit 2448de44340a2fc9fcd1c5bbb5555ae6a3c25dd0 diff --git a/volume/git/avalon-core b/volume/git/avalon-core index 10a460f..899b889 160000 --- a/volume/git/avalon-core +++ b/volume/git/avalon-core @@ -1 +1 @@ -Subproject commit 10a460f472c5bfabdcfd557395e4720598702a48 +Subproject commit 899b8896cda9d6c5426a21eee01a17a1e277e8fe diff --git a/volume/terminal.bat b/volume/terminal.bat index 3bf5cbf..a607493 100644 --- a/volume/terminal.bat +++ b/volume/terminal.bat @@ -1,31 +1,35 @@ @echo off -set AVALON_MONGO=mongodb://192.168.99.100:27017 -set PATH=%~dp0;%~dp0bin\windows\python36;%PATH% +set AVALONCACHE=%HOMEDRIVE%%HOMEPATH%\.avalon +set PATH=%AVALONCACHE%\bin\python36;%PATH% + +if not exist "%AVALONCACHE%" ( + echo Avalon was started for the first time, hold on.. + %~dp0bin\windows\python36\python.exe %~dp0avalon_cli.py --firsttime + sleep 1 +) -:: Expose Python libraries -set PYTHONPATH=%~dp0git\avalon-core -set PYTHONPATH=%~dp0git\avalon-launcher;%PYTHONPATH% -set PYTHONPATH=%~dp0git\mindbender-config;%PYTHONPATH% -set PYTHONPATH=%~dp0git\pyblish-base;%PYTHONPATH% -set PYTHONPATH=%~dp0git\pyblish-qml;%PYTHONPATH% -set PYTHONPATH=%~dp0git\cgwire-gazu;%PYTHONPATH% +if not exist "%AVALONCACHE%" ( + echo This is a bug + exit /b +) -:: Expose cross-platform libraries -set PYTHONPATH=%~dp0bin\pythonpath;%PYTHONPATH% +set AVALON_MONGO=mongodb://192.168.99.100:27017 cls -echo. -echo Avalon Terminal -echo --------------- -echo. -echo :: Launch avalon -echo $ avalon -echo. -echo :: Get help -echo $ avalon --help -echo. -echo. +if "%1" == "" ( + echo. + echo Avalon Terminal + echo --------------- + echo. + echo :: Launch avalon + echo $ avalon + echo. + echo :: Get help + echo $ avalon --help + echo. + echo. +) -call cmd /K +call cmd /K %*