def main(argv): import optparse usage = '%prog [options] CONFIG_FILENAME' parser = optparse.OptionParser(usage=usage) parser.add_option('-m', '--manager-only', action='store_true', dest='managerOnly', default=False, help=("only validate manager-specific parts - flow and" " atmosphere configurations will not be checked")) parser.add_option('-p', '--print-only', action='store_true', dest='printOnly', default=False, help=("only print warnings - don't actually raise" " DeprecationWarning instances")) options, args = parser.parse_args(argv) if not len(args): parser.error('No filename given.') setup.setup() setup.setupPackagePath() validate(args[0], options.managerOnly, options.printOnly)
print '(got successful old result: %s->%s)' % (name, res) else: print '%s successful: %s' % (name, res) def errback(res, d): if d != self.current_deferred: print '(got failing old result: %s->%s)' % (name, res) else: print '%s failed, reason: %s' % (name, res) print name d = proc() if isinstance(d, Deferred): self.current_deferred = d d.addCallback(callback, d) d.addErrback(errback, d) else: print 'Check %s returned immediately with result %s' % (name, s) try: from flumotion.common import errors from flumotion.common import setup w = Window() w.show() setup.setup() reactor.run() except KeyboardInterrupt: print 'Interrupted'
def boot(path, gtk=False, gst=True, installReactor=True): # python 2.5 and twisted < 2.5 don't work together pythonMM = sys.version_info[0:2] from twisted.copyright import version twistedMM = tuple([int(n) for n in version.split('.')[0:2]]) if pythonMM >= (2, 5) and twistedMM < (2, 5): raise SystemError( "Twisted versions older than 2.5.0 do not work with " "Python 2.5 and newer. " "Please upgrade Twisted or downgrade Python.") if gtk or gst: init_gobject() if gst: from flumotion.configure import configure configure.gst_version = init_gst() global USE_GTK, USE_GST USE_GTK=gtk USE_GST=gst init_option_parser(gtk, gst) # installing the reactor could override our packager's import hooks ... if installReactor: from twisted.internet import gtk2reactor gtk2reactor.install(useGtk=gtk) from twisted.internet import reactor # ... so we install them again here to be safe from flumotion.common import package package.getPackager().install() # this monkeypatched var exists to let reconnecting factories know # when they should warn about a connection being closed, and when # they shouldn't because the system is shutting down. # # there is no race condition here -- the reactor doesn't handle # signals until it is run(). reactor.killed = False def setkilled(killed): reactor.killed = killed reactor.addSystemEventTrigger('before', 'startup', setkilled, False) reactor.addSystemEventTrigger('before', 'shutdown', setkilled, True) from flumotion.twisted import reflect from flumotion.common import errors from flumotion.common import setup setup.setup() from flumotion.common import log log.logTwisted() # we redefine catching __pychecker__ = 'no-reuseattr' if os.getenv('FLU_PROFILE'): def catching(proc, *args, **kwargs): import statprof statprof.start() try: return proc(*args, **kwargs) finally: statprof.stop() statprof.display() elif os.getenv('FLU_ATEXIT'): def catching(proc, *args, **kwargs): env = os.getenv('FLU_ATEXIT').split(' ') fqfn = env.pop(0) log.info('atexit', 'FLU_ATEXIT set, will call %s(*%r) on exit', fqfn, env) atexitproc = reflect.namedAny(fqfn) try: return proc(*args, **kwargs) finally: log.info('atexit', 'trying to call %r(*%r)', atexitproc, env) atexitproc(*env) else: def catching(proc, *args, **kwargs): return proc(*args, **kwargs) main = reflect.namedAny(path) try: sys.exit(catching(main, sys.argv)) except (errors.FatalError, SystemError), e: safeprintf(sys.stderr, 'ERROR: %s\n', e) sys.exit(1)
def boot(path, gtk=False, gst=True, installReactor=True): # python 2.5 and twisted < 2.5 don't work together pythonMM = sys.version_info[0:2] from twisted.copyright import version twistedMM = tuple([int(n) for n in version.split('.')[0:2]]) if pythonMM >= (2, 5) and twistedMM < (2, 5): raise SystemError("Twisted versions older than 2.5.0 do not work with " "Python 2.5 and newer. " "Please upgrade Twisted or downgrade Python.") if gtk or gst: init_gobject() if gtk: init_kiwi() if gst: from flumotion.configure import configure configure.gst_version = init_gst() global USE_GTK, USE_GST USE_GTK = gtk USE_GST = gst init_option_parser(gtk, gst) # installing the reactor could override our packager's import hooks ... if installReactor: from twisted.internet import gtk2reactor gtk2reactor.install(useGtk=gtk) from twisted.internet import reactor # ... so we install them again here to be safe from flumotion.common import package package.getPackager().install() # this monkeypatched var exists to let reconnecting factories know # when they should warn about a connection being closed, and when # they shouldn't because the system is shutting down. # # there is no race condition here -- the reactor doesn't handle # signals until it is run(). reactor.killed = False def setkilled(killed): reactor.killed = killed reactor.addSystemEventTrigger('before', 'startup', setkilled, False) reactor.addSystemEventTrigger('before', 'shutdown', setkilled, True) from flumotion.twisted import reflect from flumotion.common import errors from flumotion.common import setup setup.setup() from flumotion.common import log log.logTwisted() main = reflect.namedAny(path) wrapped = wrap_for_profiling(main) wrapped.__name__ = main.__name__ try: sys.exit(wrapped(sys.argv)) except (errors.FatalError, SystemError), e: safeprintf(sys.stderr, 'ERROR: %s\n', e) sys.exit(1)
# uncomment to see better where the problem comes from when it claims # to be in ihooks.py # import traceback; traceback.print_stack() # if it's not in our code, it's not our fault if filename.startswith('/usr/lib'): return # count the deprecation as a fatal error global exitCode exitCode += 1 warnings.showwarning = showwarning from flumotion.common import setup setup.setup() setup.setupPackagePath() registry = registry.getRegistry() basket = registry.makeBundlerBasket() bundlerNames = basket.getBundlerNames() for name in bundlerNames: # skip locale bundles, they're autogenerated and I'm too lazy to figure out # why validating the registry in the template module expects locale # bundles of core to be in the template's build dir if name.find('-locale-') > -1: continue try:
def boot(path, gtk=False, gst=True, installReactor=True): # python 2.5 and twisted < 2.5 don't work together pythonMM = sys.version_info[0:2] from twisted.copyright import version twistedMM = tuple([int(n) for n in version.split('.')[0:2]]) if pythonMM >= (2, 5) and twistedMM < (2, 5): raise SystemError( "Twisted versions older than 2.5.0 do not work with " "Python 2.5 and newer. " "Please upgrade Twisted or downgrade Python.") if gtk or gst: init_gobject() if gtk: init_kiwi() if gst: from flumotion.configure import configure configure.gst_version = init_gst() global USE_GTK, USE_GST USE_GTK=gtk USE_GST=gst init_option_parser(gtk, gst) # installing the reactor could override our packager's import hooks ... if installReactor: from twisted.internet import gtk2reactor gtk2reactor.install(useGtk=gtk) from twisted.internet import reactor # ... so we install them again here to be safe from flumotion.common import package package.getPackager().install() # this monkeypatched var exists to let reconnecting factories know # when they should warn about a connection being closed, and when # they shouldn't because the system is shutting down. # # there is no race condition here -- the reactor doesn't handle # signals until it is run(). reactor.killed = False def setkilled(killed): reactor.killed = killed reactor.addSystemEventTrigger('before', 'startup', setkilled, False) reactor.addSystemEventTrigger('before', 'shutdown', setkilled, True) from flumotion.twisted import reflect from flumotion.common import errors from flumotion.common import setup setup.setup() from flumotion.common import log log.logTwisted() main = reflect.namedAny(path) wrapped = wrap_for_profiling(main) wrapped.__name__ = main.__name__ try: sys.exit(wrapped(sys.argv)) except (errors.FatalError, SystemError), e: safeprintf(sys.stderr, 'ERROR: %s\n', e) sys.exit(1)