Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy mechanism #53

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.zip filter=lfs diff=lfs merge=lfs -text
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ Click on any of the below problems for potential causes and solutions.
</pre>
</details>


<details>
<summary>3. Open File - Security Warning</summary>
<br>
If running <code>terminal.bat</code> pops up this dialog:
<br>
<img src=https://user-images.githubusercontent.com/2152766/42368426-e8050224-80fe-11e8-95d7-f4821db84467.png>
<br>
You need to tell Windows that the virtual machine running Docker is <b>trusted</b>.
<br>
See https://superuser.com/questions/44503/how-do-i-tell-windows-7-to-trust-a-particular-network-location
</details>


<br>

Can't find your problem? Submit a [bug report](../../issues)
Expand Down
15 changes: 15 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 1 addition & 3 deletions volume/avalon.bat
Original file line number Diff line number Diff line change
@@ -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 %*
115 changes: 102 additions & 13 deletions volume/avalon_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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__))
Expand Down
2 changes: 1 addition & 1 deletion volume/bin/linux/maya2017
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
/usr/autodesk/maya2015/bin/maya
/usr/autodesk/maya2017/bin/maya
3 changes: 3 additions & 0 deletions volume/bin/windows.zip
Git LFS file not shown
1 change: 1 addition & 0 deletions volume/git/avalon-config
Submodule avalon-config added at 2448de
50 changes: 27 additions & 23 deletions volume/terminal.bat
Original file line number Diff line number Diff line change
@@ -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 %*