From 57101ae6ebdeca6fdb63964e10a5fad1f6746e5d Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 14 Jan 2012 12:08:39 +0100 Subject: [PATCH] py2app fixes --- couchpotato/core/_base/_core/main.py | 18 ++++++++---------- couchpotato/core/_base/desktop/main.py | 19 +++++++++++-------- couchpotato/environment.py | 2 +- libs/guessit/fileutils.py | 3 +-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/couchpotato/core/_base/_core/main.py b/couchpotato/core/_base/_core/main.py index e9b4bdf5..4c7e75b5 100644 --- a/couchpotato/core/_base/_core/main.py +++ b/couchpotato/core/_base/_core/main.py @@ -1,4 +1,3 @@ -from couchpotato import app from couchpotato.api import addApiView from couchpotato.core.event import fireEvent, addEvent from couchpotato.core.helpers.request import jsonified @@ -7,7 +6,6 @@ from couchpotato.core.logger import CPLog from couchpotato.core.plugins.base import Plugin from couchpotato.environment import Env from flask import request -from flask.helpers import url_for import os import time import traceback @@ -29,6 +27,7 @@ class Core(Plugin): addEvent('app.crappy_restart', self.crappyRestart) addEvent('app.load', self.launchBrowser, priority = 1) addEvent('app.base_url', self.createBaseUrl) + addEvent('app.api_url', self.createApiUrl) addEvent('setting.save.core.password', self.md5Password) @@ -43,16 +42,10 @@ class Core(Plugin): }) def crappyShutdown(self): - ctx = app.test_request_context() - ctx.push() - self.urlopen('%s%sapp.shutdown' % (fireEvent('app.base_url', single = True), url_for('api.index'))) - ctx.pop() + self.urlopen('%sapp.shutdown' % self.createApiUrl()) def crappyRestart(self): - ctx = app.test_request_context() - ctx.push() - self.urlopen('%s%sapp.restart' % (fireEvent('app.base_url', single = True), url_for('api.index'))) - ctx.pop() + self.urlopen('%sapp.restart' % self.createApiUrl()) def shutdown(self): self.initShutdown() @@ -63,6 +56,7 @@ class Core(Plugin): return 'restarting' def initShutdown(self, restart = False): + log.info('Shutting down' if not restart else 'Restarting') fireEvent('app.shutdown') @@ -122,3 +116,7 @@ class Core(Plugin): port = Env.setting('port') return '%s:%d' % (cleanHost(host).rstrip('/'), int(port)) + + def createApiUrl(self): + + return '%s/%s/' % (self.createBaseUrl(), Env.setting('api_key')) diff --git a/couchpotato/core/_base/desktop/main.py b/couchpotato/core/_base/desktop/main.py index bd52dcd5..ce1ff282 100644 --- a/couchpotato/core/_base/desktop/main.py +++ b/couchpotato/core/_base/desktop/main.py @@ -7,25 +7,28 @@ log = CPLog(__name__) if Env.get('desktop'): - #import os - #import sys - import wx - class Desktop(Plugin): def __init__(self): desktop = Env.get('desktop') desktop.setSettings({ - 'url': fireEvent('app.base_url', single = True) + 'base_url': fireEvent('app.base_url', single = True), + 'api_url': fireEvent('app.api_url', single = True), + 'api': Env.setting('api'), }) - def onClose(event): - return fireEvent('app.crappy_shutdown') - desktop.close_handler = onClose + # Events from desktop + desktop.addEvents({ + 'onClose': self.onClose, + }) + # Events to desktop addEvent('app.after_shutdown', desktop.afterShutdown) + def onClose(self, event): + return fireEvent('app.crappy_shutdown', single = True) + else: class Desktop(Plugin): diff --git a/couchpotato/environment.py b/couchpotato/environment.py index c6b427e5..39adb3df 100644 --- a/couchpotato/environment.py +++ b/couchpotato/environment.py @@ -14,7 +14,7 @@ class Env(object): _args = None _quiet = False _deamonize = False - _version = 0.5 + _desktop = None ''' Data paths and directories ''' _app_dir = "" diff --git a/libs/guessit/fileutils.py b/libs/guessit/fileutils.py index 7c07af71..1c263b81 100644 --- a/libs/guessit/fileutils.py +++ b/libs/guessit/fileutils.py @@ -18,7 +18,6 @@ # along with this program. If not, see . # -import ntpath import os.path @@ -45,7 +44,7 @@ def split_path(path): """ result = [] while True: - head, tail = ntpath.split(path) + head, tail = os.path.split(path) # on Unix systems, the root folder is '/' if head == '/' and tail == '':