diff --git a/Mylar.py b/Mylar.py index cc04f8e1..d22006ca 100644 --- a/Mylar.py +++ b/Mylar.py @@ -16,6 +16,7 @@ import os, sys, locale import time +import threading from lib.configobj import ConfigObj @@ -64,6 +65,7 @@ def main(): parser.add_argument('--config', help='Specify a config file to use') parser.add_argument('--nolaunch', action='store_true', help='Prevent browser from launching on startup') parser.add_argument('--pidfile', help='Create a pid file (only relevant when running as a daemon)') + parser.add_argument('--safe', action='store_true', help='redirect the startup page to point to the Manage Comics screen on startup') args = parser.parse_args() @@ -73,10 +75,28 @@ def main(): mylar.VERBOSE = 0 if args.daemon: - mylar.DAEMON=True - mylar.VERBOSE = 0 - if args.pidfile : - mylar.PIDFILE = args.pidfile + if sys.platform == 'win32': + print "Daemonize not supported under Windows, starting normally" + else: + mylar.DAEMON=True + mylar.VERBOSE=0 + + if args.pidfile : + mylar.PIDFILE = args.pidfile + + # If the pidfile already exists, mylar may still be running, so exit + if os.path.exists(mylar.PIDFILE): + sys.exit("PID file '" + mylar.PIDFILE + "' already exists. Exiting.") + + # The pidfile is only useful in daemon mode, make sure we can write the file properly + if mylar.DAEMON: + try: + file(mylar.PIDFILE, 'w').write("pid\n") + except IOError, e: + raise SystemExit("Unable to write PID file: %s [%d]" % (e.strerror, e.errno)) + else: + logger.warn("Not running in daemon mode. PID file creation disabled.") + if args.datadir: mylar.DATA_DIR = args.datadir @@ -88,6 +108,11 @@ def main(): else: mylar.CONFIG_FILE = os.path.join(mylar.DATA_DIR, 'config.ini') + if args.safe: + mylar.SAFESTART = True + else: + mylar.SAFESTART = False + # Try to create the DATA_DIR if it doesn't exist #if not os.path.exists(mylar.DATA_DIR): # try: @@ -105,6 +130,9 @@ def main(): mylar.DB_FILE = os.path.join(mylar.DATA_DIR, 'mylar.db') mylar.CFG = ConfigObj(mylar.CONFIG_FILE, encoding='utf-8') + + # Rename the main thread + threading.currentThread().name = "MAIN" # Read config & start logging mylar.initialize() diff --git a/data/interfaces/default/base.html b/data/interfaces/default/base.html index 2205f0c3..462cdce1 100755 --- a/data/interfaces/default/base.html +++ b/data/interfaces/default/base.html @@ -109,6 +109,7 @@ +

*Use this if experiencing parsing problems* @@ -331,6 +333,10 @@
+
+ + +
@@ -386,6 +392,7 @@ (Mins) Force RSS +
<% rss_last=mylar.RSS_LASTRUN %>last run: ${rss_last}
@@ -502,6 +509,7 @@
+ Timestamp Level + Thread Message @@ -37,15 +39,19 @@ %for line in lineList: <% timestamp, message, level, threadname = line - + if level == 'WARNING' or level == 'ERROR': grade = 'X' else: grade = 'Z' + + if threadname is None: + threadname = '' %> ${timestamp} ${level} + ${threadname} ${message} %endfor diff --git a/data/interfaces/default/manage.html b/data/interfaces/default/manage.html index abd380f7..e946f279 100755 --- a/data/interfaces/default/manage.html +++ b/data/interfaces/default/manage.html @@ -134,6 +134,7 @@ <%def name="javascriptIncludes()"> +