-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPipeline_install.mel
86 lines (86 loc) · 3.21 KB
/
Pipeline_install.mel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
python("\n\
#Pipeline_install.mel\n\
\n\
from maya import cmds, mel\n\
import os, urllib2, shutil, zipfile\n\
\n\
def hasInternet(url):\n\
try:\n\
proxy = urllib2.ProxyHandler({})\n\
opener = urllib2.build_opener(proxy)\n\
urllib2.install_opener(opener)\n\
response = urllib2.urlopen(url, timeout=60)\n\
return True\n\
except: pass\n\
return False\n\
\n\
def launchInstall():\n\
INSTALL_URL = 'https://raw.githubusercontent.com/Alehaaaa/pipe/main/onlineInstall.py'\n\
PipelineInstall = None\n\
if hasInternet(INSTALL_URL):\n\
try: PipelineInstall = urllib2.urlopen(INSTALL_URL, timeout=60).read()\n\
except IOError: pass\n\
if PipelineInstall: exec(PipelineInstall)\n\
else:\n\
cmds.confirmDialog(title='Pipeline 2 Install', message='Internet connection not detected, needed to proceed.\\nConsider configuring your firewall so that Maya can access the internet.', button='Close')\n\
\n\
def formatPath(path):\n\
path = path.replace('/', os.sep)\n\
path = path.replace('\\\\', os.sep)\n\
return path\n\
\n\
def download(downloadUrl, saveFile):\n\
\n\
try: response = urllib2.urlopen(downloadUrl, timeout=60) \n\
except: pass\n\
\n\
if response is None: \n\
cmds.warning('Error trying to install.')\n\
return \n\
\n\
try:\n\
fileSize = int(response.info().getheaders('Content-Length')[0])\n\
fileSizeDl = 0\n\
blockSize = 128\n\
output = open(saveFile,'wb') \n\
progBar = mel.eval('$tmp = $gMainProgressBar') \n\
\n\
cmds.progressBar( progBar,\n\
edit=True,\n\
beginProgress=True,\n\
status='Downloading Pipeline...',\n\
progress=0,\n\
maxValue=100 ) \n\
\n\
while True:\n\
buffer = response.read(blockSize)\n\
if not buffer:\n\
output.close()\n\
cmds.progressBar(progBar, edit=True, progress=100) \n\
cmds.progressBar(progBar, edit=True, endProgress=True) \n\
break\n\
\n\
fileSizeDl += len(buffer)\n\
output.write(buffer)\n\
p = float(fileSizeDl) / fileSize *100\n\
\n\
cmds.progressBar(progBar, edit=True, progress=p) \n\
\n\
except:\n\
output = open(saveFile,'wb')\n\
output.write(response.read())\n\
output.close()\n\
return output\n\
launchInstall()\n\
\n\
currentShelf = cmds.tabLayout(mel.eval('$nul=$gShelfTopLevel'),q=1,st=1)\n\
def find():\n\
buttons = [b for b in cmds.shelfLayout(currentShelf, q=True, ca=True) if 'separator' not in b]\n\
for b in buttons:\n\
if cmds.shelfButton(b, q=True, l=True) == 'pipeline':\n\
return True\n\
break\n\
\n\
if not find():\n\
cmds.shelfButton(parent=currentShelf,i=os.path.join(os.environ['MAYA_APP_DIR'],cmds.about(version=True),'scripts','pipeline','pipeline_logo32.svg'),label='pipeline',c='import pipeline;pipeline.start()',annotation='Pipeline 2')\n\
");