コード例 #1
0
 def on_action_connect_activate(self, action):
     """Establish the connection for the destination"""
     selected_row = get_treeview_selected_row(self.ui.tvw_connections)
     if selected_row and not self.is_selected_row_host():
         host = self.hosts[self.model_hosts.get_key(
             self.ui.store_hosts.iter_parent(selected_row))]
         destination_name = self.model_hosts.get_key(selected_row)
         destination = host.destinations[destination_name]
         description = self.model_hosts.get_association(selected_row)
         service_name = self.model_hosts.get_service(selected_row)
         service_arguments = self.model_hosts.get_arguments(selected_row)
         arguments = json.loads(service_arguments)
         association = host.find_association(description=description,
                                             destination=destination.name,
                                             service=service_name,
                                             arguments=arguments)
         if service_name in model_services.services:
             service = model_services.services[service_name]
             command = service.command
             # Prepares the arguments
             arguments_map = {}
             arguments_map['address'] = destination.value
             for key in association.service_arguments:
                 arguments_map[key] = association.service_arguments[key]
             # Execute command
             try:
                 command = command.format(**arguments_map)
                 processes.processes.add_process(host, destination, service,
                                                 command)
             except KeyError as error:
                 # An error occurred processing the command
                 error_msg1 = _('Connection open failed')
                 error_msg2 = _('An error occurred processing the '
                                'service command.')
                 show_message_dialog(class_=UIMessageDialogClose,
                                     parent=self.ui.win_main,
                                     message_type=Gtk.MessageType.ERROR,
                                     title=None,
                                     msg1=error_msg1,
                                     msg2=error_msg2,
                                     is_response_id=None)
                 debug.add_error(error_msg2)
                 debug.add_error('Host: "%s"' % host.name)
                 debug.add_error('Destination name: "%s"' %
                                 destination.name)
                 debug.add_error('Destination value: "%s"' %
                                 destination.value)
                 debug.add_error('Service: %s' % service.name),
                 debug.add_error('Command: "%s"' % command)
         else:
             debug.add_warning('service %s not found' % service_name)
コード例 #2
0
ファイル: services.py プロジェクト: muflone/gCentralAccess
 def on_action_remove_activate(self, action):
     """Remove the selected service"""
     selected_row = get_treeview_selected_row(self.ui.tvw_services)
     if selected_row and show_message_dialog(
             class_=UIMessageDialogNoYes,
             parent=self.ui.dialog_services,
             message_type=Gtk.MessageType.WARNING,
             title=None,
             msg1=_("Remove service"),
             msg2=_("Remove the selected service?"),
             is_response_id=Gtk.ResponseType.YES):
         self.model.remove(selected_row)
コード例 #3
0
 def on_action_delete_activate(self, action):
     """Remove the selected host"""
     selected_row = get_treeview_selected_row(self.ui.tvw_connections)
     if selected_row and show_message_dialog(
             class_=UIMessageDialogNoYes,
             parent=self.ui.win_main,
             message_type=Gtk.MessageType.QUESTION,
             title=None,
             msg1=_("Remove host"),
             msg2=_("Remove the selected host?"),
             is_response_id=Gtk.ResponseType.YES):
         self.remove_host(self.model_hosts.get_key(selected_row))
コード例 #4
0
ファイル: host.py プロジェクト: Cloudxtreme/gCentralAccess
 def on_action_associations_remove_activate(self, action):
     """Remove the selected destination"""
     selected_row = get_treeview_selected_row(self.ui.tvw_associations)
     if selected_row and show_message_dialog(
             class_=UIMessageDialogNoYes,
             parent=self.ui.dialog_host,
             message_type=Gtk.MessageType.QUESTION,
             title=None,
             msg1=_("Remove association"),
             msg2=_("Remove the selected association?"),
             is_response_id=Gtk.ResponseType.YES):
         self.model_associations.remove(selected_row)
コード例 #5
0
ファイル: host.py プロジェクト: muflone/gCentralAccess
 def on_action_associations_remove_activate(self, action):
     """Remove the selected destination"""
     selected_row = get_treeview_selected_row(self.ui.tvw_associations)
     if selected_row and show_message_dialog(
             class_=UIMessageDialogNoYes,
             parent=self.ui.dialog_host,
             message_type=Gtk.MessageType.QUESTION,
             title=None,
             msg1=_("Remove association"),
             msg2=_("Remove the selected association?"),
             is_response_id=Gtk.ResponseType.YES):
         self.model_associations.remove(selected_row)
コード例 #6
0
 def on_action_remove_activate(self, action):
     """Remove the selected service"""
     selected_row = get_treeview_selected_row(self.ui.tvw_arguments)
     if selected_row and show_message_dialog(
             class_=UIMessageDialogNoYes,
             parent=self.ui.dialog_arguments,
             message_type=Gtk.MessageType.WARNING,
             title=None,
             msg1=_("Remove argument"),
             msg2=_("Remove the selected argument?"),
             is_response_id=Gtk.ResponseType.YES):
         self.model_arguments.remove(selected_row)
コード例 #7
0
 def on_action_remove_activate(self, action):
     """Remove the selected group"""
     selected_row = get_treeview_selected_row(self.ui.tvw_groups)
     group_name = self.model.get_key(selected_row) if selected_row else ''
     if selected_row and group_name and show_message_dialog(
             class_=UIMessageDialogNoYes,
             parent=self.ui.dialog_groups,
             message_type=Gtk.MessageType.WARNING,
             title=None,
             msg1=_('Remove the group'),
             msg2=_('Remove the group «%s»?') % group_name,
             is_response_id=Gtk.ResponseType.YES):
         group_path = os.path.join(DIR_HOSTS, group_name)
         # Check for directory not empty
         if len(os.listdir(group_path)) and not show_message_dialog(
                 class_=UIMessageDialogNoYes,
                 parent=self.ui.dialog_groups,
                 message_type=Gtk.MessageType.WARNING,
                 title=None,
                 msg1=_('The group is not empty'),
                 msg2='%s\n%s\n\n%s' % (
                     text('If you delete an item, it will '
                          'be permanently lost.'),
                     _('All the hosts defined for the group will be lost.'),
                     _('Are you sure you want to delete the '
                       'group «%s»?') % group_name,
                 ),
                 is_response_id=Gtk.ResponseType.YES):
             # Exit immediately without deleting the group
             return
         # Delete all the contained files and the directory for the group
         for filename in os.listdir(group_path):
             os.remove(os.path.join(group_path, filename))
         os.rmdir(group_path)
         debug.add_info(_('Removed the group "%s"') % group_name)
         self.model.remove(selected_row)
コード例 #8
0
ファイル: groups.py プロジェクト: muflone/gCentralAccess
 def on_action_remove_activate(self, action):
     """Remove the selected group"""
     selected_row = get_treeview_selected_row(self.ui.tvw_groups)
     group_name = self.model.get_key(selected_row) if selected_row else ''
     if selected_row and group_name and show_message_dialog(
             class_=UIMessageDialogNoYes,
             parent=self.ui.dialog_groups,
             message_type=Gtk.MessageType.WARNING,
             title=None,
             msg1=_('Remove the group'),
             msg2=_('Remove the group «%s»?') % group_name,
             is_response_id=Gtk.ResponseType.YES):
         group_path = os.path.join(DIR_HOSTS, group_name)
         # Check for directory not empty
         if len(os.listdir(group_path)) and not show_message_dialog(
                 class_=UIMessageDialogNoYes,
                 parent=self.ui.dialog_groups,
                 message_type=Gtk.MessageType.WARNING,
                 title=None,
                 msg1=_('The group is not empty'),
                 msg2='%s\n%s\n\n%s' % (
                     text('If you delete an item, it will '
                          'be permanently lost.'),
                     _('All the hosts defined for the group will be lost.'),
                     _('Are you sure you want to delete the '
                       'group «%s»?') % group_name,
                                    ),
                 is_response_id=Gtk.ResponseType.YES):
             # Exit immediately without deleting the group
             return
         # Delete all the contained files and the directory for the group
         for filename in os.listdir(group_path):
             os.remove(os.path.join(group_path, filename))
         os.rmdir(group_path)
         debug.add_info(_('Removed the group "%s"') % group_name)
         self.model.remove(selected_row)