[Git][NTPsec/ntpsec][master] In pyntpq, abstract away the detail of a positive config response.

Eric S. Raymond gitlab at mg.gitlab.com
Tue Nov 1 11:00:24 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
272c1e84 by Eric S. Raymond at 2016-11-01T06:59:29-04:00
In pyntpq, abstract away the detail of a positive config response.

- - - - -


2 changed files:

- ntpq/pyntpq
- pylib/packet.py


Changes:

=====================================
ntpq/pyntpq
=====================================
--- a/ntpq/pyntpq
+++ b/ntpq/pyntpq
@@ -1141,8 +1141,8 @@ usage: lopeers
         if self.debug > 2:
             self.warn("In Config\nKeyword = :config\nCommand = %s\n" % line)
         try:
-            response = self.session.config(line)
-            m = re.match("column ([0-9]+) syntax error", response)
+            self.session.config(line)
+            m = re.match("column ([0-9]+) syntax error", self.session.response)
             if m:
                 col = int(m.group(1))
                 if col >= 0 and col <= len(line):
@@ -1152,7 +1152,7 @@ usage: lopeers
                         self.say(line + "\n")
                     self.say("_" * (col- 1))
                 self.say("^\n")
-            self.say(response + "\n")
+            self.say(self.session.response + "\n")
         except Mode6Exception as e:
             print(e.message)
 


=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -692,7 +692,7 @@ class Mode6Session:
         return collections.OrderedDict(items)
 
     def config(self, configtext):
-        "Send configuration text to the daemon."
+        "Send configuration text to the daemon. Return True if accepted."
         self.doquery(opcode=CTL_OP_CONFIGURE, qdata=configtext, auth=True)
         # Copes with an implementation error - ntpd uses putdata without
         # setting the size correctly.
@@ -700,6 +700,7 @@ class Mode6Session:
             raise Mode6Exception(SERR_AUTH)
         elif b"\x00" in self.response:
             self.response = self.response[:self.response.index(b"\x00")]
-        return self.response.rstrip()
+        self.response = self.response.rstrip()
+        return self.response == "Config Succeeded"
 
 # end



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/272c1e84a586eaf840dcbfb93665f392a1a93220
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161101/4fd379ee/attachment.html>


More information about the vc mailing list