51 """ |
51 """ |
52 self._check_parameter(parameter) |
52 self._check_parameter(parameter) |
53 stderr = Popen((self._bin, '-e', parameter + '=' + str(value)), |
53 stderr = Popen((self._bin, '-e', parameter + '=' + str(value)), |
54 stderr=PIPE).communicate()[1] |
54 stderr=PIPE).communicate()[1] |
55 if stderr: |
55 if stderr: |
56 raise VMMError(stderr.strip(), VMM_ERROR) |
56 raise VMMError(stderr.strip().decode(), VMM_ERROR) |
57 |
57 |
58 def read(self, parameter, expand_vars=True): |
58 def read(self, parameter, expand_vars=True): |
59 """Returns the parameters value. |
59 """Returns the parameters value. |
60 |
60 |
61 If expand_vars is True (default), all variables in the value will be |
61 If expand_vars is True (default), all variables in the value will be |
105 def _read(self, parameter): |
105 def _read(self, parameter): |
106 """Ask postconf for the value of a single configuration parameter.""" |
106 """Ask postconf for the value of a single configuration parameter.""" |
107 stdout, stderr = Popen([self._bin, '-h', parameter], stdout=PIPE, |
107 stdout, stderr = Popen([self._bin, '-h', parameter], stdout=PIPE, |
108 stderr=PIPE).communicate() |
108 stderr=PIPE).communicate() |
109 if stderr: |
109 if stderr: |
110 raise VMMError(stderr.strip(), VMM_ERROR) |
110 raise VMMError(stderr.strip().decode(), VMM_ERROR) |
111 return stdout.strip() |
111 return stdout.strip().decode() |
112 |
112 |
113 def _read_multi(self, parameters): |
113 def _read_multi(self, parameters): |
114 """Ask postconf for multiple configuration parameters. Returns a dict |
114 """Ask postconf for multiple configuration parameters. Returns a dict |
115 parameter: value items.""" |
115 parameter: value items.""" |
116 cmd = [self._bin] |
116 cmd = [self._bin] |
117 cmd.extend(parameter[1:] for parameter in parameters) |
117 cmd.extend(parameter[1:] for parameter in parameters) |
118 stdout, stderr = Popen(cmd, stdout=PIPE, stderr=PIPE).communicate() |
118 stdout, stderr = Popen(cmd, stdout=PIPE, stderr=PIPE).communicate() |
119 if stderr: |
119 if stderr: |
120 raise VMMError(stderr.strip(), VMM_ERROR) |
120 raise VMMError(stderr.strip().decode(), VMM_ERROR) |
121 par_val = {} |
121 par_val = {} |
122 for line in stdout.splitlines(): |
122 for line in stdout.decode().splitlines(): |
123 par, val = line.split(' = ') |
123 par, val = line.split(' = ') |
124 par_val[par] = val |
124 par_val[par] = val |
125 return par_val |
125 return par_val |
126 |
126 |
127 del _ |
127 del _ |