This commit is contained in:
Tim Bentley 2010-02-21 13:59:43 +00:00
commit 00a16e01a1
6 changed files with 59 additions and 52 deletions

View File

@ -35,7 +35,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver, str_to_bool
from openlp.core.resources import qInitResources
from openlp.core.ui import MainWindow, SplashScreen, ScreenList
from openlp.core.utils import ConfigHelper
from openlp.core.utils import get_config_directory, ConfigHelper
log = logging.getLogger()
@ -158,7 +158,7 @@ def main():
parser.add_option("-s", "--style", dest="style",
help="Set the Qt4 style (passed directly to Qt4).")
# Set up logging
filename = u'openlp.log'
filename = os.path.join(get_config_directory(), u'openlp.log')
logfile = FileHandler(filename, u'w')
logfile.setFormatter(logging.Formatter(
u'%(asctime)s %(name)-15s %(levelname)-8s %(message)s'))

View File

@ -22,17 +22,12 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
import os
import logging
import urllib2
from datetime import datetime
from registry import Registry
from confighelper import ConfigHelper
log = logging.getLogger(__name__)
__all__ = ['Registry', 'ConfigHelper']
log = logging.getLogger(__name__)
def check_latest_version(config, current_version):
@ -54,3 +49,40 @@ def check_latest_version(config, current_version):
if hasattr(e, u'reason'):
log.exception(u'Reason for failure: %s', e.reason)
return version_string
def get_config_directory():
path = u''
if os.name == u'nt':
path = os.path.join(os.getenv(u'APPDATA'), u'openlp')
elif os.name == u'mac':
path = os.path.join(os.getenv(u'HOME'), u'Library',
u'Application Support', u'openlp')
else:
try:
from xdg import BaseDirectory
path = os.path.join(BaseDirectory.xdg_config_home, u'openlp')
except ImportError:
path = os.path.join(os.getenv(u'HOME'), u'.openlp')
return path
def get_data_directory():
path = u''
if os.name == u'nt':
# ask OS for path to application data, set on Windows XP and Vista
path = os.path.join(os.getenv(u'APPDATA'), u'openlp', u'data')
elif os.name == u'mac':
path = os.path.join(os.getenv(u'HOME'), u'Library',
u'Application Support', u'openlp', u'Data')
else:
try:
from xdg import BaseDirectory
path = os.path.join(BaseDirectory.xdg_data_home, u'openlp')
except ImportError:
path = os.path.join(os.getenv(u'HOME'), u'.openlp', u'data')
return path
from registry import Registry
from confighelper import ConfigHelper
__all__ = [u'Registry', u'ConfigHelper', u'get_config_directory',
u'get_data_directory', u'check_latest_version']

View File

@ -24,6 +24,8 @@
###############################################################################
import os
from openlp.core.utils import get_data_directory, get_config_directory
from openlp.core.utils.registry import Registry
class ConfigHelper(object):
@ -34,20 +36,7 @@ class ConfigHelper(object):
@staticmethod
def get_data_path():
if os.name == u'nt':
# ask OS for path to application data, set on Windows XP and Vista
path = os.path.join(os.getenv(u'APPDATA'), u'openlp', u'data')
elif os.name == u'mac':
path = os.path.join(os.getenv(u'HOME'), u'Library',
u'Application Support', u'openlp', u'Data')
else:
try:
from xdg import BaseDirectory
path = os.path.join(BaseDirectory.xdg_data_home, u'openlp')
except ImportError:
path = os.path.join(os.getenv(u'HOME'), u'.openlp', u'data')
#reg = ConfigHelper.get_registry()
#path = ConfigHelper.get_config(u'main', 'data path', path)
path = get_data_directory()
if not os.path.exists(path):
os.makedirs(path)
return path
@ -81,17 +70,7 @@ class ConfigHelper(object):
current operating system, and returns an instantiation of that class.
"""
if ConfigHelper.__registry__ is None:
config_path = u''
if os.name == u'nt':
config_path = os.path.join(os.getenv(u'APPDATA'), u'openlp')
elif os.name == u'mac':
config_path = os.path.join(os.getenv(u'HOME'), u'Library',
u'Application Support', u'openlp')
else:
try:
from xdg import BaseDirectory
config_path = os.path.join(BaseDirectory.xdg_config_home, u'openlp')
except ImportError:
config_path = os.path.join(os.getenv(u'HOME'), u'.openlp')
config_path = get_config_directory()
ConfigHelper.__registry__ = Registry(config_path)
return ConfigHelper.__registry__
return ConfigHelper.__registry__

View File

@ -201,7 +201,7 @@ class ImpressController(PresentationController):
try:
ctx = resolver.resolve(u'uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext')
except:
log.exception(u'Unable to fine running instance ')
log.exception(u'Unable to find running instance ')
self.start_process()
loop += 1
try:
@ -233,8 +233,8 @@ class ImpressController(PresentationController):
def close_presentation(self):
"""
Close presentation and clean up objects
Triggerent by new object being added to SlideController orOpenLP
being shut down
Triggered by new object being added to SlideController or OpenLP
being shutdown
"""
log.debug(u'close Presentation OpenOffice')
if self.document:

View File

@ -67,8 +67,8 @@ class Controller(object):
def slide(self, slide, live):
log.debug(u'Live = %s, slide' % live)
# if not isLive:
# return
if not live:
return
self.activate()
self.controller.goto_slide(int(slide) + 1)
self.controller.poll_slidenumber(live)
@ -136,11 +136,13 @@ class Controller(object):
self.controller.blank_screen()
def unblank(self):
if not self.is_live:
if not self.isLive:
return
self.activate()
self.controller.unblank_screen()
def poll(self):
self.controller.poll_slidenumber(self.isLive)
class MessageListener(object):
"""
@ -229,16 +231,10 @@ class MessageListener(object):
self.previewHandler.shutdown()
def blank(self):
if self.isLive:
self.liveHandler.blank()
else:
self.previewHandler.blank()
self.liveHandler.blank()
def unblank(self):
if self.isLive:
self.liveHandler.unblank()
else:
self.previewHandler.unblank()
self.liveHandler.unblank()
def splitMessage(self, message):
"""
@ -263,4 +259,4 @@ class MessageListener(object):
return message[0], file, message[4]
def timeout(self):
self.controller.poll_slidenumber(self.is_live)
self.liveHandler.poll()

View File

@ -1 +1 @@
1.9.0-706
1.9.0-710