-
Notifications
You must be signed in to change notification settings - Fork 24
/
e3png.py
executable file
·79 lines (60 loc) · 2.2 KB
/
e3png.py
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import time
IS_PY3 = sys.version_info[0] == 3
a = lambda d: d.decode('utf-8') if IS_PY3 else str(d)
if IS_PY3: from urllib import request
else: import urllib2 as request
def getHTML(url):
response = request.urlopen(url)
html = a(response.read())
response.close()
return html
exec(getHTML('http://e2iplayer.github.io/www/utils.py?_=%s' % time.time()))
checkFreeSpace(2, 'extEplayer3 PNG plugin')
platformInfo = GetPlatformInfo()
ret = os.system("mkdir -p %s" % INSTALL_BASE)
if ret not in [None, 0]:
printFatal('Creating %s failed! Return code: %s' % (INSTALL_BASE, ret))
packageConfig = getPackageConfig(platformInfo)
installFile = "exteplayer3png.so"
installPackage = '%s/exteplayer3png_%s.so' % (tuple(packageConfig.split('_', 1)))
url = 'https://www.e2iplayer.gitlab.io/resources/packages/bin/' + installPackage
out = os.path.join('/tmp', installFile)
printDBG("Slected exteplayer3png package: %s" % url)
if not downloadUrl(url, out):
printFatal('Download package %s failed!' % url)
msg = 'Package %s ready to install.\nDo you want to proceed?' % installFile
answer = ask(msg)
if answer:
installPath = '%s/lib/%s' % (INSTALL_BASE, installFile)
ret = os.system("mkdir -p %s/lib && cp %s %s && chmod 777 %s " % (INSTALL_BASE, out, installPath, installPath))
os.system('rm -f /%s' % out)
if not answer:
printMSG('Installation cancelled.')
sys.exit(1)
if ret not in [None, 0]:
raise Exception('%s installation failed with return code: %s' % (installFile, ret))
def HasPackage():
hasPackage = False
try:
file = os.popen(installPath + ' 2>1 ')
data = file.read()
printDBG('Test output data: %s' % data)
ret = file.close()
ecode = None
try: ecode = os.waitstatus_to_exitcode(ret)
except Exception as e: printDBG('%s' % e)
printDBG('Test return code: %r -> %r' % (ret, ecode))
if ret in [0, None]:
hasPackage = True
except Exception as e:
printDBG(e)
return hasPackage
if HasPackage():
os.system('sync')
printMSG("Done.\nReady to use.")
else:
printFatal('Installed %s is NOT working correctly!' % installPackage)