py2app fixes
This commit is contained in:
@@ -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'))
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -14,7 +14,7 @@ class Env(object):
|
||||
_args = None
|
||||
_quiet = False
|
||||
_deamonize = False
|
||||
_version = 0.5
|
||||
_desktop = None
|
||||
|
||||
''' Data paths and directories '''
|
||||
_app_dir = ""
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
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 == '':
|
||||
|
||||
Reference in New Issue
Block a user