コード例 #1
0
def init_logging(appName):
    hdlr = Log.StreamHandler()
    hdlr.setLevel(log.DEBUG)
    hdlr.setFormatter(Log.GetFormatter())

    appLogger = Log.GetLogger(appName)
    Log.HandleLoggers(appLogger, Log.GetDefaultLoggers())
コード例 #2
0
def SetLogging():
    logFile = None
    debugMode = 1

    if logFile is None:
        logname = os.path.join(UserConfig.instance().GetConfigDir(),
                               "NodeSetupWizard.log")
    else:
        logname = logFile

    hdlr = Log.FileHandler(logname)
    hdlr.setFormatter(Log.GetFormatter())
    Log.HandleLoggers(hdlr, Log.GetDefaultLoggers())

    if debugMode:
        hdlr = Log.StreamHandler()
        hdlr.setFormatter(Log.GetLowDetailFormatter())
        Log.HandleLoggers(hdlr, Log.GetDefaultLoggers())
コード例 #3
0
def SetLogging():
    debugMode = 1
    logFile = None

    if logFile is None:
        logname = os.path.join(GetUserConfigDir(), "Test.log")
    else:
        logname = logFile

    hdlr = Log.FileHandler(logname)
    hdlr.setFormatter(Log.GetFormatter())
    hdlr.setLevel(Log.WARN)
    Log.HandleLoggers(hdlr, Log.GetDefaultLoggers())

    if debugMode:
        hdlr = Log.StreamHandler()
        hdlr.setFormatter(Log.GetLowDetailFormatter())
        Log.HandleLoggers(hdlr, Log.GetDefaultLoggers())
コード例 #4
0
    def Initialize(self, name=None, args=None):
        """
       This method sets up everything for reasonable execution.
       At the first sign of any problems it raises exceptions and exits.
       """
        self.name = name

        # 1. Process Command Line Arguments
        argvResult = self.ProcessArgs(args=args)

        # 2. Load the Toolkit wide configuration.
        try:
            self.agtkConfig = AGTkConfig.instance(0)
        except Exception:
            self.log.exception("Toolkit Initialization failed.")
            sys.exit(-1)

        # 3. Load the user configuration, creating one if necessary.
        try:
            self.userConfig = UserConfig.instance(initIfNeeded=1)
        except Exception:
            self.log.exception("User Initialization failed.")
            sys.exit(-1)

        # Load client preferences
        self.preferences = Preferences()
        self.ProcessArgsThatUsePreferences()

        # 4. Redirect logging to files in the user's directory,
        #    purging memory to file

        fh = Log.defLogHandler

        if self.options.logfilename is not None:
            if not self.options.logfilename.endswith(".log"):
                self.name = self.options.logfilename + ".log"
            else:
                self.name = self.options.logfilename
        elif self.name is not None:
            if not self.name.endswith(".log"):
                self.name = self.name + ".log"

        self.log.info("Logfile Name: %s", self.name)

        if self.name:
            if not self.name.startswith(os.sep) \
                                      and not self.name.startswith("."):
                filename = os.path.join(self.userConfig.GetLogDir(), self.name)
            else:
                filename = self.name

            fh = Log.RotatingFileHandler(filename, "a",
                                         self.options.logfilesize,
                                         self.options.numlogfiles)

            fh.setFormatter(Log.GetFormatter())
            self.fhLoggerLevels = Log.HandleLoggers(fh,
                                                    Log.GetDefaultLoggers())
            self.fhLoggerLevels.SetLevel(Log.DEBUG)
            self.fhLoggerLevels.SetLevel(Log.CRITICAL, Log.RTPSensor)
            self.loggerLevels = self.fhLoggerLevels

            # Send the log in memory to stream (debug) or file handler.
        if self.options.debug or int(
                self.preferences.GetPreference(Preferences.LOG_TO_CMD)):
            Log.mlh.setTarget(Log.defStreamHandler)
        else:
            Log.mlh.setTarget(fh)
        Log.mlh.close()
        Log.RemoveLoggerLevels(Log.memLevels, Log.GetLoggers())

        self.__SetLogPreference()

        self.CheckDependencies()

        # Check if machine clock is synchronized.
        # - Disabled for 3.0: clock-sync is important when using proxy certs, which we're not
        #self.__CheckForInvalidClock()

        self.__context = None

        return argvResult
コード例 #5
0
        except CertificateRepository.RepoDoesNotExist:
            log.exception("SubmitRequest:Validate:You do not have a certificate repository. Certificate request can not be completed.")


            print "Your certificate repository is not initialized; certificate request cannot be completed"
            return 0

        except:
            log.exception("SubmitRequest:Validate: Certificate request can not be completed")
            print "Error occured. Certificate request can not be completed.",
            return 0

if __name__ == "__main__":

    h = Log.StreamHandler()
    h.setFormatter(Log.GetFormatter())
    Log.HandleLoggers(h, Log.GetDefaultLoggers())

    os.mkdir("foo")
    log.debug("foo")

    try:
        cm = CertificateManager("foo")
        ui = CertificateManagerUserInterface(cm)

        x = cm.ImportIdentityCertificatePEM(cm.certRepo,
                                            r"v\venueServer_cert.pem",
                                            r"v\venueServer_key.pem", None)
        
        if 0:
            certMgrUI = Toolkit.GetDefaultApplication().GetCertificateManagerUI()