Browse Source

[2737] Few more occurrences

Few more occurrences of the magic keywords scattered through the code
replaced by constants.
Michal 'vorner' Vaner 12 years ago
parent
commit
d3a0ac2204
2 changed files with 4 additions and 2 deletions
  1. 3 1
      src/bin/cmdctl/cmdctl.py.in
  2. 1 1
      src/lib/python/isc/config/ccsession.py

+ 3 - 1
src/bin/cmdctl/cmdctl.py.in

@@ -42,6 +42,7 @@ import random
 import time
 import time
 import signal
 import signal
 from isc.config import ccsession
 from isc.config import ccsession
+import isc.cc.proto_defs
 import isc.util.process
 import isc.util.process
 import isc.net.parse
 import isc.net.parse
 from optparse import OptionParser, OptionValueError
 from optparse import OptionParser, OptionValueError
@@ -459,7 +460,8 @@ class CommandControl():
                     else:
                     else:
                         return rcode, {}
                         return rcode, {}
                 else:
                 else:
-                    errstr = str(answer['result'][1])
+                    errstr = \
+                        str(answer[isc.cc.proto_defs.CC_PAYLOAD_RESULT][1])
             except ccsession.ModuleCCSessionError as mcse:
             except ccsession.ModuleCCSessionError as mcse:
                 errstr = str("Error in ccsession answer:") + str(mcse)
                 errstr = str("Error in ccsession answer:") + str(mcse)
 
 

+ 1 - 1
src/lib/python/isc/config/ccsession.py

@@ -82,7 +82,7 @@ def parse_answer(msg):
        containing an error message"""
        containing an error message"""
     if type(msg) != dict:
     if type(msg) != dict:
         raise ModuleCCSessionError("Answer message is not a dict: " + str(msg))
         raise ModuleCCSessionError("Answer message is not a dict: " + str(msg))
-    if 'result' not in msg:
+    if CC_PAYLOAD_RESULT not in msg:
         raise ModuleCCSessionError("answer message does not contain 'result' element")
         raise ModuleCCSessionError("answer message does not contain 'result' element")
     elif type(msg[CC_PAYLOAD_RESULT]) != list:
     elif type(msg[CC_PAYLOAD_RESULT]) != list:
         raise ModuleCCSessionError("wrong result type in answer message")
         raise ModuleCCSessionError("wrong result type in answer message")