Author: dmeyer
Date: Sat Feb 10 20:47:55 2007
New Revision: 9201

Modified:
   trunk/core/src/conf.py

Log:
log and data file cleanup

Modified: trunk/core/src/conf.py
==============================================================================
--- trunk/core/src/conf.py      (original)
+++ trunk/core/src/conf.py      Sat Feb 10 20:47:55 2007
@@ -221,11 +221,6 @@
 # Directories were to search the config file
 cfgfilepath = [ '.', os.path.expanduser('~/.' + application), '/etc/' + 
application ]
 
-SHAREDIR = ''
-
-DATADIR  = '/var/lib/' + application
-LOGDIR   = '/var/log/' + application
-
 # directory for 'share' files
 base = os.path.normpath(os.path.join(os.path.dirname(__file__), '../../../..'))
 SHAREDIR = os.path.abspath(os.path.join(base, 'share', application))
@@ -242,27 +237,9 @@
 i18n.install(unicode=True)
 
 # create needed directories.
-# FIXME: make sure we can write to them
-
-# create datadir if not in setup mode
-if not os.path.isdir(DATADIR):
-    try:
-        if not 'setup.py' in sys.argv[:2]:
-            os.makedirs(DATADIR)
-    except OSError:
-        DATADIR = os.path.expanduser('~/.' + application + '/lib')
-        if not os.path.isdir(DATADIR):
-            os.makedirs(DATADIR)
-
-# create logdir
-if not os.path.isdir(LOGDIR):
-    try:
-        if not 'setup.py' in sys.argv[:2]:
-            os.makedirs(LOGDIR)
-    except OSError:
-        LOGDIR = os.path.expanduser('~/.' + application + '/log')
-        if not os.path.isdir(LOGDIR):
-            os.makedirs(LOGDIR)
+DATADIR = os.path.expanduser('~/.' + application + '/data')
+if not os.path.isdir(DATADIR) and not 'setup.py' in sys.argv[:2]:
+    os.makedirs(DATADIR)
 
 # create and setup the root logger object.
 # using logging.getLogger() gives the root logger, calling
@@ -288,13 +265,23 @@
 formatter = logging.Formatter('%(asctime)s %(levelname)-8s [%(name)6s] '+\
                               '%(filename)s %(lineno)s: '+\
                               '%(message)s')
-syslogfile = os.path.splitext(os.path.basename(sys.argv[0]))[0]
-if syslogfile.startswith('freevo-'):
-    syslogfile = syslogfile[7:]
+logfiletmpl = os.path.splitext(os.path.basename(sys.argv[0]))[0]
+if logfiletmpl.startswith('freevo-'):
+    logfiletmpl = logfiletmpl[7:]
 
-syslogfile = '%s/%s-%s' % (LOGDIR, syslogfile, os.getuid())
 if not 'setup.py' in sys.argv[:2]:
-    handler = RotatingFileHandler(syslogfile, maxBytes=1000000, backupCount=2)
+    logdir = '/var/log/' + application
+    logfile = '%s/%s-%s' % (logdir, logfiletmpl, os.getuid())
+    try:
+        if not os.path.isdir(logdir):
+            os.makedirs(logdir)
+        handler = RotatingFileHandler(logfile, maxBytes=1000000, backupCount=2)
+    except (OSError, IOError):
+        logdir = os.path.expanduser('~/.' + application + '/log')
+        logfile = '%s/%s-%s' % (logdir, logfiletmpl, os.getuid())
+        if not os.path.isdir(logdir):
+            os.makedirs(logdir)
+        handler = RotatingFileHandler(logfile, maxBytes=1000000, backupCount=2)
     handler.setFormatter(formatter)
     logger.addHandler(handler)
 

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to