コード例 #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 ProcessArgsThatUsePreferences(self):
        """
       Process toolkit wide logging arguments. Then return the modified
       argv so the app can choose to parse more if it requires that.
       """

        if self.options.debug or int(
                self.preferences.GetPreference(Preferences.LOG_TO_CMD)):
            self.streamLoggerLevels = Log.HandleLoggers(
                Log.defStreamHandler, Log.GetDefaultLoggers())
            self.streamLoggerLevels.SetLevel(Log.DEBUG)
            self.streamLoggerLevels.SetLevel(Log.CRITICAL, Log.RTPSensor)
            # When in debug mode, we'll make the stream the primary handler.
            self.loggerLevels = self.streamLoggerLevels
        else:
            # If not in debug, we only used the StreamHandler before Logging was initialized.
            #    so we don't have a StreamLoggerLevels.
            self.streamLoggerLevels = None
コード例 #5
0
    def __init__(self, args):
        # Initialize Logging
        ntl = Log.handlers.NTEventLogHandler("AG VenueServer")
        ntl.setLevel(Log.DEBUG)
        self.log = Log.GetLogger(Log.VenueServer)
        Log.HandleLoggers(ntl, Log.GetDefaultLoggers())

        # Initialize Win32 Service stuff
        win32serviceutil.ServiceFramework.__init__(self, args)
        self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

        # Make a hosting environment
        self.server = Server(self._defaultPort)

        # Make a venue server
        self.venueService = VenueServer(self.server)

        # Make a Service Manager Service
        self.server.RegisterObject(self.venueService, path='/VenueServer')

        # tell the world we are here
        self.log.info("Created VenueServer.")
コード例 #6
0
    def __init__(self, args):
        # Initilialize Logging
        self.ntl = Log.handlers.NTEventLogHandler("AG Node Service")
        self.ntl.setLevel(Log.DEBUG)
        self.log = Log.GetLogger(Log.NodeService)
        Log.HandleLoggers(self.ntl, Log.GetDefaultLoggers())

        # Initialize Win32 Service stuff
        win32serviceutil.ServiceFramework.__init__(self, args)
        self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

        # Make a node service
        self.nodeService = AGNodeService()

        # Make a hosting environment
        self.server = Server(self._defaultPort)

        # Make a node service service
        self.server.RegisterObject(self.nodeService, path='/NodeService')

        # Tell the world we're here
        self.log.info("Created Node Service.")
コード例 #7
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
コード例 #8
0
            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()
            passphraseCB = certMgrUI.GetPassphraseCallback("DOE cert", "")
コード例 #9
0
def main():
    """
    This is the function that does all the real work.
    """
    app = CmdlineApplication.instance()
    app.Initialize("CreateVenues")

    venueServerUri = "https://localhost:8000/VenueServer"

    if len(sys.argv) > 2:
        venueServerUri = sys.argv[2]

    configFile = sys.argv[1]

    venueServer = VenueServerIW(venueServerUri, tracefile=sys.stdout)
    #venueServer.SetEncryptAllMedia(0)

    config = ConfigParser.ConfigParser()
    config.read(configFile)
    venues = {}

    # Start up the logging
    log = Log.GetLogger("CreateVenues")
    hdlr = Log.StreamHandler()
    hdlr.setLevel(Log.INFO)
    Log.HandleLoggers(hdlr, Log.GetDefaultLoggers())

    # We do this in two iterations because we need valid URLs for connections
    for sec in config.sections():
        # Build Venue Descriptions
        vdesc = VenueDescription3(config.get(sec, 'name'),
                                  config.get(sec, 'description'))
        vdesc.streams = []

        # Static Video
        if config.has_option(sec, 'video'):
            (host, port) = string.split(config.get(sec, 'video'), ':')
            vcap = Capability3(Capability.PRODUCER, Capability.VIDEO)
            vsd = StreamDescription3(
                vdesc.name,
                MulticastNetworkLocation(host.strip(), int(port), 127), vcap,
                0, None, 1)
            vdesc.streams.append(vsd)

        # Static Audio
        if config.has_option(sec, 'audio'):
            (host, port) = string.split(config.get(sec, 'audio'), ':')
            acap = Capability3(Capability3.PRODUCER, Capability3.AUDIO)
            asd = StreamDescription3(
                vdesc.name,
                MulticastNetworkLocation(host.strip(), int(port), 127), acap,
                0, None, 1)
            vdesc.streams.append(asd)

        # Make the venue, then store the resulting URL
        print "VD #%s : %s" % (sec, vdesc.name)
        vdesc.uri = venueServer.AddVenue(vdesc)
        config.set(sec, 'uri', vdesc.uri)

        if config.has_option(sec, 'default'):
            venueServer.SetDefaultVenue(vdesc.id)

        venues[sec] = vdesc

    for sec in config.sections():
        # Build up connections
        exits = string.split(config.get(sec, 'exits'), ', ')
        for vexit in exits:
            if venues.has_key(vexit):
                toVenue = venues[vexit]
                uri = toVenue.uri
                conn = ConnectionDescription(toVenue.name, toVenue.description,
                                             toVenue.uri)
                venues[sec].connections.append(conn)
            else:
                print "Error making connection to venue: ", vexit

        # Set the connections on the given venue
        print "CD #%s/%s: %s" % (sec, venues[sec].name, config.get(
            sec, 'exits'))

        # venue = Client.Handle(venues[sec].uri).GetProxy()
        print "URL: %s" % venues[sec].uri
        venue = VenueIW(venues[sec].uri, tracefile=sys.stdout)
        venue.SetConnections(venues[sec].connections)
コード例 #10
0
import sys
import re
from AccessGrid import Log

hdlr = Log.StreamHandler()
hdlr.setLevel(Log.DEBUG)
Log.HandleLoggers(Log.StreamHandler(), Log.GetDefaultLoggers())

sys.path.append(r"c:\home\olson\ag\dev\AccessGrid")

from AccessGrid import DataStore

defaultURL = "https://localhost:9011/test"

if len(sys.argv) > 1:
    url = sys.argv[1]
else:
    url = defaultURL

files = [
    r"c:\temp\tarfile-0.6.5.zip",
    r"c:\boot.ini",
    r"c:\Program Files\Inno Setup 3\whatsnew.htm",
    #         r"file name with spaces.txt",
    #         r"c:\home\olson\ag\dev\AccessGrid\AccessGrid\put.py",
    #          r"c:\temp\put.py",
    r"c:\home\olson\docs\AG\ag-2-design\datastore-simplified.doc"
]

if re.search("^https:", url):
    x = DataStore.GSIHTTPUploadFiles(url, files, None)