Example #1
0
    def InitLogging(self, debug=0, log=None):
        """
        Returns the log file.
        
        **Arguments**
        
        *debug* Not relevant. Note: Use WXGUIApplication.Initialize() in
        application main method instead.

        *log* Not relevant. Note: Use WXGUIApplication.Initialize() in
        application main method instead.
        """

        # We don't really need this method if all shared apps uses
        # WXGUIApplication() in main call. Keep this around for now to
        # maintain interoperability with old shared apps.

        # For this to work, you have to use WXGUIApplication in your
        # application's main call.

        self.log = Log.GetLogger(self.__appName)

        #Log.SetDefaultLevel(self.__appName, Log.DEBUG)

        # Log to file
        #if log == None:
        #    logFile = self.__appName + ".log"
        #else:
        #    logFile = log

        #fileHandler = Log.FileHandler(logFile)
        #fileHandler.setFormatter(Log.GetFormatter())
        #Log.HandleLoggers(fileHandler, Log.GetDefaultLoggers())

        return self.log
Example #2
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())
Example #3
0
 def __init__(self):
     '''
     Initiates the class. Creates a network service matcher and a dictionary
     to keep track of available network services.
     '''
     
     self.__services = dict()
     self.__matcher = NetworkServiceMatcher()
     self.log = Log.GetLogger('NetworkServicesManager')
    def __init__(self, url):
        self.url = url
        self.serverProxy = None
        self.registryPeers = None
        self.bridges = None
        self.bridgeCache = BridgeCache()
        self.log = Log.GetLogger('RegistryClient')

        self.proxyURL = BuildPreferencesProxyURL()
    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.")
Example #6
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.")
Example #7
0
    def __init__(self,
                 qbexec,
                 portRange=None,
                 logger=Log.GetLogger("BridgeFactory")):
        self.qbexec = qbexec
        self.portRange = portRange
        global log
        log = logger

        self.bridges = dict()
        self.processManager = ProcessManager()
        self.processManager.WaitForChildren(self.OnBridgeDeath)

        self.bridgesByPid = {}

        self.addressAllocator = NetworkAddressAllocator()

        # Use the port range if given
        if portRange:
            log.info("Allocator using port range: %s" % (portRange, ))
            self.SetPortMin(portRange[0])
            self.SetPortMax(portRange[1])
Example #8
0
# Standard Python library
import sys
import threading
import urlparse
import urllib
import asyncore

# Medusa
from FTPS import filesys
from FTPS import ftps_server

# M2Crypto
from M2Crypto import Rand, SSL

from AccessGrid import Log
log = Log.GetLogger('FTPSServer')
Log.SetDefaultLevel('FTPSServer', Log.DEBUG)


class authorizer:
    def __init__(self, root='/', authorizecb=None):
        self.root = root
        self.authorizecb = authorizecb

    def authorize(self, channel, username, password):

        channel.read_only = 0
        if self.authorizecb and self.authorizecb(channel, username, password):
            return 1, 'Ok.', filesys.os_filesystem(self.root)
        else:
            return 0, 'Connection rejected.', None
Example #9
0
# Created:     2003/08/02
# RCS-ID:      $Id: ProcessManager.py,v 1.14 2007-04-16 19:39:46 turam Exp $
# Copyright:   (c) 2002-2003
# Licence:     See COPYING.txt
#-----------------------------------------------------------------------------
"""
"""
__revision__ = "$Id: ProcessManager.py,v 1.14 2007-04-16 19:39:46 turam Exp $"

import win32api
import win32con
import win32event
import win32process
from AccessGrid import Log

log = Log.GetLogger(Log.ProcessManager)


class ProcessManager:
    def __init__(self):
        self.processes = []
        self.threadid = dict()

    def WaitForChildren(self, callback):
        log.warn('ProcessManager callback not yet implemented on Windows')

    def StartProcess(self, command, arglist, detached=1, maxWait=20):
        """
        Start a new process.

        @param command : the name of the command to be started. It can
Example #10
0
from types import StringType
import sys
import zipfile
import tempfile
import shutil
from optparse import OptionParser, Option

from AccessGrid import Log

from AccessGrid.AppDb import AppDb
from AccessGrid.PluginDb import PluginDb
from AccessGrid.Utilities import LoadConfig
from AccessGrid.Platform.Config import SystemConfig, AGTkConfig, UserConfig
from AccessGrid import Toolkit, Utilities

log = Log.GetLogger(Log.Agpm)

tempfile.tmpdir = SystemConfig.instance().GetTempDir()
gUseGui = False


class InvalidApplicationDescription(Exception):
    pass


def ShowResult(result, title="Package Manager"):
    if True == gUseGui:
        from AccessGrid.UIUtilities import MessageDialog
        import wx
        try:
            wxapp = wx.PySimpleApp()
Example #11
0
#-----------------------------------------------------------------------------
# Name:        UMTPClient.py
# Purpose:     Interface for UMTP Servers
# Created:     2006/06/22
# RCS-ID:      $Id: UMTPClient.py,v 1.1 2006/06/26 13:29:30 ngkim Exp $
#-----------------------------------------------------------------------------

from AccessGrid.Preferences import Preferences
from AccessGrid.Registry.RegistryClient import RegistryClient
from AccessGrid.UMTP import UMTPAgent
from AccessGrid.BridgeClient import BridgeClient
from AccessGrid import Log
from AccessGrid.NetworkLocation import MulticastNetworkLocation
from AccessGrid.GUID import GUID

log = Log.GetLogger("UMTPClient")


class UMTPClient(BridgeClient):
    def __init__(self, host=None, port=None, timeout=1):
        BridgeClient.__init__(self, host, port)

        self.host = host
        self.port = port

        self.agent = UMTPAgent(log)

    def SetHostPort(self, host, port):
        self.host = host
        self.port = port
Example #12
0
    def __init__(self):
        """
       The application constructor that enforces the singleton pattern.
       """
        if AppBase.instance():
            raise Exception, "Only one instance of AppBase is allowed; already have instance of %s" % (
                AppBase.instance().__class__, )

        AppBase.set_instance(self)

        self.parser = OptionParser()
        self.parser.add_option("-d",
                               "--debug",
                               action="store_true",
                               dest="debug",
                               default=0,
                               help="Set the debug level of this program.")
        self.parser.add_option("-l",
                               "--logfile",
                               dest="logfilename",
                               metavar="LOGFILE",
                               default=None,
                               help="Specify a log file to output logging to.")
        self.parser.add_option(
            "--numlogfiles",
            dest="numlogfiles",
            metavar="NUMLOGFILES",
            default=1,
            type="int",
            help="Specify the number of log files to retain")
        self.parser.add_option("--logfilesize",
                               dest="logfilesize",
                               metavar="LOGFILESIZE",
                               default=10000000,
                               type="long",
                               help="Specify the size of log files to retain")
        self.parser.add_option(
            "-c",
            "--configfile",
            dest="configfilename",
            metavar="CONFIGFILE",
            default=None,
            help="Specify a configuration file for the program.")
        self.parser.add_option(
            "--version",
            action="store_true",
            dest="version",
            default=0,
            help="Print out what version of the toolkit this is.")
        self.parser.add_option("--secure",
                               type="int",
                               dest="secure",
                               default=0,
                               help="Specify whether the service uses SSL.")
        self.parser.add_option("--cert",
                               dest="cert",
                               metavar="CERTFILE",
                               default=None,
                               help="Specify a certificate file to use.")
        self.parser.add_option("--key",
                               dest="key",
                               metavar="KEYFILE",
                               default=None,
                               help="Specify a certificate key file to use.")
        self.parser.add_option(
            "--cadir",
            dest="cadir",
            metavar="CADIR",
            default=None,
            help="Specify the directory containing CA certificates.")

        self.options = None
        self.userConfig = None
        self.agtkConfig = None
        self.systemConfig = SystemConfig.instance()
        self.log = None
        self.loggerLevels = None
        self.fhLoggerLevels = None

        self._certificateManager = None
        self._certMgrUI = None

        # This initializes logging
        self.log = Log.GetLogger(Log.Toolkit)
        self.log.debug("Initializing AG Toolkit version %s %s", GetVersion(),
                       GetStatus())
        self.log.info("Command and arguments: %s" % sys.argv)

        self.__context = None
        self.__passphrase = None
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)
from gov.lbl.dsd.bajjer import *
import string, random
import time
import calendar
import string

from AccessGrid import Log
#from AccessGrid.Platform.Config import UserConfig

log = Log.GetLogger('JabberClient')
Log.SetDefaultLevel('JabberClient', Log.DEBUG)

# Generating random numbers between:
start = 100000000
end = 999999999

AuthorizationFailure = stream.AuthorizationFailure


class JabberClient:
    def __init__(self):
        #log.info("Connecting to Jabber Server '%s' ..." % host)
        #self._stream = stream.JabberClientStream(host, port=port, use_ssl=True)
        self.currentRoom = ''
        self.currentRoomId = ''
        self.to = ''
        self._auth_info = None
        self.email = None
        self.jid = None
        self.name = None
        self.resource = None
from AccessGrid.NetworkLocation import ProviderProfile
from AccessGrid.Descriptions import AGServiceDescription
from AccessGrid.Descriptions import AGServiceManagerDescription
from AccessGrid.interfaces.AGServiceManager_client import AGServiceManagerIW
from AccessGrid.interfaces.AGService_client import AGServiceIW
from AccessGrid.Descriptions import ResourceDescription
from AccessGrid.Utilities import LoadConfig, SaveConfig
from AccessGrid.AGParameter import ValueParameter
from AccessGrid.Descriptions import NodeConfigDescription
from AccessGrid.AGServiceManager import AGServiceManager
from AccessGrid.Platform.Config import UserConfig, SystemConfig

from AccessGrid.interfaces.AGNodeService_interface import AGNodeService as AGNodeServiceI
from AccessGrid.interfaces.AGNodeService_client import AGNodeServiceIW

log = Log.GetLogger(Log.NodeService)


class SetStreamException(Exception):
    pass


class ServiceManagerAlreadyExists(Exception):
    pass


class ServiceManagerNotFound(Exception):
    pass


class ServiceManagerCannotBeRemovedBuiltIn(Exception):
import os
import re
import sys

from AccessGrid import Log
from AccessGrid.VenueClientObserver import VenueClientObserver
from AccessGrid.Platform import IsWindows
from AccessGrid.Platform.ProcessManager import ProcessManager

import wx

log = Log.GetLogger("Plugin")


class Plugin(VenueClientObserver):
    def __init__(self, directory, name, description, commandline, icon):
        self.directory = directory
        self.name = name
        self.description = description

        if not self.description or len(self.description) == 0:
            #
            # Fallback to at least something for the description
            #
            self.description = self.name

        self.commandline = commandline
        if self.commandline and len(self.commandline) == 0:
            self.commandline = None

        self.icon = icon
from AccessGrid.AGParameter import ValueParameter, RangeParameter
from AccessGrid.AGParameter import OptionSetParameter
from AccessGrid.Descriptions import AGServiceManagerDescription, AGServiceDescription
from AccessGrid.Descriptions import NodeConfigDescription
from AccessGrid.AGNodeService import AGNodeService
from AccessGrid.interfaces.AGNodeService_client import AGNodeServiceIW
from AccessGrid.AGServiceManager import AGServiceManager
from AccessGrid.interfaces.AGServiceManager_client import AGServiceManagerIW
from AccessGrid.interfaces.AGService_client import AGServiceIW
from AccessGrid import Version
from AccessGrid.Preferences import Preferences
from AccessGrid.Utilities import BuildServiceUrl

from AccessGrid import ServiceDiscovery

log = Log.GetLogger(Log.NodeManagementUIClasses)
Log.SetDefaultLevel(Log.NodeManagementUIClasses, Log.WARN)

###
### MENU DEFS
###

ID_FILE_EXIT  = 100
ID_FILE_LOAD_CONFIG = 101
ID_FILE_STORE_CONFIG = 102

ID_FILE_ATTACH = 800
ID_NODE_LEASH = 801
ID_NODE_BRIDGE = 802

ID_HOST_ADD = 300
"""
SOAPpy server wrappers

This module provides helper classes for servers using the SOAPpy server.
"""
__revision__ = "$Id: Server.py,v 1.21 2004-12-08 16:48:08 judson Exp $"

# External imports
import urlparse
from threading import Thread, Event

from SOAPpy.Server import ThreadingSOAPServer, GetSOAPContext
from SOAPpy.Config import SOAPConfig

from AccessGrid import Log
log = Log.GetLogger(Log.Hosting)


class _Server:
    """
    The server base class provides all the functionality required for
    a SOAP server based upon the SOAPpy module.
    """
    def __init__(self, addr, server):
        """
        @param addr: the address for the server to listen on
        @param server: the server object to use
        @type addr: (host, port) tuple
        @type server: one of ThreadingSOAPServer or ThreadingSOAPServer
        """
        self.addr = addr
#-----------------------------------------------------------------------------
"""
"""
__revision__ = "$Id: Descriptions.py,v 1.108 2007/12/20 16:37:23 turam Exp $"
__docformat__ = "restructuredtext en"

import string

from AccessGrid.GUID import GUID
from AccessGrid import Log
from AccessGrid.NetworkLocation import MulticastNetworkLocation
from AccessGrid.NetworkLocation import UnicastNetworkLocation
from AccessGrid.NetworkLocation import ProviderProfile
from AccessGrid.ClientProfile import ClientProfile

log = Log.GetLogger(Log.DataStore)


class ObjectDescription:
    """
    An object description has four parts:
        id : string
        name : string
        description : string
        uri : uri (string)
    """
    def __init__(self, name=None, description=None, uri=None, oid=None):

        # Catch annoying None case
        if oid != None:
            self.id = oid
import wx

import time
import os

from AccessGrid import Toolkit
from AccessGrid import Log
from AccessGrid.Platform.Config import UserConfig
from AccessGrid.UIUtilities import MessageDialog, ErrorDialog
from AccessGrid.Security.CertificateRepository import RepoInvalidCertificate
from AccessGrid.Security.Utilities import NewMd5Hash
import CertificateRequestTool

log = Log.GetLogger('CertificateStatusDialog')

class CertificateStatusDialog(wx.Dialog):
    '''
    Dialog showing submitted certificate requests.  It allows users to check status
    of requests and store them to right location.
    '''
    def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, id, title,
                          style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER )

        self.SetSize(wx.Size(700,350))

        self.info = wx.StaticText(self, -1, "You have requested following certificates:")
        self.list = wx.ListCtrl(self, wx.NewId(),
                               style = wx.LC_REPORT | wx.SUNKEN_BORDER)
        
        self.importButton = wx.Button(self, -1, "Import certificate")
Example #21
0
import sys
import base64

from AccessGrid import Events
from AccessGrid import Toolkit
from AccessGrid.Platform.Config import UserConfig
from AccessGrid.Platform import IsWindows,IsLinux,IsOSX,IsFreeBSD
from AccessGrid import DataStore
from AccessGrid import Platform
from AccessGrid.GUID import GUID
from AccessGrid.Toolkit import CmdlineApplication
from AccessGrid.ClientProfile import ClientProfile
from AccessGrid.SharedApplication import SharedApplicationIW

from AccessGrid import Log
log = Log.GetLogger("VenueVNCClient")

class vncSharedAppClient:
    """
    """
    def __init__( self, appUrl, clientProfile ):

        self.appUrl = appUrl

        self.appProxy=SharedApplicationIW(self.appUrl)
        print( "Application URL: %s" %(self.appUrl) )
        #print( "Application URL Valid? " + self.appProxy.isValid( ) )
        # Join the application
        #  ** NEW METHOD **
        (self.publicId, self.privateId) = self.appProxy.Join(clientProfile)
        #  ** OLD METHOD **
Example #22
0
 def __init__(self):
     self.log = Log.GetLogger('NetworkServiceMatcher')
"""
"""
__revision__ = "$Id: Config.py,v 1.42 2006-10-02 19:10:32 turam Exp $"

import os
import sys
import re
import struct
import time
import select
import socket
import shutil

from AccessGrid import Log
from AccessGrid.Version import GetVersion
log = Log.GetLogger(Log.Toolkit)

class AGTkConfig:
    """
    This class encapsulates a system configuration for the Access Grid
    Toolkit. This object provides primarily read-only access to configuration
    data that is created when the toolkit is installed.

    @type version: string
    @ivar version: The version of this installation.
    @type installDir: string
    @ivar installDir: The directory this toolkit is installed in.
    @type appDir: string
    @ivar appDir: The directory for system installed shared applications
    @type nodeServicesDir: string
    @ivar nodeServicesDir: the directory for system installed node services
import wx

from AccessGrid import Log
from AccessGrid.Events import Event
from AccessGrid.Platform import IsWindows, Config
from AccessGrid.ClientProfile import ClientProfile
from AccessGrid.Toolkit import WXGUIApplication
from AccessGrid.SharedAppClient import SharedAppClient
from AccessGrid.Platform.Config import UserConfig

import os
import getopt
from time import localtime, strftime

log = Log.GetLogger(Log.AppMonitor)


class AppMonitor:
    '''
    An Application Monitor connects to an Application Service and
    displays current application state such as participants and their status,
    application name, and description. It also includes an event window
    that shows when participants joined, data changed, and so forth.
    '''
    def __init__(self, parent, appUrl):
        '''
        Opens the Application Monitor frame and loads it with
        current application state. Also, register callbacks for
        events that updates the state.
        
        **Arguments**
from AccessGrid.Utilities import LoadConfig, SaveConfig
from AccessGrid.hosting import PathFromURL, IdFromURL
from AccessGrid.GUID import GUID
from AccessGrid.Venue import Venue, VenueI
from AccessGrid.MulticastAddressAllocator import MulticastAddressAllocator
from AccessGrid.DataStore import HTTPTransferServer
from AccessGrid.scheduler import Scheduler

from AccessGrid.Descriptions import ConnectionDescription, StreamDescription
from AccessGrid.Descriptions import DataDescription, VenueDescription
from AccessGrid.Descriptions import ServiceDescription
from AccessGrid.NetworkLocation import MulticastNetworkLocation
from AccessGrid.NetworkLocation import UnicastNetworkLocation
from AccessGrid.Types import Capability

log = Log.GetLogger(Log.VenueServer)

# ZSI Stuff
from AccessGrid.cache.VenueServer_messages import *
from AccessGrid.hosting.Tools import CreateObj
from AccessGrid.cache import Venue_interface


def GetHostingEnvironment():
    global __server
    return __server


class VenueServerException(Exception):
    """
    A generic exception type to be raised by the Venue code.
"""
__revision__ = "$Id: AGServicePackage.py,v 1.5 2007/08/15 19:20:27 eolson Exp $"
__docformat__ = "restructuredtext en"

import string
import os
import zipfile
import sys
import StringIO
import ConfigParser

from AccessGrid import Log
from AccessGrid.Descriptions import AGServicePackageDescription
from AccessGrid import Utilities

log = Log.GetLogger("AGServicePackage")


class InvalidServicePackage(Exception):
    pass


class InvalidServiceDescription(Exception):
    pass


class AGServicePackage:
    """
    Class to represent a service package, a zipfile containing a 
    service description file (.svc) and an implementation file,
    either a Python script or an executable
Example #27
0
import time
import string

import os
import os.path
import re
import shutil

import wx

from AccessGrid.UIUtilities import MessageDialog, ErrorDialog, ErrorDialogWithTraceback
from AccessGrid import Log
from AccessGrid import Toolkit

log = Log.GetLogger(Log.CertificateManagerWXGUI)

from AccessGrid.Security import CertificateManager
from AccessGrid.Security import CertificateRepository


def ValidateExportPath(path):
    """
    Validate the path for exporting.

    @param path: Pathname to be validated.
    
    @return: A tuple (success, message).

    Success is 0 for success, 1 for can't write, 2 for file exists. Yes, this
    is a little arbitrary but this isn't a general purpose routine, it's to
Example #28
0
import os
import sys

from AccessGrid.Plugin import Plugin
from AccessGrid.Descriptions import PluginDescription
from AccessGrid import Log

from AccessGrid.Platform import Config

log = Log.GetLogger("PluginFactory")

def BuildPlugin(pluginDesc):
    if not pluginDesc:
        log.exception("Null plugin description.")
        return None

    if not isinstance(pluginDesc, PluginDescription):
        log.exception("Invalid type, expected PluginDescription.")
        return None

    namenospace = pluginDesc.name.replace(' ', '_')

    sysdir = os.path.join(Config.AGTkConfig.instance().GetPluginDir(),
                          namenospace)
    userdir = os.path.join(Config.UserConfig.instance().GetPluginDir(),
                           namenospace)
    olddir = os.getcwd()
        
    if os.access(userdir, os.R_OK):
        pluginDir = userdir
    elif os.access(sysdir, os.R_OK):
Example #29
0
import os
import ConfigParser

from AccessGrid import Log
from AccessGrid.Descriptions import ConnectionDescription
log = Log.GetLogger("VenueCache")


class VenueCache:
    def __init__(self, venuesFile, venueServers):
        self.venuesFile = venuesFile
        self.venueServers = venueServers
        self.venues = {}

    def Update(self):
        log.debug("Updating venue cache")
        from AccessGrid.interfaces.VenueServer_client import VenueServerIW

        venueList = []

        for url in self.venueServers:
            try:
                venueList = VenueServerIW(url).GetVenues()
                venueList.sort(cmp=lambda x, y: cmp(x.name, y.name))
                self.venues[url] = VenueCache.VenueList(url, venueList)
                log.debug("Retrieved %d venues from server %s", len(venueList),
                          url)
            except:
                log.exception("Exception retrieving venues from %s", url)

    def GetVenues(self):
# Licence:     See COPYING.TXT
#-----------------------------------------------------------------------------

import time
import select
import socket
import xmlrpclib
from AccessGrid.NetworkLocation import MulticastNetworkLocation, UnicastNetworkLocation
from GUID import GUID
from BridgeClient import BridgeClient
from AccessGrid.UrllibTransport import UrllibTransport, TimeoutTransport
from AccessGrid import Utilities
from AccessGrid.Descriptions import BridgeDescription
from AccessGrid import Log

log = Log.GetLogger("QuickBridgeClient")


class ConnectionError(Exception):
    pass


class QuickBridgeClient(BridgeClient):
    def __init__(self, host=None, port=None, timeout=1):
        BridgeClient.__init__(self, host, port)

        transport = None
        self.proxyURL = Utilities.BuildPreferencesProxyURL()
        if self.proxyURL:
            self.transport = UrllibTransport(self.proxyURL, timeout)
        else: