py2app fixes

This commit is contained in:
Ruud committed 2012-01-14 12:08:39 +01:00
1 parent 66dfe75f73
commit 57101ae6eb
4 files changed
+21 -21

No files matched your search

+8 -10
View File
@@ -1,4 +1,3 @@
from couchpotato import app
from couchpotato.api import addApiView from couchpotato.api import addApiView
from couchpotato.core.event import fireEvent, addEvent from couchpotato.core.event import fireEvent, addEvent
from couchpotato.core.helpers.request import jsonified 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.core.plugins.base import Plugin
from couchpotato.environment import Env from couchpotato.environment import Env
from flask import request from flask import request
from flask.helpers import url_for
import os import os
import time import time
import traceback import traceback
@@ -29,6 +27,7 @@ class Core(Plugin):
addEvent('app.crappy_restart', self.crappyRestart) addEvent('app.crappy_restart', self.crappyRestart)
addEvent('app.load', self.launchBrowser, priority = 1) addEvent('app.load', self.launchBrowser, priority = 1)
addEvent('app.base_url', self.createBaseUrl) addEvent('app.base_url', self.createBaseUrl)
addEvent('app.api_url', self.createApiUrl)
addEvent('setting.save.core.password', self.md5Password) addEvent('setting.save.core.password', self.md5Password)
@@ -43,16 +42,10 @@ class Core(Plugin):
}) })
def crappyShutdown(self): def crappyShutdown(self):
ctx = app.test_request_context() self.urlopen('%sapp.shutdown' % self.createApiUrl())
ctx.push()
self.urlopen('%s%sapp.shutdown' % (fireEvent('app.base_url', single = True), url_for('api.index')))
ctx.pop()
def crappyRestart(self): def crappyRestart(self):
ctx = app.test_request_context() self.urlopen('%sapp.restart' % self.createApiUrl())
ctx.push()
self.urlopen('%s%sapp.restart' % (fireEvent('app.base_url', single = True), url_for('api.index')))
ctx.pop()
def shutdown(self): def shutdown(self):
self.initShutdown() self.initShutdown()
@@ -63,6 +56,7 @@ class Core(Plugin):
return 'restarting' return 'restarting'
def initShutdown(self, restart = False): def initShutdown(self, restart = False):
log.info('Shutting down' if not restart else 'Restarting')
fireEvent('app.shutdown') fireEvent('app.shutdown')
@@ -122,3 +116,7 @@ class Core(Plugin):
port = Env.setting('port') port = Env.setting('port')
return '%s:%d' % (cleanHost(host).rstrip('/'), int(port)) return '%s:%d' % (cleanHost(host).rstrip('/'), int(port))
def createApiUrl(self):
return '%s/%s/' % (self.createBaseUrl(), Env.setting('api_key'))
+11 -8
View File
@@ -7,25 +7,28 @@ log = CPLog(__name__)
if Env.get('desktop'): if Env.get('desktop'):
#import os
#import sys
import wx
class Desktop(Plugin): class Desktop(Plugin):
def __init__(self): def __init__(self):
desktop = Env.get('desktop') desktop = Env.get('desktop')
desktop.setSettings({ 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): # Events from desktop
return fireEvent('app.crappy_shutdown') desktop.addEvents({
desktop.close_handler = onClose 'onClose': self.onClose,
})
# Events to desktop
addEvent('app.after_shutdown', desktop.afterShutdown) addEvent('app.after_shutdown', desktop.afterShutdown)
def onClose(self, event):
return fireEvent('app.crappy_shutdown', single = True)
else: else:
class Desktop(Plugin): class Desktop(Plugin):
+1 -1
View File
@@ -14,7 +14,7 @@ class Env(object):
_args = None _args = None
_quiet = False _quiet = False
_deamonize = False _deamonize = False
_version = 0.5 _desktop = None
''' Data paths and directories ''' ''' Data paths and directories '''
_app_dir = "" _app_dir = ""
+1 -2
View File
@@ -18,7 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
import ntpath
import os.path import os.path
@@ -45,7 +44,7 @@ def split_path(path):
""" """
result = [] result = []
while True: while True:
head, tail = ntpath.split(path) head, tail = os.path.split(path)
# on Unix systems, the root folder is '/' # on Unix systems, the root folder is '/'
if head == '/' and tail == '': if head == '/' and tail == '':