-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRun.py
54 lines (45 loc) · 1.69 KB
/
Run.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
import subprocess
import sys
import os
import shutil
from tempfile import gettempdir
tmp = os.path.join(gettempdir(), '.{}'.format(hash(os.times())))
if not os.path.exists(tmp):
os.makedirs(tmp)
def GetPackage(package):
try:
try:
module = __import__(package)
return module
except Exception:
subprocess.check_call([sys.executable, \
'-m', 'pip', 'install', package])
module = __import__(package)
return module
except Exception as e:
print('Error: %s' % str(e))
if 'requests' not in sys.modules:
requests = GetPackage('requests')
if 'arcade' not in sys.modules:
arcade = GetPackage('arcade')
def GetFile(url, file_name):
FILE = requests.get(url, stream=True)
if FILE.status_code == 200:
FILE.raw.decode_content = True
saved_file = tmp + '\\' + file_name
with open(saved_file, 'wb') as f:
shutil.copyfileobj(FILE.raw, f)
print('%s' % str(saved_file))
return saved_file
else:
print('%s couldn\'t be retreived' % str(file_name))
url_base = 'https://ipfs.io/ipfs/'
file_hash = 'QmaMsJWCKFEpRhK4TBG1GMJQKe4QRkUGFWpdWYedG52QgC'
background_ipfs = 'QmZocCDpmZTundwxqVSW73CZ7kmHFKSrreF7hzzqiB2kcT'
avatar_ipfs = 'QmUg7Hgv4jRcqrFhnhY6DdqKsP9W71ram22GXayZhaDuvE'
coin_ipfs = 'QmVsaqaWAYe4L6Z4uzXka7B3d4jYGrpJEGzZYc2d7oXth5'
HOGE_GAME = GetFile(url_base + file_hash, 'HogeCollector.py')
BACKGROUND_IMAGE = GetFile(url_base + background_ipfs, 'background.png')
AVATAR_IMAGE = GetFile(url_base + avatar_ipfs, 'avatar.png')
COIN_IMAGE = GetFile(url_base + coin_ipfs, 'coin.png')
exec(open(HOGE_GAME).read(), globals())