Changeset 772
- Timestamp:
- 06/05/07 20:05:26 (6 years ago)
- Location:
- branch/ggpolo
- Files:
-
- 3 added
- 7 modified
-
config/scheduler-schemas.conf (added)
-
config/umit.conf (modified) (1 diff)
-
setup.py (modified) (4 diffs)
-
share/scripts (added)
-
share/scripts/scheduler_control.py (added)
-
umitCore/BasePaths.py (modified) (2 diffs)
-
umitCore/Paths.py (modified) (5 diffs)
-
umitCore/Scheduler.py (modified) (5 diffs)
-
umitCore/SendMail.py (modified) (1 diff)
-
umitGUI/MainWindow.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branch/ggpolo/config/umit.conf
r625 r772 21 21 config_dir = config 22 22 docs_dir = docs 23 scripts_dir = share/scripts 23 24 24 25 [search] -
branch/ggpolo/setup.py
r762 r772 64 64 sql_dir = os.path.join('share', 'umit', 'sql') 65 65 maemo_dir = os.path.join("maemo") 66 scripts_dir = os.path.join('share', 'umit', 'scripts') 66 67 67 68 dist_config_dir = os.path.join('dist', config_dir) … … 151 152 [os.path.join('config', 'tl.conf')] + 152 153 [os.path.join('config', 'tl_colors_evt_std.conf')] + 154 [os.path.join('config', 'scheduler-schemas.conf')] + 153 155 glob(os.path.join('config', '*.xml'))+ 154 156 glob(os.path.join('config', '*.txt'))), … … 156 158 # UmitDB sql 157 159 (sql_dir, glob(os.path.join("umitDB/sql", '*.sql'))), 160 161 # Scheduler script 162 (scripts_dir, [os.path.join('share', 'scripts', 163 'scheduler_control.py')]), 158 164 159 165 (misc_dir, glob(os.path.join('misc', '*.dmp'))), … … 254 260 parser.set(sec, "pixmaps_dir", os.path.join(self.install_data, 255 261 pixmaps_dir)) 262 parser.set(sec, "scripts_dir", os.path.join(self.install_data, 263 scripts_dir)), 256 264 parser.set(sec, "icons_dir", os.path.join(self.install_data, icons_dir)) 257 265 parser.set(sec, "locale_dir", os.path.join(self.install_data, -
branch/ggpolo/umitCore/BasePaths.py
r748 r772 48 48 umit_opt = 'umit.opt', 49 49 pixmaps_dir = os.path.join('share', 'pixmaps'), 50 scripts_dir = os.path.join('share', 'scripts'), 50 51 i18n_dir = os.path.join('share','locale'), 51 52 i18n_message_file = 'umit.mo', … … 66 67 tl_conf = "tl.conf", 67 68 tl_colors_std = "tl_colors_evt_std.conf", 69 70 # scheduler 71 sched_schemas = "scheduler-schemas.conf", 72 sched_control = "scheduler_control.py", 68 73 69 74 services = "nmap-services", -
branch/ggpolo/umitCore/Paths.py
r748 r772 39 39 "config_dir", 40 40 "misc_dir", 41 "docs_dir"] 41 "docs_dir", 42 "scripts_dir"] 43 44 scripts_files_list = ["sched_control"] 42 45 43 46 config_files_list = ["config_file", … … 52 55 "tl_conf", 53 56 "tl_colors_std", 57 "sched_schemas", 54 58 "umit_version"] 55 59 … … 61 65 misc_files_list = ["services_dump", 62 66 "os_dump", 63 "os_classification"] 67 "os_classification", 68 "sched_running"] 64 69 65 70 other_settings = ["nmap_command_path"] … … 125 130 return return_if_exists(os.path.join(self.config_parser.get(self.paths_section, "misc_dir"), 126 131 base_paths[name])) 127 132 elif name in self.scripts_files_list: 133 return return_if_exists(os.path.join(self.config_parser.get(self.paths_section, "scripts_dir"), base_paths[name])) 134 128 135 try: 129 136 return self.__dict__[name] … … 172 179 copy_config_file("tl.conf", main_dir, user_dir) 173 180 copy_config_file("tl_colors_evt_std.conf", main_dir, user_dir) 181 copy_config_file("scheduler-schemas.conf", main_dir, user_dir) 174 182 copy_config_file("wizard.xml", main_dir, user_dir) 175 183 -
branch/ggpolo/umitCore/Scheduler.py
r770 r772 33 33 from umitCore.SendMail import send_mail 34 34 from umitCore.Paths import Path 35 from umitCore.BasePaths import base_paths 35 36 from umitDB.xmlstore import XMLStore 36 37 … … 39 40 umitdb_ng = Path.umitdb_ng 40 41 except: 41 from umitCore.Paths import Path42 42 Path.set_umit_conf(join(split(__file__)[0], 'config', 'umit.conf')) 43 43 … … 391 391 running_scans = { } 392 392 393 def stop(): 394 """ 395 Clean temp files used by running scans. 396 """ 397 for running, opts in running_scans.items(): 398 print "Cleaning up scan \"%s\"" % opts[3] 399 scan = opts[0] 400 scan.close() # delete temporary files 401 402 403 def run(schema_file=None): 393 def start(schema_file=None): 404 394 """ 405 395 Run scheduler forever. 406 396 """ 407 397 if not schema_file: 408 print "Get file from umitCore.Path" 409 print "Not working yet" 410 sys.exit(0) 398 schema_file = Path.sched_schemas 411 399 412 400 next_time = calc_next_time() 413 401 414 402 s = Scheduler(schema_file) 415 403 416 404 scount = 0 417 405 while 1: # run forever and ever ;) … … 419 407 420 408 if current_time < next_time: 421 time.sleep(next_time - current_time + .1)409 time.sleep(next_time - current_time + .1) 422 410 423 411 # check if time has changed by more than two minutes (clock changes) … … 475 463 scount -= 1 476 464 del running_scans[running] 477 465 478 466 next_time += 60 479 467 468 def stop(): 469 """ 470 Stop Scheduler. 471 """ 472 #try: 473 # os.remove(os.path.split(Path.config_file)[0] + "/schedrunning") 474 #except OSError, e: # scheduler wasnt running probably. 475 # print e 476 # sys.exit(0) 477 478 for running, opts in running_scans.items(): 479 print "Cleaning up scan \"%s\"" % opts[3] 480 scan = opts[0] 481 scan.close() # delete temporary files 480 482 481 483 if __name__ == "__main__": 482 try: 483 run('schema-sample.conf') 484 except KeyboardInterrupt: 485 stop() 486 484 cmds = {"start":start(), 485 "stop":stop() 486 } 487 cmds[sys.argv[1]] -
branch/ggpolo/umitCore/SendMail.py
r770 r772 27 27 28 28 def send_mail(mail_from, mail_to, subject, text, f_attach, server="localhost", 29 authrequired= 0, user='', password=''):29 authrequired=False, user='', password=''): 30 30 """ 31 31 Send email with attachment. -
branch/ggpolo/umitGUI/MainWindow.py
r767 r772 52 52 from umitDB.xmlstore import XMLStore 53 53 from umitInventory.viewer import InvViewer 54 import umitCore.Scheduler as Scheduler 55 import subprocess 54 56 55 57 root = False … … 261 263 ), 262 264 265 # Scan Scheduler 266 ('Scheduler', None, _('_Scheduler'), None), 267 268 ('Sched Status', None, _('Scheduler S_tatus'), 269 None, _("View Scheduler Status"), 270 self._view_schedstat), 271 263 272 # Top Level 264 273 ('Help', None, _('_Help'), None), … … 312 321 <menuitem action='Compare Results'/> 313 322 <menuitem action='Search Scan'/> 323 <menu action='Scheduler'> 324 <menuitem action='Sched Status' /> 325 </menu> 314 326 <menu action='Inventory'> 315 327 <menuitem action='Add Scan Inv'/> … … 353 365 self.ui_manager.insert_action_group(self.main_action_group, 0) 354 366 self.ui_manager.add_ui_from_string(self.default_ui) 367 368 def _view_schedstat(self, action): 369 """ 370 View scheduler status and change its status if requested. 371 """ 372 controller = Path.sched_control 373 try: 374 open(os.path.split(Path.config_file)[0] + "/schedrunning", 'r') 375 376 cmd_button_text = _("Stop Scheduler") 377 status_text = _("running") 378 start = False 379 except IOError: 380 cmd_button_text = _("Run Scheduler") 381 status_text = _("stopped") 382 start = True 383 384 # Show dialog 385 dlg = HIGDialog(buttons=(cmd_button_text, gtk.RESPONSE_CLOSE, 386 gtk.STOCK_OK, gtk.RESPONSE_OK)) 387 388 alert = HIGEntryLabel("<b>%s</b>" % _("Scheduler Status")) 389 390 text = HIGEntryLabel(_('Scheduler is %s!' % status_text)) 391 hbox = HIGHBox() 392 hbox.set_border_width(5) 393 hbox.set_spacing(12) 394 395 vbox = HIGVBox() 396 vbox.set_border_width(5) 397 vbox.set_spacing(12) 398 399 if start: 400 image = gtk.Image() 401 image.set_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG) 402 hbox.pack_start(image) 403 404 vbox.pack_start(alert) 405 vbox.pack_start(text) 406 hbox.pack_start(vbox) 407 408 dlg.vbox.pack_start(hbox) 409 dlg.vbox.show_all() 410 411 response = dlg.run() 412 dlg.destroy() 413 414 if response == gtk.RESPONSE_CLOSE: 415 if start: 416 subprocess.Popen([sys.executable, controller, 'start']) 417 else: 418 subprocess.Popen([sys.executable, controller, 'stop']) 355 419 356 420 def _view_inv(self, action):
