Bug#632041: [Piuparts-devel] Bug#632041: Bug#632041: Bug#632041: piuparts: Provide state of running master

2013-01-01 Thread Holger Levsen
Hi Scott,

happy new year! :-)

On Sonntag, 10. Juli 2011, Scott Schaefer wrote:
> Leave this bug open, and I'll come back to it

ping ;-)


cheers,
Holger


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#632041: [Piuparts-devel] Bug#632041: Bug#632041: piuparts: Provide state of running master

2011-07-10 Thread Scott Schaefer

On 07/10/2011 09:55 AM, Holger Levsen wrote:

Hi,

On Mittwoch, 29. Juni 2011, Scott Schaefer wrote:
   

Primarily as debugging aid, but hopefully also useful in production
environment, the attached patch causes piuparts-master to produce a
"dump" of package states upon receipt of SIGUSR1 (tempfile name
written to configured 'master-directory').
 

master is only running for short times so I don't consider this patch - as it
is - very useful. It should also and most importantly dump state on failure,
or on command-line request - could you please add that? ;-)

   


Yes -- I will do that, though perhaps not for a few weeks.

Another case of (too) little knowledge on my part.  I was assuming MY 
use of piuparts-master (i.e. test the entire archive) was the typical use.


OTOH, I have set of notes from my first review of the code of 5-6 
changes so that it will not simply fail.  But that raises # of other 
issues 


Leave this bug open, and I'll come back to it



Also def __init__(... dir=".") seems to be useless / pampering over an error
which should be caught elsewhere, so better just use dir as it is.


cheers,
Holger



___
Piuparts-devel mailing list
piuparts-de...@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/piuparts-devel
   





--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#632041: [Piuparts-devel] Bug#632041: piuparts: Provide state of running master

2011-07-10 Thread Holger Levsen
Hi,

On Mittwoch, 29. Juni 2011, Scott Schaefer wrote:
> Primarily as debugging aid, but hopefully also useful in production
> environment, the attached patch causes piuparts-master to produce a
> "dump" of package states upon receipt of SIGUSR1 (tempfile name
> written to configured 'master-directory').

master is only running for short times so I don't consider this patch - as it 
is - very useful. It should also and most importantly dump state on failure, 
or on command-line request - could you please add that? ;-)

Also def __init__(... dir=".") seems to be useless / pampering over an error 
which should be caught elsewhere, so better just use dir as it is.


cheers,
Holger



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#632041: piuparts: Provide state of running master

2011-06-29 Thread Scott Schaefer

Package: piuparts
Version: 0.40
Severity: wishlist
Tags: patch


Primarily as debugging aid, but hopefully also useful in production
environment, the attached patch causes piuparts-master to produce a
"dump" of package states upon receipt of SIGUSR1 (tempfile name
written to configured 'master-directory').


-- System Information:
Debian Release: 6.0.1
  APT prefers stable
  APT policy: (990, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-686 (SMP w/4 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages piuparts depends on:
ii  apt 0.8.10.3 Advanced front-end for dpkg
ii  debootstrap 1.0.26+squeeze1  Bootstrap a basic Debian system
ii  lsb-release 3.2-23.2squeeze1 Linux Standard Base version 
report

ii  lsof4.81.dfsg.1-1List open files
ii  python  2.6.6-3+squeeze6 interactive high-level 
object-orie
ii  python-debian   0.1.18   Python modules to work with 
Debian


piuparts recommends no packages.

Versions of packages piuparts suggests:
ii  ghostscript 8.71~dfsg2-9 The GPL Ghostscript 
PostScript/PDF

pn  python-rpy(no description available)

-- no debconf information

diff --git a/piuparts-master.py b/piuparts-master.py
--- a/piuparts-master.py
+++ b/piuparts-master.py
@@ -27,12 +27,24 @@
 import logging
 import ConfigParser
 import os
+import signal
+import tempfile 
 
 import piupartslib
 
 
 CONFIG_FILE = "/etc/piuparts/piuparts.conf"
 
+usr1_flag = 0;
+
+def usr1_handler(signum,frame):
+global usr1_flag
+flag = usr1_flag
+if flag != 1:
+usr1_flag = 1
+if flag == 2:
+   raise IOError;
+
 
 def setup_logging(log_level, log_file_name):
 logger = logging.getLogger()
@@ -111,7 +123,7 @@
 "successfully-tested",
 )
 
-def __init__(self, input, output, packages_file, known_circular_depends="", section=None):
+def __init__(self, input, output, packages_file, known_circular_depends="", section=None, dir="."):
 Protocol.__init__(self, input, output)
 self._commands = {
 "reserve": self._reserve,
@@ -120,6 +132,7 @@
 "fail": self._fail,
 "untestable": self._untestable,
 }
+self.basedir = dir
 self._binary_db = piupartslib.packagesdb.PackagesDB(prefix=section)
 self._binary_db.create_subdirs()
 self._binary_db.read_packages_file(packages_file)
@@ -135,7 +148,19 @@
 self._writeline("hello")
 
 def do_transaction(self):
-line = self._readline()
+global usr1_flag
+flag = usr1_flag
+line = None
+if flag == 0:
+usr1_flag = 2
+try:
+  line = self._readline()
+except IOError:
+  pass
+flag = usr1_flag
+if flag == 2:
+usr1_flag = 0
+
 if line:
 parts = line.split()
 if len(parts) > 0:
@@ -144,16 +169,27 @@
 self._commands[command](command, args)
 return True
 else:
-return False
+if flag == 1:
+(h, fname) = tempfile.mkstemp(suffix='.dmp', dir=self.basedir)
+self.dump_pkgs(h, fname)
+usr1_flag = 0
+return True
+else:
+return False
 
 def _check_args(self, count, command, args):
 if len(args) != count:
 raise CommandSyntaxError("Need exactly %d args: %s %s" %
  (count, command, " ".join(args)))
-def dump_pkgs(self):
- for st in self._binary_db.get_states():
-for pkg in self._binary_db.get_pkg_names_in_state(st):
-logging.debug("%s : %s\n" % (st,pkg))
+
+def dump_pkgs(self, oshndl, filename):
+ f = os.fdopen(oshndl, 'w')
+ if f:
+logging.debug("SIGUSR1: Dumping package states to " + filename)
+for st in self._binary_db.get_states():
+   for pkg in self._binary_db.get_pkg_names_in_state(st):
+   f.write("%s : %s\n" % (pkg,st))
+f.close()
 
 def _reserve(self, command, args):
 self._check_args(0, command, args)
@@ -208,7 +244,8 @@
 packages_file = piupartslib.open_packages_url(config["packages-url"])
 known_circular_depends = config["known_circular_depends"]
 
-m = Master(sys.stdin, sys.stdout, packages_file, known_circular_depends, section=section)
+m = Master(sys.stdin, sys.stdout, packages_file, known_circular_depends, section=section, dir=master_directory)
+signal.signal(signal.SIGUSR1,usr1_handler)
 while m.do_transaction():
 pass
 packages_file.close()