def main(): from twisted.internet import reactor from configparser import ConfigParser from wind import WindManager from overlay import OverlayManager from message import MessageKeeper from extension import ComponentManager from extension import PluginManager from sys import stderr print '-+- Parsing configuration file and CLI -+-' cfg = ConfigParser() try: cfg.parseOptions() except RuntimeError as e: print >> stderr, ' * Error while parsing configurations' for l in str(e).splitlines(): print >> stderr, '\t>', l return -1 except Warning as e: errors = str(e).splitlines() print >> stderr, ' *', errors[0] for l in errors[1:]: print >> stderr, '\t>', l print '-+- Loading Winds -+-' try: WindManager.load(cfg['winds']) except RuntimeError as e: print >> stderr, ' * Error while loading winds:' for l in str(e).splitlines(): print >> stderr, '\t>', l wdesc = WindManager.getDescriptors() if len(wdesc) == 0: print >> stderr, " * No wind was loaded. Exiting with error." return -1 print '-+- Loading Overlay -+-' try: OverlayManager.load(cfg['overlay']) except RuntimeError as e: print >> stderr, (' * Error while loading overlay\n\t' + str(e)) return -1 print '-+- Loading Management Components -+-' try: ComponentManager.load(cfg['managementComponents']) except RuntimeError as e: print >> stderr, ( ' * Error while loading management component\n\t' + str(e)) return -1 overlay = OverlayManager.getOverlay() overlay.start(cfg['node'], WindManager.getDescriptors()) MessageKeeper.startToKeep() WindManager.startListening(overlay) ComponentManager.register(overlay) if len(cfg['bootstrap']) > 0: reactor.callWhenRunning(overlay.bootstrap, None, cfg['bootstrap']) reactor.run()