fix install

This commit is contained in:
j 2016-02-01 01:11:23 +05:30
parent 62f9daf16f
commit 3d473b8765
3 changed files with 23 additions and 9 deletions

2
.gitignore vendored
View file

@ -5,3 +5,5 @@
__pycache__
pip_cache
.DS_Store
build
dist

View file

@ -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:

View file

@ -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)