Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: latin-1 -*-
- """ Scheduler plugin for RIDE ( Robotframework )
- Created by Josu Rodriguez Vilda
- Changes Contributed by Thomas Robinson
- """
- import sys, os, wx, threading, datetime, subprocess, time,random,sqlite3
- from subprocess import Popen, PIPE
- #import fileviewer
- import robot
- from robotide.version import VERSION
- from robotide.pluginapi import Plugin, ActionInfo, RideSaved, RideOpenSuite, RideTreeSelection
- ver="Ver. 1.09"
- today = datetime.date.today().strftime("%Y%m%d")
- if os.name == "nt":
- systemdrive=os.environ["SystemDrive"]
- COMPUTERNAME=os.environ["COMPUTERNAME"]
- allusersprofile = os.environ["ALLUSERSPROFILE"]
- version = "".join(sys.winver.split('.'))
- SchedulerDB = allusersprofile+"\scheduler-ride.db"
- runners = {'pybot': systemdrive + "\python" + version + "\\scripts\\pybot.bat",
- 'jybot': systemdrive + "\python" + version + "\\scripts\\jybot.bat" }
- elif os.name == "posix" :
- runners = {'pybot': 'pybot',
- 'jybot': 'jybot' }
- conn = sqlite3.connect(SchedulerDB)
- try:
- conn.execute("SELECT * FROM tasks")
- except:
- conn.execute('''CREATE TABLE [tasks]
- ([id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- [date] VARCHAR(50) NULL,
- [command] VARCHAR(300) NULL,
- [state] VARCHAR(30) NULL,
- [log] vaRCHAR(300) NULL,
- [report] varCHAR(300) NULL,
- [debug] varCHAR(300) NULL )''')
- class MyImageRenderer(wx.grid.PyGridCellRenderer):
- def __init__(self, img):
- wx.grid.PyGridCellRenderer.__init__(self)
- self.img = img
- def Draw(self, grid, attr, dc, rect, row, col, isSelected):
- image = wx.MemoryDC()
- image.SelectObject(self.img)
- dc.SetBackgroundMode(wx.SOLID)
- if isSelected:
- dc.SetBrush(wx.Brush(wx.BLUE, wx.SOLID))
- dc.SetPen(wx.Pen(wx.BLUE, 1, wx.SOLID))
- else:
- dc.SetBrush(wx.Brush(wx.WHITE, wx.SOLID))
- dc.SetPen(wx.Pen(wx.WHITE, 1, wx.SOLID))
- dc.DrawRectangleRect(rect)
- width, height = self.img.GetWidth(), self.img.GetHeight()
- if width > rect.width - 2:
- width = rect.width - 2
- if height > rect.height - 2:
- height = rect.height - 2
- dc.Blit(rect.x + 1, rect.y + 1, width, height, image, 0, 0, wx.COPY, True)
- class SchedulerPlugin(Plugin):
- """ Ver. 1.09
- Displays a tab where you can program different testcase execution, and test suites.
- The executions are stored in database and its implementation to give the possibility to continue running after closing the program or after a restart.
- Compatibility with RobotFramework 2.5
- """
- def __init__(self, application):
- Plugin.__init__(self, application, default_settings = {'Name': "Scheduler-plugin-for-RIDE",
- 'Creator': "Josu Rodriguez Vilda",
- 'Contributed':"Thomas Robinson",
- 'Date': "13/12/2010",
- 'Version': "1.09"})
- self._panel = None
- def add_to_grid(self,arg1,arg2,arg3,arg4,arg5,arg6):
- conn.execute("INSERT INTO tasks VALUES (Null,'"+arg1+"','"+arg2+"','"+arg3+"','"+arg4+"','"+arg5+"','"+arg6+"')")
- conn.commit()
- last = conn.execute("SELECT last_insert_rowid() ")
- return last.fetchall()[0][0]
- def button_add(self, event):
- path = self.model.suite.source
- #path = os.path.dirname(path)
- print path
- selection = self.test_suite_tree.GetSelections()
- row = self.task_grid.GetNumberRows()
- for item in selection:
- command = self.make_command(str(self.test_suite_tree.GetString(item)).lstrip())
- bmp = wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_OTHER, (16, 16))
- imageRenderer = MyImageRenderer(bmp)
- last = self.add_to_grid('', command, "Paused.", "", "", "")
- self.task_grid.AppendRows()
- self.task_grid.SetCellRenderer(row, 0, imageRenderer)
- self.task_grid.SetRowSize(row, bmp.GetHeight() + 2)
- self.task_grid.SetCellValue(row, 0, str(last))
- self.task_grid.SetCellValue(row, 1, command)
- self.task_grid.SetCellValue(row, 2, "Paused.")
- row += 1
- def button_empty(self, event):
- self.db_query("DELETE FROM tasks")
- conn = sqlite3.connect(SchedulerDB)
- c = conn.cursor()
- print c.rowcount
- conn.close()
- self.refresh_grid()
- def button_run(self, event):
- if threading.activeCount() < 2:
- self.thread1=threading.Thread(target=self.thread, name="WoW", args=( None, ))
- self.thread1.start()
- def db_query(self, query):
- conn = sqlite3.connect(SchedulerDB)
- c = conn.cursor()
- c.execute(query)
- conn.commit()
- conn.close()
- return c
- def disable(self):
- self.unregister_actions()
- self.delete_tab(self._panel)
- self._panel = None
- def dump_suite(self, suite, indent):
- print "Suite: %s" % suite
- try:
- #print "suite name: %s" % suite.name
- #print "suite Directory: %s" % suite.directory
- self.li.append(str(indent * " " + " + " + str(suite.name)))
- for test in suite.children:
- if test.has_tests()!="True":
- self.dump_suite(test, indent+6)
- else:
- self.li.append(str(indent*" "+" - "+str(test.name)))
- for test in suite.testcase_table.tests:
- self.li.append(str(indent*" "+" - "+str(test.name)))
- except:
- print "dump_suite: Pass"
- pass
- def enable(self):
- self.register_action(ActionInfo('&Scheduler', 'View', self.show, doc = 'Displays a tab Scheduler.'))
- self.register_action(ActionInfo('Scheduler', 'Update', self.update, doc = ''))
- self.register_action(ActionInfo('Scheduler', 'Run Paused Tasks', self.menu_execution,
- icon = wx.ArtProvider.GetBitmap(wx.ART_EXECUTABLE_FILE, wx.ART_OTHER, (16, 16)),
- doc = 'Adds the selection to existing programming.',
- shortcut = "Ctrl-E"))
- self.subscribe(self.update, RideSaved, RideOpenSuite)
- self.subscribe(self.on_tree_selection, RideTreeSelection)
- self.show()
- def execution(self, event, content): # en via de modificación por la realizacion de make command - Eliminar cuando este finalizado.
- path = self.model.suite.source
- try:
- runner = runners[self.execution_combo.GetStringSelection()]
- rows = self.task_grid.GetNumberRows()
- except:
- pass
- for item in content:
- now = str(time.time()) + str(random.random())
- selection = item
- GuiIncludeValue = str(self.include_text.GetValue())
- GuiExcludeValue = str(self.exclude_text.GetValue())
- GuiVariableValue = str(self.variable_text.GetValue())
- GuiLogLevelValue = str(self.output_text.GetValue())
- GuiCheckDebug = self.debug_cb.IsChecked()
- if selection[0] == "+":
- command = " --suite \"" + selection[2:] + "\""
- else :
- command = " --test \"" + selection[2:] + "\""
- if GuiIncludeValue != "":
- command += " --include " + GuiIncludeValue
- if GuiExcludeValue != "":
- command += " --exclude " + GuiExcludeValue
- if GuiVariableValue != "":
- command += " --variable " + GuiVariableValue
- command += " -W 90 "
- if GuiLogLevelValue != "":
- if GuiCheckDebug:
- command += " -b \"" + GuiLogLevelValue + "\\"+COMPUTERNAME + ".txt\""
- command += " --outputdir \""+GuiLogLevelValue+"\""
- command += " --log \"" + selection[2:] + now + ".html\" --report \"" + selection[2:] + \
- "-report" + now + ".html\" --output \"" + selection[2:] + now + ".xml\""
- self.task_grid.AppendRows()
- #img = wx.Bitmap("python-logo.png", wx.BITMAP_TYPE_PNG)
- bmp = wx.ArtProvider.GetBitmap(wx.ART_TIP, wx.ART_OTHER, (16, 16))
- imageRenderer = MyImageRenderer(bmp)
- last = self.add_to_grid('', runner + command + " \"" + path + "\"", "Paused.", GuiLogLevelValue + \
- "\\" + selection[2:] + now + ".html", GuiLogLevelValue + "\\" + selection[2:] + \
- "-report" + now + ".html", GuiLogLevelValue + "\\" + COMPUTERNAME + ".txt")
- self.task_grid.SetCellRenderer(rows, 0, imageRenderer)
- self.task_grid.SetRowSize(rows, bmp.GetHeight() + 2)
- self.task_grid.SetCellValue(rows, 0, str(last))
- self.task_grid.SetCellValue(rows, 1, runner + command + " \"" + path + "\"")
- self.task_grid.SetCellValue(rows, 2, "Paused.")
- self.task_grid.SetCellValue(rows, 4, GuiLogLevelValue + "\\" + selection[2:] + "-report" + now + ".html")
- self.task_grid.SetCellValue(rows, 3, GuiLogLevelValue + "\\" + selection[2:] + now + ".html")
- if GuiCheckDebug:
- self.task_grid.SetCellValue(rows, 5, GuiLogLevelValue + "\\" + COMPUTERNAME + ".txt")
- rows += 1
- self.thread1 = threading.Thread(target=self.thread, name="WoW", args=( None, ))
- if threading.activeCount() < 2:
- self.thread1.start()
- def make_command(self, item):
- path = self.model.suite.source
- #path = os.path.dirname(path)
- runner = runners[self.execution_combo.GetStringSelection()]
- now = str(time.time()) + str(random.random())
- GuiIncludeValue = str(self.include_text.GetValue())
- GuiExcludeValue = str(self.exclude_text.GetValue())
- GuiVariableValue = str(self.variable_text.GetValue())
- GuiLogLevelValue = str(self.output_text.GetValue())
- GuiCheckDebug = str(self.debug_cb.IsChecked())
- if item[0] == "+":
- command = " --suite \""+item[2:]+"\""
- else :
- command = " --test \""+item[2:]+"\""
- if GuiIncludeValue != "":
- command += " --include " + GuiIncludeValue
- if GuiExcludeValue != "":
- command += " --exclude " + GuiExcludeValue
- if GuiVariableValue != "":
- command += " --variable " + GuiVariableValue
- command += " -W 90 --loglevel " + self.loglevel_combo.GetStringSelection()
- #if (GuiLogLevelValue!=""): command = command+" --loglevel TRACE "
- if (GuiCheckDebug == "True"):
- command = command+" -b \""+GuiLogLevelValue+"\\"+COMPUTERNAME+".txt\""
- command = command+" --outputdir \""+GuiLogLevelValue+"\""
- #else :
- # command = command+" --loglevel TRACE -T "
- command = runner+command+" --log \""+item[2:]+now+".html\" --report \""+item[2:]+"-report"+now+".html\" --output \""+item[2:]+now+".xml\" \""+path+"\""
- return command
- def menu_execution(self, event):
- content = []
- nodo = Plugin.get_selected_item(self)
- if str(type(nodo)) == "<class 'robotide.model.tcuk.TestCase'>":
- content.append("- "+str(nodo.name))
- elif str(type(nodo)) == "<type 'NoneType'>":
- return "There is nothing selected."
- else:
- try:
- content.append("+ "+str(Plugin.get_selected_datafile(self).longname))
- except:
- return "The task is not executable."
- self.execution(None,content)
- def on_cell_selection(self, event):
- # Select cell, range of cells, rows and column and right click on the grid
- row=event.GetRow()
- col=event.GetCol()
- event.Skip()
- if col>2 and col<5:
- if self.task_grid.GetCellValue(row, col)!="":
- #print self.task_grid.GetCellValue(row, col)
- sp = subprocess
- pr = subprocess.Popen("\""+self.task_grid.GetCellValue(row, col)+"\"", stdout=sp.PIPE, stderr=sp.STDOUT,shell=True)
- if col == 5:
- if self.task_grid.GetCellValue(row, col)!="":
- sp = subprocess
- pr = subprocess.Popen("python -m fileviewer \""+self.task_grid.GetCellValue(row, col)+"\"", stdout=sp.PIPE, stderr=sp.STDOUT,shell=True)
- if col==0:
- task=[self.task_grid.GetCellValue(row, col)]
- res=self.remove_confirmation(task)
- if res == 5103 :
- for a in range(3,5):
- if self.task_grid.GetCellValue(row, a) != "" :
- try:
- os.remove( self.task_grid.GetCellValue(row, a));
- except:
- print "NO se ha borrado"+self.task_grid.GetCellValue(row, a)
- print self.task_grid.GetCellValue(row, 0)
- conn.execute("DELETE FROM tasks WHERE id = " + str(self.task_grid.GetCellValue(row, 0)))
- conn.commit()
- self.task_grid.DeleteRows(row, 1)
- def on_ctrl_a(self, event):
- self.debug_text.SelectAll()
- def on_delete(self, event):
- fr, to = self.debug_text.GetSelection()
- self.debug_text.Remove(fr, to)
- def on_remote_cb_check(self,event):
- if self.remote_cb.IsChecked():
- self.remoteuser_label.Enable()
- self.remotepassword_label.Enable()
- self.remotepc_text.Enable()
- self.remoteuser_text.Enable()
- self.remotepassword_text.Enable()
- else:
- self.remoteuser_label.Disable()
- self.remotepassword_label.Disable()
- self.remotepc_text.Disable()
- self.remoteuser_text.Disable()
- self.remotepassword_text.Disable()
- def on_scheduler_cb_check(self,event):
- if self.scheduler_cb.IsChecked():
- self.scheduler_runtasks_label.Enable()
- self.times_to_run.Enable()
- self.scheduler_timesat_label.Enable()
- self.date_to_run.Enable()
- else:
- self.scheduler_runtasks_label.Disable()
- self.times_to_run.Disable()
- self.scheduler_timesat_label.Disable()
- self.date_to_run.Disable()
- def on_tree_selection(self, event):
- if "Edit" in self.notebook.GetPageText(self.notebook.GetSelection()):
- return
- for i in range(self.notebook.GetPageCount()):
- if "Edit" in self.notebook.GetPageText(i):
- print self.notebook.GetPage(i)
- self.notebook.show_tab(self.notebook.GetPage(i))
- def readlines(self,fd):
- while True:
- line = fd.readline()
- if not line:
- break
- yield line
- def refresh_grid(self):
- rows = self.task_grid.GetNumberRows()
- if (rows > 0) :
- self.task_grid.DeleteRows(0, rows)
- index = 0
- for n in conn.execute("SELECT * FROM tasks"):
- if n[3] == "Running.":
- continue
- self.task_grid.AppendRows()
- self.task_grid.SetCellValue(index, 0, str(n[0]))
- self.task_grid.SetCellValue(index, 1, str(n[2]))
- self.task_grid.SetCellValue(index, 2, str(n[3]))
- self.task_grid.SetCellValue(index, 3, str(n[4]))
- self.task_grid.SetCellValue(index, 4, str(n[5]))
- self.task_grid.SetCellValue(index, 5, str(n[6]))
- bmp = None
- if n[3] == "Passed.":
- bmp = wx.ArtProvider.GetBitmap(wx.ART_TICK_MARK, wx.ART_OTHER, (16, 16))
- self.task_grid.SetCellBackgroundColour(index, 3, "green")
- self.task_grid.SetCellBackgroundColour(index, 4, "green")
- self.task_grid.SetCellBackgroundColour(index, 5, "green")
- elif n[3] == "Failed.":
- bmp = wx.ArtProvider.GetBitmap(wx.ART_ERROR, wx.ART_OTHER, (16, 16))
- self.task_grid.SetCellBackgroundColour(index, 3, "red")
- self.task_grid.SetCellBackgroundColour(index, 4, "red")
- self.task_grid.SetCellBackgroundColour(index, 5, "red")
- elif n[3] == "Paused.":
- bmp = wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_OTHER, (16, 16))
- imageRenderer = MyImageRenderer(bmp)
- self.task_grid.SetCellRenderer(index, 0, imageRenderer)
- self.task_grid.SetRowSize(index, bmp.GetHeight() + 2)
- index += 1
- conn.commit()
- def remove_confirmation(self, task):
- dial = wx.MessageDialog(None, 'Want to remove the task '+str(task)+' and its records \n',\
- 'Warning', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_EXCLAMATION)
- return dial.ShowModal()
- def show(self, event=None):
- if not self._panel:
- self._create_panel()
- self.add_tab(self._panel, "Scheduler")
- #self.show_tab(self._panel)
- def thread(self, event):
- contador = self.task_grid.GetNumberRows()
- conta=0
- while (conta < int(self.task_grid.GetNumberRows())):
- if (self.task_grid.GetCellValue(conta,2)!="Paused.") :
- conta=conta+1
- else:
- #print self.task_grid.GetCellValue(conta,2)
- conn = sqlite3.connect(SchedulerDB)
- #print self.task_grid.GetCellValue(conta,0)
- conn.execute("update tasks SET state = 'Running.' where id = "+self.task_grid.GetCellValue(conta,0))
- conn.commit()
- conn.close()
- self.task_grid.SetCellValue(conta,2, "Running.")
- bmp = wx.ArtProvider.GetBitmap(wx.ART_EXECUTABLE_FILE, wx.ART_OTHER, (16, 16))
- imageRenderer = MyImageRenderer(bmp)
- self.task_grid.SetCellRenderer(conta,0,imageRenderer)
- #self.task_grid.SetColSize(0,bmp.GetWidth()+2)
- self.task_grid.SetRowSize(conta,bmp.GetHeight()+2)
- commandtorun = self.task_grid.GetCellValue(conta, 1)
- self.pr = subprocess.Popen(commandtorun, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,shell=True)
- self.color="green"
- for line in self.readlines(self.pr.stdout):
- self.debug_text.AppendText(unicode( line, "utf-8"))
- if line.count("Log:") > 0:
- print line,
- log = line[9:-2]
- self.task_grid.SetCellValue(conta,3, log)
- self.task_grid.SetCellBackgroundColour(conta, 3, self.color)
- self.db_query("UPDATE tasks SET log = '" + log + "' where id = " + self.task_grid.GetCellValue(conta,0))
- break;
- elif line.count("Report:") > 0:
- print line,
- Report = line[9:-2]
- self.task_grid.SetCellValue(conta,4, Report)
- self.task_grid.SetCellBackgroundColour(conta, 4, self.color)
- self.db_query("UPDATE tasks SET report = '" + Report + "' where id = " + self.task_grid.GetCellValue(conta,0))
- elif line.count("Debug:") > 0:
- print line,
- Debug = line[9:-2]
- self.task_grid.SetCellValue(conta,5, Debug)
- self.task_grid.SetCellBackgroundColour(conta, 5, self.color)
- self.db_query("UPDATE tasks SET debug = '" + Debug + "' where id = " + self.task_grid.GetCellValue(conta,0))
- elif line.count("FAIL") > 0:
- print line,
- self.color = "red"
- else:
- pass
- print "---------------"
- bmp = None
- if self.color == "red":
- self.task_grid.SetCellValue(conta,2, "Failed.")
- self.db_query("UPDATE tasks SET state = 'Failed.' where id = " + self.task_grid.GetCellValue(conta,0))
- bmp = wx.ArtProvider.GetBitmap(wx.ART_ERROR, wx.ART_OTHER, (16, 16))
- else:
- self.task_grid.SetCellValue(conta,2, "Passed.")
- self.db_query("UPDATE tasks SET state = 'Passed.' where id = " + self.task_grid.GetCellValue(conta,0))
- bmp = wx.ArtProvider.GetBitmap(wx.ART_TICK_MARK, wx.ART_OTHER, (16, 16))
- imageRenderer = MyImageRenderer(bmp)
- self.task_grid.SetCellRenderer(conta,0,imageRenderer)
- #self.task_grid.SetColSize(0,bmp.GetWidth()+2)
- self.task_grid.SetRowSize(conta,bmp.GetHeight()+2)
- print "---------------"
- def update(self,message):
- """Handle publications from the main frame"""
- #application = self.manager._application
- #model = self.model()
- suite = self.model.suite
- self.li=[]
- self.test_suite_tree.Clear()
- self.dump_suite(suite, 0)
- self.test_suite_tree.InsertItems(self.li,0)
- self.test_suite_tree.Select(0)
- def _create_panel(self):
- """Add a tab for this plugin to the notebook"""
- self._panel = wx.Panel(self.notebook)
- sizer = wx.GridBagSizer(5, 5)
- self.execution_combo = wx.ComboBox(self._panel, choices=runners.keys(), style=wx.CB_READONLY)
- self.execution_combo.SetStringSelection(runners.keys()[1])
- sizer.Add(self.execution_combo, (0, 0), (1, 2), wx.EXPAND)
- self.test_suite_label = wx.StaticText(self._panel, label="--test && --suite")
- sizer.Add(self.test_suite_label, (1, 0))
- self.test_suite_tree = wx.ListBox(self._panel, style=wx.LB_EXTENDED|wx.LB_HSCROLL)
- sizer.Add(self.test_suite_tree, (2, 0), (11, 2), wx.EXPAND)
- self.include_label = wx.StaticText(self._panel, label=" --include tag")
- sizer.Add(self.include_label, (2, 2))
- self.include_text = wx.TextCtrl(self._panel)
- sizer.Add(self.include_text, (3, 2), flag=wx.EXPAND)
- self.exclude_label = wx.StaticText(self._panel, label=" --exclude tag")
- sizer.Add(self.exclude_label, (2, 3))
- self.exclude_text = wx.TextCtrl(self._panel)
- sizer.Add(self.exclude_text, (3, 3), flag=wx.EXPAND)
- self.variable_label = wx.StaticText(self._panel, label=" --variable var_name:var_value")
- sizer.Add(self.variable_label, (4, 2))
- self.variable_text = wx.TextCtrl(self._panel)
- sizer.Add(self.variable_text, (5, 2), flag=wx.EXPAND)
- self.loglevel_label = wx.StaticText(self._panel, label=" --loglevel value")
- sizer.Add(self.loglevel_label, (4, 3))
- self.loglevel_combo = wx.ComboBox(self._panel, choices=["NONE", "WARN", "INFO", "DEBUG", "TRACE"], style=wx.CB_READONLY)
- self.loglevel_combo.SetStringSelection("INFO")
- sizer.Add(self.loglevel_combo, (5, 3), flag=wx.EXPAND)
- self.output_label = wx.StaticText(self._panel, label=" --outputdir dir")
- sizer.Add(self.output_label, (6, 2))
- self.output_text = wx.TextCtrl(self._panel, value="logs\\%s" % today)
- sizer.Add(self.output_text, (7, 2), (1, 2), wx.EXPAND)
- self.debug_cb = wx.CheckBox(self._panel, label="Debug -T")
- self.debug_cb.SetValue(True)
- sizer.Add(self.debug_cb, (6, 3))
- self.remote_cb = wx.CheckBox(self._panel, label="Remote Computer")
- self.remote_cb.Bind(wx.EVT_CHECKBOX,self.on_remote_cb_check)
- sizer.Add(self.remote_cb, (8, 2))
- self.remotepc_text = wx.TextCtrl(self._panel)
- sizer.Add(self.remotepc_text, (9, 2), (1, 2), wx.EXPAND)
- self.remoteuser_label = wx.StaticText(self._panel, label="User:")
- sizer.Add(self.remoteuser_label, (10, 2))
- self.remoteuser_text = wx.TextCtrl(self._panel)
- sizer.Add(self.remoteuser_text, (11, 2), flag=wx.EXPAND)
- self.remotepassword_label = wx.StaticText(self._panel, label="Password:")
- sizer.Add(self.remotepassword_label, (10, 3))
- self.remotepassword_text = wx.TextCtrl(self._panel, style=wx.TE_PASSWORD)
- sizer.Add(self.remotepassword_text, (11, 3), flag=wx.EXPAND)
- # Initially disable all remote PC "stuff" since checkbox is not checked by default
- self.remoteuser_label.Disable()
- self.remotepassword_label.Disable()
- self.remotepc_text.Disable()
- self.remoteuser_text.Disable()
- self.remotepassword_text.Disable()
- task_notebook = wx.Notebook(self._panel)
- self.task_panel = wx.Panel(task_notebook)
- self.execution_label = wx.StaticText(self.task_panel, label="Executing: ")
- self.task_grid = wx.grid.Grid(self.task_panel)
- self.task_grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.on_cell_selection)
- self.task_grid.CreateGrid(0,6)
- self.task_grid.SetRowLabelSize(0)
- self.task_grid.SetColLabelValue(0, "")
- self.task_grid.SetColLabelValue(1, "Command")
- self.task_grid.SetColLabelValue(2, "State")
- self.task_grid.SetColLabelValue(3, "Log")
- self.task_grid.SetColLabelValue(4, "Report")
- self.task_grid.SetColLabelValue(5, "Debug")
- self.task_grid.SetColSize(0,20)
- self.task_grid.SetColSize(1,300)
- self.task_grid.SetColSize(2,70)
- self.task_grid.SetColSize(3,100)
- self.task_grid.SetColSize(4,100)
- self.task_grid.SetColSize(5,100)
- self.refresh_grid()
- self.log_panel = wx.Panel(task_notebook)
- self.log_text = wx.TextCtrl(self.log_panel, style=wx.TE_MULTILINE)
- self.debug_panel = wx.Panel(task_notebook)
- font = wx.Font(9, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
- self.debug_text = wx.TextCtrl(self.debug_panel, style=wx.TE_MULTILINE)
- self.debug_text.SetFont(font)
- ranId1 = wx.NewId()
- self.debug_panel.Bind(wx.EVT_MENU, self.on_ctrl_a, id=ranId1)
- ranId2 = wx.NewId()
- self.debug_panel.Bind(wx.EVT_MENU, self.on_delete, id=ranId2)
- accel_tbl = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('A'), ranId1), (wx.ACCEL_NORMAL, wx.WXK_DELETE, ranId2)])
- self.debug_panel.SetAcceleratorTable(accel_tbl)
- nb_task_sizer = wx.GridBagSizer()
- nb_task_sizer.Add(self.execution_label, (0,0), flag=wx.EXPAND)
- nb_task_sizer.Add(self.task_grid, (1,0), flag=wx.EXPAND)
- nb_task_sizer.AddGrowableCol(0)
- nb_task_sizer.AddGrowableRow(1)
- nb_log_sizer = wx.GridSizer(1, 1)
- nb_log_sizer.Add(self.log_text, flag=wx.EXPAND)
- nb_debug_sizer = wx.GridSizer(1, 1)
- nb_debug_sizer.Add(self.debug_text, flag=wx.EXPAND)
- self.task_panel.SetSizer(nb_task_sizer)
- self.log_panel.SetSizer(nb_log_sizer)
- self.debug_panel.SetSizer(nb_debug_sizer)
- task_notebook.AddPage(self.task_panel, "Task")
- task_notebook.AddPage(self.log_panel, "Log")
- task_notebook.AddPage(self.debug_panel, "Debug")
- scheduler_panel = wx.Panel(self._panel)
- scheduler_sizer = wx.BoxSizer()
- self.scheduler_cb = wx.CheckBox(scheduler_panel, label="Scheduler")
- self.scheduler_cb.Bind(wx.EVT_CHECKBOX,self.on_scheduler_cb_check)
- self.scheduler_runtasks_label = wx.StaticText(scheduler_panel, label=" Run tasks ")
- self.times_to_run = wx.SpinCtrl(scheduler_panel)
- self.scheduler_timesat_label = wx.StaticText(scheduler_panel, label=" times at ")
- self.date_to_run = wx.DatePickerCtrl(scheduler_panel)
- # Initially disable all scheduling "stuff" since checkbox is not checked by default
- self.scheduler_runtasks_label.Disable()
- self.times_to_run.Disable()
- self.scheduler_timesat_label.Disable()
- self.date_to_run.Disable()
- scheduler_sizer.Add(self.scheduler_cb)
- scheduler_sizer.Add(self.scheduler_runtasks_label)
- scheduler_sizer.Add(self.times_to_run)
- scheduler_sizer.Add(self.scheduler_timesat_label)
- scheduler_sizer.Add(self.date_to_run)
- scheduler_panel.SetSizer(scheduler_sizer)
- sizer.Add(scheduler_panel, (12, 2), (1, 2))
- button_panel = wx.Panel(self._panel)
- self.addtask_button = wx.Button(button_panel, label="Add Tasks")
- self.addtask_button.Bind(wx.EVT_BUTTON, self.button_add)
- self.runtasks_button = wx.Button(button_panel, label="Run Paused Tasks")
- self.runtasks_button.Bind(wx.EVT_BUTTON, self.button_run)
- self.emptytasks_button = wx.Button(button_panel, label="Empty Tasks")
- self.emptytasks_button.Bind(wx.EVT_BUTTON, self.button_empty)
- button_sizer = wx.BoxSizer()
- button_sizer.Add(self.addtask_button)
- button_sizer.Add(self.runtasks_button)
- button_sizer.Add(self.emptytasks_button)
- button_panel.SetSizer(button_sizer)
- sizer.Add(button_panel, (14, 1))
- sizer.Add(task_notebook, (15, 0), (1, 4), wx.EXPAND)
- sizer.AddGrowableCol(0)
- sizer.AddGrowableCol(1)
- sizer.AddGrowableCol(2)
- sizer.AddGrowableCol(3)
- sizer.AddGrowableRow(15)
- self._panel.SetSizer(sizer)
- def _absnorm(self, path):
- return os.path.normpath(os.path.abspath(path.replace('/', os.sep)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement