433
433
self.valid = False
434
434
self.specto.logger.log(_("There was an error initializing config file %s") % self.file_name, "critical", "specto")
436
def read_all_watches(self):
436
def read_all_watches(self, startup=False):
438
438
Read the watch options from the config file
439
439
and return a dictionary containing the info needed to start the watches.
441
441
watch_value_db = {}
444
self.cfg = ini_namespace(file(self.file_name))
446
self.specto.logger.log(_("There was an error initializing config file %s") % self.file_name, "critical", "specto")
445
self.cfg = ini_namespace(file(self.file_name))
447
self.specto.logger.log(_("There was an error initializing config file %s") % self.file_name, "critical", "specto")
449
450
names = self.cfg._sections.keys()
451
452
for name_ in names:
452
watch_value_db[i] = self.read_watch(name_)
453
watch_value_db[i] = self.read_watch(name_, startup)
454
455
return watch_value_db
456
def read_watch(self,name):
457
def read_watch(self,name, startup=False):
458
459
Read the watch options from one watch.
460
461
watch_options = {}
463
self.cfg = ini_namespace(file(self.file_name))
465
self.specto.logger.log(_("There was an error initializing config file %s") % self.file_name, "critical", "specto")
465
self.cfg = ini_namespace(file(self.file_name))
467
self.specto.logger.log(_("There was an error initializing config file %s") % self.file_name, "critical", "specto")
468
470
name = self.hide_brackets(name)
469
471
options = self.cfg._sections[name]._options.keys()
471
473
for option_ in options:
472
474
if option_ == "password" and not self.check_old_version(self.cfg[name]['type']): #don't use decoding for old watches.list
473
option = self.read_option(name, option_)
475
option = self.read_option(name, option_, startup)
474
476
option = self.decode_password(name, option)
476
option = self.read_option(name, option_)
478
option = self.read_option(name, option_, startup)
478
480
watch_options_ = { option_: option }
479
481
watch_options.update(watch_options_)
483
485
return watch_options
485
def read_option(self, name, option):
487
def read_option(self, name, option, startup=False):
486
488
""" Read one option from a watch """
487
cfg = ini_namespace(file(self.file_name))
491
self.cfg = ini_namespace(file(self.file_name))
493
self.specto.logger.log(_("There was an error initializing config file %s") % self.file_name, "critical", "specto")
489
return cfg[name][option]
496
return self.cfg[name][option]