def main(): """ Read a configuration file and perform the different event updates. A list of the modules to execute can be given. script configfile [module module ...] Example: script update_events.cfg moodle_log apache_log """ global config_defaults ####################################################################### # # OPTIONS # ####################################################################### args = sys.argv[1:] # Check that there are additional arguments if len(args) < 1: print >> sys.stderr, 'Script needs at least one parameter' sys.exit(1) if not os.path.exists(args[0]): print >> sys.stderr, 'File', args[0], 'not found.' sys.exit(1) # Initial options included in the global dictionary at the top of the # module. rule_manager.options = rule_manager.initial_config(config_defaults) # Traverse the modules and load the default values load_defaults(rule_manager.options) # Load the rules in the given configuration file rules = rule_manager.load_config_file(None, args[0], {})[1] # Initialize the file modification cache mechanism detect_new_files.initialize(\ rule_manager.get_property(None, 'anonymize', 'file_modification_cache'), True) # Traverse the sections and run first the "initialize" function and then # the "execute" function. for module_name in rules: module_prefix = module_name.split('.')[0] getattr(sys.modules[module_prefix], 'initialize')(module_name) for module_name in rules: module_prefix = module_name.split('.')[0] print >> sys.stderr, '### Execute' , module_name getattr(sys.modules[module_prefix], 'execute')(module_name) return
def main(): """ """ global config_params global module_prefix config_params['uri'] = 'ldap://ldap.uc3m.es' config_params['base'] = 'ou=Gente,o=Universidad Carlos III,c=es' rule_manager.options = rule_manager.initial_config({}) section_name = module_prefix try: configparser.options.add_section(section_name) except ConfigParser.DuplicateSectionError: pass for (vn, vv) in config_params.items(): rule_manager.set_property(None, section_name, vn, vv, createRule = True, createOption = True) initialize(module_prefix) print get('abel')
sys.exit(1) if debug: print >> sys.stderr, 'Options: ', args ####################################################################### # # MAIN PROCESSING # ####################################################################### config_params['files'] = ' '.join(args) config_params['repository'] = 'file://' + \ os.path.abspath('../Sources/VM_Pairs/as/Groups') rule_manager.options = rule_manager.initial_config({}) section_name = module_prefix try: rule_manager.options.add_section(section_name) except ConfigParser.DuplicateSectionError: pass for (vn, vv) in config_params.items(): rule_manager.set_property(None, section_name, vn, vv, createRule = True, createOption = True) initialize(module_prefix) execute(module_prefix) # Execution as script