# Get the GUI stuff import wx # We're going to be handling files and directories import os from sys import platform as _platform asup_controller = 0 class MyDialognAutosupport(wx.Dialog): def __init__(self, parent, id, path, title, pos, size): wx.Dialog.__init__(self, parent, wx.ID_ANY, title=title, pos=pos, size=size) self.InitUI1() ico = wx.Icon(path + os.sep + 'icon-netapp.ico', wx.BITMAP_TYPE_ICO) self.SetIcon(ico) def InitUI1(self): panel = wx.Panel(self) self.SetBackgroundColour("LIGHT GREY")#("sky blue") font = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT) font.SetPointSize(8) vbox = wx.BoxSizer(wx.VERTICAL) hboxEmpty = wx.BoxSizer(wx.HORIZONTAL) emptyLabel=wx.StaticText(panel, label='',size=(9,-1)) if _platform == "linux" or _platform == "linux2": hbox1 = wx.BoxSizer(wx.HORIZONTAL) st1 = wx.StaticText(panel, label='Controller1(IP(s)/Name(s)):', style=wx.ALIGN_RIGHT) self.editCntrler1 = wx.TextCtrl(panel, id=10, value="", size=(180, -1)) hbox1.Add(emptyLabel, flag=wx.RIGHT, border=8) hbox1.Add(st1, flag=wx.RIGHT, border=8) hbox1.Add(self.editCntrler1, flag=wx.RIGHT, border=30) hbox2 = wx.BoxSizer(wx.HORIZONTAL) st2 = wx.StaticText(panel, label='Controller2(IP(s)/Name(s)):', style=wx.ALIGN_RIGHT) #st2.SetFont(font) self.editCntrler2 = wx.TextCtrl(panel, id=20, value="", size=(180,-1)) hbox2.Add(emptyLabel, flag=wx.RIGHT, border=8) hbox2.Add(st2, flag=wx.RIGHT, border=8) hbox2.Add(self.editCntrler2, flag=wx.RIGHT, border=30) hbox3 = wx.BoxSizer(wx.HORIZONTAL) st3 = wx.StaticText(panel, label='User Name:', style=wx.ALIGN_RIGHT) self.editUsrname = wx.TextCtrl(panel, id=30, value="admin", size=(100,-1)) hbox3.Add(emptyLabel, flag=wx.RIGHT, border=26) hbox3.Add(st3, flag=wx.RIGHT, border=8) hbox3.Add(self.editUsrname, flag=wx.RIGHT, border=30) #130 hbox4 = wx.BoxSizer(wx.HORIZONTAL) st4 = wx.StaticText(panel, label='Password:', style=wx.ALIGN_RIGHT) self.editPassword = wx.TextCtrl(panel, id=40,value="", size=(100, -1), style=wx.TE_PASSWORD|wx.TE_PROCESS_ENTER) hbox4.Add(emptyLabel, flag=wx.RIGHT, border=30) hbox4.Add(st4, flag=wx.RIGHT, border=8) hbox4.Add(self.editPassword, flag=wx.RIGHT, border=30) #130 hbox5 = wx.BoxSizer(wx.HORIZONTAL) st5 = wx.StaticText(panel, label='Autosupport Message:', style=wx.ALIGN_RIGHT) editAutomsg = wx.TextCtrl(panel, value="Manually triggered asup ", size=(180,-1)) hbox5.Add(emptyLabel, flag=wx.RIGHT, border=16) hbox5.Add(st5, flag=wx.RIGHT, border=8) hbox5.Add(editAutomsg, flag=wx.RIGHT, border=30) hbox6 = wx.BoxSizer(wx.HORIZONTAL) line = wx.StaticLine(panel, -1, (2, 330), (600, 1)) hbox6.Add(line, flag=wx.RIGHT, border=15) hbox7 = wx.BoxSizer(wx.HORIZONTAL) self.ckbox = wx.CheckBox(panel, id=wx.NewId(),label='Use RSH instead of SSH(RSH need to be already configured)') self.ckbox.SetValue(False) hbox7.Add(emptyLabel, flag=wx.RIGHT, border=1) hbox7.Add(self.ckbox, flag=wx.RIGHT, border=15) else: hbox1 = wx.BoxSizer(wx.HORIZONTAL) st1 = wx.StaticText(panel, label='Controller1(IP(s)/Name(s)):',size=(150,-1) ,style=wx.ALIGN_RIGHT) self.editCntrler1 = wx.TextCtrl(panel, id=10,value="", size=(180,-1)) hbox1.Add(st1, flag=wx.RIGHT, border=8) hbox1.Add(self.editCntrler1, flag=wx.RIGHT, border=30) hbox2 = wx.BoxSizer(wx.HORIZONTAL) st2 = wx.StaticText(panel, label='Controller2(IP(s)/Name(s)):',size=(150,-1) ,style=wx.ALIGN_RIGHT) self.editCntrler2 = wx.TextCtrl(panel, id=20, value="", size=(180,-1)) hbox2.Add(st2, flag=wx.RIGHT, border=8) hbox2.Add(self.editCntrler2, flag=wx.RIGHT, border=30) hbox3 = wx.BoxSizer(wx.HORIZONTAL) st3 = wx.StaticText(panel, label='User Name:',size=(150,-1) ,style=wx.ALIGN_RIGHT) self.editUsrname = wx.TextCtrl(panel, id=30,value="admin", size=(100,-1)) hbox3.Add(st3, flag=wx.RIGHT, border=8) hbox3.Add(self.editUsrname, flag=wx.RIGHT, border=30) #130 hbox4 = wx.BoxSizer(wx.HORIZONTAL) st4 = wx.StaticText(panel, label='Password:' ,size=(150,-1) ,style=wx.ALIGN_RIGHT) self.editPassword = wx.TextCtrl(panel, id=40,value="", size=(100,-1),style=wx.TE_PASSWORD|wx.TE_PROCESS_ENTER) hbox4.Add(st4, flag=wx.RIGHT, border=8) hbox4.Add(self.editPassword, flag=wx.RIGHT, border=30) #130 hbox5 = wx.BoxSizer(wx.HORIZONTAL) st5 = wx.StaticText(panel, label='Autosupport Message:',size=(150,-1),style=wx.ALIGN_RIGHT) #st5.SetFont(font) editAutomsg = wx.TextCtrl(panel, value="Manually triggered asup ", size=(180,-1)) hbox5.Add(st5, flag=wx.RIGHT, border=8) hbox5.Add(editAutomsg, flag=wx.RIGHT, border=30) hbox6 = wx.BoxSizer(wx.HORIZONTAL) line = wx.StaticLine(panel, -1,(2,330),(600,1)) hbox6.Add(line, flag=wx.RIGHT, border=15) hbox7 = wx.BoxSizer(wx.HORIZONTAL) self.ckbox = wx.CheckBox(panel, id=wx.NewId(),label='Use RSH instead of SSH(RSH need to be already configured') self.ckbox.SetValue(False) hbox7.Add(self.ckbox, flag=wx.RIGHT, border=15) self.editCntrler1.Bind(wx.EVT_ENTER_WINDOW, self.onHover) self.editCntrler1.Bind(wx.EVT_LEAVE_WINDOW, self.onLeaveHover) self.editCntrler2.Bind(wx.EVT_ENTER_WINDOW, self.onHover) self.editCntrler2.Bind(wx.EVT_LEAVE_WINDOW, self.onLeaveHover) self.editUsrname.Bind(wx.EVT_ENTER_WINDOW, self.onHover) self.editUsrname.Bind(wx.EVT_LEAVE_WINDOW, self.onLeaveHover) self.editPassword.Bind(wx.EVT_ENTER_WINDOW, self.onHover) self.editPassword.Bind(wx.EVT_LEAVE_WINDOW, self.onLeaveHover) wx.EVT_CHECKBOX(panel, self.ckbox.GetId(), self.OnUseRSHinsteadSSH) hbox8 = wx.BoxSizer(wx.HORIZONTAL) line1 = wx.StaticLine(panel, -1,(2,330),(600,1)) hbox8.Add(line1, flag=wx.RIGHT, border=15) hboxBtns = wx.BoxSizer(wx.HORIZONTAL) hboxBtns.Add(emptyLabel, flag=wx.RIGHT, border=22) btn1 = wx.Button(panel, 1,label='Start', size=(70, 30)) hboxBtns.Add(btn1, flag=wx.LEFT|wx.RIGHT, border=60) btn2 = wx.Button(panel,2, label='Back', size=(70, 30)) hboxBtns.Add(btn2, flag=wx.LEFT | wx.RIGHT, border=60) vbox.Add(hboxEmpty,flag=wx.TOP | wx.BOTTOM, border=40) vbox.Add(hbox1, flag=wx.ALIGN_LEFT | wx.RIGHT | wx.TOP | wx.BOTTOM, border=2) vbox.Add(hbox2, flag=wx.ALIGN_LEFT | wx.RIGHT | wx.TOP | wx.BOTTOM, border=2) vbox.Add(hbox3, flag=wx.ALIGN_LEFT | wx.RIGHT | wx.TOP | wx.BOTTOM, border=2) vbox.Add(hbox4, flag=wx.ALIGN_LEFT | wx.RIGHT | wx.TOP | wx.BOTTOM, border=2) vbox.Add(hbox5, flag=wx.ALIGN_LEFT | wx.RIGHT | wx.TOP | wx.BOTTOM, border=4) vbox.Add(hbox6, flag=wx.ALIGN_LEFT|wx.RIGHT |wx.TOP|wx.BOTTOM, border=2) vbox.Add(hbox7, flag=wx.ALIGN_LEFT | wx.RIGHT | wx.TOP | wx.BOTTOM, border=2) vbox.Add(hbox8, flag=wx.ALIGN_LEFT | wx.RIGHT | wx.TOP | wx.BOTTOM, border=4) vbox.Add(hboxBtns, flag=wx.ALIGN_LEFT | wx.RIGHT | wx.TOP | wx.BOTTOM, border=12) self.Bind(wx.EVT_BUTTON, self.OnStart, id=1) self.Bind(wx.EVT_BUTTON, self.OnBack, id=2) panel.SetSizer(vbox) def onHover(self, event): obj_id=event.GetId() if obj_id ==10 or obj_id == 20: msg = "Enter the IP address as in format of:\n XXX.XXX.XXX.XXX !" elif obj_id == 30: msg = "You can change the User name!" elif obj_id == 40: msg = "Use minimum 8 character's along with any special character!" else: msg = "" event.GetEventObject().SetToolTipString(msg) event.Skip() def onLeaveHover(self,event): event.Skip() if event.GetId(): event.Skip() def OnStart(self, event): global asup_controller if self.editCntrler1.GetValue() and self.editCntrler2.GetValue(): asup_controller = self.editCntrler1.GetValue(), self.editCntrler2.GetValue() elif not self.editCntrler1.GetValue(): dlg = wx.MessageDialog(self, "Please enter the controller1 IP/Name...", "Notification", wx.YES_NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.editCntrler1.SetFocus() self.editCntrler1.SetInsertionPointEnd() else: dlg.Destroy() self.Close() #event.Skip() #return else: dlg = wx.MessageDialog(self, "Please enter the controller2 IP/Name...", "Notification", wx.YES_NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.dlg.Destroy() self.Close() if not self.ckbox.GetValue(): if not self.editUsrname.GetValue(): dlg = wx.MessageDialog(self, "Please enter the Username", "Notification", wx.YES_NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.dlg.Destroy() self.Close() if not self.editPassword.GetValue(): dlg = wx.MessageDialog(self, "Please enter the Password", "Notification", wx.YES_NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.dlg.Destroy() self.Close() #Need to implements by reference autoIt from-2348 line to 2460 self.Close() event.Skip() return def OnBack(self, event): event.Skip() self.EndModal(0) return def OnUseRSHinsteadSSH(self, event): if self.ckbox.GetValue(): self.ckbox.SetValue(True) self.editPassword.SetEditable(False) self.editUsrname.SetEditable(False) else: self.ckbox.SetValue(False) self.editPassword.SetEditable(True) self.editUsrname.SetEditable(True) event.Skip() return