# -*- coding: ISO-8859-15 -*- | |
# | |
# Fichero: avanzado.py | |
# Copyright: Junta de Andalucia <devmaster@guadalinex.org> | |
# Autor: Maria Dolores Perez Gutierrez y Nestor Chacon Manzano | |
# Fecha: lun mar 27 17:01:15 CET 2006 | |
# Licencia: GPL v.2 | |
# | |
# generated by wxGlade 0.3.5.1 on Tue Nov 22 13:33:24 2005 | |
# | |
# Esta es la interfaz que muestra todos los detalles y que permite asimismo configurarlos | |
# Hay secciones que requieren de mayores conocimientos por parte del usuario que si usa el asistente. | |
from watcherMods import * | |
import wx | |
import wx.grid | |
import wx.lib.buttons | |
# internacionalizacion | |
wx.Locale_AddCatalogLookupPathPrefix("/etc/acept/watcherCat/lang") | |
locale = wx.Locale(wx.LANGUAGE_DEFAULT) | |
a=locale.AddCatalog("acept") | |
_=wx.GetTranslation | |
class MyFrame1(wx.Frame): | |
def __init__(self, *args, **kwds): | |
# begin wxGlade: MyFrame1.__init__ | |
kwds["style"] = wx.DEFAULT_FRAME_STYLE | |
kwds["pos"]=wx.Point(0,0) | |
wx.Frame.__init__(self, *args, **kwds) | |
# Menu Bar | |
self.frame_1_menubar = wx.MenuBar() | |
self.SetMenuBar(self.frame_1_menubar) | |
self.aplicacion = wx.Menu() | |
self.salir = wx.MenuItem(self.aplicacion, 01, _("Salir"), _("Cierra el programa"), wx.ITEM_NORMAL) | |
self.aplicacion.AppendItem(self.salir) | |
self.frame_1_menubar.Append(self.aplicacion, _("Aplicacion")) | |
self.usuarios = wx.Menu() | |
self.horarios = wx.MenuItem(self.usuarios, 11, _("Horarios"), _("Configura el uso temporal de los recursos"), wx.ITEM_NORMAL) | |
self.usuarios.AppendItem(self.horarios) | |
self.contenidos = wx.MenuItem(self.usuarios, 12, _("Contenidos"), _("Configura el filtro de contenidos"), wx.ITEM_NORMAL) | |
self.usuarios.AppendItem(self.contenidos) | |
self.frame_1_menubar.Append(self.usuarios, _("Usuarios")) | |
self.configurar = wx.Menu() | |
self.servicios = wx.MenuItem(self.configurar, 21, _("Servicios"), _("Define nuevos servicios"), wx.ITEM_NORMAL) | |
self.configurar.AppendItem(self.servicios) | |
self.localizacion = wx.MenuItem(self.configurar, 22, _("Listas"), _("Configura diversos aspectos del filtro de contenidos"), wx.ITEM_NORMAL) | |
self.configurar.AppendItem(self.localizacion) | |
self.expresiones = wx.MenuItem(self.configurar, 23, _("Expresiones"), _("Configura el filtrado por expresiones regulares"), wx.ITEM_NORMAL) | |
self.configurar.AppendItem(self.expresiones) | |
self.frame_1_menubar.Append(self.configurar, _("Configurar")) | |
self.estadisticas = wx.Menu() | |
self.generar = wx.MenuItem(self.estadisticas, 31, _("Uso web"), _("Genera las estadisticas de uso"), wx.ITEM_NORMAL) | |
self.apli = wx.MenuItem(self.estadisticas, 32, _("Servicios"), _("Genera las estadisticas de uso"), wx.ITEM_NORMAL) | |
self.estadisticas.AppendItem(self.generar) | |
self.estadisticas.AppendItem(self.apli) | |
self.frame_1_menubar.Append(self.estadisticas, _("Estadisticas")) | |
self.ayuda = wx.Menu() | |
self.sobre = wx.MenuItem(self.ayuda, 42, _("Sobre ACEPT"), _("Datos acerca del programa"), wx.ITEM_NORMAL) | |
self.ayuda.AppendItem(self.sobre) | |
self.frame_1_menubar.Append(self.ayuda, _("Ayuda")) | |
self.padre=self.GetParent() | |
# Menu Bar end | |
self.frame_1_statusbar = self.CreateStatusBar(1, 0) | |
#self.bitmap=wx.StaticBitmap(self,-1,wx.Bitmap("/usr/share/acept/pixmaps/junta+caton.png",wx.BITMAP_TYPE_ANY)) | |
self.__set_properties() | |
self.__do_layout() | |
#Eventos del menu | |
wx.EVT_MENU(self, 01, self.Menu01) | |
wx.EVT_MENU(self, 11, self.Menu11) | |
wx.EVT_MENU(self, 12, self.Menu12) | |
wx.EVT_MENU(self, 21, self.Menu21) | |
wx.EVT_MENU(self, 22, self.Menu22) | |
wx.EVT_MENU(self, 23, self.Menu23) | |
wx.EVT_MENU(self, 31, self.Menu31) | |
wx.EVT_MENU(self, 32, self.Menu32) | |
wx.EVT_MENU(self, 42, self.Menu42) | |
wx.EVT_CLOSE(self,self.Menu01) | |
# end wxGlade# | |
def __set_properties(self): | |
# begin wxGlade: MyFrame1.__set_properties | |
self.SetTitle(_("Configuracion Avanzada")) | |
self.frame_1_statusbar.SetStatusWidths([-1]) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/fondo_junta.gif", wx.BITMAP_TYPE_ANY)) | |
self.SetIcon(_icon) | |
# statusbar fields | |
frame_1_statusbar_fields = [""] | |
for i in range(len(frame_1_statusbar_fields)): | |
self.frame_1_statusbar.SetStatusText(frame_1_statusbar_fields[i], i) | |
#self.SetSize((self.GetSize()[0]+20,self.GetSize()[1])) | |
# end wxGlade | |
def __do_layout(self): | |
# begin wxGlade: MyFrame1.__do_layout | |
sizer_1 = wx.BoxSizer(wx.VERTICAL) | |
sizer_2 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_3 = wx.BoxSizer(wx.VERTICAL) | |
sizer_4 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_3.Add((20,20),1,0,0) | |
sizer_4.Add((20,20),1,0,0) | |
#sizer_4.Add(self.bitmap, 0, 0, 0) | |
sizer_4.Add((20,20),1,0,0) | |
sizer_3.Add(sizer_4, 0, wx.EXPAND, 0) | |
sizer_3.Add((20,20),1,0,0) | |
sizer_2.Add(sizer_3,1,wx.EXPAND,0) | |
sizer_1.Add(sizer_2,1,wx.EXPAND,0) | |
self.SetAutoLayout(True) | |
self.SetSizer(sizer_1) | |
self.Layout() | |
# Segn que item de la barra de menus pulsen, se ejecuta una cosa u otra | |
def Menu01(self, event): | |
from os import system | |
self.padre.Show() | |
self.Destroy() | |
def Menu11(self, event): | |
if not child.horarios : | |
child.horarios=True | |
win=MyChild1(self, -1, "") | |
win.Show() | |
def Menu12(self, event): | |
if not child.contenidos : | |
child.contenidos=True | |
win5=MyChild5(self, -1, "") | |
win5.Show() | |
def Menu21(self, event): | |
if not child.servicios : | |
child.servicios=True | |
win2 = MyChild2(self, -1, "") | |
win2.Show(True) | |
def Menu22(self, event): | |
if not child.listas : | |
child.listas=True | |
win3 = MyChild3(self, -1, "") | |
win3.Show(True) | |
def Menu23(self, event): | |
if not child.expresiones : | |
child.expresiones=True | |
win4 = MyChild4(self, -1, "") | |
win4.Show(True) | |
def Menu31(self, event): | |
if not child.uso_web : | |
child.uso_web=True | |
win5=MyChild8(self,-1,"") | |
win5.Show(True) | |
def Menu32(self, event): | |
if not child.uso_web : | |
child.uso_aplic=True | |
win6=MyChild9(self,-1,"") | |
win6.Show(True) | |
def Menu42(self, event): | |
msg=" "+_("ACEPT \n Asistente para el Control Electronico Paterno-MaTerno \n Desarrollado por Caton Sistemas Alternativos 2006\nCONSEJERIA DE INNOVACION Y CIENCIA - JUNTA DE ANDALUCIA.") | |
dlg = wx.MessageDialog(self, msg, | |
_(‘Sobre ACEPT‘), wx.OK | wx.ICON_INFORMATION) | |
#wxYES_NO | wxNO_DEFAULT | wxCANCEL | wxICON_INFORMATION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/fondo_junta.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
dlg.ShowModal() | |
dlg.Destroy() | |
# end wxGlade | |
# end of class MyFrame1 | |
# Todo lo que concierne a la configuracion de usuarios: | |
# servicios permitidos, horarios y prorrogas | |
class MyChild1(wx.Frame): | |
def __init__(self, *args, **kwds): | |
# begin wxGlade: MyChild1.__init__ | |
kwds["style"] = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL | |
wx.Frame.__init__(self, *args, **kwds) | |
self.notebook_1 = wx.Notebook(self, -1, style=0) | |
self.notebook_1_pane_4 = wx.Panel(self.notebook_1, -1) | |
self.notebook_1_pane_3 = wx.Panel(self.notebook_1, -1) | |
self.notebook_1_pane_2 = wx.Panel(self.notebook_1, -1) | |
self.notebook_1_pane_1 = wx.Panel(self.notebook_1, -1) | |
self.combo_box_1 = wx.ComboBox(self, -1, choices=[""], style=wx.CB_DROPDOWN|wx.CB_READONLY) | |
self.button_1 = wx.Button(self, -1, _("Aceptar")) | |
self.button_2 = wx.Button(self, -1, _("Cancelar")) | |
self.label_15 = wx.StaticText(self, -1, _("Usuarios a partir de \nla siguiente UID:")) | |
self.text_ctrl_1 = wx.TextCtrl(self, -1, "1001") | |
self.rellena_usuarios() | |
self.bitmap_button_1_copy = wx.BitmapButton(self, -1, wx.Bitmap("/usr/share/acept/pixmaps/reload.png", wx.BITMAP_TYPE_ANY)) | |
self.label_2 = wx.StaticText(self.notebook_1_pane_1, -1, _("Dias")) | |
self.label_3 = wx.StaticText(self.notebook_1_pane_1, -1, _("Permitir ?")) | |
self.label_40 = wx.StaticText(self.notebook_1_pane_1, -1, _("Intervalo")) | |
self.static_line_1 = wx.StaticLine(self.notebook_1_pane_1, -1) | |
self.label_4 = wx.StaticText(self.notebook_1_pane_1, -1, _("Lunes")) | |
self.checkbox_1 = wx.CheckBox(self.notebook_1_pane_1, -1, "") | |
self.label_55 = wx.StaticText(self.notebook_1_pane_1, -1, _("de ")) | |
self.spin_ctrl_1 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=23, size=(45, 20)) | |
self.label_6 = wx.StaticText(self.notebook_1_pane_1, -1, ":") | |
self.spin_ctrl_2 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=59, size=(45, 20)) | |
self.label_7 = wx.StaticText(self.notebook_1_pane_1, -1, _(" a ")) | |
self.spin_ctrl_3 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=23, size=(45, 20)) | |
self.label_8 = wx.StaticText(self.notebook_1_pane_1, -1, ":") | |
self.spin_ctrl_4 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=59, size=(45, 20)) | |
self.label_4_copy_1 = wx.StaticText(self.notebook_1_pane_1, -1, _("Martes")) | |
self.checkbox_1_copy = wx.CheckBox(self.notebook_1_pane_1, -1, "") | |
self.label_5_copy = wx.StaticText(self.notebook_1_pane_1, -1, _("de ")) | |
self.spin_ctrl_1_copy = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=23, size=(45, 20)) | |
self.label_6_copy = wx.StaticText(self.notebook_1_pane_1, -1, ":") | |
self.spin_ctrl_2_copy = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=59, size=(45, 20)) | |
self.label_7_copy = wx.StaticText(self.notebook_1_pane_1, -1, _(" a ")) | |
self.spin_ctrl_3_copy = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=23, size=(45, 20)) | |
self.label_8_copy = wx.StaticText(self.notebook_1_pane_1, -1, ":") | |
self.spin_ctrl_4_copy = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=59, size=(45, 20)) | |
self.label_4_copy_2 = wx.StaticText(self.notebook_1_pane_1, -1, _("Miercoles")) | |
self.checkbox_1_copy_1 = wx.CheckBox(self.notebook_1_pane_1, -1, "") | |
self.label_5_copy_1 = wx.StaticText(self.notebook_1_pane_1, -1, _("de ")) | |
self.spin_ctrl_1_copy_1 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=23, size=(45, 20)) | |
self.label_6_copy_1 = wx.StaticText(self.notebook_1_pane_1, -1, ":") | |
self.spin_ctrl_2_copy_1 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=59, size=(45, 20)) | |
self.label_7_copy_1 = wx.StaticText(self.notebook_1_pane_1, -1, _(" a ")) | |
self.spin_ctrl_3_copy_1 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=23, size=(45, 20)) | |
self.label_8_copy_1 = wx.StaticText(self.notebook_1_pane_1, -1, ":") | |
self.spin_ctrl_4_copy_1 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=59, size=(45, 20)) | |
self.label_4_copy_3 = wx.StaticText(self.notebook_1_pane_1, -1, _("Jueves")) | |
self.checkbox_1_copy_2 = wx.CheckBox(self.notebook_1_pane_1, -1, "") | |
self.label_5_copy_2 = wx.StaticText(self.notebook_1_pane_1, -1, _("de ")) | |
self.spin_ctrl_1_copy_2 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=23, size=(45, 20)) | |
self.label_6_copy_2 = wx.StaticText(self.notebook_1_pane_1, -1, ":") | |
self.spin_ctrl_2_copy_2 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=59, size=(45, 20)) | |
self.label_7_copy_2 = wx.StaticText(self.notebook_1_pane_1, -1, _(" a ")) | |
self.spin_ctrl_3_copy_2 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=23, size=(45, 20)) | |
self.label_8_copy_2 = wx.StaticText(self.notebook_1_pane_1, -1, ":") | |
self.spin_ctrl_4_copy_2 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=59, size=(45, 20)) | |
self.label_4_copy_4 = wx.StaticText(self.notebook_1_pane_1, -1, _("Viernes")) | |
self.checkbox_1_copy_3 = wx.CheckBox(self.notebook_1_pane_1, -1, "") | |
self.label_5_copy_3 = wx.StaticText(self.notebook_1_pane_1, -1, _("de ")) | |
self.spin_ctrl_1_copy_3 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=23, size=(45, 20)) | |
self.label_6_copy_3 = wx.StaticText(self.notebook_1_pane_1, -1, ":") | |
self.spin_ctrl_2_copy_3 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=59, size=(45, 20)) | |
self.label_7_copy_3 = wx.StaticText(self.notebook_1_pane_1, -1, _(" a ")) | |
self.spin_ctrl_3_copy_3 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=23, size=(45, 20)) | |
self.label_8_copy_3 = wx.StaticText(self.notebook_1_pane_1, -1, ":") | |
self.spin_ctrl_4_copy_3 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=59, size=(45, 20)) | |
self.label_4_copy_5 = wx.StaticText(self.notebook_1_pane_1, -1, _("Sabado")) | |
self.checkbox_1_copy_4 = wx.CheckBox(self.notebook_1_pane_1, -1, "") | |
self.label_5_copy_4 = wx.StaticText(self.notebook_1_pane_1, -1, _("de ")) | |
self.spin_ctrl_1_copy_4 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=23, size=(45, 20)) | |
self.label_6_copy_4 = wx.StaticText(self.notebook_1_pane_1, -1, ":") | |
self.spin_ctrl_2_copy_4 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=59, size=(45, 20)) | |
self.label_7_copy_4 = wx.StaticText(self.notebook_1_pane_1, -1, _(" a ")) | |
self.spin_ctrl_3_copy_4 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=23, size=(45, 20)) | |
self.label_8_copy_4 = wx.StaticText(self.notebook_1_pane_1, -1, ":") | |
self.spin_ctrl_4_copy_4 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=59, size=(45, 20)) | |
self.label_4_copy_6 = wx.StaticText(self.notebook_1_pane_1, -1, _("Domingo")) | |
self.checkbox_1_copy_5 = wx.CheckBox(self.notebook_1_pane_1, -1, "") | |
self.label_5_copy_5 = wx.StaticText(self.notebook_1_pane_1, -1, _("de ")) | |
self.spin_ctrl_1_copy_5 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=23, size=(45, 20)) | |
self.label_6_copy_5 = wx.StaticText(self.notebook_1_pane_1, -1, ":") | |
self.spin_ctrl_2_copy_5 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=59, size=(45, 20)) | |
self.label_7_copy_5 = wx.StaticText(self.notebook_1_pane_1, -1, _(" a ")) | |
self.spin_ctrl_3_copy_5 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=23, size=(45, 20)) | |
self.label_8_copy_5 = wx.StaticText(self.notebook_1_pane_1, -1, ":") | |
self.spin_ctrl_4_copy_5 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=0, max=59, size=(45, 20)) | |
self.label_5 = wx.StaticText(self.notebook_1_pane_2, -1, _("Usuario sin limitaciones en los servicios?")) | |
self.choice_1 = wx.Choice(self.notebook_1_pane_2, -1, choices=[_("No"), _("Si")]) | |
self.button_3 = wx.Button(self.notebook_1_pane_2, -1, _("Limpiar")) | |
self.grid_1 = wx.grid.Grid(self.notebook_1_pane_2, -1, size=(1, 1)) | |
self.grid_2 = wx.grid.Grid(self.notebook_1_pane_3, -1, size=(1, 1)) | |
self.grid_3 = wx.grid.Grid(self.notebook_1_pane_4, -1, size=(1, 1)) | |
anno=int(fecha().split(" ")[-1]) | |
self.finaliza=True | |
self.__set_properties() | |
self.SetFocus() | |
self.__do_layout() | |
self.all=tod_serv(self.combo_box_1.GetValue()) | |
#si usuario seleccionado rellena campos segun su configuracion | |
if self.combo_box_1.GetValue()!=‘‘: | |
self.rellena() | |
wx.EVT_BUTTON(self, self.button_1.GetId(), self.acepta) | |
wx.EVT_BUTTON(self, self.button_2.GetId(), self.cancela) | |
wx.EVT_BUTTON(self, self.button_3.GetId(), self.limpia) | |
wx.EVT_BUTTON(self, self.bitmap_button_1_copy.GetId(), self.refresca_lista) | |
wx.EVT_CLOSE(self,self.cancela) | |
wx.EVT_COMBOBOX(self,self.combo_box_1.GetId(),self.recarga) | |
wx.EVT_CHOICE(self,self.choice_1.GetId(),self.limit) | |
wx.EVT_CHECKBOX(self,self.checkbox_1.GetId(),self.estado) | |
wx.EVT_CHECKBOX(self,self.checkbox_1_copy.GetId(),self.estado) | |
wx.EVT_CHECKBOX(self,self.checkbox_1_copy_1.GetId(),self.estado) | |
wx.EVT_CHECKBOX(self,self.checkbox_1_copy_2.GetId(),self.estado) | |
wx.EVT_CHECKBOX(self,self.checkbox_1_copy_3.GetId(),self.estado) | |
wx.EVT_CHECKBOX(self,self.checkbox_1_copy_4.GetId(),self.estado) | |
wx.EVT_CHECKBOX(self,self.checkbox_1_copy_5.GetId(),self.estado) | |
wx.grid.EVT_GRID_CELL_CHANGE(self,self.obten_cadena) | |
# end wxGlade | |
def __set_properties(self): | |
# begin wxGlade: MyChild1.__set_properties | |
self.Hide() | |
self.SetTitle(_("Horarios")) | |
self.choice_1.SetSelection(0) | |
# Crea las tablas que se van a mostrar de manera din?ica | |
self.grid_1.CreateGrid(0, 5) | |
self.grid_3.CreateGrid(0, 4) | |
self.grid_2.CreateGrid(0, 5) | |
attr=wx.grid.GridCellAttr() | |
attr.SetReadOnly(True) | |
self.grid_1.SetColAttr(0,attr) | |
self.grid_1.SetColLabelValue(0, _("Servicio")) | |
self.grid_1.SetColLabelValue(1, _("Limite Diario")) | |
self.grid_1.SetColLabelValue(2, _("Limite Semanal")) | |
self.grid_1.SetColLabelValue(3, _("Limite Mensual")) | |
self.grid_1.SetColLabelValue(4, _("Servicio sin limites")) | |
self.grid_1.AutoSize() | |
attr2=wx.grid.GridCellAttr() | |
attr2.SetReadOnly(True) | |
self.grid_3.SetColAttr(0,attr2) | |
self.grid_3.SetColLabelValue(0, _("Servicio")) | |
self.grid_3.SetColLabelValue(1, _("Total Diario")) | |
self.grid_3.SetColLabelValue(2, _("Total Semanal")) | |
self.grid_3.SetColLabelValue(3, _("Total Mensual")) | |
self.grid_3.AutoSize() | |
attr3=wx.grid.GridCellAttr() | |
attr3.SetReadOnly(True) | |
self.grid_2.SetColAttr(0,attr3) | |
self.grid_2.SetColLabelValue(0, _("Servicio")) | |
self.grid_2.SetColLabelValue(1, _("Hora")) | |
self.grid_2.SetColLabelValue(2, _("Dia")) | |
self.grid_2.SetColLabelValue(3, _("Mes")) | |
self.grid_2.SetColLabelValue(4, _("Anno")) | |
lista_srv=servicios()[0] | |
items=len(lista_srv) | |
self.grid_1.AppendRows(items) | |
self.grid_3.AppendRows(items) | |
self.grid_2.AppendRows(items) | |
year=int(fecha()[-4:]) | |
for i in range(items): | |
self.grid_1.SetCellValue(i,0,lista_srv[i]) | |
self.grid_1.SetCellEditor(i,4,wx.grid.GridCellBoolEditor()) | |
self.grid_1.SetCellRenderer(i,4,wx.grid.GridCellBoolRenderer()) | |
self.grid_2.SetCellValue(i,0,lista_srv[i]) | |
self.grid_2.SetCellEditor(i,2,wx.grid.GridCellNumberEditor(1,31)) | |
self.grid_2.SetCellEditor(i,3,wx.grid.GridCellNumberEditor(1,12)) | |
self.grid_2.SetCellEditor(i,4,wx.grid.GridCellNumberEditor(year,year+5)) | |
self.grid_3.SetCellValue(i,0,lista_srv[i]) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/fondo_junta.gif", wx.BITMAP_TYPE_ANY)) | |
self.SetIcon(_icon) | |
self.Centre | |
# end wxGlade | |
def __do_layout(self): | |
# begin wxGlade: MyChild1.__do_layout | |
sizer_3 = wx.BoxSizer(wx.VERTICAL) | |
sizer_4 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_18 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_22 = wx.BoxSizer(wx.VERTICAL) | |
sizer_34 = wx.BoxSizer(wx.VERTICAL) | |
sizer_23 = wx.BoxSizer(wx.VERTICAL) | |
sizer_24 = wx.BoxSizer(wx.VERTICAL) | |
sizer_32 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_33 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_30 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_31 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_28 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_29 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_25 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_26 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_27 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_19 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_20 = wx.BoxSizer(wx.VERTICAL) | |
sizer_21 = wx.BoxSizer(wx.VERTICAL) | |
sizer_13 = wx.BoxSizer(wx.VERTICAL) | |
sizer_14 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_15 = wx.BoxSizer(wx.VERTICAL) | |
sizer_16 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_17 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_9 = wx.BoxSizer(wx.VERTICAL) | |
sizer_66 = wx.BoxSizer(wx.HORIZONTAL) | |
grid_sizer_1 = wx.GridSizer(4, 2, 0, 0) | |
sizer_5 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_6 = wx.BoxSizer(wx.VERTICAL) | |
sizer_41 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_7 = wx.BoxSizer(wx.VERTICAL) | |
sizer_8 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_5.Add((20, 20), 0, 0, 0) | |
sizer_6.Add((20, 20), 0, 0, 0) | |
sizer_6.Add(self.combo_box_1, 0, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_6.Add((20, 20), 1, 0, 0) | |
sizer_41.Add(self.label_15, 0, 0, 0) | |
sizer_41.Add((20, 20), 0, 0, 0) | |
sizer_41.Add(self.text_ctrl_1, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_41.Add((20, 20), 0, 0, 0) | |
sizer_41.Add(self.bitmap_button_1_copy, 0, 0, 0) | |
sizer_6.Add(sizer_41, 0, wx.EXPAND, 0) | |
sizer_8.Add(self.button_1, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_8.Add((40, 10), 1, 0, 0) | |
sizer_8.Add(self.button_2, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_7.Add(sizer_8, 1, wx.EXPAND, 0) | |
sizer_7.Add((20, 20), 0, 0, 0) | |
sizer_6.Add(sizer_7, 1, wx.EXPAND, 0) | |
sizer_6.Add((20, 20), 1, 0, 0) | |
sizer_5.Add(sizer_6, 1, wx.EXPAND, 0) | |
sizer_5.Add((20, 20), 0, 0, 0) | |
sizer_4.Add(sizer_5, 0, wx.EXPAND, 0) | |
sizer_1 = wx.BoxSizer(wx.VERTICAL) | |
sizer_11_copy_copy_1_copy_6 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_11_copy_copy_1_copy_5 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_11_copy_copy_1_copy_4 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_11_copy_copy_1_copy_3 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_11_copy_copy_1_copy_2 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_11_copy_copy_1_copy_1 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_11_copy_copy_1 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_11_copy_copy_1_copy = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_11_copy_copy_1_copy.Add(self.label_2, 1, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy.Add((20, 20), 1, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy.Add(self.label_3, 0, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy.Add((20, 20), 0, wx.ALL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy.Add((10, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy.Add((20, 20), 1, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy.Add(self.label_40, 0, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy.Add((20, 20), 1, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_9.Add(sizer_11_copy_copy_1_copy, 0, wx.EXPAND, 0) | |
sizer_9.Add(self.static_line_1, 0, wx.EXPAND, 0) | |
sizer_11_copy_copy_1.Add(self.label_4, 1, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1.Add((20, 20), 1, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1.Add(self.checkbox_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1.Add((10, 20), 1, wx.ALL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1.Add(self.label_55, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1.Add(self.spin_ctrl_1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1.Add(self.label_6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1.Add(self.spin_ctrl_2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1.Add((10, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1.Add(self.label_7, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1.Add((10, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1.Add(self.spin_ctrl_3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1.Add(self.label_8, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1.Add(self.spin_ctrl_4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_9.Add(sizer_11_copy_copy_1, 1, wx.EXPAND, 0) | |
sizer_11_copy_copy_1_copy_1.Add(self.label_4_copy_1, 1, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_1.Add((20, 20), 1, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_1.Add(self.checkbox_1_copy, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_1.Add((10, 20), 1, wx.ALL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_1.Add(self.label_5_copy, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_1.Add(self.spin_ctrl_1_copy, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_1.Add(self.label_6_copy, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_1.Add(self.spin_ctrl_2_copy, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_1.Add((10, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_1.Add(self.label_7_copy, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_1.Add((10, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_1.Add(self.spin_ctrl_3_copy, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_1.Add(self.label_8_copy, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_1.Add(self.spin_ctrl_4_copy, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_1.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_9.Add(sizer_11_copy_copy_1_copy_1, 1, wx.EXPAND, 0) | |
sizer_11_copy_copy_1_copy_2.Add(self.label_4_copy_2, 1, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_2.Add((20, 20), 1, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_2.Add(self.checkbox_1_copy_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_2.Add((10, 20), 1, wx.ALL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_2.Add(self.label_5_copy_1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_2.Add(self.spin_ctrl_1_copy_1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_2.Add(self.label_6_copy_1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_2.Add(self.spin_ctrl_2_copy_1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_2.Add((10, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_2.Add(self.label_7_copy_1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_2.Add((10, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_2.Add(self.spin_ctrl_3_copy_1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_2.Add(self.label_8_copy_1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_2.Add(self.spin_ctrl_4_copy_1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_2.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_9.Add(sizer_11_copy_copy_1_copy_2, 1, wx.EXPAND, 0) | |
sizer_11_copy_copy_1_copy_3.Add(self.label_4_copy_3, 1, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_3.Add((20, 20), 1, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_3.Add(self.checkbox_1_copy_2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_3.Add((10, 20), 1, wx.ALL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_3.Add(self.label_5_copy_2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_3.Add(self.spin_ctrl_1_copy_2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_3.Add(self.label_6_copy_2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_3.Add(self.spin_ctrl_2_copy_2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_3.Add((10, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_3.Add(self.label_7_copy_2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_3.Add((10, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_3.Add(self.spin_ctrl_3_copy_2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_3.Add(self.label_8_copy_2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_3.Add(self.spin_ctrl_4_copy_2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_3.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_9.Add(sizer_11_copy_copy_1_copy_3, 1, wx.EXPAND, 0) | |
sizer_11_copy_copy_1_copy_4.Add(self.label_4_copy_4, 1, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_4.Add((20, 20), 1, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_4.Add(self.checkbox_1_copy_3, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_4.Add((10, 20), 1, wx.ALL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_4.Add(self.label_5_copy_3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_4.Add(self.spin_ctrl_1_copy_3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_4.Add(self.label_6_copy_3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_4.Add(self.spin_ctrl_2_copy_3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_4.Add((10, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_4.Add(self.label_7_copy_3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_4.Add((10, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_4.Add(self.spin_ctrl_3_copy_3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_4.Add(self.label_8_copy_3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_4.Add(self.spin_ctrl_4_copy_3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_4.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_9.Add(sizer_11_copy_copy_1_copy_4, 1, wx.EXPAND, 0) | |
sizer_11_copy_copy_1_copy_5.Add(self.label_4_copy_5, 1, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_5.Add((20, 20), 1, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_5.Add(self.checkbox_1_copy_4, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_5.Add((10, 20), 1, wx.ALL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_5.Add(self.label_5_copy_4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_5.Add(self.spin_ctrl_1_copy_4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_5.Add(self.label_6_copy_4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_5.Add(self.spin_ctrl_2_copy_4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_5.Add((10, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_5.Add(self.label_7_copy_4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_5.Add((10, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_5.Add(self.spin_ctrl_3_copy_4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_5.Add(self.label_8_copy_4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_5.Add(self.spin_ctrl_4_copy_4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_5.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_9.Add(sizer_11_copy_copy_1_copy_5, 1, wx.EXPAND, 0) | |
sizer_11_copy_copy_1_copy_6.Add(self.label_4_copy_6, 1, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_6.Add((20, 20), 1, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_6.Add(self.checkbox_1_copy_5, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_6.Add((10, 20), 1, wx.ALL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_6.Add(self.label_5_copy_5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_6.Add(self.spin_ctrl_1_copy_5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_6.Add(self.label_6_copy_5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_6.Add(self.spin_ctrl_2_copy_5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_6.Add((10, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_6.Add(self.label_7_copy_5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_6.Add((10, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_6.Add(self.spin_ctrl_3_copy_5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_6.Add(self.label_8_copy_5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_6.Add(self.spin_ctrl_4_copy_5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy_copy_1_copy_6.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_9.Add(sizer_11_copy_copy_1_copy_6, 1, wx.EXPAND, 0) | |
sizer_9.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) | |
self.notebook_1_pane_1.SetAutoLayout(True) | |
self.notebook_1_pane_1.SetSizer(sizer_9) | |
sizer_9.Fit(self.notebook_1_pane_1) | |
sizer_9.SetSizeHints(self.notebook_1_pane_1) | |
sizer_1.Add(self.notebook_1, 1, wx.EXPAND, 0) | |
self.SetAutoLayout(True) | |
self.SetSizer(sizer_1) | |
sizer_1.Fit(self) | |
sizer_1.SetSizeHints(self) | |
sizer_14.Add((20, 20), 0, 0, 0) | |
sizer_15.Add((20, 20), 0, 0, 0) | |
sizer_17.Add(self.label_5, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_17.Add((20, 20), 0, 0, 0) | |
sizer_17.Add(self.choice_1, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_17.Add((20, 20), 1, 0, 0) | |
sizer_17.Add(self.button_3, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_17.Add((20, 20), 0, 0, 0) | |
sizer_16.Add(sizer_17, 1, wx.EXPAND, 0) | |
sizer_15.Add(sizer_16, 1, wx.EXPAND, 0) | |
sizer_15.Add((20, 20), 0, 0, 0) | |
sizer_14.Add(sizer_15, 1, wx.EXPAND, 0) | |
sizer_14.Add((20, 20), 0, 0, 0) | |
sizer_13.Add(sizer_14, 0, wx.EXPAND, 0) | |
sizer_13.Add(self.grid_1, 1, wx.EXPAND, 0) | |
self.notebook_1_pane_2.SetAutoLayout(True) | |
self.notebook_1_pane_2.SetSizer(sizer_13) | |
sizer_13.Fit(self.notebook_1_pane_2) | |
sizer_13.SetSizeHints(self.notebook_1_pane_2) | |
sizer_18.Add(self.grid_2, 1, wx.EXPAND, 0) | |
self.notebook_1_pane_3.SetAutoLayout(True) | |
self.notebook_1_pane_3.SetSizer(sizer_18) | |
sizer_66.Add(self.grid_3, 1, wx.EXPAND, 0) | |
self.notebook_1_pane_4.SetAutoLayout(True) | |
self.notebook_1_pane_4.SetSizer(sizer_66) | |
sizer_18.Fit(self.notebook_1_pane_3) | |
sizer_18.SetSizeHints(self.notebook_1_pane_3) | |
self.notebook_1.AddPage(self.notebook_1_pane_1, _("Uso del pc")) | |
self.notebook_1.AddPage(self.notebook_1_pane_2, _("Servicios")) | |
self.notebook_1.AddPage(self.notebook_1_pane_4, _("Consumido")) | |
self.notebook_1.AddPage(self.notebook_1_pane_3, _("Prorrogas")) | |
# Esto es necesario para evitar un warning, a veces incluso un error mas grave | |
# segun la version de la libreria que haya instalada en el sistema | |
vers= wx.VERSION[0:2] | |
if vers[0]<=2 and vers[1]<=4: | |
sizer_4.Add(wx.NotebookSizer(self.notebook_1), 1, wx.EXPAND, 0) | |
else: | |
sizer_4.Add(self.notebook_1, 1, wx.EXPAND, 0) | |
sizer_3.Add(sizer_4, 1, wx.EXPAND, 0) | |
self.SetAutoLayout(True) | |
self.SetSizer(sizer_3) | |
sizer_3.Fit(self) | |
sizer_3.SetSizeHints(self) | |
self.Layout() | |
self.control() | |
# end wxGlade | |
# Borra el contenido de las tablas | |
def activar(self,a,b,c,d,e,f,g): | |
self.spin_ctrl_1.Enable(a) | |
self.spin_ctrl_2.Enable(a) | |
self.spin_ctrl_3.Enable(a) | |
self.spin_ctrl_4.Enable(a) | |
self.spin_ctrl_1_copy.Enable(b) | |
self.spin_ctrl_2_copy.Enable(b) | |
self.spin_ctrl_3_copy.Enable(b) | |
self.spin_ctrl_4_copy.Enable(b) | |
self.spin_ctrl_1_copy_1.Enable(c) | |
self.spin_ctrl_2_copy_1.Enable(c) | |
self.spin_ctrl_3_copy_1.Enable(c) | |
self.spin_ctrl_4_copy_1.Enable(c) | |
self.spin_ctrl_1_copy_2.Enable(d) | |
self.spin_ctrl_2_copy_2.Enable(d) | |
self.spin_ctrl_3_copy_2.Enable(d) | |
self.spin_ctrl_4_copy_2.Enable(d) | |
self.spin_ctrl_1_copy_3.Enable(e) | |
self.spin_ctrl_2_copy_3.Enable(e) | |
self.spin_ctrl_3_copy_3.Enable(e) | |
self.spin_ctrl_4_copy_3.Enable(e) | |
self.spin_ctrl_1_copy_4.Enable(f) | |
self.spin_ctrl_2_copy_4.Enable(f) | |
self.spin_ctrl_3_copy_4.Enable(f) | |
self.spin_ctrl_4_copy_4.Enable(f) | |
self.spin_ctrl_1_copy_5.Enable(g) | |
self.spin_ctrl_2_copy_5.Enable(g) | |
self.spin_ctrl_3_copy_5.Enable(g) | |
self.spin_ctrl_4_copy_5.Enable(g) | |
if a==0: | |
self.spin_ctrl_1.SetValue(0) | |
self.spin_ctrl_2.SetValue(0) | |
self.spin_ctrl_3.SetValue(0) | |
self.spin_ctrl_4.SetValue(0) | |
if b==0: | |
self.spin_ctrl_1_copy.SetValue(0) | |
self.spin_ctrl_2_copy.SetValue(0) | |
self.spin_ctrl_3_copy.SetValue(0) | |
self.spin_ctrl_4_copy.SetValue(0) | |
if c==0: | |
self.spin_ctrl_1_copy_1.SetValue(0) | |
self.spin_ctrl_2_copy_1.SetValue(0) | |
self.spin_ctrl_3_copy_1.SetValue(0) | |
self.spin_ctrl_4_copy_1.SetValue(0) | |
if d==0: | |
self.spin_ctrl_1_copy_2.SetValue(0) | |
self.spin_ctrl_2_copy_2.SetValue(0) | |
self.spin_ctrl_3_copy_2.SetValue(0) | |
self.spin_ctrl_4_copy_2.SetValue(0) | |
if e==0: | |
self.spin_ctrl_1_copy_3.SetValue(0) | |
self.spin_ctrl_2_copy_3.SetValue(0) | |
self.spin_ctrl_3_copy_3.SetValue(0) | |
self.spin_ctrl_4_copy_3.SetValue(0) | |
if f==0: | |
self.spin_ctrl_1_copy_4.SetValue(0) | |
self.spin_ctrl_2_copy_4.SetValue(0) | |
self.spin_ctrl_3_copy_4.SetValue(0) | |
self.spin_ctrl_4_copy_4.SetValue(0) | |
if g==0: | |
self.spin_ctrl_1_copy_5.SetValue(0) | |
self.spin_ctrl_2_copy_5.SetValue(0) | |
self.spin_ctrl_3_copy_5.SetValue(0) | |
self.spin_ctrl_4_copy_5.SetValue(0) | |
def estado(self,event): | |
id=event.GetId() | |
rango=self.checkbox_1.GetValue() | |
rango_copy=self.checkbox_1_copy.GetValue() | |
rango_copy_1=self.checkbox_1_copy_1.GetValue() | |
rango_copy_2=self.checkbox_1_copy_2.GetValue() | |
rango_copy_3=self.checkbox_1_copy_3.GetValue() | |
rango_copy_4=self.checkbox_1_copy_4.GetValue() | |
rango_copy_5=self.checkbox_1_copy_5.GetValue() | |
if id==self.checkbox_1.GetId(): | |
self.spin_ctrl_1.SetValue(0) | |
self.spin_ctrl_2.SetValue(0) | |
self.spin_ctrl_3.SetValue(23) | |
self.spin_ctrl_4.SetValue(59) | |
elif id==self.checkbox_1_copy.GetId(): | |
self.spin_ctrl_1_copy.SetValue(0) | |
self.spin_ctrl_2_copy.SetValue(0) | |
self.spin_ctrl_3_copy.SetValue(23) | |
self.spin_ctrl_4_copy.SetValue(59) | |
elif id==self.checkbox_1_copy_1.GetId(): | |
self.spin_ctrl_1_copy_1.SetValue(0) | |
self.spin_ctrl_2_copy_1.SetValue(0) | |
self.spin_ctrl_3_copy_1.SetValue(23) | |
self.spin_ctrl_4_copy_1.SetValue(59) | |
elif id==self.checkbox_1_copy_2.GetId(): | |
self.spin_ctrl_1_copy_2.SetValue(0) | |
self.spin_ctrl_2_copy_2.SetValue(0) | |
self.spin_ctrl_3_copy_2.SetValue(23) | |
self.spin_ctrl_4_copy_2.SetValue(59) | |
elif id==self.checkbox_1_copy_3.GetId(): | |
self.spin_ctrl_1_copy_3.SetValue(0) | |
self.spin_ctrl_2_copy_3.SetValue(0) | |
self.spin_ctrl_3_copy_3.SetValue(23) | |
self.spin_ctrl_4_copy_3.SetValue(59) | |
elif id==self.checkbox_1_copy_4.GetId(): | |
self.spin_ctrl_1_copy_4.SetValue(0) | |
self.spin_ctrl_2_copy_4.SetValue(0) | |
self.spin_ctrl_3_copy_4.SetValue(23) | |
self.spin_ctrl_4_copy_4.SetValue(59) | |
elif id==self.checkbox_1_copy_5.GetId(): | |
self.spin_ctrl_1_copy_5.SetValue(0) | |
self.spin_ctrl_2_copy_5.SetValue(0) | |
self.spin_ctrl_3_copy_5.SetValue(23) | |
self.spin_ctrl_4_copy_5.SetValue(59) | |
self.activar(rango,rango_copy,rango_copy_1,rango_copy_2,rango_copy_3,rango_copy_4,rango_copy_5) | |
def limpia(self,evt): | |
if self.grid_1.IsEnabled(): | |
columnas=self.grid_1.GetNumberRows() | |
for i in range(columnas): | |
self.grid_1.SetCellValue(i,1,‘‘) | |
self.grid_1.SetCellValue(i,2,‘‘) | |
self.grid_1.SetCellValue(i,3,‘‘) | |
self.grid_1.SetCellValue(i,4,‘0‘) | |
# Comprueba si es un usuario con limitaciones o no | |
def control(self): | |
columnas=self.grid_1.GetNumberRows() | |
todos=True | |
for i in range(columnas): | |
if self.grid_1.GetCellValue(i,4)=="0": | |
todos=False | |
if todos: | |
self.choice_1.SetSelection(1) | |
self.deshabilita() | |
# Si el usuario no tiene limites deshabilita la edicion de estos | |
# en caso contrario permite que se editen y rellena los campos | |
def limit(self,event): | |
if self.choice_1.GetSelection(): | |
self.all=True | |
self.deshabilita() | |
else: | |
self.all=False | |
self.habilita() | |
if self.combo_box_1.GetValue()!=‘‘: | |
self.rellena() | |
self.grid_1.SetCellValue(0,4,"1") | |
# Deja las tablas a 0 e impide su edicion | |
def deshabilita(self): | |
self.grid_1.Enable(False) | |
self.grid_2.Enable(False) | |
self.grid_3.Enable(False) | |
for i in range(self.grid_1.GetNumberRows()): | |
self.grid_1.SetCellValue(i,1,"") | |
self.grid_1.SetCellValue(i,2,"") | |
self.grid_1.SetCellValue(i,3,"") | |
self.grid_2.SetCellValue(i,1,"") | |
self.grid_2.SetCellValue(i,2,"") | |
self.grid_2.SetCellValue(i,3,"") | |
self.grid_2.SetCellValue(i,4,"") | |
self.grid_3.SetCellValue(i,1,"") | |
self.grid_3.SetCellValue(i,2,"") | |
self.grid_3.SetCellValue(i,3,"") | |
# Permite la edicion de las tablas | |
def habilita(self): | |
self.grid_1.Enable(True) | |
self.grid_2.Enable(True) | |
self.grid_3.Enable(True) | |
# Funcion que llama a rellena ante un evento | |
def recarga (self,event): | |
self.all=tod_serv(self.combo_box_1.GetValue()) | |
if self.combo_box_1.GetValue()!=‘‘: | |
self.rellena() | |
# Funcion que lee el archivo de configuracion y rellena los valores necesarios en la interfaz grafica | |
def rellena(self): | |
self.checkbox_1.SetValue(False) | |
self.checkbox_1_copy.SetValue(False) | |
self.checkbox_1_copy_1.SetValue(False) | |
self.checkbox_1_copy_2.SetValue(False) | |
self.checkbox_1_copy_3.SetValue(False) | |
self.checkbox_1_copy_4.SetValue(False) | |
self.checkbox_1_copy_5.SetValue(False) | |
us=self.combo_box_1.GetValue() | |
if self.all: | |
self.choice_1.SetSelection(1) | |
self.deshabilita() | |
else: | |
self.choice_1.SetSelection(0) | |
self.habilita() | |
a=usr_srv(us) | |
inicios,fines,dias=uso_pc(us) | |
semana={0:0,1:0,2:0,3:0,4:0,5:0,6:0} | |
items=len(dias) | |
for i in range(items): | |
hora_inicio=inicios[i][:2] | |
minuto_inicio=inicios[i][2:] | |
hora_fin=fines[i][:2] | |
minuto_fin=fines[i][2:] | |
dia=dias[i] | |
if dia==‘Mo‘: | |
self.checkbox_1.SetValue(True) | |
self.spin_ctrl_1.SetValue(int(hora_inicio)) | |
self.spin_ctrl_2.SetValue(int(minuto_inicio)) | |
self.spin_ctrl_3.SetValue(int(hora_fin)) | |
self.spin_ctrl_4.SetValue(int(minuto_fin)) | |
semana[0]=1 | |
elif dia==‘Tu‘: | |
self.checkbox_1_copy.SetValue(True) | |
self.spin_ctrl_1_copy.SetValue(int(hora_inicio)) | |
self.spin_ctrl_2_copy.SetValue(int(minuto_inicio)) | |
self.spin_ctrl_3_copy.SetValue(int(hora_fin)) | |
self.spin_ctrl_4_copy.SetValue(int(minuto_fin)) | |
semana[1]=1 | |
elif dia==‘We‘: | |
self.checkbox_1_copy_1.SetValue(True) | |
self.spin_ctrl_1_copy_1.SetValue(int(hora_inicio)) | |
self.spin_ctrl_2_copy_1.SetValue(int(minuto_inicio)) | |
self.spin_ctrl_3_copy_1.SetValue(int(hora_fin)) | |
self.spin_ctrl_4_copy_1.SetValue(int(minuto_fin)) | |
semana[2]=1 | |
elif dia==‘Th‘: | |
self.checkbox_1_copy_2.SetValue(True) | |
self.spin_ctrl_1_copy_2.SetValue(int(hora_inicio)) | |
self.spin_ctrl_2_copy_2.SetValue(int(minuto_inicio)) | |
self.spin_ctrl_3_copy_2.SetValue(int(hora_fin)) | |
self.spin_ctrl_4_copy_2.SetValue(int(minuto_fin)) | |
semana[3]=1 | |
elif dia==‘Fr‘: | |
self.checkbox_1_copy_3.SetValue(True) | |
self.spin_ctrl_1_copy_3.SetValue(int(hora_inicio)) | |
self.spin_ctrl_2_copy_3.SetValue(int(minuto_inicio)) | |
self.spin_ctrl_3_copy_3.SetValue(int(hora_fin)) | |
self.spin_ctrl_4_copy_3.SetValue(int(minuto_fin)) | |
semana[4]=1 | |
elif dia==‘Sa‘: | |
self.checkbox_1_copy_4.SetValue(True) | |
self.spin_ctrl_1_copy_4.SetValue(int(hora_inicio)) | |
self.spin_ctrl_2_copy_4.SetValue(int(minuto_inicio)) | |
self.spin_ctrl_3_copy_4.SetValue(int(hora_fin)) | |
self.spin_ctrl_4_copy_4.SetValue(int(minuto_fin)) | |
semana[5]=1 | |
elif dia==‘Su‘: | |
self.checkbox_1_copy_5.SetValue(True) | |
self.spin_ctrl_1_copy_5.SetValue(int(hora_inicio)) | |
self.spin_ctrl_2_copy_5.SetValue(int(minuto_inicio)) | |
self.spin_ctrl_3_copy_5.SetValue(int(hora_fin)) | |
self.spin_ctrl_4_copy_5.SetValue(int(minuto_fin)) | |
semana[6]=1 | |
self.activar(semana[0],semana[1],semana[2],semana[3],semana[4],semana[5],semana[6]) | |
dic_srv=serv_user(us) | |
columnas=self.grid_1.GetNumberRows() | |
for i in range(columnas): | |
ser=str(self.grid_1.GetCellValue(i,0)) | |
if self.all: | |
tiempos=[‘1‘] | |
else: | |
tiempos=dic_srv.get(us+"+"+ser) | |
if tiempos: | |
if tiempos[0]==‘1‘: | |
self.grid_1.SetCellValue(i,1,"") | |
self.grid_1.SetCellValue(i,2,"") | |
self.grid_1.SetCellValue(i,3,"") | |
self.grid_1.SetCellValue(i,4,"1") | |
self.grid_3.SetCellValue(i,1,"") | |
self.grid_3.SetCellValue(i,2,"") | |
self.grid_3.SetCellValue(i,3,"") | |
self.grid_2.SetCellValue(i,1,"") | |
self.grid_2.SetCellValue(i,2,"") | |
self.grid_2.SetCellValue(i,3,"") | |
self.grid_2.SetCellValue(i,4,"") | |
else: | |
self.grid_1.SetCellValue(i,1,tiempos[0]) | |
self.grid_1.SetCellValue(i,2,tiempos[1]) | |
self.grid_1.SetCellValue(i,3,tiempos[2]) | |
self.grid_1.SetCellValue(i,4,"0") | |
self.grid_3.SetCellValue(i,1,tiempos[3]) | |
self.grid_3.SetCellValue(i,2,tiempos[4]) | |
self.grid_3.SetCellValue(i,3,tiempos[5]) | |
hora_pr=tiempos[6].split()[0] | |
pr=tiempos[6].split()[1].split("/") | |
dia_pr=pr[0] | |
mes_pr=pr[1] | |
anno_pr=pr[2] | |
f_act=a=fecha().split()[3:] | |
del f_act[1:3] | |
if int(anno_pr+mes_pr+dia_pr)>=int(f_act[2]+f_act[1]+f_act[0]): | |
self.grid_2.SetCellValue(i,1,hora_pr) | |
self.grid_2.SetCellValue(i,2,dia_pr) | |
self.grid_2.SetCellValue(i,3,mes_pr) | |
self.grid_2.SetCellValue(i,4,anno_pr) | |
else: | |
self.grid_1.SetCellValue(i,1,"") | |
self.grid_1.SetCellValue(i,2,"") | |
self.grid_1.SetCellValue(i,3,"") | |
if i==0 and dic_srv=={}: | |
self.grid_1.SetCellValue(i,4,"1") | |
else: | |
self.grid_1.SetCellValue(i,4,"0") | |
self.grid_3.SetCellValue(i,1,"") | |
self.grid_3.SetCellValue(i,2,"") | |
self.grid_3.SetCellValue(i,3,"") | |
self.grid_2.SetCellValue(i,1,"") | |
self.grid_2.SetCellValue(i,2,"") | |
self.grid_2.SetCellValue(i,3,"") | |
self.grid_2.SetCellValue(i,4,"") | |
# Valida que la entrada en la casilla uid sea numerica | |
def uid_min(self): | |
numeros={"0":True, "1":1, "2":2, "3":3, "4":4, "5":5 ,"6":6, "7":7,"8":8,"9":9} | |
posicion=self.text_ctrl_1.GetLineText(0) | |
for i in posicion : | |
if not numeros.get(i): | |
return False | |
return posicion | |
# Lee los usuarios del sistema en /etc/passwd y crea una lista con ellos para mostrarlos | |
def rellena_usuarios (self): | |
uid.min=self.uid_min() | |
self.combo_box_1.Clear() | |
tmp_us=lista_usuarios(int(uid.min)) | |
for i in tmp_us: | |
self.combo_box_1.Append(i) | |
# funcion que llama a rellena_usuarios ante un evento | |
def refresca_lista(self ,event): | |
self.rellena_usuarios() | |
self.rellena() | |
def acepta(self,evt): | |
self.grid_1.SaveEditControlValue() | |
self.grid_2.SaveEditControlValue() | |
self.grid_3.SaveEditControlValue() | |
if self.finaliza : | |
self.aceptar(evt) | |
# Graba los cambios que se han realizado en el archivo de configuracion | |
def aceptar( self, evt): | |
from func import control_web_user | |
from confSquid import lee_userblacklists, actualiza_userblacklists | |
from inicSquid import inic_squid_user | |
def formato_hora(horas,minutos): | |
horas=str(horas) | |
minutos=str(minutos) | |
if len(horas)==1: | |
horas="0"+horas | |
if len(minutos)==1: | |
minutos="0"+minutos | |
return horas+minutos | |
usuario=self.combo_box_1.GetValue() | |
num_filas=self.grid_1.GetNumberRows() | |
listas_squid=lee_userblacklists(usuario,archivo.configuracion) | |
dias="" | |
nodias=[] | |
if self.checkbox_1.IsChecked(): | |
i1=self.spin_ctrl_1.GetValue() | |
i2=self.spin_ctrl_2.GetValue() | |
f1=self.spin_ctrl_3.GetValue() | |
f2=self.spin_ctrl_4.GetValue() | |
if (i1>f1) or (i1==f1 and i2>=f2): | |
nodias.append("Lunes") | |
else: | |
d="Mo" | |
inicio=formato_hora(self.spin_ctrl_1.GetValue(),self.spin_ctrl_2.GetValue()) | |
fin=formato_hora(self.spin_ctrl_3.GetValue(),self.spin_ctrl_4.GetValue()) | |
dias=dias+d+inicio+"-"+fin | |
if self.checkbox_1_copy.IsChecked(): | |
i1=self.spin_ctrl_1_copy.GetValue() | |
i2=self.spin_ctrl_2_copy.GetValue() | |
f1=self.spin_ctrl_3_copy.GetValue() | |
f2=self.spin_ctrl_4_copy.GetValue() | |
if (i1>f1) or (i1==f1 and i2>=f2): | |
nodias.append("Martes") | |
else: | |
d="Tu" | |
inicio=formato_hora(self.spin_ctrl_1_copy.GetValue(),self.spin_ctrl_2_copy.GetValue()) | |
fin=formato_hora(self.spin_ctrl_3_copy.GetValue(),self.spin_ctrl_4_copy.GetValue()) | |
dias=dias+d+inicio+"-"+fin | |
if self.checkbox_1_copy_1.IsChecked(): | |
i1=self.spin_ctrl_1_copy_1.GetValue() | |
i2=self.spin_ctrl_2_copy_1.GetValue() | |
f1=self.spin_ctrl_3_copy_1.GetValue() | |
f2=self.spin_ctrl_4_copy_1.GetValue() | |
if (i1>f1) or (i1==f1 and i2>=f2): | |
nodias.append("Miercoles") | |
else: | |
d="We" | |
inicio=formato_hora(self.spin_ctrl_1_copy_1.GetValue(),self.spin_ctrl_2_copy_1.GetValue()) | |
fin=formato_hora(self.spin_ctrl_3_copy_1.GetValue(),self.spin_ctrl_4_copy_1.GetValue()) | |
dias=dias+d+inicio+"-"+fin | |
if self.checkbox_1_copy_2.IsChecked(): | |
i1=self.spin_ctrl_1_copy_2.GetValue() | |
i2=self.spin_ctrl_2_copy_2.GetValue() | |
f1=self.spin_ctrl_3_copy_2.GetValue() | |
f2=self.spin_ctrl_4_copy_2.GetValue() | |
if (i1>f1) or (i1==f1 and i2>=f2): | |
nodias.append("Jueves") | |
else: | |
d="Th" | |
inicio=formato_hora(self.spin_ctrl_1_copy_2.GetValue(),self.spin_ctrl_2_copy_2.GetValue()) | |
fin=formato_hora(self.spin_ctrl_3_copy_2.GetValue(),self.spin_ctrl_4_copy_2.GetValue()) | |
dias=dias+d+inicio+"-"+fin | |
if self.checkbox_1_copy_3.IsChecked(): | |
i1=self.spin_ctrl_1_copy_3.GetValue() | |
i2=self.spin_ctrl_2_copy_3.GetValue() | |
f1=self.spin_ctrl_3_copy_3.GetValue() | |
f2=self.spin_ctrl_4_copy_3.GetValue() | |
if (i1>f1) or (i1==f1 and i2>=f2): | |
nodias.append("Viernes") | |
else: | |
d="Fr" | |
inicio=formato_hora(self.spin_ctrl_1_copy_3.GetValue(),self.spin_ctrl_2_copy_3.GetValue()) | |
fin=formato_hora(self.spin_ctrl_3_copy_3.GetValue(),self.spin_ctrl_4_copy_3.GetValue()) | |
dias=dias+d+inicio+"-"+fin | |
if self.checkbox_1_copy_4.IsChecked(): | |
i1=self.spin_ctrl_1_copy_4.GetValue() | |
i2=self.spin_ctrl_2_copy_4.GetValue() | |
f1=self.spin_ctrl_3_copy_4.GetValue() | |
f2=self.spin_ctrl_4_copy_4.GetValue() | |
if (i1>f1) or (i1==f1 and i2>=f2): | |
nodias.append("Sabado") | |
else: | |
d="Sa" | |
inicio=formato_hora(self.spin_ctrl_1_copy_4.GetValue(),self.spin_ctrl_2_copy_4.GetValue()) | |
fin=formato_hora(self.spin_ctrl_3_copy_4.GetValue(),self.spin_ctrl_4_copy_4.GetValue()) | |
dias=dias+d+inicio+"-"+fin | |
if self.checkbox_1_copy_5.IsChecked(): | |
i1=self.spin_ctrl_1_copy_5.GetValue() | |
i2=self.spin_ctrl_2_copy_5.GetValue() | |
f1=self.spin_ctrl_3_copy_5.GetValue() | |
f2=self.spin_ctrl_4_copy_5.GetValue() | |
if (i1>f1) or (i1==f1 and i2>=f2): | |
nodias.append("Domingo") | |
else: | |
d="Su" | |
inicio=formato_hora(self.spin_ctrl_1_copy_5.GetValue(),self.spin_ctrl_2_copy_5.GetValue()) | |
fin=formato_hora(self.spin_ctrl_3_copy_5.GetValue(),self.spin_ctrl_4_copy_5.GetValue()) | |
dias=dias+d+inicio+"-"+fin | |
guarda_config=True | |
if dias=="": | |
msg=" "+_("El horario definido para")+" ‘"+usuario+"‘ "+_("no es valido")+"\n"+_(" Revise la configuracion.") | |
dlg = wx.MessageDialog(self, msg, | |
_(‘Configuracion no valida‘), wx.OK | wx.ICON_EXCLAMATION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
dlg.ShowModal() | |
dlg.Destroy() | |
guarda_config=False | |
else: | |
if len(nodias)>0: | |
if len(nodias)==1: | |
cad_msg=‘el ‘+nodias[0] | |
fin_dlg=_("Este dia el acceso quedaria inhabilitado.") | |
else: | |
cad_msg="" | |
for i in range(len(nodias)-1): | |
cad_msg=cad_msg+nodias[i]+" " | |
cad_msg=cad_msg+"y "+nodias[len(nodias)-1] | |
fin_dlg=_("Estos dias el acceso quedaria inhabilitado.") | |
msg_dlg=_(" El horario seleccionado para")+" "+cad_msg+" "+_("no es valido")+"\n "+fin_dlg+"\n\n"+_(" Desea guadar la configuracion de todos modos ?") | |
dlg = wx.MessageDialog(self, msg_dlg, _(‘Aviso ACEPT‘), wx.YES_NO | wx.ICON_QUESTION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
if dlg.ShowModal()==wx.ID_NO: | |
guarda_config=False | |
dlg.Destroy() | |
if guarda_config: | |
tabla=[] | |
for i in range(9): | |
tabla.append([]) | |
for i in range(num_filas): | |
nom_serv=self.grid_1.GetCellValue(i,0) #nombre del servicio | |
sin_lim=self.grid_1.GetCellValue(i,4) # servicio sin limites | |
lim_d=self.grid_1.GetCellValue(i,1) #limite diario | |
lim_s=self.grid_1.GetCellValue(i,2) #limite semanal | |
lim_m=self.grid_1.GetCellValue(i,3) #limite mensual | |
tot_d=self.grid_3.GetCellValue(i,1) #total consumo diario | |
tot_s=self.grid_3.GetCellValue(i,2) #total consumo semanal | |
tot_m=self.grid_3.GetCellValue(i,3) #total consumo mensual | |
if lim_d=="" or lim_d==" ": | |
lim_d="" | |
lim_s="" | |
lim_m="" | |
if lim_s=="" or lim_s==" ": | |
lim_d="" | |
lim_s="" | |
lim_m="" | |
if lim_m=="" or lim_m==" ": | |
lim_d="" | |
lim_s="" | |
lim_m="" | |
if sin_lim !="0" and sin_lim!=‘‘: | |
tabla[0].append(nom_serv) | |
tabla[1].append(‘‘) | |
tabla[2].append(‘‘) | |
tabla[3].append(‘‘) | |
tabla[4].append(‘‘) | |
tabla[5].append(‘‘) | |
tabla[6].append(‘‘) | |
tabla[7].append(‘‘) | |
tabla[8].append("SL") | |
elif lim_d !="": | |
if tot_d=="" or tot_d==" ": | |
tot_d="00:00:00" | |
tot_s="00:00:00" | |
tot_m="00:00:00" | |
if tot_s=="" or tot_s==" ": | |
tot_d="00:00:00" | |
tot_s="00:00:00" | |
tot_m="00:00:00" | |
if tot_s=="" or tot_s==" ": | |
tot_d="00:00:00" | |
tot_s="00:00:00" | |
tot_m="00:00:00" | |
hora_pr=self.grid_2.GetCellValue(i,1) | |
dia_pr=str(self.grid_2.GetCellValue(i,2)) | |
mes_pr=str(self.grid_2.GetCellValue(i,3)) | |
anno_pr=str(self.grid_2.GetCellValue(i,4)) | |
if len(hora_pr)<8: | |
hora_pr="00:00:00" | |
if dia_pr==" " or dia_pr=="": | |
dia_pr="00" | |
if mes_pr==" " or mes_pr=="": | |
mes_pr="00" | |
if anno_pr==" " or anno_pr=="": | |
anno_pr="00" | |
if len(dia_pr)==1: | |
dia_pr="0"+dia_pr | |
if len(mes_pr)==1: | |
mes_pr="0"+mes_pr | |
if len(anno_pr)==1: | |
anno_pr="0"+anno_pr | |
tabla[0].append(nom_serv) | |
tabla[1].append(lim_d) | |
tabla[2].append(lim_s) | |
tabla[3].append(lim_m) | |
tabla[4].append(tot_d) | |
tabla[5].append(tot_s) | |
tabla[6].append(tot_m) | |
tabla[7].append(hora_pr+" "+dia_pr+"/"+mes_pr+"/"+anno_pr) #prorroga | |
tabla[8].append("") | |
if self.grid_1.IsEnabled(): | |
todos=False | |
else: | |
todos=True | |
avanz_usr(todos,usuario,tabla,listas_squid) | |
time_conf=dias | |
fija_horarios(usuario,time_conf) | |
actualiza_userblacklists(usuario, listas_squid, archivo.configuracion) | |
#se actualizan instancias de squid a modificaciones realizadas | |
if (control_web_user(usuario,archivo.aceptlog)==1): | |
inic_squid_user(usuario,archivo.aceptlog) | |
msg=_("Guardados los cambios para ")+"‘"+usuario+"‘\n"+_("Desea salir de esta ventana?") | |
dlg = wx.MessageDialog(self, msg, _(‘Aviso ACEPT‘), wx.YES_NO | wx.ICON_QUESTION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
if dlg.ShowModal()==wx.ID_YES: | |
dlg.Destroy() | |
child.horarios=False | |
self.Destroy() | |
else: | |
dlg.Destroy() | |
self.rellena() | |
# Comprueba que no se han introducido valores por encima de los maximos | |
def valida_fecha(self,fecha,col): | |
letras=len(fecha) | |
if letras==0: | |
return True | |
if fecha==" ": | |
return True | |
if letras<5 or letras >9: | |
return False | |
fecha=fecha.split(":") | |
if len(fecha[0])>2 or len(fecha[1])>2 or len(fecha[2])>2: | |
return False | |
max=[59,23,167,743] | |
try: | |
if int(fecha[0])>max[col] or int(fecha[1])>max[0] or int(fecha[2])>max[0]: | |
return False | |
else: | |
return True | |
except: | |
return False | |
# Toma las horas que se introducen en las celdas pertinentes y las manda a una funcion | |
# que comprueba si tienen el formato correcto, si no es asi la deja por defecto en "00:00:00" y | |
# lanza un aviso | |
def obten_cadena(self,evt): | |
fila=evt.GetRow() | |
columna=evt.GetCol() | |
tiempo=True | |
if self.grid_1.GetId()==evt.GetId(): | |
tabla=self.grid_1 | |
tb_name=_("servicios") | |
elif self.grid_3.GetId()==evt.GetId(): | |
tabla=self.grid_3 | |
tb_name=_("consumido") | |
else: | |
tabla=self.grid_2 | |
tb_name=_("prorrogas") | |
if tb_name==_("prorrogas") and columna !=1: | |
valido=True | |
tiempo=False | |
elif tb_name==_("servicios") and columna==4: | |
valido=True | |
tiempo=False | |
else: | |
valido=self.valida_fecha(tabla.GetCellValue(fila,columna),columna) | |
if not valido: | |
dlg = wx.MessageDialog(self, _("La celda en la fila")+" "+str(fila)+_(", columna")+" "+str(columna)+" "+_("de la seccion")+" "+tb_name+"\n"+_("contiene un valor incorrecto"), | |
_(‘Aviso ACEPT‘), wx.OK | wx.ICON_HAND) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
dlg.ShowModal() | |
dlg.Destroy() | |
tabla.SetCellValue(fila,columna,"00:00:00") | |
self.finaliza=False | |
elif tiempo : | |
horario=tabla.GetCellValue(fila,columna) | |
if len(horario)<8: | |
h=horario.split(":")[0] | |
m=horario.split(":")[1] | |
s=horario.split(":")[2] | |
if len(h)==1: | |
h="0"+h | |
if len(m)==1: | |
m="0"+m | |
if len(s)==1: | |
s="0"+s | |
tabla.SetCellValue(fila,columna,h+":"+m+":"+s) | |
self.finaliza=True | |
def cancela( self, evt): | |
child.horarios=False | |
self.Destroy() | |
# end of class MyChild1 | |
# Esta ventana se encarga de la administracion de los servicios | |
class MyChild2(wx.Frame): | |
def __init__(self, *args, **kwds): | |
# begin wxGlade: MyChild2.__init__ | |
kwds["style"] = wx.DEFAULT_FRAME_STYLE | |
wx.Frame.__init__(self, *args, **kwds) | |
self.notebook_1 = wx.Notebook(self, -1, style=0) | |
self.notebook_1_pane_2 = wx.Panel(self.notebook_1, -1) | |
self.notebook_1_pane_1 = wx.Panel(self.notebook_1, -1) | |
self.button_1 = wx.Button(self, -1, _("Nuevo Servicio")) | |
self.button_2 = wx.Button(self, -1, _("Modificar servicio")) | |
self.button_3 = wx.Button(self, -1, _("Aceptar")) | |
self.button_4 = wx.Button(self, -1, _("Salir")) | |
self.label_1 = wx.StaticText(self.notebook_1_pane_1, -1, _("Nombre")) | |
self.label_2 = wx.StaticText(self.notebook_1_pane_1, -1, _("Puertos")) | |
self.text_ctrl_1 = wx.TextCtrl(self.notebook_1_pane_1, -1, "") | |
self.text_ctrl_2 = wx.TextCtrl(self.notebook_1_pane_1, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY) | |
self.static_line_1 = wx.StaticLine(self.notebook_1_pane_1, -1) | |
self.label_16 = wx.StaticText(self.notebook_1_pane_1, -1, _("Puertos Tcp")) | |
self.spin_ctrl_1 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=1, max=65535) | |
self.button_5 = wx.Button(self.notebook_1_pane_1, -1, _("Insertar")) | |
self.button_6 = wx.Button(self.notebook_1_pane_1, -1, _("Borrar")) | |
self.button_7 = wx.Button(self.notebook_1_pane_1, -1, _("Limpiar")) | |
self.checkbox_1 = wx.CheckBox(self.notebook_1_pane_1, -1, _("Rango ?")) | |
self.spin_ctrl_3 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=1, max=65535) | |
self.label_17 = wx.StaticText(self.notebook_1_pane_1, -1, _("Puertos Udp")) | |
self.spin_ctrl_2 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=1, max=65535) | |
self.button_8 = wx.Button(self.notebook_1_pane_1, -1, _("Insertar")) | |
self.button_9 = wx.Button(self.notebook_1_pane_1, -1, _("Borrar")) | |
self.button_10 = wx.Button(self.notebook_1_pane_1, -1, _("Limpiar")) | |
self.checkbox_2 = wx.CheckBox(self.notebook_1_pane_1, -1, _("Rango ?")) | |
self.spin_ctrl_4 = wx.SpinCtrl(self.notebook_1_pane_1, -1, "", min=1, max=65535) | |
self.label_15_copy = wx.StaticText(self.notebook_1_pane_2, -1, _("Nombre")) | |
self.label_21_copy = wx.StaticText(self.notebook_1_pane_2, -1, _("Puertos")) | |
self.combo_box_3 = wx.ComboBox(self.notebook_1_pane_2, -1, choices=[], style=wx.CB_DROPDOWN|wx.CB_READONLY) | |
self.text_ctrl_2_copy = wx.TextCtrl(self.notebook_1_pane_2, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY) | |
self.static_line_2_copy = wx.StaticLine(self.notebook_1_pane_2, -1) | |
self.label_16_copy = wx.StaticText(self.notebook_1_pane_2, -1, _("Puertos Tcp")) | |
self.spin_ctrl_2_copy = wx.SpinCtrl(self.notebook_1_pane_2, -1, "", min=1, max=65535) | |
self.button_5_copy = wx.Button(self.notebook_1_pane_2, -1, _("Insertar")) | |
self.button_6_copy = wx.Button(self.notebook_1_pane_2, -1, _("Borrar")) | |
self.button_7_copy = wx.Button(self.notebook_1_pane_2, -1, _("Limpiar")) | |
self.checkbox_1_copy = wx.CheckBox(self.notebook_1_pane_2, -1, _("Rango ?")) | |
self.spin_ctrl_4_copy = wx.SpinCtrl(self.notebook_1_pane_2, -1, "", min=1, max=65535) | |
self.label_17_copy = wx.StaticText(self.notebook_1_pane_2, -1, _("Puertos Udp")) | |
self.spin_ctrl_3_copy = wx.SpinCtrl(self.notebook_1_pane_2, -1, "", min=1, max=65535) | |
self.button_8_copy = wx.Button(self.notebook_1_pane_2, -1, _("Insertar")) | |
self.button_9_copy = wx.Button(self.notebook_1_pane_2, -1, _("Borrar")) | |
self.button_10_copy = wx.Button(self.notebook_1_pane_2, -1, _("Limpiar")) | |
self.checkbox_2_copy = wx.CheckBox(self.notebook_1_pane_2, -1, _("Rango ?")) | |
self.spin_ctrl_5_copy = wx.SpinCtrl(self.notebook_1_pane_2, -1, "", min=1, max=65535) | |
self.button_11 = wx.Button(self.notebook_1_pane_2, -1, _("Eliminar servicio")) | |
#self.usuarios=MyChild1(None,-1,"") | |
self.tcp=[‘‘] | |
self.udp=[‘‘] | |
self.__set_properties() | |
self.SetFocus() | |
self.__do_layout() | |
# end wxGlade | |
def __set_properties(self): | |
# begin wxGlade: MyChild2.__set_properties | |
self.SetTitle(_("Servicios")) | |
self.notebook_1_pane_2.Hide() | |
self.spin_ctrl_3.Enable(False) | |
self.spin_ctrl_4.Enable(False) | |
self.spin_ctrl_5_copy.Enable(False) | |
self.spin_ctrl_4_copy.Enable(False) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/fondo_junta.gif", wx.BITMAP_TYPE_ANY)) | |
self.SetIcon(_icon) | |
self.Centre | |
self.lista_srv=servicios()[0] | |
self.lista_srv.sort() | |
self.combo_box_3.Append(‘‘) | |
for i in self.lista_srv: | |
self.combo_box_3.Append(i) | |
# end wxGlade | |
def __do_layout(self): | |
sizer_1 = wx.BoxSizer(wx.VERTICAL) | |
sizer_2 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_15 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_16 = wx.BoxSizer(wx.VERTICAL) | |
sizer_23_copy = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_24 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_21 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_22 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_23 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_17 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_20 = wx.BoxSizer(wx.VERTICAL) | |
sizer_18 = wx.BoxSizer(wx.VERTICAL) | |
sizer_19 = wx.BoxSizer(wx.VERTICAL) | |
sizer_5 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_6 = wx.BoxSizer(wx.VERTICAL) | |
sizer_13 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_14 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_11 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_12 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_7 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_10 = wx.BoxSizer(wx.VERTICAL) | |
sizer_8 = wx.BoxSizer(wx.VERTICAL) | |
sizer_9 = wx.BoxSizer(wx.VERTICAL) | |
sizer_3 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_4 = wx.BoxSizer(wx.VERTICAL) | |
sizer_3.Add((20, 20), 0, 0, 0) | |
sizer_4.Add((20, 20), 1, 0, 0) | |
sizer_4.Add(self.button_1, 0, wx.EXPAND, 0) | |
sizer_4.Add((20, 20), 0, 0, 0) | |
sizer_4.Add(self.button_2, 0, wx.EXPAND, 0) | |
sizer_4.Add((20, 20), 1, 0, 0) | |
sizer_4.Add(self.button_3, 0, wx.EXPAND, 0) | |
sizer_4.Add((20, 20), 0, 0, 0) | |
sizer_4.Add(self.button_4, 0, wx.EXPAND, 0) | |
sizer_4.Add((20, 20), 1, 0, 0) | |
sizer_3.Add(sizer_4, 0, wx.EXPAND, 0) | |
sizer_3.Add((20, 20), 1, 0, 0) | |
sizer_2.Add(sizer_3, 0, wx.EXPAND, 0) | |
sizer_5.Add((10, 10), 0, 0, 0) | |
sizer_8.Add(self.label_1, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_8.Add((10, 10), 0, 0, 0) | |
sizer_9.Add((10, 10), 0, wx.ALL, 0) | |
sizer_9.Add(self.label_2, 0, 0, 0) | |
sizer_9.Add((20, 20), 1, 0, 0) | |
sizer_8.Add(sizer_9, 1, wx.EXPAND, 0) | |
sizer_7.Add(sizer_8, 0, wx.EXPAND, 0) | |
sizer_7.Add((20, 20), 0, 0, 0) | |
sizer_10.Add(self.text_ctrl_1, 0, wx.EXPAND, 0) | |
sizer_10.Add((10, 10), 0, 0, 0) | |
sizer_10.Add(self.text_ctrl_2, 1, wx.EXPAND, 0) | |
sizer_10.Add((10, 10), 0, wx.ALL, 0) | |
sizer_7.Add(sizer_10, 1, wx.EXPAND, 0) | |
sizer_6.Add(sizer_7, 1, wx.EXPAND, 0) | |
sizer_6.Add(self.static_line_1, 0, wx.EXPAND, 0) | |
sizer_11.Add(self.label_16, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_11.Add((20, 20), 0, 0, 0) | |
sizer_11.Add(self.spin_ctrl_1, 0, wx.ALIGN_BOTTOM|wx.ALIGN_CENTER_HORIZONTAL, 0) | |
sizer_12.Add((20, 20), 1, 0, 0) | |
sizer_12.Add(self.button_5, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_12.Add((20, 20), 0, 0, 0) | |
sizer_12.Add(self.button_6, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_12.Add((20, 20), 0, 0, 0) | |
sizer_12.Add(self.button_7, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_12.Add((15, 15), 1, 0, 0) | |
sizer_12.Add(self.checkbox_1, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_12.Add(self.spin_ctrl_3, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_11.Add(sizer_12, 1, wx.EXPAND, 0) | |
sizer_6.Add(sizer_11, 0, wx.EXPAND, 0) | |
sizer_6.Add((20, 20), 0, wx.ALL, 0) | |
sizer_6.Add((10, 10), 0, 0, 0) | |
sizer_13.Add(self.label_17, 0, 0, 0) | |
sizer_13.Add((20, 20), 0, 0, 0) | |
sizer_13.Add(self.spin_ctrl_2, 0, wx.ALIGN_CENTER_HORIZONTAL, 0) | |
sizer_14.Add((20, 20), 1, 0, 0) | |
sizer_14.Add(self.button_8, 0, 0, 0) | |
sizer_14.Add((20, 20), 0, 0, 0) | |
sizer_14.Add(self.button_9, 0, 0, 0) | |
sizer_14.Add((20, 20), 0, 0, 0) | |
sizer_14.Add(self.button_10, 0, 0, 0) | |
sizer_14.Add((15, 15), 1, 0, 0) | |
sizer_14.Add(self.checkbox_2, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_14.Add(self.spin_ctrl_4, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_13.Add(sizer_14, 1, wx.EXPAND, 0) | |
sizer_6.Add(sizer_13, 0, wx.EXPAND, 0) | |
sizer_6.Add((20, 20), 0, 0, 0) | |
sizer_6.Add((20, 20), 0, 0, 0) | |
sizer_5.Add(sizer_6, 1, wx.EXPAND, 0) | |
sizer_5.Add((20, 20), 0, 0, 0) | |
self.notebook_1_pane_1.SetAutoLayout(True) | |
self.notebook_1_pane_1.SetSizer(sizer_5) | |
sizer_5.Fit(self.notebook_1_pane_1) | |
sizer_5.SetSizeHints(self.notebook_1_pane_1) | |
sizer_15.Add((10, 10), 0, 0, 0) | |
sizer_18.Add(self.label_15_copy, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_18.Add((10, 10), 0, 0, 0) | |
sizer_19.Add((10, 10), 0, wx.ALL, 0) | |
sizer_19.Add(self.label_21_copy, 0, 0, 0) | |
sizer_19.Add((20, 20), 1, 0, 0) | |
sizer_18.Add(sizer_19, 1, wx.EXPAND, 0) | |
sizer_17.Add(sizer_18, 0, wx.EXPAND, 0) | |
sizer_17.Add((20, 20), 0, 0, 0) | |
sizer_20.Add(self.combo_box_3, 0, wx.EXPAND, 0) | |
sizer_20.Add((10, 10), 0, 0, 0) | |
sizer_20.Add(self.text_ctrl_2_copy, 1, wx.EXPAND, 0) | |
sizer_20.Add((10, 10), 0, wx.ALL, 0) | |
sizer_17.Add(sizer_20, 1, wx.EXPAND, 0) | |
sizer_16.Add(sizer_17, 1, wx.EXPAND, 0) | |
sizer_16.Add(self.static_line_2_copy, 0, wx.EXPAND, 0) | |
sizer_21.Add(self.label_16_copy, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_21.Add((20, 20), 0, 0, 0) | |
sizer_21.Add(self.spin_ctrl_2_copy, 0, wx.ALIGN_BOTTOM|wx.ALIGN_CENTER_HORIZONTAL, 0) | |
sizer_22.Add((20, 20), 1, 0, 0) | |
sizer_22.Add(self.button_5_copy, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_22.Add((20, 20), 0, 0, 0) | |
sizer_22.Add(self.button_6_copy, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_22.Add((20, 20), 0, 0, 0) | |
sizer_22.Add(self.button_7_copy, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_22.Add((15, 15), 1, 0, 0) | |
sizer_22.Add(self.checkbox_1_copy, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_22.Add(self.spin_ctrl_4_copy, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_21.Add(sizer_22, 1, wx.EXPAND, 0) | |
sizer_16.Add(sizer_21, 0, wx.EXPAND, 0) | |
sizer_16.Add((20, 20), 0, wx.ALL, 0) | |
sizer_16.Add((10, 10), 0, 0, 0) | |
sizer_23_copy.Add(self.label_17_copy, 0, 0, 0) | |
sizer_23_copy.Add((20, 20), 0, 0, 0) | |
sizer_23_copy.Add(self.spin_ctrl_3_copy, 0, wx.ALIGN_CENTER_HORIZONTAL, 0) | |
sizer_24.Add((20, 20), 1, 0, 0) | |
sizer_24.Add(self.button_8_copy, 0, 0, 0) | |
sizer_24.Add((20, 20), 0, 0, 0) | |
sizer_24.Add(self.button_9_copy, 0, 0, 0) | |
sizer_24.Add((20, 20), 0, 0, 0) | |
sizer_24.Add(self.button_10_copy, 0, 0, 0) | |
sizer_24.Add((15, 15), 1, 0, 0) | |
sizer_24.Add(self.checkbox_2_copy, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_24.Add(self.spin_ctrl_5_copy, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_23_copy.Add(sizer_24, 1, wx.EXPAND, 0) | |
sizer_16.Add(sizer_23_copy, 0, wx.EXPAND, 0) | |
sizer_16.Add((20, 20), 0, 0, 0) | |
sizer_23.Add((20, 20), 1, 0, 0) | |
sizer_23.Add(self.button_11, 0, 0, 0) | |
sizer_16.Add(sizer_23, 0, wx.EXPAND, 0) | |
sizer_16.Add((20, 20), 0, 0, 0) | |
sizer_15.Add(sizer_16, 1, wx.EXPAND, 0) | |
sizer_15.Add((20, 20), 0, 0, 0) | |
self.notebook_1_pane_2.SetAutoLayout(True) | |
self.notebook_1_pane_2.SetSizer(sizer_15) | |
sizer_15.Fit(self.notebook_1_pane_2) | |
sizer_15.SetSizeHints(self.notebook_1_pane_2) | |
self.notebook_1.AddPage(self.notebook_1_pane_1, _("Nuevo Servicio")) | |
self.notebook_1.AddPage(self.notebook_1_pane_2, _("Modificar Servicio")) | |
# Segun la version de la libreria hace una cosa u otra | |
vers= wx.VERSION[0:2] | |
if vers[0]<=2 and vers[1]<=4: | |
sizer_2.Add(wx.NotebookSizer(self.notebook_1), 1, wx.EXPAND, 0) | |
else: | |
sizer_2.Add(self.notebook_1, 1, wx.EXPAND, 0) | |
sizer_1.Add(sizer_2, 1, wx.EXPAND, 0) | |
self.SetAutoLayout(True) | |
self.SetSizer(sizer_1) | |
sizer_1.Fit(self) | |
sizer_1.SetSizeHints(self) | |
self.Layout() | |
# end wxGlade | |
wx.EVT_BUTTON(self, self.button_1.GetId(), self.cambia_panel) | |
wx.EVT_BUTTON(self, self.button_2.GetId(), self.cambia_panel) | |
wx.EVT_BUTTON(self, self.button_3.GetId(), self.acepta) | |
wx.EVT_BUTTON(self, self.button_4.GetId(), self.cancela) | |
wx.EVT_CHECKBOX(self,self.checkbox_1.GetId(),self.activa) | |
wx.EVT_CHECKBOX(self,self.checkbox_2.GetId(),self.activa) | |
wx.EVT_CHECKBOX(self,self.checkbox_1_copy.GetId(),self.activa) | |
wx.EVT_CHECKBOX(self,self.checkbox_2_copy.GetId(),self.activa) | |
wx.EVT_SPINCTRL(self,self.spin_ctrl_1.GetId(),self.rango1) | |
wx.EVT_SPINCTRL(self,self.spin_ctrl_2.GetId(),self.rango2) | |
wx.EVT_SPINCTRL(self,self.spin_ctrl_2_copy.GetId(),self.rango3) | |
wx.EVT_SPINCTRL(self,self.spin_ctrl_3_copy.GetId(),self.rango4) | |
wx.EVT_TEXT(self,self.combo_box_3.GetId(),self.puertos) | |
wx.EVT_BUTTON(self, self.button_7.GetId(), self.limpia) | |
wx.EVT_BUTTON(self, self.button_10.GetId(), self.limpia) | |
wx.EVT_BUTTON(self, self.button_7_copy.GetId(), self.limpia) | |
wx.EVT_BUTTON(self, self.button_10_copy.GetId(), self.limpia) | |
wx.EVT_BUTTON(self, self.button_5_copy.GetId(), self.pon) | |
wx.EVT_BUTTON(self, self.button_8_copy.GetId(), self.pon) | |
wx.EVT_BUTTON(self, self.button_5.GetId(), self.pon) | |
wx.EVT_BUTTON(self, self.button_8.GetId(), self.pon) | |
wx.EVT_BUTTON(self, self.button_6_copy.GetId(), self.quita) | |
wx.EVT_BUTTON(self, self.button_9_copy.GetId(), self.quita) | |
wx.EVT_BUTTON(self, self.button_6.GetId(), self.quita) | |
wx.EVT_BUTTON(self, self.button_9.GetId(), self.quita) | |
wx.EVT_BUTTON(self, self.button_11.GetId(), self.elimina_srv) | |
wx.EVT_TEXT(self,self.text_ctrl_1.GetId(),self.valida_nombre) | |
wx.EVT_CLOSE(self,self.cancela) | |
# Borra un servicio dado del archivo de configuracion | |
def elimina_srv(self,evt): | |
srv=self.combo_box_3.GetValue() | |
if len(srv)==0: | |
dlg = wx.MessageDialog(self, _("No hay ningun servicio seleccionado."), | |
_(‘Aviso ACEPT‘), wx.OK | wx.ICON_HAND) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
dlg.ShowModal() | |
dlg.Destroy() | |
else: | |
dlg = wx.MessageDialog(self, _("Esta seguro de que desea eleminar el servicio")+" "+srv+_("?"), | |
_(‘Aviso ACEPT‘), wx.YES_NO | wx.ICON_QUESTION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
if dlg.ShowModal()==wx.ID_YES: | |
elimina_srv(srv) | |
self.combo_box_3.Clear() | |
self.combo_box_3.SetValue(‘‘) | |
self.text_ctrl_2_copy.Clear() | |
self.lista_srv=servicios()[0] | |
self.lista_srv.sort() | |
self.combo_box_3.Append(‘‘) | |
for i in self.lista_srv: | |
self.combo_box_3.Append(i) | |
dlg.Destroy() | |
else: | |
dlg.Destroy() | |
#Comprueba que el nombre de un nuevo servicio no coincida con el de uno antiguo | |
def valida_nombre(self,evt): | |
prohibidas=[‘config‘,‘squid‘,‘servicios‘,‘usuarios‘,‘source‘,‘group‘,‘blacklists‘,‘activo‘,‘total_diario‘,‘total_semanal‘,‘total_mensual‘] | |
for i in self.lista_srv: | |
if i == self.text_ctrl_1.GetValue(): | |
dlg = wx.MessageDialog(self, _("El nombre de servicio ya existe!"), | |
_(‘Aviso ACEPT‘), wx.OK | wx.ICON_HAND) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
dlg.ShowModal() | |
dlg.Destroy() | |
self.text_ctrl_1.Clear() | |
try: | |
ind=prohibidas.index(self.text_ctrl_1.GetValue()) | |
except ValueError: | |
pass | |
else: | |
dlg = wx.MessageDialog(self, _(" Este nombre de servicio no es valido \n Se trata de una palabra reservada!"), | |
_(‘Aviso ACEPT‘), wx.OK | wx.ICON_HAND) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
dlg.ShowModal() | |
dlg.Destroy() | |
self.text_ctrl_1.Clear() | |
# Quita un puerto, o un rango de ellos de la definicion de un servicio | |
def quita(self,evt): | |
numeros=[] | |
if evt.GetId()==self.button_6_copy.GetId(): | |
num=self.spin_ctrl_2_copy.GetValue() | |
if self.checkbox_1_copy.IsChecked(): | |
lim=self.spin_ctrl_4_copy.GetValue()+1 | |
else: | |
lim=num+1 | |
protocolo=self.tcp | |
pizarra=self.text_ctrl_2_copy | |
elif evt.GetId()==self.button_9_copy.GetId(): | |
num=self.spin_ctrl_3_copy.GetValue() | |
if self.checkbox_2_copy.IsChecked(): | |
lim=self.spin_ctrl_5_copy.GetValue()+1 | |
else: | |
lim=num+1 | |
protocolo=self.udp | |
pizarra=self.text_ctrl_2_copy | |
elif evt.GetId()==self.button_6.GetId(): | |
num=self.spin_ctrl_1.GetValue() | |
if self.checkbox_1.IsChecked(): | |
lim=self.spin_ctrl_3.GetValue()+1 | |
else: | |
lim=num+1 | |
protocolo=self.tcp | |
pizarra=self.text_ctrl_2 | |
elif evt.GetId()==self.button_9.GetId(): | |
num=self.spin_ctrl_2.GetValue() | |
if self.checkbox_2.IsChecked(): | |
lim=self.spin_ctrl_4.GetValue()+1 | |
else: | |
lim=num+1 | |
protocolo=self.udp | |
pizarra=self.text_ctrl_2 | |
items=len(protocolo) | |
for i in range(items): | |
if protocolo[i]==‘‘: | |
del protocolo[i] | |
for i in range(num,lim): | |
existe=False | |
for j in protocolo: | |
if int(j) == i : | |
del protocolo[protocolo.index(j)] | |
self.muestra_puertos(self.tcp,self.udp,pizarra) | |
# Incorpora un puerto o un rango de ellos a la deficinicion de un servicio | |
def pon(self,evt): | |
numeros=[] | |
if evt.GetId()==self.button_5_copy.GetId(): | |
num=self.spin_ctrl_2_copy.GetValue() | |
if self.checkbox_1_copy.IsChecked(): | |
lim=self.spin_ctrl_4_copy.GetValue()+1 | |
else: | |
lim=num+1 | |
protocolo=self.tcp | |
pizarra=self.text_ctrl_2_copy | |
elif evt.GetId()==self.button_8_copy.GetId(): | |
num=self.spin_ctrl_3_copy.GetValue() | |
if self.checkbox_2_copy.IsChecked(): | |
lim=self.spin_ctrl_5_copy.GetValue()+1 | |
else: | |
lim=num+1 | |
protocolo=self.udp | |
pizarra=self.text_ctrl_2_copy | |
elif evt.GetId()==self.button_5.GetId(): | |
num=self.spin_ctrl_1.GetValue() | |
if self.checkbox_1.IsChecked(): | |
lim=self.spin_ctrl_3.GetValue()+1 | |
else: | |
lim=num+1 | |
protocolo=self.tcp | |
pizarra=self.text_ctrl_2 | |
elif evt.GetId()==self.button_8.GetId(): | |
num=self.spin_ctrl_2.GetValue() | |
if self.checkbox_2.IsChecked(): | |
lim=self.spin_ctrl_4.GetValue()+1 | |
else: | |
lim=num+1 | |
protocolo=self.udp | |
pizarra=self.text_ctrl_2 | |
items=len(protocolo) | |
for i in range(items): | |
if protocolo[i]==‘‘: | |
del protocolo[i] | |
for i in range(num,lim): | |
existe=False | |
for j in protocolo: | |
if int(j) == i : | |
existe=True | |
if not existe: | |
numeros.append(i) | |
for i in numeros: | |
protocolo.append(str(i)) | |
items=len(protocolo) | |
for i in range(items): | |
protocolo[i]=int(protocolo[i]) | |
protocolo.sort() | |
for i in range(items): | |
protocolo[i]=str(protocolo[i]) | |
self.muestra_puertos(self.tcp,self.udp,pizarra) | |
# Borra todas los puertos de un servicio | |
def limpia(self,evt): | |
if evt.GetId()==self.button_7.GetId(): | |
self.tcp=[‘‘] | |
pizarra=self.text_ctrl_2 | |
elif evt.GetId()==self.button_10.GetId(): | |
self.udp=[‘‘] | |
pizarra=self.text_ctrl_2 | |
elif evt.GetId()==self.button_7_copy.GetId(): | |
self.tcp=[‘‘] | |
pizarra=self.text_ctrl_2_copy | |
elif evt.GetId()==self.button_10_copy.GetId(): | |
self.udp=[‘‘] | |
pizarra=self.text_ctrl_2_copy | |
self.muestra_puertos(self.tcp,self.udp,pizarra) | |
# Lee los puertos de un servicio al seleccionarlo en la lista | |
def puertos(self,evt): | |
serv=self.combo_box_3.GetValue() | |
if len(serv)>0: | |
def_serv=servicios() | |
indice=def_serv[0].index(serv) | |
self.udp=def_serv[1][indice] | |
self.tcp=def_serv[2][indice] | |
iter=len(self.tcp) | |
for i in range(iter): | |
if self.tcp[i] != ‘‘: | |
self.tcp[i]=self.tcp[i][2:] | |
iter=len(self.udp) | |
for i in range(iter): | |
if self.udp[i] != ‘‘: | |
self.udp[i]=self.udp[i][2:] | |
self.muestra_puertos(self.tcp,self.udp,self.text_ctrl_2_copy) | |
# Muestra en la interfaz grafica los puertos que componen un servicio | |
def muestra_puertos(self,tcp,udp,pizarra): | |
pizarra.Clear() | |
pizarra.AppendText("Tcp: ") | |
if tcp !=[‘‘]: | |
for i in tcp: | |
if i != tcp[-1]: | |
pizarra.AppendText(i+", ") | |
else: | |
pizarra.AppendText(i) | |
pizarra.AppendText("\nUdp: ") | |
if udp !=[‘‘]: | |
for i in udp: | |
if i != udp[-1]: | |
pizarra.AppendText(i+", ") | |
else: | |
pizarra.AppendText(i) | |
# Los rango? comprueban el valor del puerto inicial, y si se selecciona "rango" | |
# colocan el minimo como el valor ya seleccionado+1 | |
def rango1(self,evt): | |
if self.spin_ctrl_3.IsEnabled(): | |
self.spin_ctrl_3.SetRange(self.spin_ctrl_1.GetValue()+1,65535) | |
def rango2(self,evt): | |
if self.spin_ctrl_4.IsEnabled(): | |
self.spin_ctrl_4.SetRange(self.spin_ctrl_2.GetValue()+1,65535) | |
def rango3(self,evt): | |
if self.spin_ctrl_4_copy.IsEnabled(): | |
self.spin_ctrl_4_copy.SetRange(self.spin_ctrl_2_copy.GetValue()+1,65535) | |
def rango4(self,evt): | |
if self.spin_ctrl_5_copy.IsEnabled(): | |
self.spin_ctrl_5_copy.SetRange(self.spin_ctrl_3_copy.GetValue()+1,65535) | |
def activa(self,evt): | |
if self.checkbox_1.IsChecked(): | |
self.spin_ctrl_3.Enable(True) | |
self.spin_ctrl_3.SetRange(self.spin_ctrl_1.GetValue()+1,65535) | |
else: | |
self.spin_ctrl_3.Enable(False) | |
if self.checkbox_2.IsChecked(): | |
self.spin_ctrl_4.Enable(True) | |
self.spin_ctrl_4.SetRange(self.spin_ctrl_2.GetValue()+1,65535) | |
else: | |
self.spin_ctrl_4.Enable(False) | |
if self.checkbox_1_copy.IsChecked(): | |
self.spin_ctrl_4_copy.Enable(True) | |
self.spin_ctrl_4_copy.SetRange(self.spin_ctrl_2_copy.GetValue()+1,65535) | |
else: | |
self.spin_ctrl_4_copy.Enable(False) | |
if self.checkbox_2_copy.IsChecked(): | |
self.spin_ctrl_5_copy.Enable(True) | |
self.spin_ctrl_5_copy.SetRange(self.spin_ctrl_3_copy.GetValue()+1,65535) | |
else: | |
self.spin_ctrl_5_copy.Enable(False) | |
# Muestra un panel u otro, segun se seleccione en los botones laterales | |
def cambia_panel( self, evt): | |
if evt.GetId() == self.button_1.GetId(): | |
self.notebook_1_pane_2.Hide() | |
self.notebook_1_pane_1.Show() | |
self.tcp=[‘‘] | |
self.udp=[‘‘] | |
self.text_ctrl_2_copy.Clear() | |
else : | |
self.notebook_1_pane_2.Show() | |
self.notebook_1_pane_1.Hide() | |
self.combo_box_3.SetValue(self.combo_box_3.GetValue()) | |
self.text_ctrl_2.Clear() | |
def cancela( self, evt): | |
child.servicios=False | |
self.Destroy() | |
# Graba los cambios realizados en el archivo de configuracion | |
def acepta( self, evt): | |
if self.notebook_1.GetSelection() == 0: | |
servicio=self.text_ctrl_1.GetValue() | |
else: | |
servicio=self.combo_box_3.GetValue() | |
reintenta=False | |
sale=False | |
if servicio != ‘‘: | |
elimina_srv(servicio) | |
status=crea_srv(servicio,self.tcp,self.udp) | |
if status < 2: | |
msg=_("Servicio ")+" ‘"+servicio+"‘ "+_("configurado correctamente")+"\n"+_("Desea salir de esta ventana?") | |
dlg = wx.MessageDialog(self, msg,_(‘Aviso ACEPT‘), wx.YES_NO | wx.ICON_QUESTION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
if dlg.ShowModal()==wx.ID_YES: | |
sale=True | |
dlg.Destroy() | |
else: | |
sale=False | |
dlg.Destroy() | |
if self.notebook_1.GetSelection() == 0: | |
self.text_ctrl_1.SetValue(‘‘) | |
self.text_ctrl_2.Clear() | |
else: | |
self.text_ctrl_2_copy.Clear() | |
self.combo_box_3.Clear() | |
self.combo_box_3.SetValue(‘‘) | |
self.lista_srv=servicios()[0] | |
self.lista_srv.sort() | |
self.combo_box_3.Append(‘‘) | |
for i in self.lista_srv: | |
self.combo_box_3.Append(i) | |
self.combo_box_3.SetValue(self.combo_box_3.GetValue()) | |
else: | |
msg=_("No hay puertos asignados al servicio!")+"\n"+_("Desea intentarlo de nuevo?") | |
reintenta=True | |
else: | |
msg=_("No se ha seleccionado ningun servicio")+"\n"+_("Desea intentarlo de nuevo?") | |
reintenta=True | |
if reintenta: | |
dlg = wx.MessageDialog(self, msg,_(‘Aviso ACEPT‘), wx.YES_NO | wx.ICON_QUESTION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
if dlg.ShowModal()==wx.ID_YES: | |
dlg.Destroy() | |
self.combo_box_3.Clear() | |
self.combo_box_3.SetValue(‘‘) | |
self.text_ctrl_2_copy.Clear() | |
self.lista_srv=servicios()[0] | |
self.lista_srv.sort() | |
self.combo_box_3.Append(‘‘) | |
for i in self.lista_srv: | |
self.combo_box_3.Append(i) | |
self.combo_box_3.SetValue(self.combo_box_3.GetValue()) | |
else: | |
dlg.Destroy() | |
child.servicios=False | |
self.Destroy() | |
else: | |
if sale: | |
child.servicios=False | |
self.Destroy() | |
# end of class MyChild2 | |
# Esta ventana se encarga de configurar las listas negras y sus componentes, de squid | |
class MyChild3(wx.Frame): | |
def __init__(self, *args, **kwds): | |
# begin wxGlade: MyChild3.__init__ | |
kwds["style"] = wx.DEFAULT_FRAME_STYLE | |
wx.Frame.__init__(self, *args, **kwds) | |
self.label_1 = wx.StaticText(self, -1, _("Listas negras locales")) | |
self.label_2 = wx.StaticText(self, -1, _("Fuentes de listas negras")) | |
self.list_box_4_copy = wx.ListBox(self, -1, choices=[]) | |
self.button_1 = wx.Button(self, -1, _("Crear lista local")) | |
self.button_2 = wx.Button(self, -1, _("Modificar lista local")) | |
self.button_3 = wx.Button(self, -1, _("Eliminar lista local")) | |
self.static_line_4 = wx.StaticLine(self, -1, style=wx.LI_VERTICAL) | |
self.list_box_7 = wx.ListBox(self, -1, choices=[],style=wx.LB_MULTIPLE|wx.LB_SORT) | |
self.button_4 = wx.Button(self, -1, _("Eliminar fuente")) | |
self.label_3 = wx.StaticText(self, -1, _("Actualizar cada")) | |
self.spin_ctrl_45 = wx.SpinCtrl(self, -1, "", min=0, max=365) | |
self.label_4 = wx.StaticText(self, -1, _("Dias")) | |
self.button_5 = wx.Button(self, -1, _("Actualizar ahora")) | |
self.static_line_5 = wx.StaticLine(self, -1) | |
self.label_5 = wx.StaticText(self, -1, _("Nueva fuente")) | |
self.text_ctrl_1_copy = wx.TextCtrl(self, -1, "") | |
self.button_6_copy = wx.Button(self, -1, _("Insertar")) | |
self.button_7 = wx.Button(self, -1, _("Aceptar")) | |
self.button_8 = wx.Button(self, -1, _("Cancelar")) | |
self.crea=True | |
self.modifica=True | |
self.__set_properties() | |
self.SetFocus() | |
self.__do_layout() | |
self.rellena_grupos() | |
wx.EVT_BUTTON(self, self.button_1.GetId(), self.crea_grupo) | |
wx.EVT_BUTTON(self, self.button_2.GetId(), self.aviso) | |
wx.EVT_BUTTON(self, self.button_3.GetId(), self.aviso) | |
wx.EVT_BUTTON(self, self.button_4.GetId(), self.elimina_fuente) | |
wx.EVT_BUTTON(self, self.button_5.GetId(), self.actualiza) | |
wx.EVT_BUTTON(self, self.button_6_copy.GetId(), self.inserta) | |
wx.EVT_BUTTON(self, self.button_7.GetId(), self.acepta) | |
wx.EVT_BUTTON(self, self.button_8.GetId(), self.cancela) | |
wx.EVT_LISTBOX(self,self.list_box_4_copy.GetId(),self.lista_actual) | |
wx.EVT_CLOSE(self,self.cancela) | |
# end wxGlade | |
def __set_properties(self): | |
# begin wxGlade: MyChild3.__set_properties | |
self.SetTitle(_("Listas")) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/fondo_junta.gif", wx.BITMAP_TYPE_ANY)) | |
self.SetIcon(_icon) | |
self.Centre | |
# end wxGlade | |
def __do_layout(self): | |
# begin wxGlade: MyChild3.__do_layout | |
sizer_15 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_1 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_12 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_13 = wx.BoxSizer(wx.VERTICAL) | |
sizer_33 = wx.BoxSizer(wx.VERTICAL) | |
sizer_36 = wx.BoxSizer(wx.VERTICAL) | |
sizer_37 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_34_copy = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_35 = wx.BoxSizer(wx.VERTICAL) | |
sizer_14 = wx.BoxSizer(wx.VERTICAL) | |
sizer_16 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_21 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_28 = wx.BoxSizer(wx.VERTICAL) | |
sizer_29 = wx.BoxSizer(wx.VERTICAL) | |
sizer_32 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_2 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_9 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_3 = wx.BoxSizer(wx.VERTICAL) | |
sizer_4 = wx.BoxSizer(wx.VERTICAL) | |
sizer_2.Add((20, 20), 0, 0, 0) | |
sizer_3.Add(self.label_1, 0, wx.ALIGN_CENTER_HORIZONTAL, 0) | |
sizer_3.Add(self.list_box_4_copy, 1, 0, 0) | |
sizer_4.Add((20, 20), 0, 0, 0) | |
sizer_4.Add(self.button_1, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_4.Add((20, 20), 0, 0, 0) | |
sizer_4.Add(self.button_2, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 0) | |
sizer_4.Add((20, 20), 0, 0, 0) | |
sizer_4.Add(self.button_3, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 0) | |
sizer_4.Add((20, 20), 0, 0, 0) | |
sizer_3.Add(sizer_4, 0, wx.EXPAND, 0) | |
sizer_2.Add(sizer_3, 0, wx.EXPAND, 0) | |
sizer_9.Add((20, 20), 0, 0, 0) | |
sizer_2.Add(sizer_9, 0, 0, 0) | |
sizer_1.Add(sizer_2, 0, wx.EXPAND, 0) | |
sizer_12.Add(self.static_line_4, 0, wx.EXPAND, 0) | |
sizer_12.Add((20, 20), 0, 0, 0) | |
sizer_16.Add(self.list_box_7, 1, wx.EXPAND, 0) | |
sizer_16.Add((20, 20), 0, 0, 0) | |
sizer_28.Add((20, 20), 0, 0, 0) | |
sizer_28.Add(self.button_4, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_28.Add((20, 20), 1, wx.EXPAND, 0) | |
sizer_29.Add(self.label_3, 0, 0, 0) | |
sizer_32.Add(self.spin_ctrl_45, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_32.Add((20, 20), 0, wx.EXPAND, 0) | |
sizer_32.Add(self.label_4, 0, wx.ALIGN_BOTTOM, 0) | |
sizer_29.Add(sizer_32, 1, wx.EXPAND, 0) | |
sizer_28.Add(sizer_29, 1, 0, 0) | |
sizer_28.Add((20, 20), 1, 0, 0) | |
sizer_28.Add(self.button_5, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_BOTTOM, 0) | |
sizer_21.Add(sizer_28, 1, wx.EXPAND, 0) | |
sizer_16.Add(sizer_21, 0, wx.LEFT|wx.EXPAND, 0) | |
sizer_14.Add(self.label_2, 0, 0, 0) | |
sizer_14.Add(sizer_16, 1, wx.EXPAND, 0) | |
sizer_14.Add((20, 20), 0, 0, 0) | |
sizer_13.Add(sizer_14, 1, wx.EXPAND, 0) | |
sizer_35.Add((20, 20), 0, 0, 0) | |
sizer_35.Add(self.static_line_5, 0, wx.EXPAND, 0) | |
sizer_35.Add((20, 20), 0, 0, 0) | |
sizer_33.Add(sizer_35, 0, wx.EXPAND, 0) | |
sizer_34_copy.Add(self.text_ctrl_1_copy, 1, 0, 0) | |
sizer_34_copy.Add((20, 20), 0, 0, 0) | |
sizer_34_copy.Add(self.button_6_copy, 0, 0, 0) | |
sizer_34_copy.Add((20, 20), 0, 0, 0) | |
sizer_33.Add(self.label_5, 0, 0, 0) | |
sizer_33.Add(sizer_34_copy, 0, wx.EXPAND, 0) | |
sizer_36.Add((20, 20), 1, wx.EXPAND, 0) | |
sizer_37.Add(self.button_7, 1, 0, 0) | |
sizer_37.Add((20, 20), 1, 0, 0) | |
sizer_37.Add(self.button_8, 1, 0, 0) | |
sizer_36.Add(sizer_37, 1, wx.EXPAND, 0) | |
sizer_36.Add((20, 20), 0, 0, 0) | |
sizer_33.Add(sizer_36, 1, wx.EXPAND, 0) | |
sizer_13.Add(sizer_33, 1, wx.EXPAND, 0) | |
sizer_12.Add(sizer_13, 1, wx.EXPAND, 0) | |
sizer_12.Add((20, 20), 0, 0, 0) | |
sizer_1.Add(sizer_12, 1, wx.EXPAND, 0) | |
sizer_15.Add(sizer_1, 1, wx.EXPAND, 0) | |
self.SetAutoLayout(True) | |
self.SetSizer(sizer_15) | |
sizer_15.Fit(self) | |
sizer_15.SetSizeHints(self) | |
self.Layout() | |
# end wxGlade | |
# obtiene el nombre d ela lista negra seleccionada | |
def lista_actual(self,event): | |
bl_lst.nombre=self.list_box_4_copy.GetString(self.list_box_4_copy.GetSelections()[0]) | |
# Comprueba si se ha seleccionado una lista antes de realizar un cambio | |
def aviso(self,event): | |
if bl_lst.nombre==‘‘: | |
dlg = wx.MessageDialog(self, _("No ha seleccionado ninguna lista negra local!"), | |
_(‘Aviso ACEPT‘), wx.OK | wx.ICON_EXCLAMATION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
dlg.ShowModal() | |
dlg.Destroy() | |
elif event.GetId()==self.button_3.GetId(): | |
self.elimina_lista_local() | |
self.rellena_grupos() | |
bl_lst.nombre=‘‘ | |
elif event.GetId()==self.button_2.GetId(): | |
self.modifica_gr() | |
# borra una lista del archivo de configuracion | |
def elimina_lista_local(self): | |
from confSquid import elimina_blacklist | |
from inicSquid import apply_conf_squidguard | |
from watcherSquid import establece_permisos | |
dlg = wx.MessageDialog(self, _("Esta seguro de que desea eliminar la lista")+" "+bl_lst.nombre+_("?"), | |
_(‘Aviso ACEPT‘), wx.YES_NO | wx.ICON_QUESTION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
if dlg.ShowModal()==wx.ID_YES: | |
elimina_blacklist(bl_lst.nombre,archivo.configuracion) | |
apply_conf_squidguard(archivo.aceptlog) | |
dlg.Destroy() | |
else: | |
dlg.Destroy() | |
# Elimina las fuentes de la interfaz grafica | |
def elimina_fuente(self,event): | |
if len(self.list_box_7.GetSelections())==0: | |
dlg = wx.MessageDialog(self, _("No hay ninguna lista seleccionada para ser eliminada"), | |
_(‘Aviso ACEPT‘), wx.OK | wx.ICON_INFORMATION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
dlg.ShowModal() | |
else: | |
lista=[] | |
for i in self.list_box_7.GetSelections(): | |
lista.append(self.list_box_7.GetString(i)) | |
items=self.list_box_7.GetCount() | |
for i in range(items): | |
for j in lista: | |
if self.list_box_7.GetString(i)==j: | |
self.list_box_7.Delete(i) | |
# Incorpora a la interfaz grafica los grupos configurados | |
def rellena_grupos(self): | |
from confSquid import local_blacklists, lee_fuentes | |
from func import consulta_campo | |
local_blacklists=local_blacklists(archivo.configuracion) | |
system_blacklists=lee_fuentes(archivo.configuracion) | |
self.list_box_4_copy.Clear() | |
self.list_box_7.Clear() | |
for i in local_blacklists: | |
self.list_box_4_copy.Append(i) | |
for i in system_blacklists: | |
self.list_box_7.Append(i) | |
freq=consulta_campo(‘fr_update‘,archivo.aceptlog) | |
self.spin_ctrl_45.SetValue(int(freq)) | |
# a?de una uri a la lista de uris que se usan para actualizar las listas negras | |
def inserta(self,event): | |
fuente=self.text_ctrl_1_copy.GetValue() | |
if fuente: | |
self.list_box_7.Append(fuente) | |
items=self.list_box_7.GetCount() | |
items=items-1 | |
max=items | |
if items>0: | |
for i in range(items): | |
if i<=max: | |
if self.list_box_7.GetString(i)==self.list_box_7.GetString(i+1): | |
self.list_box_7.Delete(i) | |
max=max-1 | |
if i>max: | |
break | |
self.text_ctrl_1_copy.Clear() | |
else: | |
dlg = wx.MessageDialog(self, _("No se ha introducido una URL"), | |
_(‘Aviso ACEPT‘), wx.OK | wx.ICON_INFORMATION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
dlg.ShowModal() | |
# muestra la interfaz para crear listas negras locales | |
def crea_grupo(self, event): | |
if self.crea: | |
self.crea=False | |
win=MyChild6(self, -1, "") | |
win.Show() | |
# Muestra la interfaz para modificar las listas negras locales | |
def modifica_gr(self): | |
if self.modifica: | |
self.modifica=False | |
win=MyChild7(self, -1, "") | |
win.Show() | |
# Hace que se descarguen las listas negras de las uris pertinentes las configura | |
def actualiza(self,event): | |
from watcherSquid import ublacklists,establece_permisos | |
from confSquid import actualiza_fuentes | |
from func_blacklists import revisa_blacklists | |
padre=self.GetParent() | |
self.Hide() | |
self.Update() | |
padre.Hide() | |
padre.Update() | |
fuentes=[] | |
freq=self.spin_ctrl_45.GetValue() | |
items=self.list_box_7.GetCount() | |
for i in range(items): | |
fuentes.append(self.list_box_7.GetString(i)) | |
actualiza_fuentes(fuentes,freq,archivo.configuracion) | |
####barra | |
from os import system, kill | |
from time import sleep | |
f=open("/tmp/milog2","w") | |
f.close() | |
system(‘/usr/share/acept/barra.py "Configurando listas negras" &‘) | |
sleep(5) | |
pbl=ublacklists(archivo.configuracion) | |
revisa_blacklists(archivo.configuracion) | |
establece_permisos(archivo.configuracion) | |
nproblems=len(pbl[0]) | |
if nproblems>0: | |
msg1=" Problemas con la descarga de :" | |
msg2=" Problemas con extraccion de :" | |
nmsg1=len(msg1) | |
nmsg2=len(msg2) | |
for i in range(nproblems): | |
if pbl[1][i]==0: | |
msg1=msg1+‘\n‘+pbl[0][i] | |
if pbl[1][i]==1: | |
msg2=msg2+‘\n‘+pbl[0][i] | |
msg_dlg="" | |
if len(msg1)>nmsg1: | |
msg_dlg=msg_dlg+msg1 | |
if len(msg2)>nmsg2: | |
if len(msg_dlg)>0: | |
msg_dlg=msg_dlg+‘\n‘ | |
msg_dlg=msg_dlg+msg2 | |
dlg = wx.MessageDialog(self, msg_dlg, _(‘Aviso ACEPT‘), wx.OK | wx.ICON_INFORMATION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
dlg.ShowModal() | |
try: | |
f=open("/tmp/bklprg","r") | |
pid=f.read() | |
kill(int(pid),9) | |
system("rm /tmp/bklprg") | |
except: | |
pass | |
dlg = wx.MessageDialog(self, _(" Finalizado proceso de actualizacion.\nLe recomendamos revisar las listas asignadas a los usuarios. "), | |
_(‘Aviso ACEPT‘), wx.OK | wx.ICON_INFORMATION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
dlg.ShowModal() | |
padre.Show() | |
self.Show() | |
# Aplica los cambios a los archivos de configuracion | |
def acepta(self,event): | |
from confSquid import actualiza_fuentes | |
from inicSquid import apply_conf_squidguard | |
fuentes=[] | |
freq=self.spin_ctrl_45.GetValue() | |
items=self.list_box_7.GetCount() | |
for i in range(items): | |
fuentes.append(self.list_box_7.GetString(i)) | |
actualiza_fuentes(fuentes,freq,archivo.configuracion) | |
apply_conf_squidguard(archivo.aceptlog) | |
dlg = wx.MessageDialog(self, _(" Listado de fuentes actualizado.\n"+_("Desea salir de esta ventana?")), | |
_(‘Aviso ACEPT‘), wx.YES_NO | wx.ICON_QUESTION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
if dlg.ShowModal()==wx.ID_YES: | |
dlg.Destroy() | |
self.cancela(self) | |
else: | |
dlg.Destroy() | |
def cancela(self,event): | |
child.listas=False | |
self.Destroy() | |
# end of class MyChild3 | |
class MyChild4(wx.Frame): | |
def __init__(self, *args, **kwds): | |
from os.path import isfile | |
# begin wxGlade: MyFrame.__init__ | |
kwds["style"] = wx.DEFAULT_FRAME_STYLE | |
wx.Frame.__init__(self, *args, **kwds) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/fondo_junta.gif", wx.BITMAP_TYPE_ANY)) | |
self.SetIcon(_icon) | |
self.label_2 = wx.StaticText(self, -1, " Texto") | |
self.text_ctrl_2 = wx.TextCtrl(self, -1, "") | |
self.button_1 = wx.Button(self, -1, "Incluir -->") | |
self.button_1_copy = wx.Button(self, -1, "<-- Eliminar") | |
self.button_1_copy_1 = wx.Button(self, -1, "Eliminar todo") | |
self.static_line_1 = wx.StaticLine(self, -1, style=wx.LI_VERTICAL) | |
self.label_1 = wx.StaticText(self, -1, "Expresiones", style=wx.ALIGN_CENTRE) | |
self.text_ctrl_2.SetMinSize((183, 30)) | |
self.list_box_1 = wx.ListBox(self, -1, choices=[],style=wx.LB_SINGLE) | |
#self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY) | |
self.static_line_2 = wx.StaticLine(self, -1) | |
self.button_5 = wx.Button(self, -1, "Aceptar") | |
self.button_6 = wx.Button(self, -1, "Salir") | |
# Lee el archivo /etc/acept/watcherCat/expresiones y rellena list_box_1 | |
if isfile("/etc/acept/watcherCat/expresiones/expressions"): | |
f=open("/etc/acept/watcherCat/expresiones/expressions","r") | |
lineas=f.read() | |
lineas=lineas.replace("(","").replace(")","").replace("\n","") | |
for i in lineas.split(‘|‘): | |
if len(i)>0: | |
self.list_box_1.Append(i) | |
else: | |
from os.path import isdir | |
if not isdir("/etc/acept/watcherCat/expresiones"): | |
from os import mkdir | |
mkdir("/etc/acept/watcherCat/expresiones") | |
self.__set_properties() | |
self.__do_layout() | |
wx.EVT_BUTTON(self, self.button_1.GetId(),self.incluir) | |
wx.EVT_BUTTON(self,self.button_1_copy.GetId(),self.elimina) | |
wx.EVT_BUTTON(self, self.button_1_copy_1.GetId(),self.limpia_todo) | |
wx.EVT_BUTTON(self, self.button_5.GetId(),self.aceptar) | |
wx.EVT_BUTTON(self, self.button_6.GetId(),self.cancela) | |
wx.EVT_CLOSE(self,self.cancela) | |
# end wxGlade | |
def elimina(self,event): | |
fuente=self.list_box_1.GetSelection() | |
self.list_box_1.Delete(fuente) | |
def aceptar(self,event): | |
from os.path import isdir | |
from func import parse_file | |
from func_blacklists import existe_grupo, append_grupo, revisa_grupo, revisa_blacklists, renuevadir | |
from watcherSquid import compila_libreria, establece_permisos | |
from inicSquid import apply_conf_squidguard | |
from os import system, listdir, mkdir,kill | |
padre=self.GetParent() | |
self.Hide() | |
self.Update() | |
padre.Hide() | |
padre.Update() | |
items=self.list_box_1.GetCount() | |
if items>0: | |
if not isdir("/etc/acept/watcherCat/expresiones"): | |
mkdir("/etc/acept/watcherCat/expresiones") | |
f=open("/etc/acept/watcherCat/expresiones/expressions","w") | |
f.write(‘(‘) | |
for i in range(items): | |
f.write(self.list_box_1.GetString(i)) | |
if i<items-1: | |
f.write(‘|‘) | |
f.write(‘)\n‘) | |
f.close() | |
system("cp -r /etc/acept/watcherCat/expresiones /var/lib/squidguard/db") | |
xmldoc=parse_file(archivo.configuracion) | |
grupos=xmldoc.getElementsByTagName(‘group‘) | |
if existe_grupo("expresiones",grupos)==-1: | |
append_grupo(‘expresiones‘,‘‘,xmldoc,archivo.configuracion,"/var/lib/squidguard/db/expresiones") | |
else: | |
revisa_grupo(‘expresiones‘,‘‘,xmldoc,archivo.configuracion,"/var/lib/squidguard/db/expresiones") | |
compila_libreria("expresiones",archivo.aceptlog) | |
revisa_blacklists(archivo.configuracion) | |
renuevadir("/tmp/watch_blacklist", archivo.aceptlog) | |
apply_conf_squidguard(archivo.aceptlog) | |
establece_permisos(archivo.configuracion) | |
mensaje="Proceso finalizado correctamente \n No olvide incorporar a los usuarios la lista expresiones." | |
dlg = wx.MessageDialog(self, _(mensaje), | |
_(‘Aviso ACEPT‘), wx.OK | wx.ICON_INFORMATION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
dlg.ShowModal() | |
padre.Show() | |
child.expresiones=False | |
self.Destroy() | |
def incluir(self,event): | |
fuente=self.text_ctrl_2.GetValue() | |
if fuente: | |
items=self.list_box_1.GetCount() | |
items=items | |
lista=[] | |
existe=False | |
for i in range(items): | |
lista.append(self.list_box_1.GetString(i)) | |
for i in lista: | |
if i==fuente: | |
existe=True | |
break | |
if not existe: | |
lista.append(fuente) | |
lista.sort() | |
self.list_box_1.Clear() | |
for i in lista: | |
self.list_box_1.Append(i) | |
self.text_ctrl_2.Clear() | |
else: | |
dlg = wx.MessageDialog(self, _("No se ha introducido ninguna expresion"), | |
_(‘Aviso ACEPT‘), wx.OK | wx.ICON_INFORMATION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
dlg.ShowModal() | |
def limpia_todo(self,event): | |
self.list_box_1.Clear() | |
def oculta(self): | |
from os import system | |
from os.path import isfile | |
self.Hide() | |
padre=self.GetParent() | |
padre.Hide() | |
def cancela(self,event): | |
child.expresiones=False | |
self.Destroy() | |
def __set_properties(self): | |
# begin wxGlade: MyFrame.__set_properties | |
self.SetTitle("Configurar expresiones regulares") | |
self.text_ctrl_2.SetMinSize((183, 30)) | |
self.list_box_1.SetMinSize((300, 120)) | |
# end wxGlade | |
def __do_layout(self): | |
# begin wxGlade: MyFrame.__do_layout | |
sizer_1 = wx.BoxSizer(wx.VERTICAL) | |
sizer_2 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_3 = wx.BoxSizer(wx.VERTICAL) | |
sizer_15 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_16 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_5 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_6_copy = wx.BoxSizer(wx.VERTICAL) | |
sizer_7 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_4 = wx.BoxSizer(wx.VERTICAL) | |
sizer_11_copy = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_14_copy_1 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_11 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_14_copy = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_10 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_14 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_12 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_9 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_8 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_1.Add((10, 10), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_2.Add((10, 10), 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0) | |
sizer_8.Add((10, 10), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) | |
sizer_4.Add(sizer_8, 0, wx.EXPAND, 0) | |
sizer_9.Add(self.label_2, 1, wx.ALIGN_BOTTOM|wx.ADJUST_MINSIZE, 0) | |
sizer_4.Add(sizer_9, 0, wx.EXPAND, 0) | |
sizer_12.Add(self.text_ctrl_2, 1, wx.ADJUST_MINSIZE, 0) | |
sizer_10.Add(sizer_12, 1, 0, 0) | |
sizer_14.Add((55, 18), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_14.Add(self.button_1, 1, wx.ADJUST_MINSIZE, 0) | |
sizer_10.Add(sizer_14, 1, wx.EXPAND, 0) | |
sizer_4.Add(sizer_10, 0, wx.EXPAND, 0) | |
sizer_4.Add((10, 10), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) | |
sizer_11.Add((10, 10), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) | |
sizer_14_copy.Add((55, 18), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_14_copy.Add(self.button_1_copy, 1, wx.ADJUST_MINSIZE, 0) | |
sizer_11.Add(sizer_14_copy, 1, wx.EXPAND, 0) | |
sizer_4.Add(sizer_11, 0, wx.EXPAND, 0) | |
sizer_4.Add((10, 10), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy.Add((10, 10), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) | |
sizer_14_copy_1.Add((55, 18), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_14_copy_1.Add(self.button_1_copy_1, 1, wx.ADJUST_MINSIZE, 0) | |
sizer_11_copy.Add(sizer_14_copy_1, 1, wx.EXPAND, 0) | |
sizer_4.Add(sizer_11_copy, 0, wx.EXPAND, 0) | |
sizer_4.Add((10, 10), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) | |
sizer_5.Add(sizer_4, 1, wx.EXPAND, 0) | |
sizer_7.Add((10, 10), 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0) | |
sizer_7.Add(self.static_line_1, 0, wx.EXPAND, 0) | |
sizer_7.Add((10, 10), 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0) | |
sizer_5.Add(sizer_7, 0, wx.EXPAND, 0) | |
sizer_6_copy.Add(self.label_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ADJUST_MINSIZE, 0) | |
sizer_6_copy.Add(self.list_box_1, 1, wx.ADJUST_MINSIZE, 0) | |
#sizer_6_copy.Add(self.text_ctrl_1, 1, wx.ADJUST_MINSIZE, 0) | |
sizer_6_copy.Add((10, 10), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_5.Add(sizer_6_copy, 0, wx.EXPAND, 0) | |
sizer_3.Add(sizer_5, 1, wx.EXPAND, 0) | |
sizer_3.Add(self.static_line_2, 0, wx.EXPAND, 0) | |
sizer_3.Add((10, 10), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_15.Add((20, 20), 1, wx.ADJUST_MINSIZE, 0) | |
sizer_16.Add(self.button_5, 0, wx.ADJUST_MINSIZE, 0) | |
sizer_16.Add((20, 20), 1, wx.ADJUST_MINSIZE, 0) | |
sizer_16.Add(self.button_6, 0, wx.ADJUST_MINSIZE, 0) | |
sizer_15.Add(sizer_16, 1, wx.EXPAND, 0) | |
sizer_15.Add((20, 20), 1, wx.ADJUST_MINSIZE, 0) | |
sizer_3.Add(sizer_15, 0, wx.EXPAND, 0) | |
sizer_3.Add((10, 10), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_2.Add(sizer_3, 1, wx.EXPAND, 0) | |
sizer_2.Add((10, 10), 0, wx.ADJUST_MINSIZE, 0) | |
sizer_1.Add(sizer_2, 1, wx.EXPAND, 0) | |
self.SetAutoLayout(True) | |
self.SetSizer(sizer_1) | |
sizer_1.Fit(self) | |
sizer_1.SetSizeHints(self) | |
self.Layout() | |
# end wxGlade | |
# Esta ventana se encarga de asignar listas negras o blancas a usuarios determinados | |
class MyChild5(wx.Frame): | |
def __init__(self, *args, **kwds): | |
# begin wxGlade: MyChild5.__init__ | |
kwds["style"] = wx.DEFAULT_FRAME_STYLE | |
wx.Frame.__init__(self, *args, **kwds) | |
self.label_18_copy_1 = wx.StaticText(self, -1, _("Usuarios")) | |
self.list_box_14 = wx.ListBox(self, -1, choices=[],style=wx.LB_SINGLE) | |
self.button_28 = wx.Button(self, -1, _("Aceptar")) | |
self.button_29 = wx.Button(self, -1, _("Cancelar")) | |
self.static_line_7 = wx.StaticLine(self, -1, style=wx.LI_VERTICAL) | |
self.label_18 = wx.StaticText(self, -1, _("Listas negras del sistema")) | |
self.label_19 = wx.StaticText(self, -1, _("Lista negra del usuario")) | |
self.list_box_12 = wx.ListBox(self, -1, choices=[],style=wx.LB_EXTENDED|wx.LB_SORT) | |
self.button_30_copy = wx.Button(self, -1, _("Insertar todo")) | |
self.button_31_copy_copy = wx.Button(self, -1, "-->") | |
self.button_32_copy = wx.Button(self, -1, "<--") | |
self.button_33_copy = wx.Button(self, -1, _("Borrar todo")) | |
self.list_box_13 = wx.ListBox(self, -1, choices=[],style=wx.LB_EXTENDED|wx.LB_SORT) | |
self.static_line_8 = wx.StaticLine(self, -1) | |
self.label_18_copy = wx.StaticText(self, -1, _("Introduzca un nuevo dominio")) | |
self.label_19_copy = wx.StaticText(self, -1, _("Lista blanca del usuario")) | |
self.text_ctrl_8 = wx.TextCtrl(self, -1, "") | |
self.button_34_copy = wx.Button(self, -1, "-->") | |
self.button_35_copy = wx.Button(self, -1, "<--") | |
self.button_36_copy = wx.Button(self, -1, _("Borrar todo")) | |
self.list_box_15 = wx.ListBox(self, -1, choices=[],style=wx.LB_MULTIPLE|wx.LB_SORT) | |
self.rellena_usuarios() | |
self.listas_negras() | |
self.SetFocus() | |
self.__set_properties() | |
self.__do_layout() | |
self.vieja_sel=(-1) | |
self.viejo_last=False | |
self.contador=-1 | |
wx.EVT_CLOSE(self,self.cancela) | |
wx.EVT_BUTTON(self, self.button_30_copy.GetId(), self.in_todo) | |
wx.EVT_BUTTON(self, self.button_31_copy_copy.GetId(), self.inserta_blacklist) | |
wx.EVT_BUTTON(self, self.button_32_copy.GetId(), self.elimina_listanegra) | |
wx.EVT_BUTTON(self, self.button_33_copy.GetId(), self.del_todo) | |
wx.EVT_BUTTON(self, self.button_34_copy.GetId(), self.inserta_whitelist) | |
wx.EVT_BUTTON(self, self.button_35_copy.GetId(), self.elimina_whitelist) | |
wx.EVT_BUTTON(self, self.button_36_copy.GetId(), self.del_todo_bl) | |
wx.EVT_BUTTON(self, self.button_28.GetId(), self.acepta) | |
wx.EVT_BUTTON(self, self.button_29.GetId(), self.cancela) | |
wx.EVT_LISTBOX(self,self.list_box_14.GetId(),self.datos_user) | |
wx.EVT_LISTBOX(self,self.list_box_12.GetId(),self.l12) | |
# end wxGlade | |
def __set_properties(self): | |
# begin wxGlade: MyChild5.__set_properties | |
self.SetTitle(_("Contenidos")) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/fondo_junta.gif", wx.BITMAP_TYPE_ANY)) | |
self.SetIcon(_icon) | |
self.Centre | |
# end wxGlade | |
def __do_layout(self): | |
# begin wxGlade: MyChild5.__do_layout | |
sizer_73 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_74 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_76 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_80 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_81 = wx.BoxSizer(wx.VERTICAL) | |
sizer_87 = wx.BoxSizer(wx.VERTICAL) | |
sizer_88 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_89 = wx.BoxSizer(wx.VERTICAL) | |
sizer_90_copy = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_82 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_84 = wx.BoxSizer(wx.VERTICAL) | |
sizer_90 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_75 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_77 = wx.BoxSizer(wx.VERTICAL) | |
sizer_78 = wx.BoxSizer(wx.VERTICAL) | |
sizer_79 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_85 = wx.BoxSizer(wx.VERTICAL) | |
sizer_86 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_90_copy_1 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_90_copy_1.Add((20, 20), 0, 0, 0) | |
sizer_90_copy_1.Add(self.label_18_copy_1, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_85.Add(sizer_90_copy_1, 0, 0, 0) | |
sizer_86.Add((20, 20), 0, 0, 0) | |
sizer_86.Add(self.list_box_14, 1, wx.EXPAND, 0) | |
sizer_85.Add(sizer_86, 1, wx.EXPAND, 0) | |
sizer_77.Add(sizer_85, 1, wx.EXPAND, 0) | |
sizer_78.Add((20, 20), 0, 0, 0) | |
sizer_79.Add((20, 20), 1, 0, 0) | |
sizer_79.Add(self.button_28, 0, 0, 0) | |
sizer_79.Add((20, 20), 1, 0, 0) | |
sizer_79.Add(self.button_29, 0, 0, 0) | |
sizer_78.Add(sizer_79, 1, wx.EXPAND, 0) | |
sizer_78.Add((20, 20), 0, 0, 0) | |
sizer_77.Add(sizer_78, 0, wx.EXPAND, 0) | |
sizer_75.Add(sizer_77, 1, wx.EXPAND, 0) | |
sizer_75.Add((20, 20), 0, 0, 0) | |
sizer_74.Add(sizer_75, 0, wx.EXPAND, 0) | |
sizer_80.Add(self.static_line_7, 0, wx.EXPAND, 0) | |
sizer_80.Add((20, 20), 0, 0, 0) | |
sizer_90.Add(self.label_18, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_90.Add((20, 20), 1, 0, 0) | |
sizer_90.Add(self.label_19, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_81.Add(sizer_90, 0, wx.EXPAND, 0) | |
sizer_82.Add(self.list_box_12, 1, wx.EXPAND, 0) | |
sizer_82.Add((20, 20), 0, 0, 0) | |
sizer_84.Add((20, 20), 1, 0, 0) | |
sizer_84.Add(self.button_30_copy, 0, wx.ALIGN_CENTER_HORIZONTAL, 0) | |
sizer_84.Add((20, 20), 1, 0, 0) | |
sizer_84.Add(self.button_31_copy_copy, 0, wx.ALIGN_CENTER_HORIZONTAL, 0) | |
sizer_84.Add((20, 20), 0, 0, 0) | |
sizer_84.Add(self.button_32_copy, 0, wx.ALIGN_CENTER_HORIZONTAL, 0) | |
sizer_84.Add((20, 20), 1, 0, 0) | |
sizer_84.Add(self.button_33_copy, 0, wx.ALIGN_CENTER_HORIZONTAL, 0) | |
sizer_84.Add((20, 20), 1, 0, 0) | |
sizer_82.Add(sizer_84, 0, wx.EXPAND, 0) | |
sizer_82.Add((20, 20), 0, 0, 0) | |
sizer_82.Add(self.list_box_13, 1, wx.EXPAND, 0) | |
sizer_81.Add(sizer_82, 1, wx.EXPAND, 0) | |
sizer_81.Add((20, 20), 0, 0, 0) | |
sizer_81.Add(self.static_line_8, 0, wx.EXPAND, 0) | |
sizer_90_copy.Add(self.label_18_copy, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_90_copy.Add((20, 20), 1, wx.EXPAND, 0) | |
sizer_90_copy.Add(self.label_19_copy, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_87.Add(sizer_90_copy, 0, wx.EXPAND, 0) | |
sizer_88.Add(self.text_ctrl_8, 1, 0, 0) | |
sizer_88.Add((20, 20), 0, 0, 0) | |
sizer_89.Add(self.button_34_copy, 0, 0, 0) | |
sizer_89.Add((20, 20), 0, 0, 0) | |
sizer_89.Add(self.button_35_copy, 0, 0, 0) | |
sizer_89.Add((20, 20), 1, wx.EXPAND, 0) | |
sizer_89.Add(self.button_36_copy, 0, 0, 0) | |
sizer_88.Add(sizer_89, 0, wx.EXPAND, 0) | |
sizer_88.Add((20, 20), 0, 0, 0) | |
sizer_88.Add(self.list_box_15, 1, wx.EXPAND, 0) | |
sizer_87.Add(sizer_88, 1, wx.EXPAND, 0) | |
sizer_81.Add(sizer_87, 1, wx.EXPAND, 0) | |
sizer_81.Add((20, 20), 0, 0, 0) | |
sizer_80.Add(sizer_81, 1, wx.EXPAND, 0) | |
sizer_80.Add((20, 20), 0, 0, 0) | |
sizer_76.Add(sizer_80, 1, wx.EXPAND, 0) | |
sizer_74.Add(sizer_76, 1, wx.EXPAND, 0) | |
sizer_73.Add(sizer_74, 1, wx.EXPAND, 0) | |
self.SetAutoLayout(True) | |
self.SetSizer(sizer_73) | |
sizer_73.Fit(self) | |
sizer_73.SetSizeHints(self) | |
self.Layout() | |
# end wxGlade | |
def l12(self,event): | |
try: | |
nueva_sel=self.list_box_12.GetSelections() | |
self.contador=self.contador+1 | |
last=-1 | |
if self.contador>0 and self.vieja_sel!=(-1): | |
self.contador=1 | |
items=len(self.vieja_sel) | |
for i in range(items): | |
if self.vieja_sel[i]!=nueva_sel[i]: | |
last=i | |
break | |
if self.viejo_last: | |
if self.vieja_sel[self.viejo_last] == nueva_sel[last]: | |
self.list_box_12.Deselect(self.vieja_sel[self.viejo_last]) | |
if self.contador>0: | |
self.viejo_last=-1 | |
self.vieja_sel=self.list_box_12.GetSelections() | |
except: | |
self.vieja_sel=self.list_box_12.GetSelections() | |
# quita una lista negra al usuario seleccionado | |
def elimina_listanegra(self,event): | |
lista=[] | |
for i in self.list_box_13.GetSelections(): | |
lista.append(self.list_box_13.GetString(i)) | |
items=self.list_box_13.GetCount() | |
for i in range(items): | |
for j in lista: | |
if self.list_box_13.GetString(i)==j: | |
self.list_box_13.Delete(i) | |
# quita una lista blanca al usuario seleccionado | |
def elimina_whitelist(self,event): | |
lista=[] | |
for i in self.list_box_15.GetSelections(): | |
lista.append(self.list_box_15.GetString(i)) | |
items=self.list_box_15.GetCount() | |
for i in range(items): | |
for j in lista: | |
if self.list_box_15.GetString(i)==j: | |
self.list_box_15.Delete(i) | |
# a?de una lista blanca al usuario seleccionado | |
def inserta_whitelist(self,event): | |
self.list_box_15.Append(self.text_ctrl_8.GetValue()) | |
self.text_ctrl_8.Clear() | |
items=self.list_box_15.GetCount() | |
items=items-1 | |
max=items | |
if items>0: | |
for i in range(items): | |
if i<=max: | |
if self.list_box_15.GetString(i)==self.list_box_15.GetString(i+1): | |
self.list_box_15.Delete(i) | |
max=max-1 | |
if i>max: | |
break | |
# a?de una lista negra al usuario seleccionado | |
def inserta_blacklist(self,event): | |
for i in self.list_box_12.GetSelections(): | |
self.list_box_13.Append(self.list_box_12.GetString(i)) | |
items=self.list_box_13.GetCount() | |
items=items-1 | |
max=items | |
if items>0: | |
for i in range(items): | |
if i<=max: | |
if self.list_box_13.GetString(i)==self.list_box_13.GetString(i+1): | |
self.list_box_13.Delete(i) | |
max=max-1 | |
if i>max: | |
break | |
# borra todas las listas negras del usuario | |
def del_todo(self,event): | |
self.list_box_13.Clear() | |
# borra todas las listas blancas del usuario | |
def del_todo_bl(self,event): | |
self.list_box_15.Clear() | |
# inserta todas las listas negras a un usuario | |
def in_todo(self,event): | |
self.list_box_13.Clear() | |
items=self.list_box_12.GetCount() | |
for i in range(items): | |
self.list_box_13.Append(self.list_box_12.GetString(i)) | |
# Lee las listas negras del sistema | |
def listas_negras(self): | |
from confSquid import listado_blacklists | |
listas=listado_blacklists(archivo.configuracion) | |
for i in listas: | |
self.list_box_12.Append(i) | |
# Toma los datos de la configuracion del usuario seleccionado | |
def datos_user(self,event): | |
from confSquid import lee_userblacklists, lee_whitelist | |
usr=self.list_box_14.GetString(self.list_box_14.GetSelections()[0]) | |
if len(self.list_box_12.GetSelections())>0: | |
for i in range(self.list_box_12.GetCount()): | |
self.list_box_12.SetSelection(i,False) | |
self.list_box_13.Clear() | |
self.list_box_15.Clear() | |
self.text_ctrl_8.Clear() | |
lis_ngr=lee_userblacklists(usr,archivo.configuracion) | |
lis_bl=lee_whitelist(usr,archivo.configuracion) | |
for i in lis_ngr: | |
self.list_box_13.Append(i) | |
for i in lis_bl: | |
self.list_box_15.Append(i) | |
# lee los usuarios del sistema | |
def rellena_usuarios (self): | |
self.list_box_14.Clear() | |
tmp_us=lista_usuarios(int(uid.min)) | |
for i in tmp_us: | |
self.list_box_14.Append(i) | |
# Graba cambios de filtrado de contenido para usuario en el archivo de configuracion | |
def acepta (self,event): | |
from confSquid import actualiza_userblacklists, actualiza_whitelist | |
def guarda (user): | |
from func import control_web_user | |
from inicSquid import inic_squid_user, inic_sarg_user, apply_conf_squidguard_user, inic_direct_user | |
#Se vierten cambios realizados para usuario | |
if control_web_user(user,archivo.aceptlog)==1: | |
inic_squid_user(user,archivo.aceptlog) | |
inic_sarg_user(user,archivo.aceptlog) | |
apply_conf_squidguard_user(user,archivo.aceptlog) | |
inic_direct_user(user,archivo.aceptlog) | |
if self.list_box_14.GetSelections(): | |
usr=self.list_box_14.GetString(self.list_box_14.GetSelections()[0]) | |
msg=_("Guardados los cambios para ")+"‘"+usr+"‘\n"+_("Desea salir de esta ventana?") | |
listas_negras=[] | |
lista_blanca=[] | |
items_ng=self.list_box_13.GetCount() | |
for i in range(items_ng): | |
listas_negras.append(self.list_box_13.GetString(i)) | |
items_bl=self.list_box_15.GetCount() | |
for i in range(items_bl): | |
lista_blanca.append(self.list_box_15.GetString(i)) | |
if len(self.list_box_12.GetSelections())>0: | |
for i in range(self.list_box_12.GetCount()): | |
self.list_box_12.SetSelection(i,False) | |
nodo_usuario(usr) | |
actualiza_userblacklists(usr,listas_negras,archivo.configuracion) | |
actualiza_whitelist(usr,lista_blanca,archivo.configuracion) | |
guarda(usr) | |
dlg = wx.MessageDialog(self, msg,_(‘Aviso ACEPT‘), wx.YES_NO | wx.ICON_QUESTION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
if dlg.ShowModal()==wx.ID_YES: | |
dlg.Destroy() | |
self.cancela(self) | |
else: | |
dlg.Destroy() | |
else: | |
msg=_("No ha seleccionado ningun usuario!")+"\n"+_("Desea intentarlo de nuevo?") | |
dlg = wx.MessageDialog(self, msg,_(‘Aviso ACEPT‘), wx.YES_NO | wx.ICON_QUESTION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
if dlg.ShowModal()==wx.ID_YES: | |
dlg.Destroy() | |
else: | |
dlg.Destroy() | |
self.cancela(self) | |
def cancela (self, event): | |
child.contenidos=False | |
self.Destroy() | |
# end of class MyChild5 | |
# Interfaz para la creacion de una lista local | |
class MyChild6(wx.Frame): | |
def __init__(self, *args, **kwds): | |
# begin wxGlade: Mychild6.__init__ | |
kwds["style"] = wx.DEFAULT_FRAME_STYLE | |
wx.Frame.__init__(self, *args, **kwds) | |
self.label_1_copy = wx.StaticText(self, -1, _("Nombre")) | |
self.text_ctrl_2 = wx.TextCtrl(self, -1, "") | |
self.label_2 = wx.StaticText(self, -1, _("URL")) | |
self.text_ctrl_4 = wx.TextCtrl(self, -1, "") | |
self.button_1 = wx.Button(self, -1, "-->") | |
self.button_2 = wx.Button(self, -1, "<--") | |
self.button_3 = wx.Button(self, -1, _("Eliminar todo")) | |
self.label_3 = wx.StaticText(self, -1, _("Lista de dominios")) | |
self.list_box_3 = wx.ListBox(self, -1, choices=[],style=wx.LB_MULTIPLE|wx.LB_SORT) | |
self.button_8 = wx.Button(self, -1, _("Aceptar")) | |
self.button_9 = wx.Button(self, -1, _("Cancelar")) | |
self.padre=self.GetParent() | |
self.__set_properties() | |
self.__do_layout() | |
wx.EVT_CLOSE(self,self.cancela) | |
wx.EVT_BUTTON(self, self.button_1.GetId(), self.inserta) | |
wx.EVT_BUTTON(self, self.button_2.GetId(), self.borra) | |
wx.EVT_BUTTON(self, self.button_3.GetId(), self.borra_todo) | |
wx.EVT_BUTTON(self, self.button_8.GetId(), self.acepta) | |
wx.EVT_BUTTON(self, self.button_9.GetId(), self.cancela) | |
# end wxGlade | |
def __set_properties(self): | |
# begin wxGlade: Mychild6.__set_properties | |
self.SetTitle(_("Crear lista local")) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/fondo_junta.gif", wx.BITMAP_TYPE_ANY)) | |
self.SetIcon(_icon) | |
self.Centre | |
# end wxGlade | |
def __do_layout(self): | |
# begin wxGlade: Mychild6.__do_layout | |
sizer_1 = wx.BoxSizer(wx.VERTICAL) | |
sizer_2 = wx.BoxSizer(wx.VERTICAL) | |
sizer_8 = wx.BoxSizer(wx.VERTICAL) | |
sizer_9 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_13 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_14 = wx.BoxSizer(wx.VERTICAL) | |
sizer_15 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_16 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_19 = wx.BoxSizer(wx.VERTICAL) | |
sizer_10 = wx.BoxSizer(wx.VERTICAL) | |
sizer_17 = wx.BoxSizer(wx.VERTICAL) | |
sizer_18 = wx.BoxSizer(wx.VERTICAL) | |
sizer_3 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_4 = wx.BoxSizer(wx.VERTICAL) | |
sizer_5 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_7 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_6 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_4.Add((20, 20), 0, 0, 0) | |
sizer_6.Add((20, 20), 0, 0, 0) | |
sizer_6.Add(self.label_1_copy, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_5.Add(sizer_6, 0, wx.EXPAND, 0) | |
sizer_7.Add((20, 20), 0, 0, 0) | |
sizer_7.Add(self.text_ctrl_2, 1, 0, 0) | |
sizer_7.Add((20, 20), 0, 0, 0) | |
sizer_5.Add(sizer_7, 1, wx.EXPAND, 0) | |
sizer_4.Add(sizer_5, 1, wx.EXPAND, 0) | |
sizer_3.Add(sizer_4, 1, wx.EXPAND, 0) | |
sizer_2.Add(sizer_3, 0, wx.EXPAND, 0) | |
sizer_8.Add((20, 20), 0, 0, 0) | |
sizer_9.Add((20, 20), 0, 0, 0) | |
sizer_18.Add(self.label_2, 0, 0, 0) | |
sizer_18.Add(self.text_ctrl_4, 0, wx.EXPAND, 0) | |
sizer_18.Add((20, 20), 0, 0, 0) | |
sizer_17.Add(sizer_18, 0, wx.EXPAND, 0) | |
sizer_9.Add(sizer_17, 1, wx.EXPAND, 0) | |
sizer_9.Add((20, 20), 0, 0, 0) | |
sizer_10.Add(self.button_1, 0, 0, 0) | |
sizer_10.Add((20, 20), 0, 0, 0) | |
sizer_10.Add(self.button_2, 0, 0, 0) | |
sizer_10.Add((20, 20), 1, 0, 0) | |
sizer_10.Add(self.button_3, 0, 0, 0) | |
sizer_9.Add(sizer_10, 0, wx.EXPAND, 0) | |
sizer_9.Add((20, 20), 0, 0, 0) | |
sizer_19.Add(self.label_3, 0, 0, 0) | |
sizer_19.Add(self.list_box_3, 1, wx.EXPAND, 0) | |
sizer_14.Add(sizer_19, 1, wx.EXPAND, 0) | |
sizer_14.Add((20, 20), 0, 0, 0) | |
sizer_16.Add(self.button_8, 0, 0, 0) | |
sizer_16.Add((20, 20), 1, wx.EXPAND, 0) | |
sizer_16.Add(self.button_9, 0, 0, 0) | |
sizer_15.Add(sizer_16, 1, wx.EXPAND, 0) | |
sizer_14.Add(sizer_15, 0, wx.EXPAND, 0) | |
sizer_13.Add(sizer_14, 1, wx.EXPAND, 0) | |
sizer_9.Add(sizer_13, 1, wx.EXPAND, 0) | |
sizer_9.Add((20, 20), 0, 0, 0) | |
sizer_8.Add(sizer_9, 1, wx.EXPAND, 0) | |
sizer_8.Add((20, 20), 0, 0, 0) | |
sizer_2.Add(sizer_8, 1, wx.EXPAND, 0) | |
sizer_1.Add(sizer_2, 1, wx.EXPAND, 0) | |
self.SetAutoLayout(True) | |
self.SetSizer(sizer_1) | |
sizer_1.Fit(self) | |
sizer_1.SetSizeHints(self) | |
self.Layout() | |
# end wxGlade | |
# inserta una uri a la lista | |
def inserta(self,event): | |
uri=self.text_ctrl_4.GetValue() | |
if uri: | |
self.list_box_3.Append(uri) | |
self.text_ctrl_4.Clear() | |
items=self.list_box_3.GetCount() | |
items=items-1 | |
max=items | |
if items>0: | |
for i in range(items): | |
if i<=max: | |
if self.list_box_3.GetString(i)==self.list_box_3.GetString(i+1): | |
self.list_box_3.Delete(i) | |
max=max-1 | |
if i>max: | |
break | |
# borra una uri de la lista | |
def borra(self,event): | |
lista=[] | |
for i in self.list_box_3.GetSelections(): | |
lista.append(self.list_box_3.GetString(i)) | |
items=self.list_box_3.GetCount() | |
for i in range(items): | |
for j in lista: | |
if self.list_box_3.GetString(i)==j: | |
self.list_box_3.Delete(i) | |
# borra todas las uris de la lista | |
def borra_todo(self,event): | |
self.list_box_3.Clear() | |
# Aplica los cambios | |
def acepta ( self, event): | |
from confSquid import inserta_blacklist | |
from inicSquid import apply_conf_squidguard | |
from watcherSquid import compila_libreria, establece_permisos | |
nombre=self.text_ctrl_2.GetValue() | |
if nombre: | |
msg=("Lista creada correctamente")+"\n" | |
lst_dom=[] | |
for i in range(self.list_box_3.GetCount()): | |
lst_dom.append(self.list_box_3.GetString(i)) | |
if lst_dom: | |
inserta_blacklist(nombre,lst_dom,archivo.configuracion) | |
compila_libreria(nombre,archivo.aceptlog) | |
apply_conf_squidguard(archivo.aceptlog) | |
establece_permisos(archivo.configuracion) | |
icon=wx.ICON_INFORMATION | |
else: | |
msg=_("No hay urls en la lista de dominos")+"\n" | |
icon=wx.ICON_EXCLAMATION | |
else: | |
msg=_("La Lista no tiene nombre")+"\n" | |
icon=wx.ICON_EXCLAMATION | |
dlg = wx.MessageDialog(self, msg, | |
_(‘Aviso ACEPT‘), wx.OK | icon) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
dlg.ShowModal() | |
dlg.Destroy() | |
self.cancela(self) | |
def cancela ( self, event): | |
self.padre.crea=True | |
self.padre.rellena_grupos() | |
self.Destroy() | |
# end of class Mychild6 | |
# Interfaz para la modificacion de una lista local | |
class MyChild7(wx.Frame): | |
def __init__(self, *args, **kwds): | |
# begin wxGlade: Mychild7.__init__ | |
kwds["style"] = wx.DEFAULT_FRAME_STYLE | |
wx.Frame.__init__(self, *args, **kwds) | |
self.label_1_copy = wx.StaticText(self, -1, _("Nombre")) | |
self.text_ctrl_2 = wx.TextCtrl(self, -1, "",style=wx.TE_READONLY) | |
self.label_2 = wx.StaticText(self, -1, _("URL")) | |
self.text_ctrl_4 = wx.TextCtrl(self, -1, "") | |
self.button_1 = wx.Button(self, -1, "-->") | |
self.button_2 = wx.Button(self, -1, "<--") | |
self.button_3 = wx.Button(self, -1, _("Eliminar todo")) | |
self.label_3 = wx.StaticText(self, -1, _("Lista de dominios")) | |
self.list_box_3 = wx.ListBox(self, -1, choices=[],style=wx.LB_MULTIPLE|wx.LB_SORT) | |
self.button_8 = wx.Button(self, -1, _("Aceptar")) | |
self.button_9 = wx.Button(self, -1, _("Cancelar")) | |
self.padre=self.GetParent() | |
self.__set_properties() | |
self.__do_layout() | |
self.rellena() | |
wx.EVT_CLOSE(self,self.cancela) | |
wx.EVT_BUTTON(self, self.button_1.GetId(), self.inserta) | |
wx.EVT_BUTTON(self, self.button_2.GetId(), self.borra) | |
wx.EVT_BUTTON(self, self.button_3.GetId(), self.borra_todo) | |
wx.EVT_BUTTON(self, self.button_8.GetId(), self.acepta) | |
wx.EVT_BUTTON(self, self.button_9.GetId(), self.cancela) | |
# end wxGlade | |
def __set_properties(self): | |
# begin wxGlade: Mychild7.__set_properties | |
self.SetTitle(_("Modificar lista local")) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/fondo_junta.gif", wx.BITMAP_TYPE_ANY)) | |
self.SetIcon(_icon) | |
self.Centre | |
# end wxGlade | |
def __do_layout(self): | |
# begin wxGlade: Mychild7.__do_layout | |
sizer_1 = wx.BoxSizer(wx.VERTICAL) | |
sizer_2 = wx.BoxSizer(wx.VERTICAL) | |
sizer_8 = wx.BoxSizer(wx.VERTICAL) | |
sizer_9 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_13 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_14 = wx.BoxSizer(wx.VERTICAL) | |
sizer_15 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_16 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_19 = wx.BoxSizer(wx.VERTICAL) | |
sizer_10 = wx.BoxSizer(wx.VERTICAL) | |
sizer_17 = wx.BoxSizer(wx.VERTICAL) | |
sizer_18 = wx.BoxSizer(wx.VERTICAL) | |
sizer_3 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_4 = wx.BoxSizer(wx.VERTICAL) | |
sizer_5 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_7 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_6 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_4.Add((20, 20), 0, 0, 0) | |
sizer_6.Add((20, 20), 0, 0, 0) | |
sizer_6.Add(self.label_1_copy, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_5.Add(sizer_6, 0, wx.EXPAND, 0) | |
sizer_7.Add((20, 20), 0, 0, 0) | |
sizer_7.Add(self.text_ctrl_2, 1, 0, 0) | |
sizer_7.Add((20, 20), 0, 0, 0) | |
sizer_5.Add(sizer_7, 1, wx.EXPAND, 0) | |
sizer_4.Add(sizer_5, 1, wx.EXPAND, 0) | |
sizer_3.Add(sizer_4, 1, wx.EXPAND, 0) | |
sizer_2.Add(sizer_3, 0, wx.EXPAND, 0) | |
sizer_8.Add((20, 20), 0, 0, 0) | |
sizer_9.Add((20, 20), 0, 0, 0) | |
sizer_18.Add(self.label_2, 0, 0, 0) | |
sizer_18.Add(self.text_ctrl_4, 0, wx.EXPAND, 0) | |
sizer_18.Add((20, 20), 0, 0, 0) | |
sizer_17.Add(sizer_18, 0, wx.EXPAND, 0) | |
sizer_9.Add(sizer_17, 1, wx.EXPAND, 0) | |
sizer_9.Add((20, 20), 0, 0, 0) | |
sizer_10.Add(self.button_1, 0, 0, 0) | |
sizer_10.Add((20, 20), 0, 0, 0) | |
sizer_10.Add(self.button_2, 0, 0, 0) | |
sizer_10.Add((20, 20), 1, 0, 0) | |
sizer_10.Add(self.button_3, 0, 0, 0) | |
sizer_9.Add(sizer_10, 0, wx.EXPAND, 0) | |
sizer_9.Add((20, 20), 0, 0, 0) | |
sizer_19.Add(self.label_3, 0, 0, 0) | |
sizer_19.Add(self.list_box_3, 1, wx.EXPAND, 0) | |
sizer_14.Add(sizer_19, 1, wx.EXPAND, 0) | |
sizer_14.Add((20, 20), 0, 0, 0) | |
sizer_16.Add(self.button_8, 0, 0, 0) | |
sizer_16.Add((20, 20), 1, wx.EXPAND, 0) | |
sizer_16.Add(self.button_9, 0, 0, 0) | |
sizer_15.Add(sizer_16, 1, wx.EXPAND, 0) | |
sizer_14.Add(sizer_15, 0, wx.EXPAND, 0) | |
sizer_13.Add(sizer_14, 1, wx.EXPAND, 0) | |
sizer_9.Add(sizer_13, 1, wx.EXPAND, 0) | |
sizer_9.Add((20, 20), 0, 0, 0) | |
sizer_8.Add(sizer_9, 1, wx.EXPAND, 0) | |
sizer_8.Add((20, 20), 0, 0, 0) | |
sizer_2.Add(sizer_8, 1, wx.EXPAND, 0) | |
sizer_1.Add(sizer_2, 1, wx.EXPAND, 0) | |
self.SetAutoLayout(True) | |
self.SetSizer(sizer_1) | |
sizer_1.Fit(self) | |
sizer_1.SetSizeHints(self) | |
self.Layout() | |
# end wxGlade | |
# Lee las caracteristicas de la lista a modificar y las muestra | |
def rellena(self): # | |
from confSquid import lee_blacklist | |
self.text_ctrl_2.SetValue(bl_lst.nombre) | |
blists=lee_blacklist(bl_lst.nombre,archivo.configuracion) | |
for i in blists: # | |
self.list_box_3.Append(i) | |
# | |
# | |
# a?de una uri a la lista | |
def inserta(self,event): | |
uri=self.text_ctrl_4.GetValue() | |
if uri: | |
self.list_box_3.Append(uri) | |
self.text_ctrl_4.Clear() | |
items=self.list_box_3.GetCount() | |
items=items-1 | |
max=items | |
if items>0: | |
for i in range(items): | |
if i<=max: | |
if self.list_box_3.GetString(i)==self.list_box_3.GetString(i+1): | |
self.list_box_3.Delete(i) | |
max=max-1 | |
if i>max: | |
break | |
# Borra una uri a la lista | |
def borra(self,event): | |
lista=[] | |
for i in self.list_box_3.GetSelections(): | |
lista.append(self.list_box_3.GetString(i)) | |
items=self.list_box_3.GetCount() | |
for i in range(items): | |
for j in lista: | |
if self.list_box_3.GetString(i)==j: | |
self.list_box_3.Delete(i) | |
# borra todas las uris d ela lista | |
def borra_todo(self,event): | |
self.list_box_3.Clear() | |
# Aplica los cambios | |
def acepta ( self, event): | |
from confSquid import inserta_blacklist | |
from inicSquid import apply_conf_squidguard | |
from watcherSquid import compila_libreria, establece_permisos | |
nombre=self.text_ctrl_2.GetValue() | |
if nombre: | |
msg=_("Lista modificada correctamente")+"\n" | |
lst_dom=[] | |
for i in range(self.list_box_3.GetCount()): | |
lst_dom.append(self.list_box_3.GetString(i)) | |
if lst_dom: | |
inserta_blacklist(nombre,lst_dom,archivo.configuracion) | |
compila_libreria(nombre,archivo.aceptlog) | |
apply_conf_squidguard(archivo.aceptlog) | |
establece_permisos(archivo.configuracion) | |
icon=wx.ICON_INFORMATION | |
else: | |
msg=_("No hay urls en la lista de dominos")+"\n" | |
icon=wx.ICON_EXCLAMATION | |
else: | |
msg=_("La Lista no tiene nombre")+"\n" | |
icon=wx.ICON_EXCLAMATION | |
dlg = wx.MessageDialog(self, msg, | |
_(‘Aviso ACEPT‘), wx.OK | icon) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
dlg.ShowModal() | |
dlg.Destroy() | |
self.cancela(self) | |
def cancela ( self, event): | |
self.padre.modifica=True | |
self.Destroy() | |
# end of class Mychild7 | |
# estadisticas | |
class MyChild8(wx.Frame): | |
def __init__(self, *args, **kwds): | |
# begin wxGlade: MyChild8.__init__ | |
kwds["style"] = wx.DEFAULT_FRAME_STYLE | |
wx.Frame.__init__(self, *args, **kwds) | |
self.label_2 = wx.StaticText(self, -1, _("Los registros se almacenan automaticamente")) | |
self.label_3 = wx.StaticText(self, -1, _("Cada")) | |
self.spin_ctrl_1 = wx.SpinCtrl(self, -1, "", min=1, max=100) | |
self.label_4 = wx.StaticText(self, -1, _("Dias")) | |
self.button_1 = wx.Button(self, -1, _("Salvar")) | |
self.static_line_2 = wx.StaticLine(self, -1) | |
self.label_5 = wx.StaticText(self, -1, _("Configurar consulta"), style=wx.ALIGN_CENTRE) | |
self.label_6_copy_2 = wx.StaticText(self, -1, _("Consultar")) | |
self.label_6_copy_3 = wx.StaticText(self, -1, _("Usuario")) | |
self.label_6_copy_4 = wx.StaticText(self, -1, _("Periodo")) | |
self.label_6_copy_5 = wx.StaticText(self, -1, _("Palabra clave")) | |
self.combo_box_2 = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN) | |
self.combo_box_3 = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN) | |
self.combo_box_4 = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN) | |
self.text_ctrl_2 = wx.TextCtrl(self, -1, "") | |
self.static_line_1 = wx.StaticLine(self, -1, style=wx.LI_VERTICAL) | |
self.label_7 = wx.StaticText(self, -1, _("Resultados de la consulta"), style=wx.ALIGN_CENTRE) | |
self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY) | |
self.button_2 = wx.Button(self, -1, _("Consultar")) | |
self.button_3 = wx.Button(self, -1, _("Guardar como")) | |
self.button_4 = wx.Button(self, -1, _("Cerrar")) | |
self.__set_properties() | |
self.__do_layout() | |
wx.EVT_BUTTON(self, self.button_1.GetId(), self.guarda_intervalo) | |
wx.EVT_BUTTON(self, self.button_2.GetId(), self.consulta) | |
wx.EVT_BUTTON(self, self.button_3.GetId(), self.guarda) | |
wx.EVT_COMBOBOX(self,self.combo_box_2.GetId(),self.recarga) | |
wx.EVT_COMBOBOX(self,self.combo_box_3.GetId(),self.user_period) | |
wx.EVT_CLOSE(self,self.cierra) | |
wx.EVT_BUTTON(self, self.button_4.GetId(), self.cierra) | |
# end wxGlade | |
def __set_properties(self): | |
# begin wxGlade: MyChild8.__set_properties | |
self.SetTitle(_("Registros de navegacion web")) | |
self.combo_box_2.Append("") | |
self.combo_box_2.Append(_("Numero de paginas visitadas por usuario")) | |
self.combo_box_2.Append(_("Trafico por usuario")) | |
self.combo_box_2.Append(_("Paginas visitadas ordenadas por usuario")) | |
self.combo_box_2.Append(_("Paginas visitadas ordenadas por url")) | |
self.combo_box_2.Append(_("Paginas visitadas ordenadas cronologicamente")) | |
self.combo_box_2.Append(_("Paginas visitadas por numero de visitas")) | |
self.combo_box_2.Append(_("Paginas visitadas ordenadas por trafico")) | |
self.combo_box_2.Append(_("Busqueda por palabras clave en las url")) | |
self.combo_box_2.SetSelection(0) | |
self.combo_box_3.SetSelection(-1) | |
self.combo_box_4.SetSelection(-1) | |
self.combo_box_3.Enable(False) | |
self.combo_box_4.Enable(False) | |
self.text_ctrl_2.Enable(False) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/fondo_junta.gif", wx.BITMAP_TYPE_ANY)) | |
self.SetIcon(_icon) | |
self.Centre | |
self.intervalo_dias() | |
# end wxGlade | |
def __do_layout(self): | |
# begin wxGlade: MyChild8.__do_layout | |
sizer_1 = wx.BoxSizer(wx.VERTICAL) | |
sizer_2 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_3 = wx.BoxSizer(wx.VERTICAL) | |
sizer_17 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_4 = wx.BoxSizer(wx.VERTICAL) | |
sizer_6 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_7 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_18 = wx.BoxSizer(wx.VERTICAL) | |
sizer_19 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_9 = wx.BoxSizer(wx.VERTICAL) | |
sizer_12 = wx.BoxSizer(wx.VERTICAL) | |
sizer_15 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_16_copy = wx.BoxSizer(wx.VERTICAL) | |
sizer_14_copy_5_copy = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_14_copy_4_copy = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_14_copy_3_copy = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_14_copy_2_copy = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_16 = wx.BoxSizer(wx.VERTICAL) | |
sizer_14_copy_5 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_14_copy_4 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_14_copy_3 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_14_copy_2 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_10 = wx.BoxSizer(wx.VERTICAL) | |
sizer_11 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_2.Add((20, 20), 0, 0, 0) | |
sizer_3.Add((20, 20), 0, 0, 0) | |
sizer_10.Add(self.label_2, 0, 0, 0) | |
sizer_10.Add((10, 10), 0, 0, 0) | |
sizer_11.Add(self.label_3, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_11.Add((10, 10), 0, 0, 0) | |
sizer_11.Add(self.spin_ctrl_1, 0, 0, 0) | |
sizer_11.Add((10, 10), 0, wx.ALL, 0) | |
sizer_11.Add(self.label_4, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_11.Add((15, 15), 0, 0, 0) | |
sizer_11.Add(self.button_1, 0, 0, 0) | |
sizer_10.Add(sizer_11, 0, wx.EXPAND, 0) | |
sizer_10.Add((10, 10), 0, 0, 0) | |
sizer_10.Add(self.static_line_2, 0, wx.EXPAND, 0) | |
sizer_9.Add(sizer_10, 0, wx.EXPAND, 0) | |
sizer_9.Add((15, 15), 0, 0, 0) | |
sizer_12.Add(self.label_5, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 0) | |
sizer_16.Add((10, 10), 1, wx.EXPAND, 0) | |
sizer_14_copy_2.Add(self.label_6_copy_2, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_14_copy_2.Add((5, 22), 0, 0, 0) | |
sizer_16.Add(sizer_14_copy_2, 0, wx.EXPAND, 0) | |
sizer_16.Add((10, 10), 1, 0, 0) | |
sizer_14_copy_3.Add(self.label_6_copy_3, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_14_copy_3.Add((5, 22), 0, 0, 0) | |
sizer_16.Add(sizer_14_copy_3, 0, wx.EXPAND, 0) | |
sizer_16.Add((10, 10), 1, 0, 0) | |
sizer_14_copy_4.Add(self.label_6_copy_4, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_14_copy_4.Add((5, 22), 0, 0, 0) | |
sizer_16.Add(sizer_14_copy_4, 0, wx.EXPAND, 0) | |
sizer_16.Add((10, 10), 1, 0, 0) | |
sizer_14_copy_5.Add(self.label_6_copy_5, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_14_copy_5.Add((5, 22), 0, 0, 0) | |
sizer_16.Add(sizer_14_copy_5, 0, wx.EXPAND, 0) | |
sizer_16.Add((10, 10), 1, 0, 0) | |
sizer_15.Add(sizer_16, 0, wx.EXPAND, 0) | |
sizer_15.Add((10, 10), 0, 0, 0) | |
sizer_16_copy.Add((10, 10), 1, 0, 0) | |
sizer_14_copy_2_copy.Add(self.combo_box_2, 1, 0, 0) | |
sizer_16_copy.Add(sizer_14_copy_2_copy, 0, wx.EXPAND, 0) | |
sizer_16_copy.Add((10, 10), 1, 0, 0) | |
sizer_14_copy_3_copy.Add(self.combo_box_3, 1, 0, 0) | |
sizer_16_copy.Add(sizer_14_copy_3_copy, 0, wx.EXPAND, 0) | |
sizer_16_copy.Add((10, 10), 1, 0, 0) | |
sizer_14_copy_4_copy.Add(self.combo_box_4, 1, 0, 0) | |
sizer_16_copy.Add(sizer_14_copy_4_copy, 0, wx.EXPAND, 0) | |
sizer_16_copy.Add((10, 10), 1, 0, 0) | |
sizer_14_copy_5_copy.Add(self.text_ctrl_2, 1, wx.EXPAND, 0) | |
sizer_16_copy.Add(sizer_14_copy_5_copy, 0, wx.EXPAND, 0) | |
sizer_16_copy.Add((10, 10), 1, 0, 0) | |
sizer_15.Add(sizer_16_copy, 1, wx.EXPAND, 0) | |
sizer_12.Add(sizer_15, 1, wx.EXPAND, 0) | |
sizer_9.Add(sizer_12, 1, wx.EXPAND, 0) | |
sizer_7.Add(sizer_9, 0, wx.EXPAND, 0) | |
sizer_7.Add((10, 10), 0, 0, 0) | |
sizer_7.Add(self.static_line_1, 0, wx.EXPAND, 0) | |
sizer_7.Add((10, 10), 0, 0, 0) | |
sizer_19.Add((5, 10), 1, 0, 0) | |
sizer_19.Add(self.label_7, 0, 0, 0) | |
sizer_19.Add((5, 8), 1, 0, 0) | |
sizer_18.Add(sizer_19, 0, wx.EXPAND, 0) | |
sizer_18.Add((10, 10), 0, wx.EXPAND, 0) | |
sizer_18.Add(self.text_ctrl_1, 1, wx.EXPAND, 0) | |
sizer_7.Add(sizer_18, 1, wx.EXPAND, 0) | |
sizer_6.Add(sizer_7, 1, wx.EXPAND, 0) | |
sizer_4.Add(sizer_6, 1, wx.EXPAND, 0) | |
sizer_3.Add(sizer_4, 1, wx.EXPAND, 0) | |
sizer_3.Add((20, 20), 0, 0, 0) | |
sizer_17.Add(self.button_2, 1, 0, 0) | |
sizer_17.Add((20, 20), 1, 0, 0) | |
sizer_17.Add(self.button_3, 1, 0, 0) | |
sizer_17.Add((20, 20), 1, 0, 0) | |
sizer_17.Add(self.button_4, 1, 0, 0) | |
sizer_3.Add(sizer_17, 0, wx.EXPAND, 0) | |
sizer_3.Add((20, 20), 0, 0, 0) | |
sizer_2.Add(sizer_3, 1, wx.EXPAND, 0) | |
sizer_2.Add((20, 20), 0, 0, 0) | |
sizer_1.Add(sizer_2, 1, wx.EXPAND, 0) | |
self.SetAutoLayout(True) | |
self.SetSizer(sizer_1) | |
sizer_1.Fit(self) | |
sizer_1.SetSizeHints(self) | |
self.Layout() | |
# end wxGlade | |
def consulta(self,event): | |
from confSquid import mostrar_reg_nav | |
valores={0:"limpia",1:"A",2:"B",3:"C",4:"D",5:"E",6:"F",7:"G",8:"H"} | |
seleccion=valores.get(self.combo_box_2.GetSelection()) | |
usuario=self.combo_box_3.GetValue() | |
periodo=self.combo_box_4.GetValue() | |
clave=self.text_ctrl_2.GetValue() | |
if seleccion!="limpia": | |
salida=mostrar_reg_nav(seleccion,usuario,periodo,archivo.configuracion,clave) | |
self.text_ctrl_1.Clear() | |
for i in salida: | |
self.text_ctrl_1.AppendText(i) | |
self.text_ctrl_1.AppendText("\n") | |
def guarda(self,event): | |
from os.path import exists | |
def escribe(path,contenido): | |
f=open(path,"w") | |
f.write(contenido) | |
f.close() | |
wildcard=_("Archivos de texto")+" (*.txt)|*.txt|" | |
dlg=wx.FileDialog(self,_("Salvar el informe en..."),"","",wildcard,wx.SAVE) | |
dlg.SetFilterIndex(2) | |
if dlg.ShowModal()==wx.ID_OK: | |
path=dlg.GetPath() | |
if exists(path): | |
dlg2 = wx.MessageDialog(self, _("El Archivo indicado ya existe\n Desea sobreescribirlo?"), | |
_(‘Aviso ACEPT‘), wx.YES_NO | wx.ICON_QUESTION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg2.SetIcon(_icon) | |
if dlg2.ShowModal()==wx.ID_YES: | |
escribe(path,self.text_ctrl_1.GetValue()) | |
dlg2.Destroy() | |
else: | |
escribe(path,self.text_ctrl_1.GetValue()) | |
dlg.Destroy() | |
def recarga(self,event): | |
from confSquid import extrae_periodos | |
from func import users_control_web | |
valores={0:"limpia",1:"A",2:"B",3:"C",4:"D",5:"E",6:"F",7:"G",8:"H"} | |
seleccion=valores.get(self.combo_box_2.GetSelection()) | |
if seleccion=="A" or seleccion=="B" or seleccion=="C": | |
self.combo_box_4.Clear() | |
self.combo_box_4.Enable(True) | |
self.combo_box_3.Clear() | |
self.combo_box_3.Enable(False) | |
self.text_ctrl_2.Clear() | |
self.text_ctrl_2.Enable(False) | |
entradas=extrae_periodos(archivo.configuracion) | |
for i in entradas: | |
self.combo_box_4.Append(i) | |
elif seleccion=="limpia": | |
self.combo_box_3.Clear() | |
self.combo_box_4.Clear() | |
self.text_ctrl_2.Clear() | |
self.combo_box_3.Enable(False) | |
self.combo_box_4.Enable(False) | |
self.text_ctrl_2.Enable(False) | |
elif seleccion=="H": | |
self.combo_box_3.Clear() | |
self.combo_box_4.Clear() | |
self.combo_box_3.Enable(True) | |
self.combo_box_4.Enable(True) | |
self.text_ctrl_2.Enable(True) | |
users=users_control_web(archivo.aceptlog) | |
self.combo_box_3.Append("Todos") | |
for i in users: | |
self.combo_box_3.Append(i) | |
entradas=extrae_periodos(archivo.configuracion) | |
for i in entradas: | |
self.combo_box_4.Append(i) | |
else: | |
self.combo_box_3.Clear() | |
self.combo_box_4.Clear() | |
self.combo_box_3.Enable(True) | |
self.combo_box_4.Enable(True) | |
self.text_ctrl_2.Enable(True) | |
self.text_ctrl_2.Clear() | |
self.text_ctrl_2.Enable(False) | |
users=users_control_web(archivo.aceptlog) | |
self.combo_box_3.Append(_("Todos")) | |
for i in users: | |
self.combo_box_3.Append(i) | |
entradas=extrae_periodos(archivo.configuracion) | |
for i in entradas: | |
self.combo_box_4.Append(i) | |
#rellena combo_box 3 y 4 | |
def user_period(self,event): | |
from confSquid import extrae_periodos,extrae_periodos_user | |
user=self.combo_box_3.GetValue() | |
self.combo_box_4.Clear() | |
if user!=_("Todos"): | |
entradas=extrae_periodos_user(user,archivo.configuracion) | |
for i in entradas: | |
self.combo_box_4.Append(i) | |
else: | |
entradas=extrae_periodos(archivo.configuracion) | |
for i in entradas: | |
self.combo_box_4.Append(i) | |
def guarda_intervalo(self,event): | |
from func import actualiza_campo | |
actualiza_campo(‘fr_recol‘,str(self.spin_ctrl_1.GetValue()),archivo.aceptlog) | |
def intervalo_dias(self): | |
from func import consulta_campo | |
self.spin_ctrl_1.SetValue(int(consulta_campo(‘fr_recol‘,archivo.aceptlog))) | |
def cierra(self,event): | |
import os,os.path | |
for item in os.listdir(‘/var/log/acept/squid/var/rg‘): | |
file=os.path.join(‘/var/log/acept/squid/var/rg‘,item) | |
os.remove(file) | |
child.uso_web=False | |
self.Destroy() | |
# end of class MyChild8 | |
# estadisticas | |
class MyChild9(wx.Frame): | |
def __init__(self, *args, **kwds): | |
# begin wxGlade: MyChild9.__init__ | |
kwds["style"] = wx.DEFAULT_FRAME_STYLE | |
wx.Frame.__init__(self, *args, **kwds) | |
self.label_2 = wx.StaticText(self, -1, _("Opciones de la consulta")) | |
self.static_line_2 = wx.StaticLine(self, -1) | |
self.label_6_copy_2 = wx.StaticText(self, -1, _("Consultar")) | |
self.label_6_copy_3 = wx.StaticText(self, -1, _("Intervalo de tiempo")) | |
self.label_6_copy_4 = wx.StaticText(self, -1, _("Periodo")) | |
self.combo_box_2 = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN) | |
self.combo_box_3 = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN) | |
self.combo_box_4 = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN) | |
self.static_line_1 = wx.StaticLine(self, -1, style=wx.LI_VERTICAL) | |
self.label_7 = wx.StaticText(self, -1, _("Resultados de la consulta"), style=wx.ALIGN_CENTRE) | |
self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY) | |
self.button_2 = wx.Button(self, -1, _("Consultar")) | |
self.button_4 = wx.Button(self, -1, _("Cerrar")) | |
self.__set_properties() | |
self.__do_layout() | |
self.rellena() | |
wx.EVT_BUTTON(self, self.button_2.GetId(), self.consulta) | |
wx.EVT_COMBOBOX(self,self.combo_box_3.GetId(),self.recarga) | |
wx.EVT_CLOSE(self,self.cierra) | |
wx.EVT_BUTTON(self, self.button_4.GetId(), self.cierra) | |
# end wxGlade | |
def __set_properties(self): | |
# begin wxGlade: MyChild9.__set_properties | |
self.SetTitle(_("Registros del uso de Servicios")) | |
self.combo_box_2.Append(_("Servicios utilizados por tiempo de uso")) | |
self.combo_box_2.Append(_("Servicios utilizados por usuario")) | |
self.combo_box_2.Append(_("Servicios utilizados por usuario y tiempo de uso")) | |
self.combo_box_3.Append(_("Mensual")) | |
self.combo_box_3.Append(_("Semanal")) | |
self.combo_box_2.SetSelection(0) | |
self.combo_box_3.SetSelection(0) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/fondo_junta.gif", wx.BITMAP_TYPE_ANY)) | |
self.SetIcon(_icon) | |
self.Centre | |
# end wxGlade | |
def __do_layout(self): | |
# begin wxGlade: MyChild9.__do_layout | |
sizer_1 = wx.BoxSizer(wx.VERTICAL) | |
sizer_2 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_3 = wx.BoxSizer(wx.VERTICAL) | |
sizer_17 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_4 = wx.BoxSizer(wx.VERTICAL) | |
sizer_6 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_7 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_18 = wx.BoxSizer(wx.VERTICAL) | |
sizer_19 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_9 = wx.BoxSizer(wx.VERTICAL) | |
sizer_12 = wx.BoxSizer(wx.VERTICAL) | |
sizer_15 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_16_copy = wx.BoxSizer(wx.VERTICAL) | |
sizer_14_copy_5_copy = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_14_copy_4_copy = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_14_copy_3_copy = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_14_copy_2_copy = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_16 = wx.BoxSizer(wx.VERTICAL) | |
sizer_14_copy_4 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_14_copy_3 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_14_copy_2 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_10 = wx.BoxSizer(wx.VERTICAL) | |
sizer_11 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_2.Add((20, 20), 0, 0, 0) | |
sizer_3.Add((20, 20), 0, 0, 0) | |
sizer_10.Add(self.label_2, 0, 0, 0) | |
sizer_11.Add((10, 10), 0, 0, 0) | |
sizer_11.Add((10, 10), 0, wx.ALL, 0) | |
sizer_11.Add((15, 15), 0, 0, 0) | |
sizer_10.Add(sizer_11, 0, wx.EXPAND, 0) | |
sizer_10.Add(self.static_line_2, 0, wx.EXPAND, 0) | |
sizer_9.Add(sizer_10, 0, wx.EXPAND, 0) | |
sizer_9.Add((15, 15), 0, 0, 0) | |
sizer_16.Add((10, 10), 1, wx.EXPAND, 0) | |
sizer_14_copy_2.Add(self.label_6_copy_2, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_14_copy_2.Add((5, 22), 0, 0, 0) | |
sizer_16.Add(sizer_14_copy_2, 0, wx.EXPAND, 0) | |
sizer_16.Add((10, 10), 1, 0, 0) | |
sizer_14_copy_3.Add(self.label_6_copy_3, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_14_copy_3.Add((5, 22), 0, 0, 0) | |
sizer_16.Add(sizer_14_copy_3, 0, wx.EXPAND, 0) | |
sizer_16.Add((10, 10), 1, 0, 0) | |
sizer_14_copy_4.Add(self.label_6_copy_4, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_14_copy_4.Add((5, 22), 0, 0, 0) | |
sizer_16.Add(sizer_14_copy_4, 0, wx.EXPAND, 0) | |
sizer_16.Add((10, 10), 1, 0, 0) | |
sizer_16.Add((10, 10), 1, 0, 0) | |
sizer_15.Add(sizer_16, 0, wx.EXPAND, 0) | |
sizer_15.Add((10, 10), 0, 0, 0) | |
sizer_16_copy.Add((10, 10), 1, 0, 0) | |
sizer_14_copy_2_copy.Add(self.combo_box_2, 1, 0, 0) | |
sizer_16_copy.Add(sizer_14_copy_2_copy, 0, wx.EXPAND, 0) | |
sizer_16_copy.Add((10, 10), 1, 0, 0) | |
sizer_14_copy_3_copy.Add(self.combo_box_3, 1, 0, 0) | |
sizer_16_copy.Add(sizer_14_copy_3_copy, 0, wx.EXPAND, 0) | |
sizer_16_copy.Add((10, 10), 1, 0, 0) | |
sizer_14_copy_4_copy.Add(self.combo_box_4, 1, 0, 0) | |
sizer_16_copy.Add(sizer_14_copy_4_copy, 0, wx.EXPAND, 0) | |
sizer_16_copy.Add((10, 10), 1, 0, 0) | |
sizer_16_copy.Add(sizer_14_copy_5_copy, 0, wx.EXPAND, 0) | |
sizer_16_copy.Add((10, 10), 1, 0, 0) | |
sizer_15.Add(sizer_16_copy, 1, wx.EXPAND, 0) | |
sizer_12.Add(sizer_15, 1, wx.EXPAND, 0) | |
sizer_9.Add(sizer_12, 1, wx.EXPAND, 0) | |
sizer_7.Add(sizer_9, 0, wx.EXPAND, 0) | |
sizer_7.Add((10, 10), 0, 0, 0) | |
sizer_7.Add(self.static_line_1, 0, wx.EXPAND, 0) | |
sizer_7.Add((10, 10), 0, 0, 0) | |
sizer_19.Add((5, 10), 1, 0, 0) | |
sizer_19.Add(self.label_7, 0, 0, 0) | |
sizer_19.Add((5, 8), 1, 0, 0) | |
sizer_18.Add(sizer_19, 0, wx.EXPAND, 0) | |
sizer_18.Add((10, 10), 0, wx.EXPAND, 0) | |
sizer_18.Add(self.text_ctrl_1, 1, wx.EXPAND, 0) | |
sizer_7.Add(sizer_18, 1, wx.EXPAND, 0) | |
sizer_6.Add(sizer_7, 1, wx.EXPAND, 0) | |
sizer_4.Add(sizer_6, 1, wx.EXPAND, 0) | |
sizer_3.Add(sizer_4, 1, wx.EXPAND, 0) | |
sizer_3.Add((20, 20), 0, 0, 0) | |
sizer_17.Add(self.button_2, 1, 0, 0) | |
sizer_17.Add((20, 20), 1, 0, 0) | |
sizer_17.Add((20, 20), 1, 0, 0) | |
sizer_17.Add(self.button_4, 1, 0, 0) | |
sizer_3.Add(sizer_17, 0, wx.EXPAND, 0) | |
sizer_3.Add((20, 20), 0, 0, 0) | |
sizer_2.Add(sizer_3, 1, wx.EXPAND, 0) | |
sizer_2.Add((20, 20), 0, 0, 0) | |
sizer_1.Add(sizer_2, 1, wx.EXPAND, 0) | |
self.SetAutoLayout(True) | |
self.SetSizer(sizer_1) | |
sizer_1.Fit(self) | |
sizer_1.SetSizeHints(self) | |
self.Layout() | |
# end wxGlade | |
def consulta(self,event): | |
from confSquid import mostrar_uso_aplicaciones | |
valores={0:"A",1:"B",2:"C"} | |
valores2={0:"m",1:"s"} | |
consulta=valores.get(self.combo_box_2.GetSelection()) | |
tipo=valores2.get(self.combo_box_3.GetSelection()) | |
if len(self.combo_box_4.GetValue())==0: | |
dlg = wx.MessageDialog(self, _("Seleccione el periodo para el que desea realizar la consulta"), _(‘Aviso ACEPT‘),wx.OK | wx.ICON_EXCLAMATION) | |
_icon = wx.EmptyIcon() | |
_icon.CopyFromBitmap(wx.Bitmap("/usr/share/acept/pixmaps/aviso.png", wx.BITMAP_TYPE_ANY)) | |
dlg.SetIcon(_icon) | |
dlg.ShowModal() | |
else: | |
periodo=self.combo_box_4.GetValue() | |
salida=mostrar_uso_aplicaciones(consulta,‘Todos‘,tipo,periodo,archivo.configuracion) | |
self.text_ctrl_1.Clear() | |
for i in salida: | |
if consulta==‘C‘: | |
for j in range(len(salida[i])): | |
self.text_ctrl_1.AppendText(i) | |
self.text_ctrl_1.AppendText(‘\t ‘) | |
self.text_ctrl_1.AppendText(salida[i][j]) | |
self.text_ctrl_1.AppendText("\n") | |
else: | |
self.text_ctrl_1.AppendText(i) | |
self.text_ctrl_1.AppendText(‘\t ‘) | |
if consulta==‘B‘: | |
for j in range(len(salida[i])): | |
self.text_ctrl_1.AppendText(salida[i][j]) | |
self.text_ctrl_1.AppendText(‘ ‘) | |
else: | |
self.text_ctrl_1.AppendText(salida[i]) | |
self.text_ctrl_1.AppendText("\n") | |
def recarga(self,event): | |
self.rellena() | |
def rellena(self): | |
from confSquid import extrae_periodos_uso_aplic | |
valores={0:"m",1:"s"} | |
seleccion=valores.get(self.combo_box_3.GetSelection()) | |
periodos=extrae_periodos_uso_aplic(seleccion) | |
self.combo_box_4.Clear() | |
for i in periodos: | |
self.combo_box_4.Append(i) | |
def cierra(self,event): | |
child.uso_aplic=False | |
self.Destroy() |
原文:http://www.cnblogs.com/chengxuyuan326260/p/6391510.html