Skip to content

Commit

Permalink
Add modified aToolsInstall
Browse files Browse the repository at this point in the history
  • Loading branch information
MKlimenko committed Mar 1, 2022
1 parent 8a60386 commit 8ec4bfb
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 1 deletion.
84 changes: 84 additions & 0 deletions aToolsInstall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from maya import cmds, mel
import os, shutil, urllib.request, urllib.error, urllib.parse, shutil, zipfile, importlib

def formatPath(path):
path = path.replace('/', os.sep)
path = path.replace('\\', os.sep)
return path

def download(downloadUrl, saveFile):

try: response = urllib.request.urlopen(downloadUrl, timeout=60)
except: pass

if response is None:
cmds.warning('Error trying to install.')
return

fileSize = int(response.info().get('Content-Length')[0])
fileSizeDl = 0
blockSize = 128
output = open(saveFile,'wb')
progBar = mel.eval('$tmp = $gMainProgressBar')

cmds.progressBar( progBar,
edit=True,
beginProgress=True,
status='Downloading aTools...',
progress=0,
maxValue=100 )

while True:
buffer = response.read(blockSize)
if not buffer:
output.close()
cmds.progressBar(progBar, edit=True, progress=100)
cmds.progressBar(progBar, edit=True, endProgress=True)
break

fileSizeDl += len(buffer)
output.write(buffer)
p = float(fileSizeDl) / fileSize *100

cmds.progressBar(progBar, edit=True, progress=p)

return output


def aToolsInstall():

mayaAppDir = mel.eval('getenv MAYA_APP_DIR')
aToolsPath = mayaAppDir + os.sep + "scripts"
aToolsFolder = aToolsPath + os.sep + "aTools" + os.sep
tmpZipFile = "%s%stmp.zip"%(aToolsPath, os.sep)
DOWNLOAD_URL = "http://www.trickorscript.com/aTools/aTools.zip"

if os.path.isfile(tmpZipFile): os.remove(tmpZipFile)
if os.path.isdir(aToolsFolder): shutil.rmtree(aToolsFolder)

output = download(DOWNLOAD_URL, tmpZipFile)

zfobj = zipfile.ZipFile(tmpZipFile)
for name in zfobj.namelist():
uncompressed = zfobj.read(name)

filename = formatPath('%s%s%s'%(aToolsPath, os.sep, name))
d = os.path.dirname(filename)

if not os.path.exists(d): os.makedirs(d)
if filename.endswith(os.sep): continue

output = open(filename,'wb')
output.write(uncompressed)
output.close()

#delete temp
zfobj.close()
if os.path.isfile(tmpZipFile): os.remove(tmpZipFile)

from aTools import setup; setup.install()

#refresh
cmds.evalDeferred("from aTools.animTools.animBar import animBarUI; importlib.reload(animBarUI); animBarUI.show('refresh')")

aToolsInstall()
2 changes: 1 addition & 1 deletion aTools_install.mel
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def hasInternet(url):\n\
return False\n\
\n\
def launchInstall():\n\
INSTALL_URL = 'http://www.trickorscript.com/aTools/aToolsInstall.py' \n\
INSTALL_URL = 'https://raw.githubusercontent.com/MKlimenko/aTools_python3/master/aToolsInstall.py' \n\
aToolsInstall = None\n\
if hasInternet(INSTALL_URL):\n\
try: \n\
Expand Down

0 comments on commit 8ec4bfb

Please sign in to comment.