[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. 0.50-90-g8664feb

Andreas Beckmann anbe at debian.org
Sat Apr 13 14:09:37 UTC 2013


The following commit has been merged in the develop branch:
commit e423d1506700d20b3b5bf1b191680741d08deb80
Author: Andreas Beckmann <anbe at debian.org>
Date:   Mon Apr 8 00:56:15 2013 +0200

    p-m: add "section" command to master-slave protocol
    
    Adds support for selecting the section inside the protocol
    instead of requiring a command line parameter.
    Forbid all other commands as long as no section was selected.
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>

diff --git a/piuparts-master-backend.py b/piuparts-master-backend.py
index ce98053..875b479 100644
--- a/piuparts-master-backend.py
+++ b/piuparts-master-backend.py
@@ -134,6 +134,7 @@ class Master(Protocol):
     def __init__(self, input, output, section):
         Protocol.__init__(self, input, output)
         self._commands = {
+            "section": self._switch_section,
             "recycle": self._recycle,
             "idle": self._idle,
             "status": self._status,
@@ -143,6 +144,7 @@ class Master(Protocol):
             "fail": self._fail,
             "untestable": self._untestable,
         }
+        self._section = None
         self._init_section(section)
         self._writeline("hello")
 
@@ -177,6 +179,8 @@ class Master(Protocol):
         # for submitting finished logs
         self._binary_db = piupartslib.packagesdb.PackagesDB(prefix=section)
 
+        return True
+
     def _init_db(self):
         if self._package_databases is not None:
             return
@@ -253,6 +257,8 @@ class Master(Protocol):
             if len(parts) > 0:
                 command = parts[0]
                 args = parts[1:]
+                if self._section is None and command != "section":
+                    raise CommandSyntaxError("Expected 'section' command, got %s" % command)
                 if command in self._commands:
                     self._commands[command](command, args)
                     return True
@@ -269,6 +275,13 @@ class Master(Protocol):
             for name in self._binary_db.get_pkg_names_in_state(st):
                 logging.debug("%s : %s\n" % (st,name))
 
+    def _switch_section(self, command, args):
+        self._check_args(1, command, args)
+        if self._init_section(args[0]):
+            self._short_response("ok")
+        else:
+            self._short_response("error")
+
     def _recycle(self, command, args):
         self._check_args(0, command, args)
         if self._binary_db.enable_recycling():

-- 
piuparts git repository



More information about the Piuparts-commits mailing list