From ac0d9b012e70a0054a87e757a37fc6e06d14e8b4 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Fri, 15 May 2020 17:58:27 +0200 Subject: [PATCH] Generalized deemix gui file --- deemix_gui.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ deemix_gui.spec | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 deemix_gui.py create mode 100644 deemix_gui.spec diff --git a/deemix_gui.py b/deemix_gui.py new file mode 100644 index 0000000..bddfaf7 --- /dev/null +++ b/deemix_gui.py @@ -0,0 +1,48 @@ +#!/usr/env/bin python3 +import webview + +from threading import Thread, Lock +import sys +from time import sleep +from server import run_server +from http.client import HTTPConnection +from deemix.utils.localpaths import getConfigFolder + +server_lock = Lock() + +def url_ok(url, port): + try: + conn = HTTPConnection(url, port) + conn.request('GET', '/') + r = conn.getresponse() + return r.status == 200 + except: + print("Server not started") + return False + +if __name__ == '__main__': + url = "127.0.0.1" + if len(sys.argv) >= 2: + port = int(sys.argv[1]) + else: + port = 9666 + t = Thread(target=run_server, args=(port, )) + t.daemon = True + t.start() + + while not url_ok(url, port): + sleep(1) + + window = webview.create_window('deemix', 'http://'+url+':'+str(port)) + if sys.platform == "win32": + from webview.platforms.cef import settings + settings.update({ + 'persist_session_cookies': True, + 'cache_path': getConfigFolder() + }) + webview.start(gui='cef', debug=True) + else: + webview.start(debug=True) + conn = HTTPConnection(url, port) + conn.request('GET', '/shutdown') + t.join() diff --git a/deemix_gui.spec b/deemix_gui.spec new file mode 100644 index 0000000..9690737 --- /dev/null +++ b/deemix_gui.spec @@ -0,0 +1,36 @@ +# -*- mode: python ; coding: utf-8 -*- + +block_cipher = None + + +a = Analysis(['deemix_win.py'], + binaries=[], + datas=[('public', 'public'), ('deemix/app/default.json','deemix/app'), ('./icon.ico', '.')], + hiddenimports=['engineio.async_drivers.threading', 'pkg_resources.py2_warn'], + hookspath=[], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) +exe = EXE(pyz, + a.scripts, + [], + exclude_binaries=True, + name='deemix_win', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + console=True, icon='icon.ico' ) +coll = COLLECT(exe, + a.binaries, + a.zipfiles, + a.datas, + strip=False, + upx=True, + upx_exclude=[], + name='deemix_win')