← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol/openlp/bug-1086987 into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol/openlp/bug-1086987 into lp:openlp.

Commit message:
bzr merge lp:~googol/openlp/bug-1086987 -m "fixed Bug 1086987 (Log system does not log all exceptions)" --fixes lp:1086987

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1086987 in OpenLP: "Log system does not log all exceptions"
  https://bugs.launchpad.net/openlp/+bug/1086987

For more details, see:
https://code.launchpad.net/~googol/openlp/bug-1086987/+merge/144027

Hello,

- fixed Bug 1086987  (Log system does not log all exceptions)

In fact I just ensured that the path to the log file is printed again. I couldn't reproduce the other bug again (although I could ealier today). If I spot it again, I might tackle it.
-- 
https://code.launchpad.net/~googol/openlp/bug-1086987/+merge/144027
Your team OpenLP Core is requested to review the proposed merge of lp:~googol/openlp/bug-1086987 into lp:openlp.
=== modified file 'openlp/core/__init__.py'
--- openlp/core/__init__.py	2012-12-29 20:56:56 +0000
+++ openlp/core/__init__.py	2013-01-20 17:21:20 +0000
@@ -213,7 +213,7 @@
     """
     Setup our logging using log_path
     """
-    check_directory_exists(log_path)
+    check_directory_exists(log_path, True)
     filename = os.path.join(log_path, u'openlp.log')
     logfile = logging.FileHandler(filename, u'w')
     logfile.setFormatter(logging.Formatter(u'%(asctime)s %(name)-55s %(levelname)-8s %(message)s'))
@@ -243,12 +243,6 @@
     # Parse command line options and deal with them.
     # Use args supplied programatically if possible.
     (options, args) = parser.parse_args(args) if args else parser.parse_args()
-    if options.portable:
-        app_path = AppLocation.get_directory(AppLocation.AppDir)
-        set_up_logging(os.path.abspath(os.path.join(app_path, u'..', u'..', u'Other')))
-        log.info(u'Running portable')
-    else:
-        set_up_logging(AppLocation.get_directory(AppLocation.CacheDir))
     qt_args = []
     if options.loglevel.lower() in ['d', 'debug']:
         log.setLevel(logging.DEBUG)
@@ -273,14 +267,16 @@
         app.setApplicationName(u'OpenLPPortable')
         Settings.setDefaultFormat(Settings.IniFormat)
         # Get location OpenLPPortable.ini
+        app_path = AppLocation.get_directory(AppLocation.AppDir)
+        set_up_logging(os.path.abspath(os.path.join(app_path, u'..', u'..', u'Other')))
+        log.info(u'Running portable')
         portable_settings_file = os.path.abspath(os.path.join(app_path, u'..', u'..', u'Data', u'OpenLP.ini'))
         # Make this our settings file
         log.info(u'INI file: %s', portable_settings_file)
         Settings.setFilename(portable_settings_file)
         portable_settings = Settings()
         # Set our data path
-        data_path = os.path.abspath(os.path.join(app_path,
-            u'..', u'..', u'Data',))
+        data_path = os.path.abspath(os.path.join(app_path, u'..', u'..', u'Data',))
         log.info(u'Data path: %s', data_path)
         # Point to our data path
         portable_settings.setValue(u'advanced/data path', data_path)
@@ -288,6 +284,7 @@
         portable_settings.sync()
     else:
         app.setApplicationName(u'OpenLP')
+        set_up_logging(AppLocation.get_directory(AppLocation.CacheDir))
     app.setApplicationVersion(get_application_version()[u'version'])
     # Instance check
     if not options.testing:

=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py	2013-01-02 11:26:21 +0000
+++ openlp/core/lib/__init__.py	2013-01-20 17:21:20 +0000
@@ -415,17 +415,21 @@
     return text
 
 
-def check_directory_exists(dir):
+def check_directory_exists(directory, do_not_log=False):
     """
     Check a theme directory exists and if not create it
 
-    ``dir``
-        Theme directory to make sure exists
+    ``directory``
+        The directory to make sure exists
+
+    ``do_not_log``
+        To not log anything. This is need for the start up, when the log isn't ready.
     """
-    log.debug(u'check_directory_exists %s' % dir)
+    if not do_not_log:
+        log.debug(u'check_directory_exists %s' % directory)
     try:
-        if not os.path.exists(dir):
-            os.makedirs(dir)
+        if not os.path.exists(directory):
+            os.makedirs(directory)
     except IOError:
         pass
 

=== modified file 'openlp/core/utils/__init__.py'
--- openlp/core/utils/__init__.py	2013-01-15 21:52:26 +0000
+++ openlp/core/utils/__init__.py	2013-01-20 17:21:20 +0000
@@ -154,16 +154,13 @@
             return os.path.join(unicode(os.getenv(u'APPDATA'), encoding), u'openlp', u'data')
         elif dir_type == AppLocation.LanguageDir:
             return os.path.split(openlp.__file__)[0]
-        return os.path.join(unicode(os.getenv(u'APPDATA'), encoding),
-            u'openlp')
+        return os.path.join(unicode(os.getenv(u'APPDATA'), encoding), u'openlp')
     elif sys.platform == u'darwin':
         if dir_type == AppLocation.DataDir:
-            return os.path.join(unicode(os.getenv(u'HOME'), encoding),
-                u'Library', u'Application Support', u'openlp', u'Data')
+            return os.path.join(unicode(os.getenv(u'HOME'), encoding), u'Library', u'Application Support', u'openlp', u'Data')
         elif dir_type == AppLocation.LanguageDir:
             return os.path.split(openlp.__file__)[0]
-        return os.path.join(unicode(os.getenv(u'HOME'), encoding),
-            u'Library', u'Application Support', u'openlp')
+        return os.path.join(unicode(os.getenv(u'HOME'), encoding), u'Library', u'Application Support', u'openlp')
     else:
         if dir_type == AppLocation.LanguageDir:
             prefixes = [u'/usr/local', u'/usr']


References