This commit is contained in:
j 2016-01-18 10:53:59 +05:30
parent cd8158de05
commit 0e87b10079
2 changed files with 6 additions and 8 deletions

11
install
View file

@ -10,8 +10,7 @@ from urllib.request import urlopen
from threading import Thread from threading import Thread
import subprocess import subprocess
def makefolder(path): def makedirs(dirname):
dirname = os.path.dirname(path)
if not os.path.exists(dirname): if not os.path.exists(dirname):
os.makedirs(dirname) os.makedirs(dirname)
@ -92,8 +91,7 @@ class Install(Thread):
return return
target = self.target target = self.target
target = os.path.normpath(os.path.join(os.path.abspath(target))) target = os.path.normpath(os.path.join(os.path.abspath(target)))
if not os.path.exists(target): makedirs(target)
os.makedirs(target)
os.chdir(target) os.chdir(target)
release = self.get_release() release = self.get_release()
self.status['release'] = release self.status['release'] = release
@ -114,15 +112,16 @@ class Install(Thread):
self.status['installing'] = 'setup' self.status['installing'] = 'setup'
if sys.platform.startswith('linux'): if sys.platform.startswith('linux'):
os.system('./ctl install_launcher') os.system('./ctl install_launcher')
makedirs('config')
with open('config/release.json', 'w') as fd: with open('config/release.json', 'w') as fd:
json.dump(release, fd, indent=2) json.dump(release, fd, indent=2)
os.makedirs('updates') makedirs('updates')
os.system('./ctl setup') os.system('./ctl setup')
self.status['progress'] = 1 self.status['progress'] = 1
self.status['done'] = True self.status['done'] = True
def download(self, url, filename): def download(self, url, filename):
makefolder(filename) makedirs(os.path.dirname(filename))
print('downloading',os.path.basename(filename)) print('downloading',os.path.basename(filename))
with open(filename, 'wb') as f: with open(filename, 'wb') as f:
with closing(urlopen(url)) as u: with closing(urlopen(url)) as u:

View file

@ -86,7 +86,6 @@ def shutdown():
os.unlink(state.PID) os.unlink(state.PID)
def run(): def run():
setup.create_db()
PID = sys.argv[2] if len(sys.argv) > 2 else None PID = sys.argv[2] if len(sys.argv) > 2 else None
if len(sys.argv) > 3 and sys.argv[2] == 'debug': if len(sys.argv) > 3 and sys.argv[2] == 'debug':
PID = sys.argv[3] PID = sys.argv[3]
@ -130,8 +129,8 @@ def run():
(r"(.*)", MainHandler), (r"(.*)", MainHandler),
] ]
setup.create_db()
http_server = HTTPServer(Application(handlers, **options)) http_server = HTTPServer(Application(handlers, **options))
http_server.listen(settings.server['port'], settings.server['address']) http_server.listen(settings.server['port'], settings.server['address'])
if PID: if PID: