1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-21 18:50:38 +03:00

Handle error of missing control

This commit is contained in:
Игорь Чудов 2019-11-15 16:35:27 +04:00
parent e461b684a3
commit 8e6da8a16a
Signed by untrusted user: nir
GPG Key ID: 0F3883600CAE7AAC
2 changed files with 17 additions and 3 deletions

View File

@ -6,6 +6,8 @@ class control:
self.control_name = name
self.control_value = value
self.possible_values = self._query_control_values()
if self.possible_values == None:
raise Exception('Unable to query possible values')
def _query_control_values(self):
proc = subprocess.Popen(['sudo', 'control', self.control_name, 'list'], stdout=subprocess.PIPE)
@ -13,6 +15,10 @@ class control:
values = line.split()
return values
def _map_control_status(self, int_status):
str_status = self.possible_values[int_status].decode()
return str_status
def get_control_name(self):
return self.control_name
@ -22,6 +28,11 @@ class control:
return line.rstrip('\n\r')
def set_control_status(self):
print('Setting control {} to {}'.format(self.control_name, self.control_value))
proc = subprocess.Popen(['sudo', 'control', self.control_name, status], stdout=subprocess.PIPE)
status = self._map_control_status(self.control_value)
print('Setting control {} to {}'.format(self.control_name, status))
try:
proc = subprocess.Popen(['sudo', 'control', self.control_name, status], stdout=subprocess.PIPE)
except:
print('Unable to set {} to {}'.format(self.control_name, status))

View File

@ -242,7 +242,10 @@ class control_applier(applier_frontend):
self.control_settings = self._get_controls(self.polparsers)
self.controls = []
for setting in self.control_settings:
self.controls.append(control.control(setting.valuename, setting.data))
try:
self.controls.append(control.control(setting.valuename, setting.data))
except:
print('Unable to work with control: {}'.format(setting.valuename))
#for e in polfile.pol_file.entries:
# print('{}:{}:{}:{}:{}'.format(e.type, e.data, e.valuename, e.keyname))