Example #1
0
 def testLog(self):
     log.resetErrorOccurred()
     self.logCheck(log.warning, ("a warning",), "warning: a warning")
     self.logCheck(log.debug, ("a debug",), [])
     assert(not log.errorOccurred())
     log.setVerbosity(2)
     self.logCheck(log.warning, ("a warning",), "warning: a warning")
     self.logCheck(log.debug, ("a debug",), "+ a debug")
     log.setVerbosity(0)
     self.logCheck(log.warning, ("a warning",), "warning: a warning")
     self.logCheck(log.debug, ("a debug",), [])
     assert(not log.errorOccurred())
     self.logCheck(log.error, ("an error",), "error: an error")
     assert(log.errorOccurred())
Example #2
0
 def testLog(self):
     log.resetErrorOccurred()
     self.logCheck(log.warning, ("a warning", ), "warning: a warning")
     self.logCheck(log.debug, ("a debug", ), [])
     assert (not log.errorOccurred())
     log.setVerbosity(2)
     self.logCheck(log.warning, ("a warning", ), "warning: a warning")
     self.logCheck(log.debug, ("a debug", ), "+ a debug")
     log.setVerbosity(0)
     self.logCheck(log.warning, ("a warning", ), "warning: a warning")
     self.logCheck(log.debug, ("a debug", ), [])
     assert (not log.errorOccurred())
     self.logCheck(log.error, ("an error", ), "error: an error")
     assert (log.errorOccurred())
Example #3
0
    def runCommand(self, thisCommand, cfg, argSet, args, debugAll=False):
        client = conaryclient.ConaryClient(cfg)
        repos = client.getRepos()
        callback = commit.CheckinCallback(cfg)

        if not cfg.buildLabel and cfg.installLabelPath:
            cfg.buildLabel = cfg.installLabelPath[0]

        sys.excepthook = util.genExcepthook(debug=cfg.debugExceptions,
                                            debugCtrlC=debugAll)

        if cfg.installLabelPath:
            cfg.installLabel = cfg.installLabelPath[0]
        else:
            cfg.installLabel = None

        cfg.initializeFlavors()
        log.setMinVerbosity(log.INFO)
        log.resetErrorOccurred()

        # set the build flavor here, just to set architecture information
        # which is used when initializing a recipe class
        use.setBuildFlagsFromFlavor(None, cfg.buildFlavor, error=False)

        profile = False
        if argSet.has_key('lsprof'):
            import cProfile
            prof = cProfile.Profile()
            prof.enable()
            profile = 'lsprof'
            del argSet['lsprof']

        keyCache = openpgpkey.getKeyCache()
        keyCache.setPublicPath(cfg.pubRing)
        repos = conaryclient.ConaryClient(cfg).getRepos()
        keyCacheCallback = openpgpkey.KeyCacheCallback(repos, cfg)
        keyCache.setCallback(keyCacheCallback)

        try:
            rv = options.MainHandler.runCommand(self,
                                                thisCommand,
                                                cfg,
                                                argSet,
                                                args,
                                                callback=callback,
                                                repos=client.getRepos(),
                                                profile=profile)
        finally:
            if profile == 'lsprof':
                prof.disable()
                prof.dump_stats('cvc.lsprof')
                prof.print_stats()
            elif profile:
                prof.stop()

        if log.errorOccurred():
            sys.exit(2)
        return rv
Example #4
0
    def runCommand(self, thisCommand, cfg, argSet, args, debugAll=False):
        client = conaryclient.ConaryClient(cfg)
        repos = client.getRepos()
        callback = commit.CheckinCallback(cfg)

        if not cfg.buildLabel and cfg.installLabelPath:
            cfg.buildLabel = cfg.installLabelPath[0]

        sys.excepthook = util.genExcepthook(debug=cfg.debugExceptions,
                                            debugCtrlC=debugAll)

        if cfg.installLabelPath:
            cfg.installLabel = cfg.installLabelPath[0]
        else:
            cfg.installLabel = None

        cfg.initializeFlavors()
        log.setMinVerbosity(log.INFO)
        log.resetErrorOccurred()

        # set the build flavor here, just to set architecture information
        # which is used when initializing a recipe class
        use.setBuildFlagsFromFlavor(None, cfg.buildFlavor, error=False)

        profile = False
        if argSet.has_key('lsprof'):
            import cProfile
            prof = cProfile.Profile()
            prof.enable()
            profile = 'lsprof'
            del argSet['lsprof']

        keyCache = openpgpkey.getKeyCache()
        keyCache.setPublicPath(cfg.pubRing)
        repos = conaryclient.ConaryClient(cfg).getRepos()
        keyCacheCallback = openpgpkey.KeyCacheCallback(repos,
                                                       cfg)
        keyCache.setCallback(keyCacheCallback)

        try:
            rv = options.MainHandler.runCommand(self, thisCommand,
                                                cfg, argSet, args,
                                                callback=callback,
                                                repos=client.getRepos(),
                                                profile=profile)
        finally:
            if profile == 'lsprof':
                prof.disable()
                prof.dump_stats('cvc.lsprof')
                prof.print_stats()
            elif profile:
                prof.stop()

        if log.errorOccurred():
            sys.exit(2)
        return rv
Example #5
0
    def testLogWithPercentChar(self):
        log.resetErrorOccurred()
        log.setVerbosity(2)
        fooString = "Some message with a %s char in it"
        self.logCheck(log.error,   (fooString,), "error: %s" % fooString)
        assert(log.errorOccurred())
        self.logCheck(log.warning, (fooString,), "warning: %s" % fooString)
        self.logCheck(log.debug,   (fooString,), "+ %s" % fooString)
        self.logCheck(log.info,    (fooString,), "+ %s" % fooString)

        fooString = "This %s work"
        arg1 = "does"
        efooString = fooString % arg1

        self.logCheck(log.error,   (fooString, arg1), "error: %s" % efooString)
        assert(log.errorOccurred())
        self.logCheck(log.warning, (fooString, arg1), "warning: %s" % efooString)
        self.logCheck(log.debug,   (fooString, arg1), "+ %s" % efooString)
        self.logCheck(log.info,    (fooString, arg1), "+ %s" % efooString)
Example #6
0
 def testLogWithObject(self):
     log.resetErrorOccurred()
     log.setVerbosity(2)
     foo = object()
     fooString = str(foo)
     self.logCheck(log.error,   (foo,), "error: %s" % fooString)
     assert(log.errorOccurred())
     self.logCheck(log.warning, (foo,), "warning: %s" % fooString)
     self.logCheck(log.debug,   (foo,), "+ %s" % fooString)
     self.logCheck(log.info,    (foo,), "+ %s" % fooString)
Example #7
0
 def testLogWithObject(self):
     log.resetErrorOccurred()
     log.setVerbosity(2)
     foo = object()
     fooString = str(foo)
     self.logCheck(log.error, (foo, ), "error: %s" % fooString)
     assert (log.errorOccurred())
     self.logCheck(log.warning, (foo, ), "warning: %s" % fooString)
     self.logCheck(log.debug, (foo, ), "+ %s" % fooString)
     self.logCheck(log.info, (foo, ), "+ %s" % fooString)
Example #8
0
    def testLogWithPercentChar(self):
        log.resetErrorOccurred()
        log.setVerbosity(2)
        fooString = "Some message with a %s char in it"
        self.logCheck(log.error, (fooString, ), "error: %s" % fooString)
        assert (log.errorOccurred())
        self.logCheck(log.warning, (fooString, ), "warning: %s" % fooString)
        self.logCheck(log.debug, (fooString, ), "+ %s" % fooString)
        self.logCheck(log.info, (fooString, ), "+ %s" % fooString)

        fooString = "This %s work"
        arg1 = "does"
        efooString = fooString % arg1

        self.logCheck(log.error, (fooString, arg1), "error: %s" % efooString)
        assert (log.errorOccurred())
        self.logCheck(log.warning, (fooString, arg1),
                      "warning: %s" % efooString)
        self.logCheck(log.debug, (fooString, arg1), "+ %s" % efooString)
        self.logCheck(log.info, (fooString, arg1), "+ %s" % efooString)
Example #9
0
        built = cook.cookObject(repos,
                                cfg,
                                toCook,
                                version,
                                prep=False,
                                macros=m,
                                targetLabel=targetLabel,
                                changeSetFile=csFile,
                                alwaysBumpCount=False,
                                ignoreDeps=False,
                                logBuild=True,
                                crossCompile=crossCompile,
                                requireCleanSources=False,
                                groupOptions=groupOptions)
        if not built:
            if log.errorOccurred():
                msg = 'Check logs'
            else:
                msg = 'Unknown failure'
            errMsg = 'Error building recipe %s=%s[%s]: %s' % (name, version,
                                                              flavor, msg)
            _buildFailed(failureFd, errMsg)
    except Exception, msg:
        errMsg = 'Error building recipe %s=%s[%s]: %s' % (name, version,
                                                          flavor, str(msg))
        _buildFailed(failureFd, errMsg, traceback.format_exc())


def setupEnvironment():
    """
    Grab a fresh copy of the environment, based on the currently installed
Example #10
0
        m._override('buildbranch', str(buildBranch))
        m._override('binarybranch', str(binaryBranch))
        toCook = compat.ConaryVersion().getObjectsToCook(loaders, recipeClasses)
        built = cook.cookObject(repos, cfg, toCook, version,
                                prep=False,
                                macros=m,
                                targetLabel=targetLabel,
                                changeSetFile=csFile,
                                alwaysBumpCount=False,
                                ignoreDeps=False,
                                logBuild=True,
                                crossCompile=crossCompile,
                                requireCleanSources=False,
                                groupOptions=groupOptions)
        if not built:
            if log.errorOccurred():
                msg = 'Check logs'
            else:
                msg = 'Unknown failure'
            errMsg = 'Error building recipe %s=%s[%s]: %s' % (name, version,
                                                              flavor, msg)
            _buildFailed(failureFd, errMsg)
    except Exception, msg:
        errMsg = 'Error building recipe %s=%s[%s]: %s' % (name, version,
                                                          flavor, str(msg))
        _buildFailed(failureFd, errMsg, traceback.format_exc())


def setupEnvironment():
    """
    Grab a fresh copy of the environment, based on the currently installed