[Blends-commit] r2986 - in /blends/trunk/webtools: blendstasktools.py tasks.py

tille at users.alioth.debian.org tille at users.alioth.debian.org
Mon Oct 24 13:52:16 UTC 2011


Author: tille
Date: Mon Oct 24 13:52:16 2011
New Revision: 2986

URL: http://svn.debian.org/wsvn/blends/?sc=1&rev=2986
Log:
Write locking messages to apropriate logfiles rather than stderr; alioth admins are not keen to install python-psutil - so lets ignore the locking feature then (and keep on stressing UDD hard :-()

Modified:
    blends/trunk/webtools/blendstasktools.py
    blends/trunk/webtools/tasks.py

Modified: blends/trunk/webtools/blendstasktools.py
URL: http://svn.debian.org/wsvn/blends/blends/trunk/webtools/blendstasktools.py?rev=2986&op=diff
==============================================================================
--- blends/trunk/webtools/blendstasktools.py (original)
+++ blends/trunk/webtools/blendstasktools.py Mon Oct 24 13:52:16 2011
@@ -205,22 +205,29 @@
                         'non-free' : 'non-free'
             }
 
-import psutil
+try:
+    import psutil
+    has_psutils=True
+except ImportError:
+    has_psutils=False
 
 LOCKFILE='/var/lock/blends.lock'
 def LockBlendsTools():
     """Locking mechanism to make sure the scripts will not run in parallel
        which happened because of IO problems on udd.debian.org"""
+    if not has_psutils:
+	logger.warning("Package python-psutil is missing.  No locking support available")
+	return
     if os.path.exists(LOCKFILE):
         try:
             lf = open(LOCKFILE, 'r')
             pid = int(lf.readline())
             lf.close()
             if pid in psutil.get_pid_list():
-                print >>stderr, "Another process rebuilding web sentinal pages with PID %i is running. Exit." % pid
+                logger.error("Another process rebuilding web sentinal pages with PID %i is running. Exit." % pid)
                 exit()
             else:
-                print >>stderr, "Warning: Process with PID %i is not running any more but lockfile remained.  Removing %s ..." % (pid, LOCKFILE)
+                logger.warning("Process with PID %i is not running any more but lockfile remained.  Removing %s ..." % (pid, LOCKFILE))
                 os.unlink(LOCKFILE)
         except IOError as e:
             pass
@@ -676,6 +683,8 @@
         formatter = logging.Formatter("%(levelname)s - %(filename)s (%(lineno)d): %(message)s")
         handler.setFormatter(formatter)
         logger.addHandler(handler)
+
+	LockBlendsTools()
 
         # This Instance of the Available class contains all
         # information about packages that are avialable in Debian

Modified: blends/trunk/webtools/tasks.py
URL: http://svn.debian.org/wsvn/blends/blends/trunk/webtools/tasks.py?rev=2986&op=diff
==============================================================================
--- blends/trunk/webtools/tasks.py (original)
+++ blends/trunk/webtools/tasks.py Mon Oct 24 13:52:16 2011
@@ -17,7 +17,7 @@
 from genshi import Markup
 from genshi.template.eval import UndefinedError
 
-from blendstasktools import Tasks, GetDependencies2Use, pkgstatus, pkgstatus_sortedkeys, LockBlendsTools, UnlockBlendsTools
+from blendstasktools import Tasks, GetDependencies2Use, pkgstatus, pkgstatus_sortedkeys, UnlockBlendsTools
 from blendsunicode   import to_unicode
 from blendslanguages import languages, language_dict
 
@@ -26,7 +26,7 @@
                         % argv[0]
 	exit(-1)
 
-LockBlendsTools()
+# LockBlendsTools() #  logger handler not defined at this moment, needs rethinking ... FIXME
 tasks    = Tasks(argv[1])
 tasks.GetAllDependencies()
 packages = tasks.GetNamesOnlyDict()




More information about the Blends-commit mailing list