fix install
This commit is contained in:
parent
62f9daf16f
commit
3d473b8765
3 changed files with 23 additions and 9 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -5,3 +5,5 @@
|
||||||
__pycache__
|
__pycache__
|
||||||
pip_cache
|
pip_cache
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
build
|
||||||
|
dist
|
||||||
|
|
|
@ -25,7 +25,6 @@ class OMLTrayIcon(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
launch()
|
launch()
|
||||||
name = "Open Media Library"
|
name = "Open Media Library"
|
||||||
default_menu_index = 1
|
|
||||||
self.icon = "ico/oml.ico"
|
self.icon = "ico/oml.ico"
|
||||||
self.hover_text = name
|
self.hover_text = name
|
||||||
self.on_quit = quit
|
self.on_quit = quit
|
||||||
|
@ -40,7 +39,7 @@ class OMLTrayIcon(object):
|
||||||
self.menu_actions_by_id = dict(self.menu_actions_by_id)
|
self.menu_actions_by_id = dict(self.menu_actions_by_id)
|
||||||
del self._next_action_id
|
del self._next_action_id
|
||||||
|
|
||||||
self.default_menu_index = (default_menu_index or 0)
|
self.default_menu_index = 0
|
||||||
self.window_class_name = name
|
self.window_class_name = name
|
||||||
|
|
||||||
message_map = {win32gui.RegisterWindowMessage("TaskbarCreated"): self.restart,
|
message_map = {win32gui.RegisterWindowMessage("TaskbarCreated"): self.restart,
|
||||||
|
@ -212,7 +211,7 @@ def check_pid(pid):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def launch(sysTrayIcon=None):
|
def launch(sysTrayIcon=None):
|
||||||
base = os.path.join(os.getenv('APPDATA'), 'Open Media Library')
|
base = os.path.join(os.getenv('LOCALAPPDATA'), 'Open Media Library')
|
||||||
pid = os.path.join(base, 'data', 'openmedialibrary.pid')
|
pid = os.path.join(base, 'data', 'openmedialibrary.pid')
|
||||||
if os.path.exists(pid) and check_pid(pid):
|
if os.path.exists(pid) and check_pid(pid):
|
||||||
webbrowser.open_new_tab(os.path.join(base, 'openmedialibrary', 'static', 'html', 'load.html'))
|
webbrowser.open_new_tab(os.path.join(base, 'openmedialibrary', 'static', 'html', 'load.html'))
|
||||||
|
@ -222,10 +221,10 @@ def launch(sysTrayIcon=None):
|
||||||
subprocess.Popen([python, 'oml', 'server', pid], cwd=oml, start_new_session=True)
|
subprocess.Popen([python, 'oml', 'server', pid], cwd=oml, start_new_session=True)
|
||||||
webbrowser.open_new_tab(os.path.join(base, 'openmedialibrary', 'static', 'html', 'load.html'))
|
webbrowser.open_new_tab(os.path.join(base, 'openmedialibrary', 'static', 'html', 'load.html'))
|
||||||
else:
|
else:
|
||||||
install.run()
|
install.run(base)
|
||||||
|
|
||||||
def quit(sysTrayIcon):
|
def quit(sysTrayIcon):
|
||||||
base = os.path.join(os.getenv('APPDATA'), 'Open Media Library')
|
base = os.path.join(os.getenv('LOCALAPPDATA'), 'Open Media Library')
|
||||||
pid = os.path.join(base, 'data', 'openmedialibrary.pid')
|
pid = os.path.join(base, 'data', 'openmedialibrary.pid')
|
||||||
if os.path.exists(pid):
|
if os.path.exists(pid):
|
||||||
with open(pid) as fd:
|
with open(pid) as fd:
|
||||||
|
|
|
@ -72,6 +72,9 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(content)
|
self.wfile.write(content)
|
||||||
|
|
||||||
|
def log_message(self, format, *args):
|
||||||
|
pass
|
||||||
|
|
||||||
class Install(Thread):
|
class Install(Thread):
|
||||||
|
|
||||||
release_url = "http://downloads.openmedialibrary.com/release.json"
|
release_url = "http://downloads.openmedialibrary.com/release.json"
|
||||||
|
@ -142,6 +145,19 @@ class Install(Thread):
|
||||||
class Server(socketserver.ThreadingMixIn, socketserver.TCPServer):
|
class Server(socketserver.ThreadingMixIn, socketserver.TCPServer):
|
||||||
allow_reuse_address = True
|
allow_reuse_address = True
|
||||||
|
|
||||||
|
class InstallServer(Thread):
|
||||||
|
def __init__(self, target):
|
||||||
|
self.target = target
|
||||||
|
Thread.__init__(self)
|
||||||
|
self.daemon = True
|
||||||
|
self.start()
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
httpd = Server(("127.0.0.1", PORT), Handler)
|
||||||
|
install = Install(self.target, httpd)
|
||||||
|
httpd.install = install
|
||||||
|
httpd.serve_forever()
|
||||||
|
|
||||||
def open_oml(base):
|
def open_oml(base):
|
||||||
python = os.path.join(base, 'platform_win32', 'pythonw.exe')
|
python = os.path.join(base, 'platform_win32', 'pythonw.exe')
|
||||||
pid = os.path.join(base, 'data', 'openmedialibrary.pid')
|
pid = os.path.join(base, 'data', 'openmedialibrary.pid')
|
||||||
|
@ -149,7 +165,4 @@ def open_oml(base):
|
||||||
subprocess.Popen([python, 'oml', 'server', pid], cwd=oml, start_new_session=True)
|
subprocess.Popen([python, 'oml', 'server', pid], cwd=oml, start_new_session=True)
|
||||||
|
|
||||||
def run(target):
|
def run(target):
|
||||||
httpd = Server(("", PORT), Handler)
|
return InstallServer(target)
|
||||||
install = Install(target, httpd)
|
|
||||||
httpd.install = install
|
|
||||||
httpd.serve_forever()
|
|
||||||
|
|
Loading…
Reference in a new issue