From 3d473b876577579471455a4acc80e1fb0770539a Mon Sep 17 00:00:00 2001 From: j Date: Mon, 1 Feb 2016 01:11:23 +0530 Subject: [PATCH] fix install --- .gitignore | 2 ++ trayicon/Open Media Library.py | 9 ++++----- trayicon/install.py | 21 +++++++++++++++++---- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 10f128e..6359107 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ __pycache__ pip_cache .DS_Store +build +dist diff --git a/trayicon/Open Media Library.py b/trayicon/Open Media Library.py index b5bc338..61d626e 100644 --- a/trayicon/Open Media Library.py +++ b/trayicon/Open Media Library.py @@ -25,7 +25,6 @@ class OMLTrayIcon(object): def __init__(self): launch() name = "Open Media Library" - default_menu_index = 1 self.icon = "ico/oml.ico" self.hover_text = name self.on_quit = quit @@ -40,7 +39,7 @@ class OMLTrayIcon(object): self.menu_actions_by_id = dict(self.menu_actions_by_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 message_map = {win32gui.RegisterWindowMessage("TaskbarCreated"): self.restart, @@ -212,7 +211,7 @@ def check_pid(pid): return True 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') if os.path.exists(pid) and check_pid(pid): 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) webbrowser.open_new_tab(os.path.join(base, 'openmedialibrary', 'static', 'html', 'load.html')) else: - install.run() + install.run(base) 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') if os.path.exists(pid): with open(pid) as fd: diff --git a/trayicon/install.py b/trayicon/install.py index 32bca93..bb3e567 100644 --- a/trayicon/install.py +++ b/trayicon/install.py @@ -72,6 +72,9 @@ class Handler(http.server.SimpleHTTPRequestHandler): self.end_headers() self.wfile.write(content) + def log_message(self, format, *args): + pass + class Install(Thread): release_url = "http://downloads.openmedialibrary.com/release.json" @@ -142,6 +145,19 @@ class Install(Thread): class Server(socketserver.ThreadingMixIn, socketserver.TCPServer): 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): python = os.path.join(base, 'platform_win32', 'pythonw.exe') 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) def run(target): - httpd = Server(("", PORT), Handler) - install = Install(target, httpd) - httpd.install = install - httpd.serve_forever() + return InstallServer(target)