diff options
author | Angelo Naselli <anaselli@linux.it> | 2015-01-13 19:17:37 +0100 |
---|---|---|
committer | Angelo Naselli <anaselli@linux.it> | 2015-01-13 19:17:37 +0100 |
commit | e3ff92a394b3182f0e654a6a80a05c0102bb76e9 (patch) | |
tree | c331623580e8778ffbe44eded372731dcc01152e /lib | |
parent | eddfc0c31310467bd06e87bd1ccd6343dc1897e5 (diff) | |
download | colin-keep-e3ff92a394b3182f0e654a6a80a05c0102bb76e9.tar colin-keep-e3ff92a394b3182f0e654a6a80a05c0102bb76e9.tar.gz colin-keep-e3ff92a394b3182f0e654a6a80a05c0102bb76e9.tar.bz2 colin-keep-e3ff92a394b3182f0e654a6a80a05c0102bb76e9.tar.xz colin-keep-e3ff92a394b3182f0e654a6a80a05c0102bb76e9.zip |
Do not crash if cannot have privileges
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AdminPanel/Module/Services.pm | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/lib/AdminPanel/Module/Services.pm b/lib/AdminPanel/Module/Services.pm index 4d099c5..9a35397 100644 --- a/lib/AdminPanel/Module/Services.pm +++ b/lib/AdminPanel/Module/Services.pm @@ -504,37 +504,65 @@ sub _servicePanel { $item = $serviceTbl->changedItem(); if ($item) { yui::YUI::app()->busyCursor(); - $self->sh_services->set_service($item->label(), $item->checked()); - # we can push/pop service, but this (slower) should return real situation + eval { + $self->sh_services->set_service($item->label(), $item->checked()); + }; + my $errors = $@; $self->loadServices(); yui::YUI::app()->normalCursor(); + + if ($errors) { + $self->sh_gui->warningMsgBox({ + title => $self->loc->N($item->checked() ? "Enabling %s" : "Disabling %s", $item->label()), + text => "$errors", + richtext => 1, + }); + $dialog->startMultipleChanges(); + $self->_fillServiceTable($serviceTbl); + $dialog->recalcLayout(); + $dialog->doneMultipleChanges(); + } } } } elsif ($widget == $startButton) { $item = $serviceTbl->selectedItem(); if ($item) { - yui::YUI::app()->busyCursor(); my $serviceName = $item->label(); - $self->sh_services->restart_or_start($serviceName); - # we can push/pop service, but this (slower) should return real situation - $self->_waitUnitStatus($serviceName, 1); -# $self->loadServices(); - $self->_serviceStatus($serviceTbl, $item); + yui::YUI::app()->busyCursor(); + eval { + $self->sh_services->restart_or_start($serviceName); + $self->_waitUnitStatus($serviceName, 1); + }; + my $errors = $@; yui::YUI::app()->normalCursor(); + $self->_serviceStatus($serviceTbl, $item); + + $self->sh_gui->warningMsgBox({ + title => $self->loc->N("Starting %s", $serviceName), + text => "$errors", + richtext => 1, + }) if $errors; } } elsif ($widget == $stopButton) { $item = $serviceTbl->selectedItem(); if ($item) { - yui::YUI::app()->busyCursor(); my $serviceName = $item->label(); - $self->sh_services->stopService($serviceName); - # we can push/pop service, but this (slower) should return real situation - $self->_waitUnitStatus($serviceName, 0); -# $self->loadServices(); - $self->_serviceStatus($serviceTbl, $item); + yui::YUI::app()->busyCursor(); + eval { + $self->sh_services->stopService($serviceName); + $self->_waitUnitStatus($serviceName, 0); + }; + my $errors = $@; yui::YUI::app()->normalCursor(); + $self->_serviceStatus($serviceTbl, $item); + + $self->sh_gui->warningMsgBox({ + title => $self->loc->N("Stopping %s", $serviceName), + text => "$errors", + richtext => 1, + }) if $errors; } } elsif ($widget == $refreshButton) { |