Home | Trees | Indices | Help |
|
---|
|
1 # -*- coding: iso-8859-15 -*- 2 # generated by wxGlade HG on Tue May 19 21:48:13 2009 3 4 # 5 # ArcJobToolWindow main window class 6 # 7 8 """ 9 Implements the arcgui main window. 10 """ 11 12 import wx 13 from wx.lib.dialogs import * 14 15 16 # begin wxGlade: dependencies 17 # end wxGlade 18 19 # begin wxGlade: extracode 20 21 # end wxGlade 22 23 import sys, shutil 24 25 from datetime import datetime 26 27 try: 28 import arc 29 except: 30 print "ARC1 Python binding not found. Please check search paths." 31 sys.exit(-1) 32 33 import os, sys, threading, types, shutil 34 35 # ArcGUI imports 36 37 from arcjobtool.plugins.Plugins import PluginManager 38 39 from arcjobtool.ArcUtils import ArcClient, ManagedJobDescription 40 from arcjobtool.AddOutputFileDialog import AddOutputFileDialog 41 from arcjobtool.ArcSplash import ArcSplash 42 from arcjobtool.ClientSettingsDialog import ClientSettingsDialog 43 from arcjobtool.CertificateInfoWindow import * 44 from arcjobtool.DefaultServicesDialog import DefaultServicesDialog 45 from arcjobtool.JobPropertiesDialog import JobPropertiesDialog 46 from arcjobtool.ProxyDialog import * 47 from arcjobtool.PlatformUtils import * 48 from arcjobtool.ArcGuiThreads import * 49 50 import arcjobtool.Tasks 5153 """ 54 User authentication class with graphical login dialog. 55 56 The parentWindow property should be set before the passphrase dialog 57 is shown. 58 """8560 """ 61 Class constructor 62 63 Initialises parentWindow property to None. 64 """ 65 UserAuthentication.__init__(self, userConfig) 66 self.parentWindow = None6769 """ 70 Passphrase callback (virtual) 71 72 Shows a proxy passphrase dialog. 73 """ 74 proxyDialog = ProxyDialog(self.parentWindow) 75 proxyDialog.ShowModal() 76 if proxyDialog.dialogResult: 77 self.period = proxyDialog.proxyLifetime 78 self.proxyType = proxyDialog.proxyType 79 passphrase = proxyDialog.passphrase 80 proxyDialog.Destroy() 81 return passphrase 82 else: 83 proxyDialog.Destroy() 84 return ""87 """ 88 Main frame class for arcjobtool. 89 """1017 1019 """ 1020 Open selected job definition 1021 """ 1022 if len(self.__selectedJobDefinition)!=0: 1023 1024 # Determine full path of job definition dir 1025 1026 definitionName = self.__selectedJobDefinition[1]+".arcdef" 1027 fullPath = os.path.join(self.__definitionDir, definitionName) 1028 resultPath = os.path.join(fullPath,"results") 1029 if os.path.isdir(resultPath): 1030 showDir(resultPath) 1031 else: 1032 wx.MessageBox("No results have been downloaded to job definition.") 1033 1034 else: 1035 wx.MessageBox("Please select a jobdefinition.") 1036 1037 1039 """ 1040 Open selected job definition 1041 """ 1042 if len(self.__selectedJobDefinition)!=0: 1043 1044 # Determine full path of job definition dir 1045 1046 definitionName = self.__selectedJobDefinition[1]+".arcdef" 1047 fullPath = os.path.join(self.__definitionDir, definitionName) 1048 resultPath = os.path.join(fullPath,"results") 1049 if os.path.isdir(resultPath): 1050 shutil.rmtree(resultPath) 1051 else: 1052 wx.MessageBox("No results have been downloaded to job definition.") 1053 1054 else: 1055 wx.MessageBox("Please select a jobdefinition.") 105691 92 self.__applicationDir = os.path.dirname(sys.argv[0]) 93 94 if os.environ.has_key("ARCJOBTOOL_SHARE"): 95 self.__imageDir = os.path.join(os.environ["ARCJOBTOOL_SHARE"], "images") 96 else: 97 self.__imageDir = os.path.join(self.__applicationDir, "../share/arcjobtool/images") 98 99 ARCJOBTOOL_NEW_DEFINITON_IMAGE = os.path.join(self.__imageDir, "document-new.png") 100 ARCJOBTOOL_EDIT_DEFINITON_IMAGE = os.path.join(self.__imageDir, "gtk-edit.png") 101 ARCJOBTOOL_SUBMIT_DEFINITION_IMAGE = os.path.join(self.__imageDir, "system-run.png") 102 ARCJOBTOOL_OPEN_RESULTS_IMAGE = os.path.join(self.__imageDir, "folder-open.png") 103 ARCJOBTOOL_DELETE_DEFINITION_IMAGE = os.path.join(self.__imageDir, "edit-delete.png") 104 ARCJOBTOOL_VIEW_DESCRIPTION = os.path.join(self.__imageDir, "preview-xrsl.png") 105 ARCJOBTOOL_REFRESH_JOBS_IMAGE = os.path.join(self.__imageDir, "view-refresh.png") 106 ARCJOBTOOL_JOB_INFO_IMAGE = os.path.join(self.__imageDir, "edit-find.png") 107 ARCJOBTOOL_DOWNLOAD_JOB_IMAGE = os.path.join(self.__imageDir, "download-job.png") 108 ARCJOBTOOL_DOWNLOAD_ALL_IMAGE = os.path.join(self.__imageDir, "download-all.png") 109 ARCJOBTOOL_KILL_JOB_BUTTON = os.path.join(self.__imageDir, "process-stop.png") 110 ARCJOBTOOL_KILL_THREADS_BUTTON = os.path.join(self.__imageDir, "kill-threads.png") 111 ARCJOBTOOL_CLEAN_JOB_BUTTON = os.path.join(self.__imageDir, "edit-delete.png") 112 ARCJOBTOOL_REMOVE_DOWNLOADED_JOB_IMAGE = os.path.join(self.__imageDir, "edit-delete.png") 113 ARCJOBTOOL_OPEN_URL = os.path.join(self.__imageDir, "folder-open.png") 114 115 # begin wxGlade: ArcJobToolWindow.__init__ 116 kwds["style"] = wx.DEFAULT_FRAME_STYLE 117 wx.Frame.__init__(self, *args, **kwds) 118 119 # Menu Bar 120 self.mainMenuBar = wx.MenuBar() 121 self.fileMenu = wx.Menu() 122 self.changeWorkingDirMenu = wx.MenuItem(self.fileMenu, wx.NewId(), "Change working directory...\tCtrl+O", "", wx.ITEM_NORMAL) 123 self.fileMenu.AppendItem(self.changeWorkingDirMenu) 124 self.fileExitMenu = wx.MenuItem(self.fileMenu, wx.NewId(), "&Quit\tCtrl+Q", "", wx.ITEM_NORMAL) 125 self.fileMenu.AppendItem(self.fileExitMenu) 126 self.mainMenuBar.Append(self.fileMenu, "&File") 127 self.sessionMenu = wx.Menu() 128 self.sessionCertProxyInfoMenu = wx.MenuItem(self.sessionMenu, wx.NewId(), "&Cert/Proxy information... \tF2", "", wx.ITEM_NORMAL) 129 self.sessionMenu.AppendItem(self.sessionCertProxyInfoMenu) 130 self.sessionCreateProxyMenu = wx.MenuItem(self.sessionMenu, wx.NewId(), "Create new &proxy certificate...\tCtrl+L", "", wx.ITEM_NORMAL) 131 self.sessionMenu.AppendItem(self.sessionCreateProxyMenu) 132 self.mainMenuBar.Append(self.sessionMenu, "&Session") 133 self.definitionMenu = wx.Menu() 134 self.newJobDefinitionMenu = wx.MenuItem(self.definitionMenu, wx.NewId(), "&New...\tCtrl+N", "", wx.ITEM_NORMAL) 135 self.definitionMenu.AppendItem(self.newJobDefinitionMenu) 136 self.modifyDefinitionMenu = wx.MenuItem(self.definitionMenu, wx.NewId(), "&Modify...\tCtrl+E", "", wx.ITEM_NORMAL) 137 self.definitionMenu.AppendItem(self.modifyDefinitionMenu) 138 self.submitJobDefinitionMenu = wx.MenuItem(self.definitionMenu, wx.NewId(), "&Submit\tF7", "", wx.ITEM_NORMAL) 139 self.definitionMenu.AppendItem(self.submitJobDefinitionMenu) 140 self.submittMissingMenu = wx.MenuItem(self.definitionMenu, wx.NewId(), "Submit &missing\tF8", "", wx.ITEM_NORMAL) 141 self.definitionMenu.AppendItem(self.submittMissingMenu) 142 self.viewResultsMenu = wx.MenuItem(self.definitionMenu, wx.NewId(), "&View result files", "", wx.ITEM_NORMAL) 143 self.definitionMenu.AppendItem(self.viewResultsMenu) 144 self.cleanResultsMenu = wx.MenuItem(self.definitionMenu, wx.NewId(), "&Clean results", "", wx.ITEM_NORMAL) 145 self.definitionMenu.AppendItem(self.cleanResultsMenu) 146 self.deleteJobDefinitionMenu = wx.MenuItem(self.definitionMenu, wx.NewId(), "&Delete\tDel", "", wx.ITEM_NORMAL) 147 self.definitionMenu.AppendItem(self.deleteJobDefinitionMenu) 148 self.viewXRSLMenu = wx.MenuItem(self.definitionMenu, wx.NewId(), "View &XRSL...", "", wx.ITEM_NORMAL) 149 self.definitionMenu.AppendItem(self.viewXRSLMenu) 150 self.mainMenuBar.Append(self.definitionMenu, "&Definitions") 151 self.jobsMenu = wx.Menu() 152 self.refreshStatusMenu = wx.MenuItem(self.jobsMenu, wx.NewId(), "&Refresh status\tCtrl+R", "", wx.ITEM_NORMAL) 153 self.jobsMenu.AppendItem(self.refreshStatusMenu) 154 self.donwloadSelectedMenu = wx.MenuItem(self.jobsMenu, wx.NewId(), "&Download selected...", "", wx.ITEM_NORMAL) 155 self.jobsMenu.AppendItem(self.donwloadSelectedMenu) 156 self.downloadToDefinitionMenu = wx.MenuItem(self.jobsMenu, wx.NewId(), "Download &all...", "", wx.ITEM_NORMAL) 157 self.jobsMenu.AppendItem(self.downloadToDefinitionMenu) 158 self.killSelectedMenu = wx.MenuItem(self.jobsMenu, wx.NewId(), "&Kill selected", "", wx.ITEM_NORMAL) 159 self.jobsMenu.AppendItem(self.killSelectedMenu) 160 self.cleanSelectedMenu = wx.MenuItem(self.jobsMenu, wx.NewId(), "&Clean selected", "", wx.ITEM_NORMAL) 161 self.jobsMenu.AppendItem(self.cleanSelectedMenu) 162 self.remoteFromJobListMenu = wx.MenuItem(self.jobsMenu, wx.NewId(), "&Remove from job list", "", wx.ITEM_NORMAL) 163 self.jobsMenu.AppendItem(self.remoteFromJobListMenu) 164 self.mainMenuBar.Append(self.jobsMenu, "&Jobs") 165 self.settingsMenu = wx.Menu() 166 self.clientSettingsMenu = wx.MenuItem(self.settingsMenu, wx.NewId(), "&Client...\tF3", "", wx.ITEM_NORMAL) 167 self.settingsMenu.AppendItem(self.clientSettingsMenu) 168 self.servicesSettingsMenu = wx.MenuItem(self.settingsMenu, wx.NewId(), "&Services...\tF4", "", wx.ITEM_NORMAL) 169 self.settingsMenu.AppendItem(self.servicesSettingsMenu) 170 self.mainMenuBar.Append(self.settingsMenu, "Settings") 171 self.helpMenu = wx.Menu() 172 self.helpAboutArcGuiMenu = wx.MenuItem(self.helpMenu, wx.NewId(), "&About ARC Job Submission Tool...\tF1", "", wx.ITEM_NORMAL) 173 self.helpMenu.AppendItem(self.helpAboutArcGuiMenu) 174 self.mainMenuBar.Append(self.helpMenu, "&Help") 175 self.SetMenuBar(self.mainMenuBar) 176 # Menu Bar end 177 self.window_1 = wx.SplitterWindow(self, -1, style=wx.SP_3D|wx.SP_BORDER|wx.SP_LIVE_UPDATE) 178 self.mainPanel = wx.Panel(self.window_1, -1) 179 self.noteBook = wx.Notebook(self.mainPanel, -1, style=0) 180 self.jobDefinitionPane = wx.Panel(self.noteBook, -1) 181 self.newDefinitionButton = wx.BitmapButton(self.jobDefinitionPane, -1, wx.Bitmap(ARCJOBTOOL_NEW_DEFINITON_IMAGE,wx.BITMAP_TYPE_ANY), style=wx.NO_BORDER) 182 self.editDefinitionButton = wx.BitmapButton(self.jobDefinitionPane, -1, wx.Bitmap(ARCJOBTOOL_EDIT_DEFINITON_IMAGE,wx.BITMAP_TYPE_ANY), style=wx.NO_BORDER) 183 self.submitDefinitionButton = wx.BitmapButton(self.jobDefinitionPane, -1, wx.Bitmap(ARCJOBTOOL_SUBMIT_DEFINITION_IMAGE,wx.BITMAP_TYPE_ANY), style=wx.NO_BORDER) 184 self.openResultsButton = wx.BitmapButton(self.jobDefinitionPane, -1, wx.Bitmap(ARCJOBTOOL_OPEN_RESULTS_IMAGE,wx.BITMAP_TYPE_ANY), style=wx.NO_BORDER) 185 self.deleteDefinitionButton = wx.BitmapButton(self.jobDefinitionPane, -1, wx.Bitmap(ARCJOBTOOL_DELETE_DEFINITION_IMAGE,wx.BITMAP_TYPE_ANY), style=wx.NO_BORDER) 186 self.viewDescriptionButton = wx.BitmapButton(self.jobDefinitionPane, -1, wx.Bitmap(ARCJOBTOOL_VIEW_DESCRIPTION,wx.BITMAP_TYPE_ANY), style=wx.NO_BORDER) 187 self.jobDefinitionList = wx.ListCtrl(self.jobDefinitionPane, -1, style=wx.LC_ICON|wx.LC_ALIGN_LEFT|wx.LC_AUTOARRANGE|wx.LC_SINGLE_SEL|wx.LC_SORT_ASCENDING|wx.LC_HRULES|wx.SUNKEN_BORDER) 188 self.activeJobsPane = wx.Panel(self.noteBook, -1) 189 self.refreshJobsButton = wx.BitmapButton(self.activeJobsPane, -1, wx.Bitmap(ARCJOBTOOL_REFRESH_JOBS_IMAGE,wx.BITMAP_TYPE_ANY), style=wx.NO_BORDER) 190 self.jobPropertiesButton = wx.BitmapButton(self.activeJobsPane, -1, wx.Bitmap(ARCJOBTOOL_JOB_INFO_IMAGE,wx.BITMAP_TYPE_ANY), style=wx.NO_BORDER) 191 self.downloadJobButton = wx.BitmapButton(self.activeJobsPane, -1, wx.Bitmap(ARCJOBTOOL_DOWNLOAD_JOB_IMAGE,wx.BITMAP_TYPE_ANY), style=wx.NO_BORDER) 192 self.downloadAllButton = wx.BitmapButton(self.activeJobsPane, -1, wx.Bitmap(ARCJOBTOOL_DOWNLOAD_ALL_IMAGE,wx.BITMAP_TYPE_ANY), style=wx.NO_BORDER) 193 self.killJobButton = wx.BitmapButton(self.activeJobsPane, -1, wx.Bitmap(ARCJOBTOOL_KILL_JOB_BUTTON,wx.BITMAP_TYPE_ANY), style=wx.NO_BORDER) 194 self.cleanJobButton = wx.BitmapButton(self.activeJobsPane, -1, wx.Bitmap(ARCJOBTOOL_CLEAN_JOB_BUTTON,wx.BITMAP_TYPE_ANY), style=wx.NO_BORDER) 195 self.activeJobList = wx.ListCtrl(self.activeJobsPane, -1, style=wx.LC_REPORT|wx.LC_HRULES|wx.LC_VRULES|wx.SUNKEN_BORDER) 196 self.downloadedJobsPane = wx.Panel(self.noteBook, -1) 197 self.cleanDownloadedJobButton = wx.BitmapButton(self.downloadedJobsPane, -1, wx.Bitmap(ARCJOBTOOL_REMOVE_DOWNLOADED_JOB_IMAGE,wx.BITMAP_TYPE_ANY), style=wx.NO_BORDER) 198 self.downloadedJobList = wx.ListCtrl(self.downloadedJobsPane, -1, style=wx.LC_REPORT|wx.LC_HRULES|wx.LC_VRULES|wx.SUNKEN_BORDER) 199 self.noteBook_pane_4 = wx.Panel(self.noteBook, -1) 200 self.label_3 = wx.StaticText(self.noteBook_pane_4, -1, "URL") 201 self.text_ctrl_1 = wx.TextCtrl(self.noteBook_pane_4, -1, "") 202 self.bitmap_button_1 = wx.BitmapButton(self.noteBook_pane_4, -1, wx.Bitmap(ARCJOBTOOL_OPEN_URL,wx.BITMAP_TYPE_ANY)) 203 self.jobDefinitionList_copy = wx.ListCtrl(self.noteBook_pane_4, -1, style=wx.LC_ICON|wx.LC_ALIGN_LEFT|wx.LC_AUTOARRANGE|wx.LC_SINGLE_SEL|wx.LC_SORT_ASCENDING|wx.LC_HRULES|wx.SUNKEN_BORDER) 204 self.panel_1 = wx.Panel(self.window_1, -1) 205 self.logOutputLabel = wx.StaticText(self.panel_1, -1, "Output") 206 self.logOutputText = wx.TextCtrl(self.panel_1, -1, "", style=wx.TE_MULTILINE|wx.HSCROLL|wx.TE_RICH) 207 self.static_line_3 = wx.StaticLine(self, -1) 208 self.statusText = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY) 209 self.statusGauge = wx.Gauge(self, -1, 100) 210 self.killThreadsButton = wx.BitmapButton(self, -1, wx.Bitmap(ARCJOBTOOL_KILL_THREADS_BUTTON,wx.BITMAP_TYPE_ANY), style=wx.NO_BORDER) 211 212 self.__set_properties() 213 self.__do_layout() 214 215 self.Bind(wx.EVT_MENU, self.onChangeWorkingDir, self.changeWorkingDirMenu) 216 self.Bind(wx.EVT_MENU, self.onFileExit, self.fileExitMenu) 217 self.Bind(wx.EVT_MENU, self.onCertProxyInfo, self.sessionCertProxyInfoMenu) 218 self.Bind(wx.EVT_MENU, self.onCreateProxyCert, self.sessionCreateProxyMenu) 219 self.Bind(wx.EVT_MENU, self.onNewJobDefinition, self.newJobDefinitionMenu) 220 self.Bind(wx.EVT_MENU, self.onOpenJobDefinition, self.modifyDefinitionMenu) 221 self.Bind(wx.EVT_MENU, self.onSubmitJobDefinition, self.submitJobDefinitionMenu) 222 self.Bind(wx.EVT_MENU, self.onSubmitMissing, self.submittMissingMenu) 223 self.Bind(wx.EVT_MENU, self.onViewOutputFiles, self.viewResultsMenu) 224 self.Bind(wx.EVT_MENU, self.onCleanResults, self.cleanResultsMenu) 225 self.Bind(wx.EVT_MENU, self.onDeleteJobDefinition, self.deleteJobDefinitionMenu) 226 self.Bind(wx.EVT_MENU, self.onShowXrslDescription, self.viewXRSLMenu) 227 self.Bind(wx.EVT_MENU, self.onFind, self.refreshStatusMenu) 228 self.Bind(wx.EVT_MENU, self.onRetrieve, self.donwloadSelectedMenu) 229 self.Bind(wx.EVT_MENU, self.onDownloadToDefinition, self.downloadToDefinitionMenu) 230 self.Bind(wx.EVT_MENU, self.onKill, self.killSelectedMenu) 231 self.Bind(wx.EVT_MENU, self.onClean, self.cleanSelectedMenu) 232 self.Bind(wx.EVT_MENU, self.onDeleteJobList, self.remoteFromJobListMenu) 233 self.Bind(wx.EVT_MENU, self.onClientSettings, self.clientSettingsMenu) 234 self.Bind(wx.EVT_MENU, self.onServicesSettings, self.servicesSettingsMenu) 235 self.Bind(wx.EVT_MENU, self.onAbout, self.helpAboutArcGuiMenu) 236 self.Bind(wx.EVT_BUTTON, self.onNewJobDefinition, self.newDefinitionButton) 237 self.Bind(wx.EVT_BUTTON, self.onOpenJobDefinition, self.editDefinitionButton) 238 self.Bind(wx.EVT_BUTTON, self.onSubmitJobDefinition, self.submitDefinitionButton) 239 self.Bind(wx.EVT_BUTTON, self.onViewOutputFiles, self.openResultsButton) 240 self.Bind(wx.EVT_BUTTON, self.onDeleteJobDefinition, self.deleteDefinitionButton) 241 self.Bind(wx.EVT_BUTTON, self.onShowXrslDescription, self.viewDescriptionButton) 242 self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.onJobDefinitionDeselected, self.jobDefinitionList) 243 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onJobDefinitionSelected, self.jobDefinitionList) 244 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onJobDefinitionActivated, self.jobDefinitionList) 245 self.Bind(wx.EVT_LIST_KEY_DOWN, self.onJobDefinitionKeyDown, self.jobDefinitionList) 246 self.Bind(wx.EVT_BUTTON, self.onFind, self.refreshJobsButton) 247 self.Bind(wx.EVT_BUTTON, self.onJobProperties, self.jobPropertiesButton) 248 self.Bind(wx.EVT_BUTTON, self.onRetrieve, self.downloadJobButton) 249 self.Bind(wx.EVT_BUTTON, self.onDownloadToDefinition, self.downloadAllButton) 250 self.Bind(wx.EVT_BUTTON, self.onKill, self.killJobButton) 251 self.Bind(wx.EVT_BUTTON, self.onClean, self.cleanJobButton) 252 self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.onActiveJobListDeselected, self.activeJobList) 253 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onActiveJobListSelected, self.activeJobList) 254 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onActiveJobListActivated, self.activeJobList) 255 self.Bind(wx.EVT_LIST_COL_CLICK, self.onActiveJobColClick, self.activeJobList) 256 self.Bind(wx.EVT_BUTTON, self.onCleanDownloadedJobs, self.cleanDownloadedJobButton) 257 self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.onJobDefinitionDeselected, self.jobDefinitionList_copy) 258 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onJobDefinitionSelected, self.jobDefinitionList_copy) 259 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onJobDefinitionActivated, self.jobDefinitionList_copy) 260 self.Bind(wx.EVT_LIST_KEY_DOWN, self.onJobDefinitionKeyDown, self.jobDefinitionList_copy) 261 self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.onNoteBookPageChanged, self.noteBook) 262 self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.onNoteBookPageChanging, self.noteBook) 263 self.Bind(wx.EVT_BUTTON, self.onKillThreads, self.killThreadsButton)264 # end wxGlade 265267 # begin wxGlade: ArcJobToolWindow.__set_properties 268 self.SetTitle("ARC Job Submission Tool - 0.3.0") 269 self.SetSize((709, 684)) 270 self.newDefinitionButton.SetToolTipString("New job definition") 271 self.newDefinitionButton.SetSize(self.newDefinitionButton.GetBestSize()) 272 self.editDefinitionButton.SetToolTipString("Edit job definition") 273 self.editDefinitionButton.SetSize(self.editDefinitionButton.GetBestSize()) 274 self.submitDefinitionButton.SetToolTipString("Submit job definition") 275 self.submitDefinitionButton.SetSize(self.submitDefinitionButton.GetBestSize()) 276 self.openResultsButton.SetToolTipString("View files") 277 self.openResultsButton.SetSize(self.openResultsButton.GetBestSize()) 278 self.deleteDefinitionButton.SetToolTipString("Delete job definition") 279 self.deleteDefinitionButton.SetSize(self.deleteDefinitionButton.GetBestSize()) 280 self.viewDescriptionButton.SetToolTipString("Preview XRSL") 281 self.viewDescriptionButton.SetSize(self.viewDescriptionButton.GetBestSize()) 282 self.refreshJobsButton.SetToolTipString("Refresh status") 283 self.refreshJobsButton.SetSize(self.refreshJobsButton.GetBestSize()) 284 self.jobPropertiesButton.SetSize(self.jobPropertiesButton.GetBestSize()) 285 self.downloadJobButton.SetToolTipString("Download selected") 286 self.downloadJobButton.SetSize(self.downloadJobButton.GetBestSize()) 287 self.downloadAllButton.SetToolTipString("Download all") 288 self.downloadAllButton.SetSize(self.downloadAllButton.GetBestSize()) 289 self.killJobButton.SetToolTipString("Kill jobb") 290 self.killJobButton.SetSize(self.killJobButton.GetBestSize()) 291 self.cleanJobButton.SetToolTipString("Clean job") 292 self.cleanJobButton.SetSize(self.cleanJobButton.GetBestSize()) 293 self.cleanDownloadedJobButton.SetToolTipString("Clear download history") 294 self.cleanDownloadedJobButton.SetSize(self.cleanDownloadedJobButton.GetBestSize()) 295 self.bitmap_button_1.SetSize(self.bitmap_button_1.GetBestSize()) 296 self.noteBook_pane_4.Hide() 297 self.logOutputText.SetFont(wx.Font(9, wx.MODERN, wx.NORMAL, wx.NORMAL, 0, "")) 298 self.statusText.SetToolTipString("Current processing operation") 299 self.statusGauge.SetMinSize((-1, 25)) 300 self.statusGauge.SetToolTipString("Progress status indicator") 301 self.killThreadsButton.SetToolTipString("Kill all running threads") 302 self.killThreadsButton.SetSize(self.killThreadsButton.GetBestSize())303 # end wxGlade 304306 # begin wxGlade: ArcJobToolWindow.__do_layout 307 mainSizer = wx.BoxSizer(wx.VERTICAL) 308 statusPaneSizer = wx.BoxSizer(wx.HORIZONTAL) 309 sizer_1_copy = wx.BoxSizer(wx.VERTICAL) 310 panelSizer = wx.BoxSizer(wx.VERTICAL) 311 sizer_3_copy_copy_copy = wx.BoxSizer(wx.VERTICAL) 312 sizer_33 = wx.BoxSizer(wx.HORIZONTAL) 313 downloadedJobPaneVSizer = wx.BoxSizer(wx.VERTICAL) 314 downloadedJobPaneHSizer = wx.BoxSizer(wx.HORIZONTAL) 315 jobPaneVSizer = wx.BoxSizer(wx.VERTICAL) 316 jobPaneHSizer = wx.BoxSizer(wx.HORIZONTAL) 317 sizer_3_copy_copy = wx.BoxSizer(wx.VERTICAL) 318 sizer_9_copy_copy = wx.BoxSizer(wx.HORIZONTAL) 319 sizer_9_copy_copy.Add(self.newDefinitionButton, 0, 0, 0) 320 sizer_9_copy_copy.Add(self.editDefinitionButton, 0, 0, 0) 321 sizer_9_copy_copy.Add(self.submitDefinitionButton, 0, 0, 0) 322 sizer_9_copy_copy.Add(self.openResultsButton, 0, 0, 0) 323 sizer_9_copy_copy.Add(self.deleteDefinitionButton, 0, 0, 0) 324 sizer_9_copy_copy.Add(self.viewDescriptionButton, 0, 0, 0) 325 sizer_3_copy_copy.Add(sizer_9_copy_copy, 0, wx.ALL, 3) 326 sizer_3_copy_copy.Add(self.jobDefinitionList, 1, wx.ALL|wx.EXPAND, 4) 327 self.jobDefinitionPane.SetSizer(sizer_3_copy_copy) 328 jobPaneHSizer.Add(self.refreshJobsButton, 0, 0, 0) 329 jobPaneHSizer.Add(self.jobPropertiesButton, 0, 0, 0) 330 jobPaneHSizer.Add(self.downloadJobButton, 0, 0, 0) 331 jobPaneHSizer.Add(self.downloadAllButton, 0, 0, 0) 332 jobPaneHSizer.Add(self.killJobButton, 0, 0, 0) 333 jobPaneHSizer.Add(self.cleanJobButton, 0, 0, 0) 334 jobPaneVSizer.Add(jobPaneHSizer, 0, wx.ALL|wx.EXPAND, 4) 335 jobPaneVSizer.Add(self.activeJobList, 1, wx.ALL|wx.EXPAND, 4) 336 self.activeJobsPane.SetSizer(jobPaneVSizer) 337 downloadedJobPaneHSizer.Add(self.cleanDownloadedJobButton, 0, 0, 0) 338 downloadedJobPaneVSizer.Add(downloadedJobPaneHSizer, 0, wx.ALL|wx.EXPAND, 4) 339 downloadedJobPaneVSizer.Add(self.downloadedJobList, 1, wx.ALL|wx.EXPAND, 4) 340 self.downloadedJobsPane.SetSizer(downloadedJobPaneVSizer) 341 sizer_33.Add(self.label_3, 0, wx.LEFT|wx.RIGHT|wx.TOP|wx.ALIGN_CENTER_VERTICAL, 4) 342 sizer_33.Add(self.text_ctrl_1, 1, wx.RIGHT|wx.TOP|wx.EXPAND, 4) 343 sizer_33.Add(self.bitmap_button_1, 0, wx.TOP, 4) 344 sizer_3_copy_copy_copy.Add(sizer_33, 0, wx.RIGHT|wx.EXPAND, 4) 345 sizer_3_copy_copy_copy.Add(self.jobDefinitionList_copy, 1, wx.ALL|wx.EXPAND, 4) 346 self.noteBook_pane_4.SetSizer(sizer_3_copy_copy_copy) 347 self.noteBook.AddPage(self.jobDefinitionPane, "Job definitions") 348 self.noteBook.AddPage(self.activeJobsPane, "Active jobs") 349 self.noteBook.AddPage(self.downloadedJobsPane, "Downloaded jobs") 350 self.noteBook.AddPage(self.noteBook_pane_4, "Storage") 351 panelSizer.Add(self.noteBook, 3, wx.ALL|wx.EXPAND, 5) 352 self.mainPanel.SetSizer(panelSizer) 353 sizer_1_copy.Add(self.logOutputLabel, 0, wx.LEFT|wx.TOP|wx.BOTTOM, 5) 354 sizer_1_copy.Add(self.logOutputText, 1, wx.LEFT|wx.RIGHT|wx.EXPAND, 5) 355 self.panel_1.SetSizer(sizer_1_copy) 356 self.window_1.SplitHorizontally(self.mainPanel, self.panel_1, 462) 357 mainSizer.Add(self.window_1, 1, wx.EXPAND, 0) 358 mainSizer.Add(self.static_line_3, 0, wx.TOP|wx.EXPAND, 6) 359 statusPaneSizer.Add(self.statusText, 1, wx.ALL, 1) 360 statusPaneSizer.Add(self.statusGauge, 1, wx.ALL, 2) 361 statusPaneSizer.Add(self.killThreadsButton, 0, 0, 0) 362 mainSizer.Add(statusPaneSizer, 0, wx.ALL|wx.EXPAND, 3) 363 self.SetSizer(mainSizer) 364 self.Layout() 365 self.Centre() 366 # end wxGlade 367 368 # Call custom intialisation routine 369 370 self.__initApp()371373 """ 374 Check user setup 375 376 Checks for existing configuration files, certificate directories. 377 If it is the first time configuration files are created. If a proxy 378 certificate not available or expired one is created. 379 """ 380 381 # Check for arc configuration directory 382 383 if not os.path.exists(os.path.expanduser("~/.arc")): 384 os.mkdir(os.path.expanduser("~/.arc")) 385 386 # Check for client configuration file 387 388 jobListFilename = os.path.expanduser("~/.arc/jobs.xml") 389 userConfigFilename = os.path.expanduser("~/.arc/arcjobtool.conf") 390 391 # Check for existing client.conf 392 393 self.userConfig = arc.UserConfig(userConfigFilename, jobListFilename) 394 self.arcGuiConfig = ArcGuiConfig(self.userConfig, None) 395 self.arcGuiConfig.filename = userConfigFilename 396 397 if os.path.exists(self.arcGuiConfig.filename): 398 self.arcGuiConfig.read() 399 else: 400 401 # No configuration file found. Create a default config 402 403 wx.MessageBox("No ArcGUI configuration found. Please review your settings.") 404 self.arcGuiConfig.create() 405 self.userConfig = arc.UserConfig(userConfigFilename, jobListFilename) 406 407 # Let the user review the default settings 408 409 dialog = ClientSettingsDialog(self) 410 dialog.arcGuiConfig = self.arcGuiConfig 411 dialog.ShowModal() 412 dialog.Destroy() 413 414 self.caCertificatePath = self.userConfig.CACertificatePath() 415 self.userCertFilename = self.userConfig.CertificatePath() 416 self.userKeyFilename = self.userConfig.KeyPath() 417 self.proxyFilename = self.userConfig.ProxyPath() 418 419 self.historyFile = os.path.expanduser("~/.arc/download_history.log") 420 421 if self.userConfig.CredentialsFound(): 422 self.logInfoMsg("Found credentials") 423 else: 424 self.logWarningMsg("Credentials not found") 425 426 if not os.path.exists(self.proxyFilename): 427 428 # Create proxy certificate if not found. 429 430 wx.MessageBox("No proxy file found.") 431 userAuth = GuiUserAuthentication(self.userConfig) 432 userAuth.parentWindow = self 433 authOk = userAuth.createLocalProxy() 434 if not authOk: 435 if userAuth.errorMessage!="": 436 wx.MessageBox(userAuth.errorMessage) 437 return False 438 else: 439 return True 440 else: 441 442 # Check proxy expiration 443 444 proxyCred = arc.Credential(self.proxyFilename, "", "", "") 445 446 if False: 447 448 # Test proxy expiration. 449 450 monthPeriod = arc.Period("4",arc.PeriodWeeks) 451 currTime = arc.Time() + monthPeriod 452 else: 453 currTime = arc.Time() 454 455 endTime = proxyCred.GetEndTime() 456 457 # If the existing proxyCert has expired we create a new one. 458 459 if endTime<currTime: 460 wx.MessageBox("Proxy has expired.") 461 userAuth = GuiUserAuthentication(self.userConfig) 462 userAuth.parentWindow = self 463 authOk = userAuth.createLocalProxy() 464 if not authOk: 465 if userAuth.errorMessage!="": 466 wx.MessageBox(userAuth.errorMessage) 467 return False 468 else: 469 return True 470 return True471 477479 """ 480 Wrapper function for sending info messages to log. 481 """ 482 self.logMsg(arc.INFO, msg)483485 """ 486 Wrapper function for sending debug messages to log. 487 """ 488 self.logMsg(arc.DEBUG, msg)489491 """ 492 Wrapper function for sending warning messages to log. 493 """ 494 self.logMsg(arc.WARNING, msg)495497 """ 498 Wrapper function for sending error messages to log. 499 """ 500 self.logMsg(arc.ERROR, msg)501503 """ 504 Sets up logging for arcjobtool. 505 """ 506 logcout = arc.LogStream(self) 507 arc.Logger_getRootLogger().removeDestinations() 508 arc.Logger_getRootLogger().addDestination(logcout) 509 510 self.logger = arc.Logger(arc.Logger_getRootLogger(), "ArcJobToolWindow")511513 514 self.__sortKey = "" 515 self.__outputLine = "" 516 self.__selectedJobDefinition = [] 517 self.__selectedActiveJobs = [] 518 self.__jobDefinitions = {} 519 520 self.__progressCounter = 0 521 522 os.chdir(workingDir) 523 self.__definitionDir = os.getcwd() 524 525 self.logInfoMsg("Initialise job status grid.") 526 527 self.__clearGrid() 528 self.__updateGrid() 529 530 # Initialise job list 531 532 self.logInfoMsg("Initialise job definition icon view.") 533 534 self.__setupDefinitionDir() 535 self.__setupDefinitionList() 536 self.__updateJobDefinitionList() 537 self.__updateDownloadList()538540 """ 541 Application initialisation 542 """ 543 544 self.__setupLogging() 545 self.logLevel = arc.INFO 546 547 # Setup user configuration. If no configuration found it will 548 # be created when the file is saved with SaveToFile 549 550 self.logInfoMsg("Initiating arcjobtool.") 551 552 # Setup instance variables 553 554 self.__progressDialog = None 555 self.__currentSelection = [] 556 self.__sortKey = "" 557 self.__outputLine = "" 558 self.__selectedJobDefinition = [] 559 self.__selectedActiveJobs = [] 560 self.__jobDefinitions = {} 561 562 self.__progressCounter = 0 563 564 self.__definitionDir = os.getcwd() 565 566 # Check setup 567 568 if not self.checkSetup(): 569 self.Destroy() 570 sys.exit(-1) 571 572 sys.stdout = self 573 574 # Show splash window 575 576 if self.arcGuiConfig.showSplash: 577 arcSplash = ArcSplash(self) 578 arcSplash.Show(True) 579 580 # Create an ArcClient instance 581 582 self.logInfoMsg("Creating ArcClient instance.") 583 584 self.__arcClient = ArcClient(self.userConfig, sys.stdout) 585 self.__arcClient.downloadDir = os.path.abspath(".") 586 self.__arcClient.brokerName = self.arcGuiConfig.brokerName 587 588 self.arcGuiConfig.arcClient = self.__arcClient 589 590 self.__certInfoOpen = False 591 592 # Initialise special controls 593 594 self.statusGauge.Hide() 595 self.statusText.Disable() 596 self.killThreadsButton.Disable() 597 598 # Initialise menus 599 600 self.mainMenuBar.EnableTop(2, True) 601 self.mainMenuBar.EnableTop(3, False) 602 603 # Initialise timer for progress update 604 605 self.logInfoMsg("Initialise progress timer.") 606 607 self.__timerID = 100 608 self.__progressTimer = wx.Timer(self, self.__timerID) # message will be sent to the panel 609 wx.EVT_TIMER(self, self.__timerID, self.onProgressTimer) 610 611 self.logInfoMsg("Initialise status update timer.") 612 613 self.__statusTimerID = 101 614 self.__statusTimer = wx.Timer(self, self.__statusTimerID) 615 wx.EVT_TIMER(self, self.__statusTimerID, self.onStatusTimer) 616 617 self.logInfoMsg("Initialise download update timer.") 618 619 self.__downloadTimerID = 102 620 self.__downloadTimer = wx.Timer(self, self.__downloadTimerID) 621 wx.EVT_TIMER(self, self.__downloadTimerID, self.onDownloadTimer) 622 623 # Events for non-blocking arc handling 624 625 self.logInfoMsg("Setting up events bindings.") 626 627 self.Bind(EVT_UPDATE_STATUS_DONE, self.onUpdateStatusDone) 628 self.Bind(EVT_RETRIEVE_JOBS_DONE, self.onRetrieveJobsDone) 629 self.Bind(EVT_CLEAN_JOBS_DONE, self.onCleanJobsDone) 630 self.Bind(EVT_KILL_JOBS_DONE, self.onKillJobsDone) 631 self.Bind(EVT_PROGRESS_UPDATE, self.onProgressUpdate) 632 self.Bind(EVT_LOG_UPDATE, self.onLogUpdate) 633 self.Bind(EVT_SUBMIT_JOB_DONE, self.onSubmitJobDone) 634 self.Bind(EVT_CERTINFO_CLOSE, self.onCertInfoClose) 635 self.Bind(wx.EVT_CLOSE, self.onWindowClose) 636 637 # Initialise grid 638 639 self.logInfoMsg("Initialise job status grid.") 640 641 self.__clearGrid() 642 self.__updateGrid() 643 644 # Initialise job list 645 646 self.logInfoMsg("Initialise job definition icon view.") 647 648 self.__setupDefinitionDir() 649 self.__setupDefinitionList() 650 self.__updateJobDefinitionList() 651 self.__updateDownloadList() 652 653 self.logInfoMsg("Sending of first status update thread.") 654 655 self.__updateStatusThread = UpdateStatusThread(self, self.__arcClient) 656 self.__updateStatusThread.logger = self.logger 657 self.__updateStatusThread.start() 658 self.startProgress() 659 660 self.__retrieveJobsThread = RetrieveJobsThread(self, self.__arcClient, [], "", self.historyFile) 661 self.__retrieveJobsThread.logger = self.logger 662 663 if self.arcGuiConfig.automaticDownload: 664 self.logInfoMsg("Download timer started.") 665 self.__downloadTimer.Stop() 666 self.__downloadTimer.Start(self.arcGuiConfig.automaticDownloadInterval) 667 else: 668 self.logInfoMsg("Download timer disabled.") 669 self.__downloadTimer.Stop() 670 671 if self.arcGuiConfig.automaticUpdate: 672 self.logInfoMsg("Update timer started.") 673 self.__statusTimer.Stop() 674 self.__statusTimer.Start(self.arcGuiConfig.automaticUpdateInterval) 675 else: 676 self.logInfoMsg("Update timer disabled.") 677 self.__statusTimer.Stop()678680 """ 681 Start progress counter. 682 683 Increases a counter to be able to stop progress update when 684 no threads are running. The function will show the status text 685 and satus gauge controls. 686 """ 687 if self.__progressCounter == 0: 688 self.__progressTimer.Start(100) 689 self.statusText.Enable() 690 self.statusGauge.Show() 691 self.statusGauge.GetParent().GetSizer().Layout() 692 self.killThreadsButton.Enable() 693 694 self.__progressCounter += 1695697 """ 698 Releases a reference to a progress updating thread. 699 700 When the progress counter i 0 the progress timer is stopped and 701 the status and gauge controls are hidden. 702 """ 703 if self.__progressCounter>0: 704 self.__progressCounter -= 1 705 706 if self.__progressCounter == 0: 707 self.__progressTimer.Stop() 708 self.statusText.SetValue("") 709 self.statusGauge.Hide() 710 self.statusText.Disable() 711 self.killThreadsButton.Disable()712714 """ 715 Received the log stream from ARC. 716 717 Sends an event to the Window, so that it can 718 be updated correctly. 719 """ 720 evt = UpdateLogEvent(EVT_LOG_UPDATE_TYPE, -1, string) 721 wx.PostEvent(self, evt)722 728 734736 """ 737 Update grid with job information. 738 """ 739 self.__clearGrid() 740 741 self.activeJobList.InsertColumn(0, "JobID") 742 self.activeJobList.InsertColumn(1, "Name") 743 self.activeJobList.InsertColumn(2, "State") 744 self.activeJobList.InsertColumn(3, "Error") 745 #self.activeJobList.InsertColumn(4, "ExitCode") 746 747 sortedKeys = self.__arcClient.sortKeysBy(self.__sortKey) 748 749 row = 0 750 751 for jobId in sortedKeys: 752 self.activeJobList.InsertStringItem(row,jobId) 753 if self.__arcClient.jobDict[jobId].has_key("Name"): 754 self.activeJobList.SetStringItem(row,1,self.__arcClient.jobDict[jobId]["Name"]) 755 else: 756 self.activeJobList.SetStringItem(row,1,"Unknown") 757 758 if self.__arcClient.jobDict[jobId].has_key("State"): 759 self.activeJobList.SetStringItem(row,2,self.__arcClient.jobDict[jobId]["State"]) 760 else: 761 self.activeJobList.SetStringItem(row,2,"Unknown") 762 763 if self.__arcClient.jobDict[jobId].has_key("Error"): 764 self.activeJobList.SetStringItem(row,3,str(self.__arcClient.jobDict[jobId]["Error"])) 765 else: 766 self.activeJobList.SetStringItem(row,3,"") 767 768 #if self.__arcClient.jobDict[jobId].has_key("ExitCode"): 769 # self.activeJobList.SetStringItem(row,4,str(self.__arcClient.jobDict[jobId]["ExitCode"])) 770 #else: 771 # self.activeJobList.SetStringItem(row,4,"") 772 773 if self.__arcClient.jobDict[jobId].has_key("State"): 774 if self.__arcClient.jobDict[jobId]["State"] == "FINISHED": 775 self.activeJobList.SetItemBackgroundColour(row, wx.Colour(192, 255, 192)) 776 elif self.__arcClient.jobDict[jobId]["State"] == "FAILED": 777 self.activeJobList.SetItemBackgroundColour(row, wx.Colour(255, 192, 192)) 778 else: 779 self.activeJobList.SetItemBackgroundColour(row, wx.Colour(255, 255, 192)) 780 781 row += 1 782 783 self.activeJobList.SetColumnWidth(0, wx.LIST_AUTOSIZE) 784 self.activeJobList.SetColumnWidth(1, wx.LIST_AUTOSIZE) 785 self.activeJobList.SetColumnWidth(2, wx.LIST_AUTOSIZE) 786 self.activeJobList.SetColumnWidth(3, wx.LIST_AUTOSIZE)787789 """ 790 Update status for grid jobs. 791 """ 792 793 if not self.__updateStatusThread.isAlive(): 794 self.__updateStatusThread = UpdateStatusThread(self, self.__arcClient) 795 self.__updateStatusThread.logger = self.logger 796 self.__updateStatusThread.start() 797 self.startProgress()798800 """ 801 Setup definitions dir $HOME/.arcgui 802 """ 803 804 # Check if definition dir exists. If not 805 # Create it. 806 807 if not os.path.exists(self.__definitionDir): 808 os.mkdir(self.__definitionDir)809811 """ 812 Sets up the job definition list control. 813 814 Loads items and images into the list control. 815 """ 816 self.__pluginMgr = PluginManager() 817 818 imageList = wx.ImageList(48,48) 819 820 if os.environ.has_key("ARCJOBTOOL_SHARE"): 821 arcGuiImagePath = os.path.join(os.environ["ARCJOBTOOL_SHARE"], "images") 822 823 bitmapFilename = os.path.join(arcGuiImagePath, "archive.png") 824 imageList.Add(wx.Bitmap(bitmapFilename, wx.BITMAP_TYPE_ANY)) 825 826 self.jobDefinitionList.AssignImageList(imageList, wx.IMAGE_LIST_NORMAL)827829 """ 830 Updates the job definition list control. 831 """ 832 833 dirList = os.listdir(self.__definitionDir) 834 835 self.jobDefinitionList.ClearAll() 836 self.__jobDefinitions = {} 837 838 for dirEntry in dirList: 839 fullPath = os.path.join(self.__definitionDir, dirEntry) 840 if os.path.isdir(fullPath): 841 if fullPath.find(".arcdef")!=-1: 842 self.__jobDefinitions[dirEntry.split(".arcdef")[0]] = fullPath 843 self.jobDefinitionList.InsertImageStringItem(0, dirEntry.split(".arcdef")[0], 0)844846 """ 847 Deletes the selected job definition from disk. 848 """ 849 850 if len(self.__selectedJobDefinition)!=0: 851 if wx.MessageBox("Delete job definition", "ArcGui", style=wx.YES_NO)==wx.YES: 852 definitionName = self.__selectedJobDefinition[1]+".arcdef" 853 fullPath = os.path.join(self.__definitionDir, definitionName) 854 if os.path.exists(fullPath): 855 shutil.rmtree(fullPath) 856 self.__updateJobDefinitionList() 857 else: 858 wx.MessageBox("Please select a jobdefinition.")859861 """ 862 Open selected job definition. 863 """ 864 if len(self.__selectedJobDefinition)!=0: 865 866 # Determine full path of job definition dir 867 868 definitionName = self.__selectedJobDefinition[1]+".arcdef" 869 fullPath = os.path.join(self.__definitionDir, definitionName) 870 871 # Instantiate plugin from work dir using plugin manager 872 873 plugin = self.__pluginMgr.pluginFromWorkDir(fullPath) 874 875 if plugin==None: 876 wx.MessageBox("Failed to load plugin for job definition.") 877 return 878 879 # Load plugin data from job definition 880 881 plugin.onLoad(fullPath) 882 883 # Show plugin user interface 884 885 plugin.onEdit() 886 887 if plugin.onNeedSave(): 888 self.logInfoMsg("Saving plugin data.") 889 plugin.onSave(fullPath) 890 891 plugin.onClean() 892 plugin.onSetup() 893 else: 894 wx.MessageBox("Please select a jobdefinition.")895897 """ 898 Submit selected job definition. 899 """ 900 if len(self.__selectedJobDefinition)!=0: 901 902 # Determine full path of job definition dir 903 904 definitionName = self.__selectedJobDefinition[1]+".arcdef" 905 fullPath = os.path.join(self.__definitionDir, definitionName) 906 907 # Instantiate plugin from work dir using plugin manager 908 909 plugin = self.__pluginMgr.pluginFromWorkDir(fullPath) 910 911 if plugin==None: 912 wx.MessageBox("Failed to load plugin for job definition.") 913 return 914 915 # Load plugin data from job definition 916 917 plugin.onLoad(fullPath) 918 919 # Get jobList 920 921 jobList = plugin.task.jobList 922 923 #for job in jobList: 924 # job.Print(True) 925 # print job.UnParse(format="XRSL") 926 927 worker = SubmitJobThread(self, self.__arcClient, jobList) 928 worker.logger = self.logger 929 worker.start() 930 self.startProgress() 931 932 else: 933 wx.MessageBox("Please select a jobdefinition.")934936 """ 937 Submit jobs with missing results. 938 """ 939 if len(self.__selectedJobDefinition)!=0: 940 941 # Determine full path of job definition dir 942 943 definitionName = self.__selectedJobDefinition[1]+".arcdef" 944 fullPath = os.path.join(self.__definitionDir, definitionName) 945 946 # Instantiate plugin from work dir using plugin manager 947 948 plugin = self.__pluginMgr.pluginFromWorkDir(fullPath) 949 950 if plugin==None: 951 wx.MessageBox("Failed to load plugin for job definition.") 952 return 953 954 # Load plugin data from job definition 955 956 plugin.onLoad(fullPath) 957 958 # Get jobList 959 960 jobList = plugin.task.jobList 961 jobInfoList = plugin.task.jobInfo 962 963 missingJobList = [] 964 965 for job, jobInfo in zip(jobList, jobInfoList): 966 taskName = jobInfo[0] 967 resultDir = os.path.join(fullPath, "results") 968 taskResultDir = os.path.join(resultDir, taskName) 969 970 971 if not os.path.exists(taskResultDir): 972 missingJobList.append(job) 973 974 if len(missingJobList)>0: 975 worker = SubmitJobThread(self, self.__arcClient, missingJobList) 976 worker.logger = self.logger 977 worker.start() 978 self.startProgress() 979 else: 980 wx.MessageBox("Result set is complete. No jobs submitted.") 981 982 else: 983 wx.MessageBox("Please select a jobdefinition.")984 986 """ 987 Open selected job definition 988 """ 989 if len(self.__selectedJobDefinition)!=0: 990 991 # Determine full path of job definition dir 992 993 definitionName = self.__selectedJobDefinition[1]+".arcdef" 994 fullPath = os.path.join(self.__definitionDir, definitionName) 995 996 # Instantiate plugin from work dir using plugin manager 997 998 plugin = self.__pluginMgr.pluginFromWorkDir(fullPath) 999 1000 if plugin==None: 1001 wx.MessageBox("Failed to load plugin for job definition.") 1002 return 1003 1004 # Load plugin data from job definition 1005 1006 plugin.onLoad(fullPath) 1007 1008 # Get jobList 1009 1010 jobList = plugin.task.jobList 1011 1012 wx.MessageBox(jobList[0].UnParse("xrsl")) 1013 1014 1015 else: 1016 wx.MessageBox("Please select a jobdefinition.")1058 """ 1059 Download all finished jobs to specified. 1060 """ 1061 1062 # Make sure there are jobs selected 1063 1064 if len(self.__selectedActiveJobs)==0: 1065 wx.MessageBox("Please select a job.") 1066 return 1067 1068 # Don't do anything if there is a running retrieval thread. 1069 1070 if self.__retrieveJobsThread.isAlive(): 1071 wx.MessageBox("Job download already in progress.") 1072 return 1073 1074 # Create time stamp for downloaded files. 1075 1076 now = datetime.now() 1077 downloadStamp = now.strftime("download_%Y_%m_%d_%H_%M") 1078 1079 currentDir = os.getcwd() 1080 1081 jobIds = [] 1082 jobDownloadDirs = [] 1083 1084 for selection in self.__selectedActiveJobs: 1085 1086 jobId = str(self.activeJobList.GetItem(selection,0).GetText()) 1087 selectedItem = str(self.activeJobList.GetItem(selection,1).GetText()) 1088 1089 if selectedItem != "": 1090 if len(selectedItem.split("_"))>2: 1091 jobName = "_".join(selectedItem.split("_")[:-1]) 1092 jobParamId = selectedItem.split("_")[-1] 1093 else: 1094 jobName = selectedItem.split("_")[0] 1095 jobParamId = selectedItem.split("_")[1] 1096 1097 if self.__jobDefinitions.has_key(jobName): 1098 1099 # Create a results directory if not already there 1100 1101 definitionDir = os.path.join(currentDir, self.__jobDefinitions[jobName]) 1102 resultsDir = os.path.join(definitionDir, "results") 1103 if not os.path.isdir(resultsDir): 1104 os.mkdir(resultsDir) 1105 1106 # Create a timestamped directory for this download. 1107 1108 downloadsDir = resultsDir 1109 1110 if False: 1111 downloadsDir = os.path.join(resultsDir, downloadStamp) 1112 if not os.path.isdir(downloadsDir): 1113 os.mkdir(downloadsDir) 1114 1115 downloadDir = os.path.join(downloadsDir, "%s_%s" % (jobName, jobParamId)) 1116 jobIds.append(jobId) 1117 jobDownloadDirs.append(downloadDir) 1118 1119 for jobId, jobDownloadDir in zip(jobIds, jobDownloadDirs): 1120 self.logInfoMsg("Downloading:"+str(jobId)+" to "+str(jobDownloadDir)) 1121 1122 if len(jobDownloadDirs)>0: 1123 if not self.__retrieveJobsThread.isAlive(): 1124 self.__retrieveJobsThread = RetrieveJobsThread(self, self.__arcClient, jobIds, jobDownloadDirs, self.historyFile) 1125 self.__retrieveJobsThread.logger = self.logger 1126 self.__retrieveJobsThread.start() 1127 self.startProgress()11281130 """ 1131 Download all finished jobs to definitions. 1132 """ 1133 1134 # Make sure we are not already downloading jobs. 1135 1136 if self.__retrieveJobsThread.isAlive(): 1137 return 1138 1139 # Create time stamp for downloaded files. 1140 1141 now = datetime.now() 1142 downloadStamp = now.strftime("download_%Y_%m_%d_%H_%M") 1143 1144 currentDir = os.getcwd() 1145 1146 jobIds = [] 1147 jobDownloadDirs = [] 1148 1149 for selection in range(self.activeJobList.GetItemCount()): 1150 1151 jobId = str(self.activeJobList.GetItem(selection,0).GetText()) 1152 selectedItem = str(self.activeJobList.GetItem(selection,1).GetText()) 1153 1154 if selectedItem != "": 1155 if len(selectedItem.split("_"))>2: 1156 jobName = "_".join(selectedItem.split("_")[:-1]) 1157 jobParamId = selectedItem.split("_")[-1] 1158 else: 1159 jobName = selectedItem.split("_")[0] 1160 jobParamId = selectedItem.split("_")[1] 1161 1162 if self.__jobDefinitions.has_key(jobName): 1163 1164 # Create a results directory if not already there 1165 1166 definitionDir = os.path.join(currentDir, self.__jobDefinitions[jobName]) 1167 resultsDir = os.path.join(definitionDir, "results") 1168 if not os.path.isdir(resultsDir): 1169 os.mkdir(resultsDir) 1170 1171 # Create a timestamped directory for this download. 1172 1173 downloadsDir = resultsDir 1174 1175 if False: 1176 downloadsDir = os.path.join(resultsDir, downloadStamp) 1177 if not os.path.isdir(downloadsDir): 1178 os.mkdir(downloadsDir) 1179 1180 downloadDir = os.path.join(downloadsDir, "%s_%s" % (jobName, jobParamId)) 1181 jobIds.append(jobId) 1182 jobDownloadDirs.append(downloadDir) 1183 1184 for jobId, jobDownloadDir in zip(jobIds, jobDownloadDirs): 1185 self.logInfoMsg("Downloading: "+str(jobId)+" to "+str(jobDownloadDir)) 1186 1187 if len(jobDownloadDirs)>0: 1188 if not self.__retrieveJobsThread.isAlive(): 1189 self.__retrieveJobsThread = RetrieveJobsThread(self, self.__arcClient, jobIds, jobDownloadDirs, self.historyFile) 1190 self.__retrieveJobsThread.logger = self.logger 1191 self.__retrieveJobsThread.start() 1192 self.startProgress() 1193 else: 1194 if self.activeJobList.GetItemCount()!=0: 1195 if silent: 1196 self.logWarningMsg("Could not find any job definition to download to. Make sure the working directory is correct.") 1197 else: 1198 wx.MessageBox("Could not find any job definition to download to. Make sure the working directory is correct.") 1199 else: 1200 if silent: 1201 self.logWarningMsg("Nothing to download.") 1202 else: 1203 wx.MessageBox("Nothing to download.")12041206 """ 1207 Update grid with job information. 1208 """ 1209 if not os.path.exists(self.historyFile): 1210 return 1211 1212 self.__clearDownloadList() 1213 1214 self.downloadedJobList.InsertColumn(0, "JobID") 1215 self.downloadedJobList.InsertColumn(1, "Date") 1216 self.downloadedJobList.InsertColumn(2, "Dir") 1217 1218 # Read download history file 1219 1220 historyFile = open(self.historyFile, "r") 1221 lines = historyFile.readlines() 1222 historyFile.close() 1223 1224 # Add lines to history list 1225 1226 history = [] 1227 1228 for line in lines: 1229 history.append(line.split(";")) 1230 1231 row = 0 1232 1233 for download in history: 1234 try: 1235 self.downloadedJobList.InsertStringItem(row,download[0]) 1236 self.downloadedJobList.SetStringItem(row,1,download[1]) 1237 self.downloadedJobList.SetStringItem(row,2,download[2]) 1238 except: 1239 pass 1240 1241 row += 1 1242 1243 self.downloadedJobList.SetColumnWidth(0, wx.LIST_AUTOSIZE) 1244 self.downloadedJobList.SetColumnWidth(1, wx.LIST_AUTOSIZE) 1245 self.downloadedJobList.SetColumnWidth(2, wx.LIST_AUTOSIZE)12461248 """ 1249 Clean download history 1250 """ 1251 1252 if os.path.exists(self.historyFile): 1253 historyFile = open(self.historyFile, "w") 1254 historyFile.close() 1255 1256 self.__updateDownloadList()1257 1259 """ 1260 Event handler: updating job status. 1261 """ 1262 self.__updateStatus() 1263 1265 """ 1266 Event handler: Retrieve selected jobs. 1267 """ 1268 1269 self.__downloadSelectedJobs() 1270 1272 """ 1273 Event handler: Download job directly to job definition directory. 1274 """ 1275 1276 self.__downloadAllJobs(silent = False) 1277 1278 1280 """ 1281 Event handler: Kill selected jobs. 1282 """ 1283 if len(self.__selectedActiveJobs)>0: 1284 jobIds = [] 1285 for selection in self.__selectedActiveJobs: 1286 jobIds.append(str(self.activeJobList.GetItem(selection,0).GetText())) 1287 1288 worker = KillJobsThread(self, self.__arcClient, jobIds) 1289 worker.logger = self.logger 1290 worker.start() 1291 self.startProgress() 1292 1294 """ 1295 Event handler: Clean selected jobs. 1296 """ 1297 if len(self.__selectedActiveJobs)>0: 1298 jobIds = [] 1299 for selection in self.__selectedActiveJobs: 1300 jobIds.append(str(self.activeJobList.GetItem(selection,0).GetText())) 1301 1302 worker = CleanJobsThread(self, self.__arcClient, jobIds) 1303 worker.logger = self.logger 1304 worker.start() 1305 self.startProgress() 1306 1308 """ 1309 Event handler: Clean selected jobs. 1310 """ 1311 if len(self.__selectedActiveJobs)>0: 1312 jobIds = [] 1313 for selection in self.__selectedActiveJobs: 1314 jobIds.append(str(self.activeJobList.GetItem(selection,0).GetText())) 1315 1316 worker = CleanJobsThread(self, self.__arcClient, jobIds, force=True) 1317 worker.logger = self.logger 1318 worker.start() 1319 self.startProgress() 1320 1322 """ 1323 Close ArcGUI application 1324 """ 1325 self.Close() 1326 1328 """ 1329 Show certificate information window. 1330 """ 1331 if not self.__certInfoOpen: 1332 window = CertificateInfoWindow(self) 1333 window.userConfig = self.__arcClient.userConfig 1334 window.Show(True) 1335 self.__certInfoOpen = True 1336 1338 """ 1339 Create proxy certificate. 1340 """ 1341 1342 userAuth = GuiUserAuthentication(self.userConfig) 1343 userAuth.parentWindow = self 1344 authOk = userAuth.createLocalProxy() 1345 if not authOk: 1346 if userAuth.errorMessage!="": 1347 wx.MessageBox(userAuth.errorMessage) 1348 1350 """ 1351 Show client settings dialog 1352 """ 1353 dialog = ClientSettingsDialog(self) 1354 dialog.arcGuiConfig = self.arcGuiConfig 1355 dialog.ShowModal() 1356 dialog.Destroy() 1357 1358 if self.arcGuiConfig.automaticDownload: 1359 self.logInfoMsg("Download timer interval changed.") 1360 self.__downloadTimer.Stop() 1361 self.__downloadTimer.Start(self.arcGuiConfig.automaticDownloadInterval) 1362 else: 1363 self.logInfoMsg("Download timer disabled.") 1364 self.__downloadTimer.Stop() 1365 1366 if self.arcGuiConfig.automaticUpdate: 1367 self.logInfoMsg("Status update interval changed.") 1368 self.__statusTimer.Stop() 1369 self.__statusTimer.Start(self.arcGuiConfig.automaticUpdateInterval) 1370 else: 1371 self.logInfoMsg("Status timer disabled.") 1372 self.__statusTimer.Stop() 1373 1375 """ 1376 Show default services dialog 1377 """ 1378 dialog = DefaultServicesDialog(self) 1379 dialog.arcGuiConfig = self.arcGuiConfig 1380 dialog.ShowModal() 1381 dialog.Destroy() 13821384 """ 1385 Handle close notification event from certificate info window. 1386 """ 1387 self.__certInfoOpen = False13881390 """ 1391 Event method handling window close. Ask user if configuration 1392 should be saved. 1393 """ 1394 pass 1395 if wx.MessageBox("Save configuration?", "ARC Job Submission Tool", style=wx.YES_NO)==wx.YES: 1396 self.arcGuiConfig.write() 1397 1398 self.Destroy()13991401 """ 1402 Event method handling timer event for updating 1403 job status. Starts a UpdateStatusThread. 1404 """ 1405 self.logInfoMsg("Update status thread tick.") 1406 self.__updateStatus()14071409 """ 1410 Event method handling timer event for updating 1411 statusGauge when a working thread is active. 1412 """ 1413 self.statusGauge.Pulse() 1414 wx.Yield()14151417 """ 1418 Event method handling timer event for automatic downloading 1419 of jobs. 1420 """ 1421 self.logInfoMsg("Download thread tick.") 1422 self.__downloadAllJobs()14231425 """ 1426 Event method called when job status query is finished. 1427 """ 1428 self.releaseProgress() 1429 self.__updateGrid()14301432 """ 1433 Event method called when all jobs have been downloaded. 1434 """ 1435 self.releaseProgress() 1436 self.statusGauge.SetValue(0) 1437 self.__updateStatus() 1438 self.__updateDownloadList()14391441 """ 1442 Event method called when all jobs have been cleaned. 1443 """ 1444 self.releaseProgress() 1445 self.statusGauge.SetValue(0) 1446 self.__updateStatus()14471449 """ 1450 Event method called when all jobs have been killed. 1451 """ 1452 self.releaseProgress() 1453 self.statusGauge.SetValue(0) 1454 self.__updateStatus()14551457 """ 1458 Event method called when job submit is finished. 1459 """ 1460 self.releaseProgress() 1461 self.statusGauge.SetValue(0) 1462 1463 submitJobCount = 0 1464 1465 for result in event.resultList: 1466 try: 1467 a = result==None # This is a hack '==' does not work in arclib 1468 except: 1469 submitJobCount += 1 1470 1471 failedJobCount = len(event.resultList)-submitJobCount 1472 1473 i = 1 1474 submitReport = "" 1475 submitReport += "%d total jobs. (%d submitted, %d failed submission)." % ( 1476 failedJobCount+submitJobCount, submitJobCount, failedJobCount 1477 ) 1478 1479 wx.MessageBox(submitReport, "Submitted jobs") 1480 1481 self.__updateStatus()14821484 """ 1485 Event method for handling status messages. 1486 """ 1487 1488 self.statusText.SetValue(event.info)14891491 """ 1492 Event method for handling log messages. 1493 """ 1494 1495 # Make sure to collect logs into hole lines 1496 1497 outputLine = "" 1498 warningLine = "" 1499 errorLine = "" 1500 1501 if event.output.find("\n")!=-1: 1502 self.__outputLine += event.output.split("\n")[0] 1503 outputLine = self.__outputLine 1504 self.__outputLine = "" 1505 else: 1506 self.__outputLine += event.output 1507 1508 if outputLine!="": 1509 if outputLine.find("INFO")!=-1: 1510 self.logOutputText.GetDefaultStyle().SetTextColour("blue") 1511 elif outputLine.find("ERROR")!=-1: 1512 self.logOutputText.GetDefaultStyle().SetTextColour("red") 1513 errorLine = outputLine 1514 elif outputLine.find("WARNING")!=-1: 1515 self.logOutputText.GetDefaultStyle().SetTextColour("darkyellow") 1516 warningLine = warningLine 1517 elif outputLine.find("DEBUG")!=-1: 1518 self.logOutputText.GetDefaultStyle().SetTextColour("darkgreen") 1519 1520 self.logOutputText.AppendText(str(outputLine+"\n")) 1521 self.logOutputText.Refresh()1522 1524 """ 1525 Event method handling about menu. Shows splash window. 1526 """ 1527 arcSplash = ArcSplash(self) 1528 arcSplash.Show(True) 1529 1531 """ 1532 Create a new job defintion 1533 1534 Parses installed plugins and asks the users for which job definition 1535 to create. 1536 """ 1537 plugins = self.__pluginMgr.plugins 1538 1539 # Create a plugin name list and an instance dictionary for 1540 # looking up the correct plugin instance from the seletion 1541 1542 pluginNames = [] 1543 pluginInstances = {} 1544 1545 for pluginClass in plugins: 1546 plugin = pluginClass() 1547 pluginNames.append(plugin.shortname) 1548 pluginInstances[plugin.shortname] = plugin 1549 1550 # Ask user for definition plugin 1551 1552 result = singleChoiceDialog(self, "Select job definition", "New job definition", pluginNames) 1553 if result.accepted: 1554 pluginShortname = result.selection 1555 plugin = pluginInstances[pluginShortname] 1556 1557 # Ask for a definition name 1558 1559 result = textEntryDialog(self, "Definition name", "New job definition", "noname") 1560 if result.accepted: 1561 self.logInfoMsg("Creating job definition.") 1562 1563 # Create directory for definition 1564 1565 jobName = result.text 1566 dirName = os.path.join(self.__definitionDir, jobName+".arcdef") 1567 1568 if not os.path.exists(dirName): 1569 1570 # Create job definition directory 1571 1572 os.mkdir(dirName) 1573 1574 # Add a plugin id file in job definition directory 1575 1576 pluginIdFilename = os.path.join(dirName, "plugin.id") 1577 pluginIdFile = open(pluginIdFilename, "w") 1578 pluginIdFile.write(plugin.__class__.__name__) 1579 pluginIdFile.close() 1580 1581 # Ask the plugin to setup the directory 1582 1583 plugin.onSave(dirName) 1584 plugin.onSetup() 1585 1586 # Update job definition list 1587 1588 self.__updateJobDefinitionList() 1589 1590 else: 1591 wx.MessageBox("A job definition with the same name already exists.") 1592 1594 """ 1595 Event method: Submit selected job definition. 1596 """ 1597 self.__submitSelectedJobDefinition() 1598 1600 """ 1601 Event method for opening a job definition. 1602 """ 1603 self.__openSelectedJobDefinition() 1604 1606 """ 1607 Event method for deleting job definition. 1608 """ 1609 self.__deleteSelectedJobDefinition() 1610 1612 """ 1613 Event method for setting current job definition selection. 1614 """ 1615 self.__selectedJobDefinition = [event.GetIndex(), event.GetText()] 1616 1618 """ 1619 Event method for handling keyboard entry in job definition icon view. 1620 """ 1621 if event.GetKeyCode() == wx.WXK_DELETE: 1622 self.__deleteSelectedJobDefinition() 1623 1625 """ 1626 Event method for handling job definition deselection. 1627 """ 1628 self.__selectedJobDefinition = [] 1629 1631 """ 1632 Event method for handling job definition activation. 1633 """ 1634 self.__selectedJobDefinition = [event.GetIndex(), event.GetText()] 1635 self.__openSelectedJobDefinition() 1636 1638 """ 1639 Event method for displaying the xrsl description for the 1640 selected job definition. 1641 """ 1642 self.__showSelectedJobXrsl() 1643 1645 """ 1646 Event method for handling unselecting an item in the active job list. 1647 """ 1648 self.__selectedActiveJobs = [] 1649 1651 """ 1652 Event method for handling selecting an item in the active job list. 1653 """ 1654 self.__selectedActiveJobs.append(event.GetIndex()) 1655 1657 """ 1658 Event method for handling double click in the active job list. 1659 """ 1660 dialog = JobPropertiesDialog(self) 1661 dialog.jobDict = self.__arcClient.jobDict 1662 dialog.jobId = str(self.activeJobList.GetItem(self.__selectedActiveJobs[0],0).GetText()) 1663 dialog.ShowModal() 1664 dialog.Destroy() 1665 1667 """ 1668 Event method for displaying the output files for a job definition. 1669 """ 1670 self.__showSelectedJobFiles() 1671 1673 self.__cleanSelectedResults() 1674 1676 self.__cleanDownloadList() 1677 1679 self.__submitMissing() 1680 1682 """ 1683 Event method implementing a click on the column header for sorting 1684 the active jobs according to column header. 1685 """ 1686 columnItem = self.activeJobList.GetColumn(event.GetColumn()) 1687 fieldName = columnItem.GetText() 1688 self.__sortKey = fieldName 1689 self.__updateGrid() 1690 1692 dlg = wx.DirDialog(None, "Choose working dir:", style=wx.DD_DEFAULT_STYLE | wx.DD_CHANGE_DIR) 1693 if dlg.ShowModal() == wx.ID_OK: 1694 self.__changeWorkingDir(dlg.GetPath()) 1695 dlg.Destroy() 1696 1698 1699 if len(self.__selectedActiveJobs)==0: 1700 wx.MessageBox("Please select an active job.") 1701 return 1702 1703 dialog = JobPropertiesDialog(self) 1704 dialog.jobDict = self.__arcClient.jobDict 1705 dialog.jobId = str(self.activeJobList.GetItem(self.__selectedActiveJobs[0],0).GetText()) 1706 dialog.ShowModal() 1707 dialog.Destroy() 1708 1710 """ 1711 Kill running threads 1712 1713 Only _really_ affects retrieveJobsThread... 1714 """ 1715 if wx.MessageBox("Kill running threads?", "ARC Job Submission Tool", style=wx.YES_NO)==wx.YES: 1716 if self.__updateStatusThread.isAlive(): 1717 self.__updateStatusThread.stop() 1718 1719 if self.__retrieveJobsThread.isAlive(): 1720 self.__retrieveJobsThread.stop() 17211723 """ 1724 Return the current log level. 1725 """ 1726 return arc.Logger_getRootLogger().getThreshold()1727 1733 1734 logLevel = property(getLogLevel, setLogLevel) 1735 1736 1738 """ 1739 Handle tab changing. 1740 """ 1741 if event.GetSelection()==0: 1742 self.mainMenuBar.EnableTop(2, True) 1743 self.mainMenuBar.EnableTop(3, False) 1744 elif event.GetSelection()==1: 1745 self.mainMenuBar.EnableTop(2, False) 1746 self.mainMenuBar.EnableTop(3, True) 1747 else: 1748 self.mainMenuBar.EnableTop(2, False) 1749 self.mainMenuBar.EnableTop(3, False) 1750 1752 event.Skip() 1753 1754 # end of class ArcJobToolWindow 1755
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Jun 14 23:32:37 2010 | http://epydoc.sourceforge.net |