Пример #1
0
    def __init__(self, name, location, listenPort, umtpexec, registryUrlList, dataPort=None):
        if not os.path.exists(umtpexec):
            raise Exception("UMTP executable does not exist at this location:", umtpexec)
        self.umtpexec = umtpexec
        self.providerProfile = ProviderProfile(name, location)
        self.listenPort = listenPort
        self.dataPort = dataPort

        self.listeningServer = AsyncAGXMLRPCServerThreaded( ("", listenPort), intervalSecs=1, 
                                                    callback=self.MaintenanceCallback,
                                                    logRequests=0)
        
        self._RegisterRemoteFunctions()
        self.registryClients = []
        for registryUrl in registryUrlList:
            self.registryClients.append(RegistryClient(url=registryUrl))
        self.hostname = SystemConfig.instance().GetHostname()
        self.hostip = SystemConfig.instance().GetLocalIPAddress()
        self.addressAllocator = NetworkAddressAllocator()
        self.bridgeDescription = BridgeDescription(guid=GUID(), name=name, host=self.hostname, 
                                                   port=self.listenPort, serverType=UMTP_TYPE, 
                                                   description="", 
                                                   portMin=dataPort,
                                                   portMax=dataPort)
        self._RegisterWithRegistry()

        # Instantiate the process manager
        self.processManager = ProcessManager()
        self.processManager.WaitForChildren(self.OnProcessDeath)

        self.running = False
    def __init__( self ):
        AGService.__init__( self )

        self.capabilities = [ Capability( Capability.PRODUCER,
                                          Capability.VIDEO ) ]
        if IsWindows():
            vic = "smash-5.2.exe"
        else:
            vic = "smash-5.2"

        self.executable = os.path.join(os.getcwd(),vic)

        self.sysConf = SystemConfig.instance()

        # Set configuration parameters

        # note: the datatype of the port parameter changes when a resource is set!
        self.streamname = TextParameter( "streamname", "Video" )
        self.port = TextParameter( "port", "" )
        self.encoding = OptionSetParameter( "encoding", "h261", VideoProducerService.encodings )
        self.standard = OptionSetParameter( "standard", "NTSC", VideoProducerService.standards )
        self.bandwidth = RangeParameter( "bandwidth", 800, 0, 3072 )
        self.framerate = RangeParameter( "framerate", 24, 1, 30 )
        self.quality = RangeParameter( "quality", 75, 1, 100 )
        self.configuration.append( self.streamname )
        self.configuration.append( self.port )
        self.configuration.append( self.encoding )
        self.configuration.append( self.standard )
        self.configuration.append( self.bandwidth )
        self.configuration.append( self.framerate )
        self.configuration.append (self.quality )
        
        self.profile = None
    def __init__(self):
        AGService.__init__(self)

        self.capabilities = [Capability(Capability.PRODUCER, Capability.VIDEO)]
        if IsWindows():
            vic = "smash-5.2.exe"
        else:
            vic = "smash-5.2"

        self.executable = os.path.join(os.getcwd(), vic)

        self.sysConf = SystemConfig.instance()

        # Set configuration parameters

        # note: the datatype of the port parameter changes when a resource is set!
        self.streamname = TextParameter("streamname", "Video")
        self.port = TextParameter("port", "")
        self.encoding = OptionSetParameter("encoding", "h261",
                                           VideoProducerService.encodings)
        self.standard = OptionSetParameter("standard", "NTSC",
                                           VideoProducerService.standards)
        self.bandwidth = RangeParameter("bandwidth", 800, 0, 3072)
        self.framerate = RangeParameter("framerate", 24, 1, 30)
        self.quality = RangeParameter("quality", 75, 1, 100)
        self.configuration.append(self.streamname)
        self.configuration.append(self.port)
        self.configuration.append(self.encoding)
        self.configuration.append(self.standard)
        self.configuration.append(self.bandwidth)
        self.configuration.append(self.framerate)
        self.configuration.append(self.quality)

        self.profile = None
    def __init__(self):
        AGService.__init__(self)

        self.capabilities = [Capability(Capability.PRODUCER, Capability.VIDEO)]
        self.executable = os.path.join(os.getcwd(),
                                       'qtStream.app/Contents/MacOS/qtStream')

        self.sysConf = SystemConfig.instance()

        # Set configuration parameters

        # note: the datatype of the port parameter changes when a resource is set!
        self.streamname = TextParameter("streamname", "Video")
        self.port = TextParameter("port", "")
        self.encoding = OptionSetParameter("encoding", "h261",
                                           MacVideoProducerService.encodings)
        self.bandwidth = RangeParameter("bandwidth", 1200, 0, 3072)
        self.framerate = RangeParameter("framerate", 15, 1, 30)
        self.quality = RangeParameter("quality", 90, 1, 100)
        self.transmitOnStart = OptionSetParameter(
            "transmitonstartup", "On", MacVideoProducerService.onOffOptions)
        self.configuration.append(self.streamname)
        self.configuration.append(self.port)
        self.configuration.append(self.encoding)
        self.configuration.append(self.bandwidth)
        self.configuration.append(self.framerate)
        self.configuration.append(self.quality)
        self.configuration.append(self.transmitOnStart)

        self.profile = None
    def __init__( self ):
        AGService.__init__( self )

        self.capabilities = [ Capability( Capability.PRODUCER,
                                          Capability.VIDEO ) ]
        self.executable = os.path.join(os.getcwd(),'qtStream.app/Contents/MacOS/qtStream')

        self.sysConf = SystemConfig.instance()

        # Set configuration parameters

        # note: the datatype of the port parameter changes when a resource is set!
        self.streamname = TextParameter( "streamname", "Video" )
        self.port = TextParameter( "port", "" )
        self.encoding = OptionSetParameter( "encoding", "h261", MacVideoProducerService.encodings )
        self.bandwidth = RangeParameter( "bandwidth", 1200, 0, 3072 )
        self.framerate = RangeParameter( "framerate", 15, 1, 30 )
        self.quality = RangeParameter( "quality", 90, 1, 100 )
        self.transmitOnStart = OptionSetParameter( "transmitonstartup", "On", MacVideoProducerService.onOffOptions )
        self.configuration.append( self.streamname )
        self.configuration.append( self.port )
        self.configuration.append( self.encoding )
        self.configuration.append( self.bandwidth )
        self.configuration.append( self.framerate )
        self.configuration.append (self.quality )
        self.configuration.append (self.transmitOnStart )
        
        self.profile = None
Пример #6
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 testSaveLoad(self):
       c = ClientProfile()
       filename = os.path.join( SystemConfig.instance().GetTempDir(),".testProfile") 
       c.Save(filename)

       d = ClientProfile()
       d.Load(filename)
       assert d.CheckProfile()
Пример #8
0
    def testSaveLoad(self):
        c = ClientProfile()
        filename = os.path.join(SystemConfig.instance().GetTempDir(),
                                ".testProfile")
        c.Save(filename)

        d = ClientProfile()
        d.Load(filename)
        assert d.CheckProfile()
Пример #9
0
 def JoinBridge(self,multicastNetworkLocation):
     mnl = multicastNetworkLocation
     log.info("Bridge request: mcast %s %s" % (mnl["host"],str(mnl["port"])))
     uaddr = SystemConfig.instance().GetHostname()
     retBridge = self.bridgeFactory.CreateBridge(id=mnl["id"], maddr=mnl["host"],
                 mport=mnl["port"], mttl=mnl["ttl"], uaddr=uaddr,uport=None)
     networkLocation = UnicastNetworkLocation(host=retBridge.uaddr, port=retBridge.uport)
     networkLocation.profile = self.providerProfile
     networkLocation.id = GUID()
     networkLocation.privateId = GUID()
     return networkLocation
 def _GetLocation(self):
    """
    """
    hn = SystemConfig.instance().GetHostname()
    if isWindows():
       return "windows://" + hn
    elif isLinux():
       if os.getenv("DISPLAY"):
          return "X11://" + hn + ":" + os.getenv("DISPLAY").split(":")[-1]
       else:
          return "X11://" + hn + ":0.0"
    else:
       return "unknown://hn"
    def __init__(self, parent, title):
        TitledPage.__init__(self, parent, title)
        self.emailId = wx.NewId()
        self.hostId = wx.NewId()
        self.text = wx.StaticText(self, -1, "The e-mail address will be used for verification, please make sure it is valid.")
        self.emailText = wx.StaticText(self, -1, "E-mail:")
        self.hostText = wx.StaticText(self, -1, "Machine Name:")
        self.emailCtrl = wx.TextCtrl(self, self.emailId, validator = HostCertValidator())

        self.hostName = SystemConfig.instance().GetHostname();
        
        self.hostCtrl = wx.TextCtrl(self, self.hostId, self.hostName, validator = HostCertValidator())
        self.SetEvents()
        self.Layout()
Пример #12
0
    def __init__( self ):
        AGService.__init__( self )
        self.capabilities = [ Capability( Capability.CONSUMER,
                                          Capability.VIDEO,
                                          "H261",
                                          90000, self.id) ]

        if IsWindows():
            vic = "vic.exe"
        else:
            vic = "vic"

        self.executable = os.path.join(os.getcwd(),vic)
        if not os.path.isfile(self.executable):
            self.executable = vic

        self.sysConf = SystemConfig.instance()

        self.profile = None
        self.windowGeometry = None

        self.startPriority = '7'
        self.startPriorityOption.value = self.startPriority

        # Set configuration parameters
        self.tiles = OptionSetParameter( "Thumbnail Columns", "4", VideoConsumerService.tileOptions )
        self.positionWindow = OptionSetParameter( 'Position Window', 'Justify Left', ['Off', 'Justify Left', 'Justify Right'])
        
        self.configuration.append( self.tiles )
        self.configuration.append( self.positionWindow)

        if IsWindows():
            try:
                import win32api

                # get number of processors
                systemInfo = win32api.GetSystemInfo()
                numprocs = systemInfo[5]
                self.allProcsMask = 2**numprocs-1

                self.procOptions = ['All']
                for i in range(numprocs):
                    self.procOptions.append(str(i+1))

                self.processorUsage = OptionSetParameter( "Processor usage", self.procOptions[0], self.procOptions )
                self.configuration.append( self.processorUsage )
            except:
                self.log.exception('Error initializing processor usage options')
Пример #13
0
 def JoinBridge(self, multicastNetworkLocation):
     mnl = multicastNetworkLocation
     log.info("Bridge request: mcast %s %s" %
              (mnl["host"], str(mnl["port"])))
     uaddr = SystemConfig.instance().GetHostname()
     retBridge = self.bridgeFactory.CreateBridge(id=mnl["id"],
                                                 maddr=mnl["host"],
                                                 mport=mnl["port"],
                                                 mttl=mnl["ttl"],
                                                 uaddr=uaddr,
                                                 uport=None)
     networkLocation = UnicastNetworkLocation(host=retBridge.uaddr,
                                              port=retBridge.uport)
     networkLocation.profile = self.providerProfile
     networkLocation.id = GUID()
     networkLocation.privateId = GUID()
     return networkLocation
    def __init__(self, parent, title):
        TitledPage.__init__(self, parent, title)
        self.serviceId = wx.NewId()
        self.hostId = wx.NewId()
        self.emailId = wx.NewId()

        self.text = wx.StaticText(
            self, -1,
            "The e-mail address will be used for verification, please make sure it is valid."
        )
        self.serviceText = wx.StaticText(self, -1, "Service Type:")
        self.serviceDropdown = wx.ComboBox(
            self,
            -1,
            "",
            style=wx.CB_DROPDOWN | wx.CB_READONLY,
            choices=map(lambda x: x[0], ServiceTypes))
        self.hostText = wx.StaticText(self, -1, "Machine Name:")
        self.emailText = wx.StaticText(self, -1, "E-mail:")
        self.serviceCtrl = wx.TextCtrl(self, self.serviceId)
        self.serviceNameText = wx.StaticText(self, -1, "Service Name:")
        self.serviceCtrl.Enable(0)
        self.serviceNameText.Enable(0)

        self.serviceName = None
        self.userTyped = 0

        self.hostName = SystemConfig.instance().GetHostname()

        self.hostCtrl = wx.TextCtrl(self, self.hostId, self.hostName)
        self.emailCtrl = wx.TextCtrl(self, self.emailId)

        self.SetValidator(ServiceCertValidator())

        wx.EVT_COMBOBOX(self.serviceDropdown, self.serviceDropdown.GetId(),
                        self.OnServiceSelected)

        wx.EVT_TEXT(self.serviceCtrl, self.serviceId, self.OnServiceText)
        wx.EVT_TEXT(self.emailCtrl, self.emailId, self.EnterText)
        wx.EVT_TEXT(self.hostCtrl, self.hostId, self.EnterText)
        wx.EVT_CHAR(self.serviceCtrl, self.OnServiceChar)
        self.Layout()
    def __init__(self, parent, id, title, choices, serviceType, text, size=wx.Size(450,130) ):
    
    
        wx.Dialog.__init__(self, parent, id, title, style =
                          wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
                          size=size)
                          
        self.serviceType = serviceType
              
        # Set up sizers
        sizer1 = wx.BoxSizer(wx.VERTICAL)
       
        self.text = wx.StaticText(self,-1,text)
        sizer1.Add( self.text,0,border=5,flag=wx.ALL)

        self.comboBoxCtrl = wx.ComboBox(self,-1, choices=choices)
        sizer1.Add( self.comboBoxCtrl, 0, flag=wx.ALL|wx.EXPAND,border=5)
        
        # Create ok/cancel buttons
        sizer3 = wx.BoxSizer(wx.HORIZONTAL)
        okButton = wx.Button( self, wx.ID_OK, "OK")
        cancelButton = wx.Button( self, wx.ID_CANCEL, "Cancel" )
        sizer3.Add(okButton, 0, wx.ALL, 10)
        sizer3.Add(cancelButton, 0, wx.ALL, 10)
        sizer1.Add(sizer3, 0, wx.ALIGN_CENTER)
        
        self.SetSizer( sizer1 )
        
        x,y = wx.GetMousePosition()
        w,h = self.GetSize()
        self.Move( (x-w/2,y-h/2) )
        wx.EVT_TEXT_ENTER(self, self.comboBoxCtrl.GetId(), self.OnOK)

        self.exists = threading.Event()
        self.exists.set()
        
        self.browser = ServiceDiscovery.Browser(serviceType,self.BrowseCallback)
        self.browser.Start()
        
        self.hostname = SystemConfig.instance().GetHostname()

        self.Fit()
Пример #16
0
 def __init__(self, name, location, listenPort, qbexec, registryUrlList, portRange=None):
     if not os.path.exists(qbexec):
         raise Exception("QuickBridge executable does not exist at this location:", qbexec)
     self.bridgeFactory = BridgeFactory(qbexec=qbexec, portRange=portRange, logger=log)
     self.providerProfile = ProviderProfile(name, location)
     self.listenPort = listenPort
     self.listeningServer = AsyncAGXMLRPCServerThreaded( ("", listenPort), intervalSecs=1, 
                                                 callback=self.MaintenanceCallback,
                                                 logRequests=0)
     self._RegisterRemoteFunctions()
     self.registryClients = []
     for registryUrl in registryUrlList:
         self.registryClients.append(RegistryClient(url=registryUrl))
     hostname = SystemConfig.instance().GetHostname()
     self.bridgeDescription = BridgeDescription(guid=GUID(), name=name, host=hostname, 
                                                port=self.listenPort, serverType=QUICKBRIDGE_TYPE, 
                                                description="", 
                                                portMin=self.bridgeFactory.GetPortMin(),
                                                portMax=self.bridgeFactory.GetPortMax())
     self._RegisterWithRegistry()
     self.running = False
    def __init__(self, parent, title):
        TitledPage.__init__(self, parent, title)
        self.emailId = wx.NewId()
        self.hostId = wx.NewId()
        self.text = wx.StaticText(
            self, -1,
            "The e-mail address will be used for verification, please make sure it is valid."
        )
        self.emailText = wx.StaticText(self, -1, "E-mail:")
        self.hostText = wx.StaticText(self, -1, "Machine Name:")
        self.emailCtrl = wx.TextCtrl(self,
                                     self.emailId,
                                     validator=HostCertValidator())

        self.hostName = SystemConfig.instance().GetHostname()

        self.hostCtrl = wx.TextCtrl(self,
                                    self.hostId,
                                    self.hostName,
                                    validator=HostCertValidator())
        self.SetEvents()
        self.Layout()
Пример #18
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)

        sbox = wx.StaticBox(self, -1, "Proxy server")
        self.sizer = wx.StaticBoxSizer(sbox, wx.VERTICAL)

        self.SetSizer(self.sizer)
        self.SetAutoLayout(1)

        #
        # Stuff for the proxy configuration.
        #

        proxies = SystemConfig.instance().GetProxySettings()

        defaultProxyHost = ""
        defaultProxyPort = ""
        defaultEnabled = 0

        if proxies != []:
            defaultProxy, defaultEnabled = proxies[0]
            defaultProxyHost, defaultProxyPort = defaultProxy
            if defaultProxyPort is None:
                defaultProxyPort = ""

        self.proxyEnabled = wx.CheckBox(
            self, -1,
            "Use a proxy server to connect to the certificate server")

        wx.EVT_CHECKBOX(self, self.proxyEnabled.GetId(), self.OnCheckbox)

        self.proxyText = wx.TextCtrl(self, -1, defaultProxyHost)
        self.proxyPort = wx.TextCtrl(self, -1, defaultProxyPort)

        self.proxyEnabled.SetValue(defaultEnabled)
        self.UpdateProxyEnabledState()

        self._Layout()
        self.Fit()
Пример #19
0
    def do_request_service(self, line):
        """
        Usage:

        request_service <servicename> <email>

        Generate and submit a certificate request for <servicename> on
        this host. <email> is the confirmation email address.
        
        """
        args = split_quoted(line)
        if len(args) != 2:
            print "Usage: request_service <servicename> <email>"
            return 0

        serviceName, email = args

        host = SystemConfig.instance().GetHostname()

        reqInfo = CertificateManager.ServiceCertificateRequestInfo(
            serviceName, host, email)

        self.certMgrUI.RequestCertificate(reqInfo, None, 0, None, None)
    def __init__(self, parent, title):
        TitledPage.__init__(self, parent, title)
        self.serviceId = wx.NewId()
        self.hostId = wx.NewId()
        self.emailId = wx.NewId()
            
        self.text = wx.StaticText(self, -1, "The e-mail address will be used for verification, please make sure it is valid.")
        self.serviceText = wx.StaticText(self, -1, "Service Type:")
        self.serviceDropdown = wx.ComboBox(self, -1, "",
                                          style = wx.CB_DROPDOWN | wx.CB_READONLY,
                                          choices = map(lambda x: x[0], ServiceTypes))
        self.hostText = wx.StaticText(self, -1, "Machine Name:")
        self.emailText = wx.StaticText(self, -1, "E-mail:")
        self.serviceCtrl = wx.TextCtrl(self, self.serviceId)
        self.serviceNameText = wx.StaticText(self, -1, "Service Name:")
        self.serviceCtrl.Enable(0)
        self.serviceNameText.Enable(0)

        self.serviceName = None
        self.userTyped = 0
        
        self.hostName = SystemConfig.instance().GetHostname();

        self.hostCtrl = wx.TextCtrl(self, self.hostId, self.hostName)
        self.emailCtrl = wx.TextCtrl(self, self.emailId)


        self.SetValidator(ServiceCertValidator())

        wx.EVT_COMBOBOX(self.serviceDropdown, self.serviceDropdown.GetId(),
                     self.OnServiceSelected)

        wx.EVT_TEXT(self.serviceCtrl, self.serviceId, self.OnServiceText)
        wx.EVT_TEXT(self.emailCtrl, self.emailId, self.EnterText)
        wx.EVT_TEXT(self.hostCtrl, self.hostId , self.EnterText)
        wx.EVT_CHAR(self.serviceCtrl, self.OnServiceChar)
        self.Layout()
Пример #21
0
 def __init__(self,
              name,
              location,
              listenPort,
              qbexec,
              registryUrlList,
              portRange=None):
     if not os.path.exists(qbexec):
         raise Exception(
             "QuickBridge executable does not exist at this location:",
             qbexec)
     self.bridgeFactory = BridgeFactory(qbexec=qbexec,
                                        portRange=portRange,
                                        logger=log)
     self.providerProfile = ProviderProfile(name, location)
     self.listenPort = listenPort
     self.listeningServer = AsyncAGXMLRPCServerThreaded(
         ("", listenPort),
         intervalSecs=1,
         callback=self.MaintenanceCallback,
         logRequests=0)
     self._RegisterRemoteFunctions()
     self.registryClients = []
     for registryUrl in registryUrlList:
         self.registryClients.append(RegistryClient(url=registryUrl))
     hostname = SystemConfig.instance().GetHostname()
     self.bridgeDescription = BridgeDescription(
         guid=GUID(),
         name=name,
         host=hostname,
         port=self.listenPort,
         serverType=QUICKBRIDGE_TYPE,
         description="",
         portMin=self.bridgeFactory.GetPortMin(),
         portMax=self.bridgeFactory.GetPortMax())
     self._RegisterWithRegistry()
     self.running = False
Пример #22
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)

        sbox = wx.StaticBox(self, -1, "Proxy server")
        self.sizer = wx.StaticBoxSizer(sbox, wx.VERTICAL)

        self.SetSizer(self.sizer)
        self.SetAutoLayout(1)
        
        #
        # Stuff for the proxy configuration.
        #
        
        proxies = SystemConfig.instance().GetProxySettings()

        defaultProxyHost = ""
        defaultProxyPort = ""
        defaultEnabled = 0
        
        if proxies != []:
            defaultProxy, defaultEnabled = proxies[0]
            defaultProxyHost, defaultProxyPort = defaultProxy
            if defaultProxyPort is None:
                defaultProxyPort = ""

        self.proxyEnabled = wx.CheckBox(self, -1, "Use a proxy server to connect to the certificate server")

        wx.EVT_CHECKBOX(self, self.proxyEnabled.GetId(), self.OnCheckbox)

        self.proxyText = wx.TextCtrl(self, -1, defaultProxyHost)
        self.proxyPort = wx.TextCtrl(self, -1, defaultProxyPort)

        self.proxyEnabled.SetValue(defaultEnabled)
        self.UpdateProxyEnabledState()

        self._Layout()
        self.Fit()
Пример #23
0
    def do_request_service(self, line):
        """
        Usage:

        request_service <servicename> <email>

        Generate and submit a certificate request for <servicename> on
        this host. <email> is the confirmation email address.
        
        """
        args = split_quoted(line)
        if len(args) != 2:
            print "Usage: request_service <servicename> <email>"
            return 0

        serviceName, email = args

        host = SystemConfig.instance().GetHostname()

        reqInfo = CertificateManager.ServiceCertificateRequestInfo(serviceName,
                                                                    host,
                                                                    email)

        self.certMgrUI.RequestCertificate(reqInfo, None, 0, None, None)
Пример #24
0
    def __init__( self ):
        AGService.__init__( self )
        self.thepath = os.getcwd()

        self.capabilities = [ Capability( Capability.CONSUMER,
                                          Capability.VIDEO,
                                          "H261",
                                          90000, self.id),
                              Capability( Capability.PRODUCER,
                                          Capability.VIDEO,
                                          "H261",
                                          90000, self.id)]
        if IsWindows():
            vic = "vic.exe"
        else:
            vic = "vic"

        self.executable = os.path.join(os.getcwd(),vic)
        if not os.path.isfile(self.executable):
            self.executable = vic

        self.sysConf = SystemConfig.instance()

        self.profile = None
        self.windowGeometry = None
        
        self.startPriority = '7'
        self.startPriorityOption.value = self.startPriority
        self.id = str(GUID())

        # Set configuration parameters
        # note: the datatype of the port parameter changes when a resource is set!
        self.streamname = TextParameter( "Stream Name", "" )
        self.port = TextParameter( "port", "" )
        self.encoding = OptionSetParameter( "Encoding", "h261", VideoService.encodingOptions )
        if IsWindows(): 
            standard = "PAL"
        else:
            standard = "NTSC"
        self.standard = OptionSetParameter( "Standard", standard, VideoService.standardOptions )
        self.tiles = OptionSetParameter( "Thumbnail Columns", "4", VideoService.tileOptions )
        self.bandwidth = RangeParameter( "Bandwidth", 800, 0, 3072 )
        self.framerate = RangeParameter( "Frame Rate", 24, 1, 30 )
        self.quality = RangeParameter( "Quality", 75, 1, 100 )
        self.transmitOnStart = OptionSetParameter( "Transmit on Startup", "On", VideoService.onOffOptions )
        self.muteSources = OptionSetParameter( "Mute Sources", "Off", VideoService.onOffOptions )
        self.positionWindow = OptionSetParameter( 'Position Window', 'Justify Left', ['Off', 'Justify Left', 'Justify Right'])
        
        self.configuration.append( self.streamname )
        self.configuration.append( self.port )
        self.configuration.append( self.encoding )
        self.configuration.append( self.standard )
        self.configuration.append( self.tiles )
        self.configuration.append( self.bandwidth )
        self.configuration.append( self.framerate )
        self.configuration.append (self.quality )
        self.configuration.append (self.transmitOnStart )
        self.configuration.append (self.muteSources )
        self.configuration.append (self.positionWindow )
        if IsWindows():
            try:
                import win32api

                # get number of processors
                systemInfo = win32api.GetSystemInfo()
                numprocs = systemInfo[5]
                self.allProcsMask = 2**numprocs-1

                self.procOptions = ['All']
                for i in range(numprocs):
                    self.procOptions.append(str(i+1))

                self.processorUsage = OptionSetParameter( "Processor usage", self.procOptions[0], self.procOptions )
                self.configuration.append( self.processorUsage )
            except:
                self.log.exception('Error initializing processor usage options')

        self.__GetResources()
Пример #25
0
 def testGetDefaultRouteIP(self):
     SystemConfig.instance().GetDefaultRouteIP()
Пример #26
0
 def testFreeSpace(self):
     free = SystemConfig.instance().GetFileSystemFreeSpace("/")
     assert free > 0
Пример #27
0
 def testGetHostname(self):
     SystemConfig.instance().GetHostname()
Пример #28
0
 def testGetDefaultRouteIP(self):
     SystemConfig.instance().GetDefaultRouteIP()
Пример #29
0
 def testGetTempDir(self):
     tempDir = SystemConfig.instance().GetTempDir()
     assert tempDir != "" and tempDir is not None, 'empty temp dir'
     assert os.path.isdir(tempDir), 'temp dir does not exist'
Пример #30
0
 def testFreeSpace(self):
     free = SystemConfig.instance().GetFileSystemFreeSpace("/")
     assert free > 0
Пример #31
0
    def Start( self ):
        """
        Start service
        """
        try:
            # Set processor affinity (windows only)
            if IsWindows():
                try:
                    if self.processorUsage.value == 'All':
                        self.log.info('Setting processor affinity to all processors')
                        SystemConfig.instance().SetProcessorAffinity(self.allProcsMask)
                    else:
                        val = 2**(int(self.processorUsage.value)-1)
                        self.log.info('Ssetting processor affinity : use processor %s', self.processorUsage.value)
                        SystemConfig.instance().SetProcessorAffinity(int(self.processorUsage.value))
                except:
                    self.log.exception("Exception setting processor affinity")

            # Enable firewall
            self.sysConf.AppFirewallConfig(self.executable, 1)

            # Resolve assigned resource to a device understood by vic
            if self.resource == "None":
                vicDevice = "None"
            else:
                vicDevice = self.resource[0]
                vicDevice = vicDevice.replace("[","\[")
                vicDevice = vicDevice.replace("]","\]")

            if IsWindows():
                try:
                    self.MapWinDevice(self.resource[0])
                except:
                    self.log.exception("Exception mapping device")

            #
            # Write vic startup file
            #
            startupfile = os.path.join(UserConfig.instance().GetTempDir(),
               'VideoServiceH264_%s.vic' % self.id )

            f = open(startupfile,"w")
            if self.port.value == '':
                portstr = "None"
            else:
                portstr = self.port.value

            if self.standard.value == '':
                standardstr = "None"
            else:
                standardstr = self.standard.value

            if self.muteSources.value == "On":
                # streams are muted, so disable autoplace
                disableAutoplace = "true"
            else:
                # streams are not muted, so don't disable autoplace
                # (flags should not be negative!)
                disableAutoplace = "false"

            if self.inputsize.value == "Small":
                inputsize = 4
            elif self.inputsize.value == "Large" and self.encoding.value != "h261":
                inputsize = 1
            else:
                inputsize = 2

            if self.resolution != None:
                resolution = self.resolution.value
            else:
                resolution = "none"

            name=email="Participant"
            if self.profile:
                name = self.profile.name
                email = self.profile.email
            else:
                # Error case
                name = email = Toolkit.GetDefaultSubject().GetCN()
                self.log.error("Starting service without profile set")

            f.write( vicstartup % ( disableAutoplace,
                                    OnOff(self.muteSources.value),
                                    self.bandwidth.value,
                                    self.framerate.value,
                                    self.quality.value,
                                    self.encoding.value,
                                    standardstr,
                                    vicDevice,
                                    "%s(%s)" % (name,self.streamname.value),
                                    email,
                                    OnOff(self.encodingDeinterlacer.value),
                                    resolution,
                                    email,
                                    OnOff(self.transmitOnStart.value),
                                    portstr,
                                    portstr,
                                    inputsize) )
            f.close()

            # Open permissions on vic startupfile
            os.chmod(startupfile,0777)

            # Replace double backslashes in the startupfile name with single
            #  forward slashes (vic will crash otherwise)
            if IsWindows():
                startupfile = startupfile.replace("\\","/")

            #
            # Start the service; in this case, store command line args in a list and let
            # the superclass _Start the service
            options = []
            options.append( "-u" )
            options.append( startupfile )
            options.append( "-C" )
            options.append( str(self.streamDescription.name) )
            if IsOSX():
                if self.transmitOnStart.value:
                    options.append( "-X")
                    options.append( "transmitOnStartup=1")
            if self.streamDescription.encryptionFlag != 0:
                options.append( "-K" )
                options.append( self.streamDescription.encryptionKey )

            # Set drop time to something reasonable
            options.append('-XsiteDropTime=5')

            if not self.positionWindow.value == 'Off':
                # - set vic window geometry
                try:

                    if not self.windowGeometry:
                        h = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)
                        w_sys = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X)
                        try:
                            w = GetScreenWidth(w_sys,h)
                        except ValueError:
                            self.log.debug('Error computing screen width; using system screen width %d', w_sys)
                            w = w_sys
                        window_width = w-300
                        window_height = 300
                        window_x = 300
                        window_y = h-375
                        border_w = wx.SystemSettings_GetMetric(wx.SYS_FRAMESIZE_X)
                        if border_w > 0:
                            window_width -= 4*border_w
                            window_x += 2*border_w
                        self.windowGeometry = (window_width,window_height,window_x,window_y)
                    if self.positionWindow.value == 'Justify Left':
                        options.append('-Xgeometry=%dx%d+%d+%d' % self.windowGeometry)
                    else:
                        options.append('-Xgeometry=%dx%d-%d+%d' % self.windowGeometry)
                except:
                    self.log.exception('Error calculating window placement')


            if self.profile:
                options.append("-X")
                options.append("site=%s" % self.profile.publicId)

            # Set number of columns to use for thumbnail display
            options.append("-Xtile=%s" % self.tiles.value)

            # Check whether the network location has a "type" attribute
            # Note: this condition is only to maintain compatibility between
            # older venue servers creating network locations without this attribute
            # and newer services relying on the attribute; it should be removed
            # when the incompatibility is gone
            if self.streamDescription.location.__dict__.has_key("type"):
                # use TTL from multicast locations only
                if self.streamDescription.location.type == MulticastNetworkLocation.TYPE:
                    options.append( "-t" )
                    options.append( '%d' % (self.streamDescription.location.ttl) )
            options.append( '%s/%d' % ( self.streamDescription.location.host,
                                           self.streamDescription.location.port) )

            self.log.info("Starting VideoServiceH264")
            self.log.info(" executable = %s" % self.executable)
            self.log.info(" options = %s" % options)
            os.chdir(self.thepath)
            self._Start( options )
            #os.remove(startupfile)
        except:
            self.log.exception("Exception in VideoServiceH264.Start")
            raise Exception("Failed to start service")
Пример #32
0
 def testUsername(self):
     username = SystemConfig.instance().GetUsername()
     assert len(username) > 0
Пример #33
0
    def Start(self):
        """Start service"""
        try:

            # Set processor affinity (windows only)
            if IsWindows():
                try:
                    if self.processorUsage.value == 'All':
                        self.log.info(
                            'Setting processor affinity to all processors')
                        SystemConfig.instance().SetProcessorAffinity(
                            self.allProcsMask)
                    else:
                        val = 2**(int(self.processorUsage.value) - 1)
                        self.log.info(
                            'Ssetting processor affinity : use processor %s',
                            self.processorUsage.value)
                        SystemConfig.instance().SetProcessorAffinity(
                            int(self.processorUsage.value))
                except:
                    self.log.exception("Exception setting processor affinity")

            # Enable firewall
            self.sysConf.AppFirewallConfig(self.executable, 1)

            # Resolve assigned resource to a device understood by vic
            if self.resource == "None":
                vicDevice = "None"
            else:
                vicDevice = self.resource[0]
                vicDevice = vicDevice.replace("[", "\[")
                vicDevice = vicDevice.replace("]", "\]")

            if IsWindows():
                try:
                    self.MapWinDevice(self.resource[0])
                except:
                    self.log.exception("Exception mapping device")

            #
            # Write vic startup file
            #
            startupfile = os.path.join(UserConfig.instance().GetTempDir(),
                                       'VideoProducerService_%s.vic' % self.id)

            f = open(startupfile, "w")
            if self.port.value == '':
                portstr = "None"
            else:
                portstr = self.port.value

            name = email = "Participant"
            if self.profile:
                name = self.profile.name
                email = self.profile.email
            else:
                # Error case
                name = email = Toolkit.GetDefaultSubject().GetCN()
                self.log.error("Starting service without profile set")

            f.write(vicstartup % (
                self.bandwidth.value, self.framerate.value, self.quality.value,
                self.encoding.value, self.standard.value, vicDevice, "%s(%s)" %
                (name, self.streamname.value), email, email, portstr, portstr))
            f.close()

            # Open permissions on vic startupfile
            os.chmod(startupfile, 0777)

            # Replace double backslashes in the startupfile name with single
            #  forward slashes (vic will crash otherwise)
            if IsWindows():
                startupfile = startupfile.replace("\\", "/")

            #
            # Start the service; in this case, store command line args in a list and let
            # the superclass _Start the service
            options = []
            options.append("-u")
            options.append(startupfile)
            options.append("-C")
            options.append(str(self.streamname.value))
            if IsOSX():
                options.append("-X")
                options.append("transmitOnStartup=1")
            if self.streamDescription.encryptionFlag != 0:
                options.append("-K")
                options.append(self.streamDescription.encryptionKey)

            if self.profile:
                options.append("-X")
                options.append("site=%s" % self.profile.publicId)

            options.append('-X')
            options.append('noMulticastBind=true')

            # Check whether the network location has a "type" attribute
            # Note: this condition is only to maintain compatibility between
            # older venue servers creating network locations without this attribute
            # and newer services relying on the attribute; it should be removed
            # when the incompatibility is gone
            if self.streamDescription.location.__dict__.has_key("type"):
                # use TTL from multicast locations only
                if self.streamDescription.location.type == MulticastNetworkLocation.TYPE:
                    options.append("-t")
                    options.append('%d' %
                                   (self.streamDescription.location.ttl))
            options.append('%s/%d' % (self.streamDescription.location.host,
                                      self.streamDescription.location.port))

            self.log.info("Starting VideoProducerService")
            self.log.info(" executable = %s" % self.executable)
            self.log.info(" options = %s" % options)
            self._Start(options)
            #os.remove(startupfile)
        except:
            self.log.exception("Exception in VideoProducerService.Start")
            raise Exception("Failed to start service")
Пример #34
0
 def GetResources(self):
     resources = SystemConfig.instance().GetResources()
     ret = map(lambda x: ResourceDescription(x[0]) , resources)
     return ret
Пример #35
0
    def __init__(self):
        AGService.__init__(self)
        self.capabilities = [
            Capability(Capability.PRODUCER, Capability.VIDEO, "H261", 90000,
                       self.id)
        ]

        if IsWindows():
            vic = "vic.exe"
        else:
            vic = "vic"

        self.executable = os.path.join(os.getcwd(), vic)
        if not os.path.isfile(self.executable):
            self.executable = vic

        self.sysConf = SystemConfig.instance()

        self.startPriority = '5'
        self.startPriorityOption.value = self.startPriority
        self.id = str(GUID())

        # Set configuration parameters

        # note: the datatype of the port parameter changes when a resource is set!
        self.streamname = TextParameter("Stream Name", "")
        self.port = TextParameter("Port", "")
        self.encoding = OptionSetParameter("Encoding", "h261",
                                           VideoProducerService.encodings)
        if IsWindows():
            standard = "PAL"
        else:
            standard = "NTSC"
        self.standard = OptionSetParameter("Standard", standard,
                                           VideoProducerService.standards)
        self.bandwidth = RangeParameter("Bandwidth", 800, 0, 3072)
        self.framerate = RangeParameter("Frame Rate", 24, 1, 30)
        self.quality = RangeParameter("Quality", 75, 1, 100)
        self.configuration.append(self.streamname)
        self.configuration.append(self.port)
        self.configuration.append(self.encoding)
        self.configuration.append(self.standard)
        self.configuration.append(self.bandwidth)
        self.configuration.append(self.framerate)
        self.configuration.append(self.quality)

        if IsWindows():
            try:
                import win32api

                # get number of processors
                systemInfo = win32api.GetSystemInfo()
                numprocs = systemInfo[5]
                self.allProcsMask = 2**numprocs - 1

                self.procOptions = ['All']
                for i in range(numprocs):
                    self.procOptions.append(str(i + 1))

                self.processorUsage = OptionSetParameter(
                    "Processor usage", self.procOptions[0], self.procOptions)
                self.configuration.append(self.processorUsage)
            except:
                self.log.exception(
                    'Error initializing processor usage options')

        self.profile = None
        self.resource = ''

        self.__GetResources()
Пример #36
0
    def Start( self ):
        """Start service"""
        try:

            # Set processor affinity (windows only)
            if IsWindows():
                try:
                    if self.processorUsage.value == 'All':
                        self.log.info('Setting processor affinity to all processors')
                        SystemConfig.instance().SetProcessorAffinity(self.allProcsMask)
                    else:
                        val = 2**(int(self.processorUsage.value)-1)
                        self.log.info('Ssetting processor affinity : use processor %s', self.processorUsage.value)
                        SystemConfig.instance().SetProcessorAffinity(int(self.processorUsage.value))
                except:
                    self.log.exception("Exception setting processor affinity")

            # Enable firewall
            self.sysConf.AppFirewallConfig(self.executable, 1)

            # Start the service; in this case, store command line args
            # in a list and let the superclass _Start the service
            options = []
            if self.streamDescription.name and \
                   len(self.streamDescription.name.strip()) > 0:
                options.append( "-C" )
                options.append( self.streamDescription.name )
            if self.streamDescription.encryptionFlag != 0:
                options.append( "-K" )
                options.append( self.streamDescription.encryptionKey )
            # Check whether the network location has a "type"
            # attribute Note: this condition is only to maintain
            # compatibility between older venue servers creating
            # network locations without this attribute and newer
            # services relying on the attribute; it should be removed
            # when the incompatibility is gone
            if self.streamDescription.location.__dict__.has_key("type"):
                if self.streamDescription.location.type == MulticastNetworkLocation.TYPE:
                    options.append( "-t" )
                    options.append( '%d' % ( self.streamDescription.location.ttl ) )

            # Set name and email on command line, in case rtp defaults
            # haven't been written (to avoid vic prompting for
            # name/email)
            name=email="Participant"
            if self.profile:
                name = self.profile.name
                email = self.profile.email
            options.append('-XrtpName=%s' % (name,))
            options.append('-XrtpEmail=%s' % (email,))

            # Set some tk resources to customize vic
            # - this is a consumer, so disable device selection in vic
            options.append('-XrecvOnly=1')
            # - set drop time to something reasonable
            options.append('-XsiteDropTime=5')

            if not self.positionWindow.value == 'Off':
                # - set vic window geometry
                try:
                    
                    if not self.windowGeometry:
                        h = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)
                        w_sys = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X)
                        try:
                            w = GetScreenWidth(w_sys,h)
                        except ValueError:
                            self.log.debug('Error computing screen width; using system screen width %d', w_sys)
                            w = w_sys
                        window_width = w-300
                        window_height = 300
                        window_x = 300
                        window_y = h-375
                        border_w = wx.SystemSettings_GetMetric(wx.SYS_FRAMESIZE_X)
                        if border_w > 0:
                            window_width -= 4*border_w
                            window_x += 2*border_w
                        self.windowGeometry = (window_width,window_height,window_x,window_y)
                    if self.positionWindow.value == 'Justify Left':
                        options.append('-Xgeometry=%dx%d+%d+%d' % self.windowGeometry)
                    else:
                        options.append('-Xgeometry=%dx%d-%d+%d' % self.windowGeometry)
                except:
                    self.log.exception('Error calculating window placement')

            # - set number of columns of thumbnails to display
            options.append('-Xtile=%s' % self.tiles.value)
                    
            # Add address/port options (these must occur last; don't
            # add options beyond here)
            options.append( '%s/%d' % (self.streamDescription.location.host,
                                       self.streamDescription.location.port))

            # Create a socket, send some data out, and listen for incoming data
            try:
                host = self.streamDescription.location.host
                port = self.streamDescription.location.port
                timeout = 1
                s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
                s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
                if IsOSX():
                    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
                s.bind(('', port))
                s.sendto('qwe',(host,port))
                fdList = []
                while not fdList:
                    fdList = select.select([s.fileno()],[],[],timeout)
                s.close()
                s = None
            except:
                self.log.warn("Failed attempt to open firewall by sending data out on video port; continuing anyway")
                if s:
                    s.close()
                    s = None

            self.log.info("Starting VideoConsumerService")
            self.log.info(" executable = %s" % self.executable)
            self.log.info(" options = %s" % options)
            self._Start( options )
        except:
            self.log.exception("Exception in VideoConsumerService.Start")
            raise Exception("Failed to start service")
    def __init__(self):
        AGService.__init__(self)
        self.thepath = os.getcwd()
        self.windowGeometry = None

        self.capabilities = [
            Capability(Capability.CONSUMER, Capability.AUDIO, "L16", 16000,
                       self.id),
            Capability(Capability.CONSUMER, Capability.AUDIO, "L16", 8000,
                       self.id),
            Capability(Capability.CONSUMER, Capability.AUDIO, "L8", 16000,
                       self.id),
            Capability(Capability.CONSUMER, Capability.AUDIO, "L8", 8000,
                       self.id),
            Capability(Capability.CONSUMER, Capability.AUDIO, "PCMU", 16000,
                       self.id),
            Capability(Capability.CONSUMER, Capability.AUDIO, "PCMU", 8000,
                       self.id),
            Capability(Capability.CONSUMER, Capability.AUDIO, "GSM", 16000,
                       self.id),
            Capability(Capability.CONSUMER, Capability.AUDIO, "GSM", 8000,
                       self.id),
            Capability(Capability.PRODUCER, Capability.AUDIO, "L16", 16000,
                       self.id)
        ]

        if Platform.IsWindows():
            rat = "rat.exe"
            ratmedia = "ratmedia.exe"
            ratui = "rat-ui.exe"
            ratkill = "rat-kill.exe"
        else:
            rat = "rat"
            ratmedia = "ratmedia"
            ratui = "rat-ui"
            ratkill = "rat-kill"

        self.executable = os.path.join(os.getcwd(), rat)
        self.rat_media = os.path.join(os.getcwd(), ratmedia)
        self.rat_ui = os.path.join(os.getcwd(), ratui)
        self.rat_kill = os.path.join(os.getcwd(), ratkill)
        if not os.path.isfile(self.executable):
            self.executable = rat
            self.rat_media = ratmedia
            self.rat_ui = ratui
            self.rat_kill = ratkill
            # For some reason, a full path is need for ratkill
            for dir in os.getenv("PATH").split(":"):
                ratkill_fullpath = os.path.join(dir, ratkill)
                if os.access(ratkill_fullpath, os.X_OK):
                    self.rat_kill = ratkill_fullpath
                    break

        self.sysConf = SystemConfig.instance()

        # Set configuration parameters
        self.talk = OptionSetParameter("Talk", "Off", ["On", "Off"])
        self.inputGain = RangeParameter("Input Gain", 50, 0, 100)
        if Platform.isOSX():
            self.outputGain = RangeParameter("Output Gain", 4, 0, 100)
        else:
            self.outputGain = RangeParameter("Output Gain", 50, 0, 100)
        self.silenceSuppression = OptionSetParameter(
            "Silence Suppression", "Off", ["Off", "Automatic", "Manual"])

        self.positionWindow = OptionSetParameter(
            'Position Window', 'Off', ['Off', 'Justify Left', 'Justify Right'])

        self.configuration.append(self.talk)
        self.configuration.append(self.inputGain)
        self.configuration.append(self.outputGain)
        self.configuration.append(self.silenceSuppression)
        self.configuration.append(self.positionWindow)

        if Platform.isLinux() or Platform.isFreeBSD():
            # note: the forceOSSAC97 attribute will only exist for the above platforms
            self.forceOSSAC97 = OptionSetParameter("Force AC97", "False",
                                                   ["True", "False"])
            self.configuration.append(self.forceOSSAC97)

        self.useSiteId = OptionSetParameter("Use site id", "On", ["On", "Off"])
        self.configuration.append(self.useSiteId)

        self.profile = None
Пример #38
0
    def __init__( self ):
        AGService.__init__( self )
        self.thepath = os.getcwd()
        self.windowGeometry = None

        self.capabilities = [ Capability( Capability.CONSUMER,
                                          Capability.AUDIO,
                                          "L16",16000,self.id),
                              Capability( Capability.CONSUMER,
                                          Capability.AUDIO,
                                          "L16",8000,self.id),
                              Capability( Capability.CONSUMER,
                                          Capability.AUDIO,
                                          "L8",16000, self.id),
                              Capability( Capability.CONSUMER,
                                          Capability.AUDIO,
                                          "L8",8000, self.id),
                               Capability( Capability.CONSUMER,
                                          Capability.AUDIO,
                                           "PCMU", 16000, self.id),
                              Capability( Capability.CONSUMER,
                                          Capability.AUDIO,
                                          "PCMU",8000, self.id),
                              Capability( Capability.CONSUMER,
                                          Capability.AUDIO,
                                          "GSM",16000, self.id),
                              Capability( Capability.CONSUMER,
                                          Capability.AUDIO,
                                          "GSM",8000, self.id),
                              Capability( Capability.PRODUCER,
                                          Capability.AUDIO,
                                          "L16",16000, self.id)]
        
        if Platform.IsWindows():
            rat = "rat.exe"
            ratmedia = "ratmedia.exe"
            ratui = "rat-ui.exe"
            ratkill = "rat-kill.exe"
        else:
            rat = "rat"
            ratmedia = "ratmedia"
            ratui = "rat-ui"
            ratkill = "rat-kill"

        self.executable = os.path.join(os.getcwd(), rat)
        self.rat_media = os.path.join(os.getcwd(), ratmedia)
        self.rat_ui = os.path.join(os.getcwd(), ratui)
        self.rat_kill = os.path.join(os.getcwd(), ratkill)
        if not os.path.isfile(self.executable):
            self.executable = rat
            self.rat_media = ratmedia
            self.rat_ui = ratui
            self.rat_kill = ratkill
            # For some reason, a full path is need for ratkill
            for dir in os.getenv("PATH").split(":"):
                ratkill_fullpath = os.path.join(dir, ratkill)
                if os.access(ratkill_fullpath, os.X_OK):
                    self.rat_kill = ratkill_fullpath
                    break

        self.sysConf = SystemConfig.instance()

        # Set configuration parameters
        self.talk = OptionSetParameter( "Talk", "Off", ["On", "Off"] )
        self.inputGain = RangeParameter( "Input Gain", 50, 0, 100 )
        if Platform.isOSX():
            self.outputGain = RangeParameter( "Output Gain", 4, 0, 100 )
        else:
            self.outputGain = RangeParameter( "Output Gain", 50, 0, 100 )
        self.silenceSuppression = OptionSetParameter( "Silence Suppression", "Off", ["Off","Automatic","Manual"] )

        self.positionWindow = OptionSetParameter( 'Position Window', 'Off', ['Off', 'Justify Left', 'Justify Right'])

        self.configuration.append(self.talk)
        self.configuration.append(self.inputGain)
        self.configuration.append(self.outputGain)
        self.configuration.append(self.silenceSuppression)
        self.configuration.append(self.positionWindow)

        if Platform.isLinux() or Platform.isFreeBSD():
            # note: the forceOSSAC97 attribute will only exist for the above platforms
            self.forceOSSAC97 = OptionSetParameter( "Force AC97", "False", ["True", "False"] )
            self.configuration.append(self.forceOSSAC97)

        self.useSiteId = OptionSetParameter( "Use site id", "On", ["On", "Off"] )
        self.configuration.append(self.useSiteId)

        self.profile = None
Пример #39
0
    def Start( self ):
        """Start service"""
        try:

            # Set processor affinity (windows only)
            if IsWindows():
                try:
                    if self.processorUsage.value == 'All':
                        self.log.info('Setting processor affinity to all processors')
                        SystemConfig.instance().SetProcessorAffinity(self.allProcsMask)
                    else:
                        val = 2**(int(self.processorUsage.value)-1)
                        self.log.info('Ssetting processor affinity : use processor %s', self.processorUsage.value)
                        SystemConfig.instance().SetProcessorAffinity(int(self.processorUsage.value))
                except:
                    self.log.exception("Exception setting processor affinity")

            # Enable firewall
            self.sysConf.AppFirewallConfig(self.executable, 1)

            # Start the service; in this case, store command line args
            # in a list and let the superclass _Start the service
            options = []
            if self.streamDescription.name and \
                   len(self.streamDescription.name.strip()) > 0:
                options.append( "-C" )
                options.append( self.streamDescription.name )
            if self.streamDescription.encryptionFlag != 0:
                options.append( "-K" )
                options.append( self.streamDescription.encryptionKey )
            # Check whether the network location has a "type"
            # attribute Note: this condition is only to maintain
            # compatibility between older venue servers creating
            # network locations without this attribute and newer
            # services relying on the attribute; it should be removed
            # when the incompatibility is gone
            if self.streamDescription.location.__dict__.has_key("type"):
                if self.streamDescription.location.type == MulticastNetworkLocation.TYPE:
                    options.append( "-t" )
                    options.append( '%d' % ( self.streamDescription.location.ttl ) )

            # Set name and email on command line, in case rtp defaults
            # haven't been written (to avoid vic prompting for
            # name/email)
            name=email="Participant"
            if self.profile:
                name = self.profile.name
                email = self.profile.email
            options.append('-XrtpName=%s' % (name,))
            options.append('-XrtpEmail=%s' % (email,))

            # Set some tk resources to customize vic
            # - this is a consumer, so disable device selection in vic
            options.append('-XrecvOnly=1')
            # - set drop time to something reasonable
            options.append('-XsiteDropTime=5')

            if not self.positionWindow.value == 'Off':
                # - set vic window geometry
                try:
                    
                    if not self.windowGeometry:
                        h = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)
                        w_sys = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X)
                        try:
                            w = GetScreenWidth(w_sys,h)
                        except ValueError:
                            self.log.debug('Error computing screen width; using system screen width %d', w_sys)
                            w = w_sys
                        window_width = w-300
                        window_height = 300
                        window_x = 300
                        window_y = h-375
                        border_w = wx.SystemSettings_GetMetric(wx.SYS_FRAMESIZE_X)
                        if border_w > 0:
                            window_width -= 4*border_w
                            window_x += 2*border_w
                        self.windowGeometry = (window_width,window_height,window_x,window_y)
                    if self.positionWindow.value == 'Justify Left':
                        options.append('-Xgeometry=%dx%d+%d+%d' % self.windowGeometry)
                    else:
                        options.append('-Xgeometry=%dx%d-%d+%d' % self.windowGeometry)
                except:
                    self.log.exception('Error calculating window placement')

            # - set number of columns of thumbnails to display
            options.append('-Xtile=%s' % self.tiles.value)
                    
            # Add address/port options (these must occur last; don't
            # add options beyond here)
            options.append( '%s/%d' % (self.streamDescription.location.host,
                                       self.streamDescription.location.port))

            # Create a socket, send some data out, and listen for incoming data
            try:
                host = self.streamDescription.location.host
                port = self.streamDescription.location.port
                timeout = 1
                s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
                s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
                if IsOSX():
                    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
                s.bind(('', port))
                s.sendto('qwe',(host,port))
                fdList = []
                while not fdList:
                    fdList = select.select([s.fileno()],[],[],timeout)
                s.close()
                s = None
            except:
                self.log.warn("Failed attempt to open firewall by sending data out on video port; continuing anyway")
                if s:
                    s.close()
                    s = None

            self.log.info("Starting VideoConsumerServiceH264")
            self.log.info(" executable = %s" % self.executable)
            self.log.info(" options = %s" % options)
            self._Start( options )
        except:
            self.log.exception("Exception in VideoConsumerServiceH264.Start")
            raise Exception("Failed to start service")
Пример #40
0
 def testGetResources(self):
     resources = SystemConfig.instance().GetResources()
     assert type(resources) == type([])
Пример #41
0
    def __init__( self ):
        AGService.__init__( self )

        if IsWindows():
            vic = "vic.exe"
        else:
            vic = "vic"

        self.executable = os.path.join(os.getcwd(),vic)
        if not os.path.isfile(self.executable):
            self.executable = vic

        proc = subprocess.Popen([self.executable, '-Q'],
                                stdin=subprocess.PIPE,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)
        deviceDOM = xml.dom.minidom.parse(proc.stdout)

        self.capabilities = []
        codecs = deviceDOM.getElementsByTagName("codec")
        for codec in codecs:
            if codec.childNodes[0].nodeType == xml.dom.minidom.Node.TEXT_NODE:
                if codec.childNodes[0].data in ['h263', 'h263+', 'raw', 'pvh']:
                    continue
                self.capabilities.append(Capability( Capability.CONSUMER,
                                          Capability.VIDEO,
                                          codec.childNodes[0].data.upper(),
                                          90000, self.id))
        deviceDOM.unlink()

        self.sysConf = SystemConfig.instance()

        self.profile = None
        self.windowGeometry = None

        self.startPriority = '7'
        self.startPriorityOption.value = self.startPriority

        # Set configuration parameters
        self.tiles = OptionSetParameter( "Thumbnail Columns", "4", VideoConsumerServiceH264.tileOptions )
        self.positionWindow = OptionSetParameter( 'Position Window', 'Justify Left', ['Off', 'Justify Left', 'Justify Right'])
        
        self.configuration.append( self.tiles )
        self.configuration.append( self.positionWindow)

        if IsWindows():
            try:
                import win32api

                # get number of processors
                systemInfo = win32api.GetSystemInfo()
                numprocs = systemInfo[5]
                self.allProcsMask = 2**numprocs-1

                self.procOptions = ['All']
                for i in range(numprocs):
                    self.procOptions.append(str(i+1))

                self.processorUsage = OptionSetParameter( "Processor usage", self.procOptions[0], self.procOptions )
                self.configuration.append( self.processorUsage )
            except:
                self.log.exception('Error initializing processor usage options')
Пример #42
0
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()
        except: pass
        dialog = MessageDialog(None, str(result), title, style = wx.OK | wx.ICON_INFORMATION)
    else:
        print str(result)
Пример #43
0
 def testGetTempDir(self):
     tempDir = SystemConfig.instance().GetTempDir()
     assert tempDir != "" and tempDir is not None, 'empty temp dir'
     assert os.path.isdir(tempDir), 'temp dir does not exist'
Пример #44
0
 def testGetProxySettings(self):
     SystemConfig.instance().GetProxySettings()
Пример #45
0
 def testGetProxySettings(self):
     SystemConfig.instance().GetProxySettings()
    def Start(self):
        """
        Start service
        """
        try:
            # Set processor affinity (windows only)
            if IsWindows():
                try:
                    if self.processorUsage.value == 'All':
                        self.log.info(
                            'Setting processor affinity to all processors')
                        SystemConfig.instance().SetProcessorAffinity(
                            self.allProcsMask)
                    else:
                        val = 2**(int(self.processorUsage.value) - 1)
                        self.log.info(
                            'Ssetting processor affinity : use processor %s',
                            self.processorUsage.value)
                        SystemConfig.instance().SetProcessorAffinity(
                            int(self.processorUsage.value))
                except:
                    self.log.exception("Exception setting processor affinity")

            # Enable firewall
            self.sysConf.AppFirewallConfig(self.executable, 1)

            # Resolve assigned resource to a device understood by vic
            if self.resource == "None":
                vicDevice = "None"
            else:
                vicDevice = self.resource[0]
                vicDevice = vicDevice.replace("[", "\[")
                vicDevice = vicDevice.replace("]", "\]")

            if IsWindows():
                try:
                    self.MapWinDevice(self.resource[0])
                except:
                    self.log.exception("Exception mapping device")

            #
            # Write vic startup file
            #
            startupfile = os.path.join(UserConfig.instance().GetTempDir(),
                                       'VideoServiceH264_%s.vic' % self.id)

            f = open(startupfile, "w")
            if self.port.value == '':
                portstr = "None"
            else:
                portstr = self.port.value

            if self.standard.value == '':
                standardstr = "None"
            else:
                standardstr = self.standard.value

            if self.muteSources.value == "On":
                # streams are muted, so disable autoplace
                disableAutoplace = "true"
            else:
                # streams are not muted, so don't disable autoplace
                # (flags should not be negative!)
                disableAutoplace = "false"

            if self.inputsize.value == "Small":
                inputsize = 4
            elif self.inputsize.value == "Large" and self.encoding.value != "h261":
                inputsize = 1
            else:
                inputsize = 2

            if self.resolution != None:
                resolution = self.resolution.value
            else:
                resolution = "none"

            name = email = "Participant"
            if self.profile:
                name = self.profile.name
                email = self.profile.email
            else:
                # Error case
                name = email = Toolkit.GetDefaultSubject().GetCN()
                self.log.error("Starting service without profile set")

            f.write(
                vicstartup %
                (disableAutoplace, OnOff(self.muteSources.value),
                 self.bandwidth.value, self.framerate.value,
                 self.quality.value, self.encoding.value, standardstr,
                 vicDevice, "%s(%s)" % (name, self.streamname.value), email,
                 OnOff(self.encodingDeinterlacer.value), resolution, email,
                 OnOff(
                     self.transmitOnStart.value), portstr, portstr, inputsize))
            f.close()

            # Open permissions on vic startupfile
            os.chmod(startupfile, 0777)

            # Replace double backslashes in the startupfile name with single
            #  forward slashes (vic will crash otherwise)
            if IsWindows():
                startupfile = startupfile.replace("\\", "/")

            #
            # Start the service; in this case, store command line args in a list and let
            # the superclass _Start the service
            options = []
            options.append("-u")
            options.append(startupfile)
            options.append("-C")
            options.append(str(self.streamDescription.name))
            if IsOSX():
                if self.transmitOnStart.value:
                    options.append("-X")
                    options.append("transmitOnStartup=1")
            if self.streamDescription.encryptionFlag != 0:
                options.append("-K")
                options.append(self.streamDescription.encryptionKey)

            # Set drop time to something reasonable
            options.append('-XsiteDropTime=5')

            if not self.positionWindow.value == 'Off':
                # - set vic window geometry
                try:

                    if not self.windowGeometry:
                        h = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)
                        w_sys = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X)
                        try:
                            w = GetScreenWidth(w_sys, h)
                        except ValueError:
                            self.log.debug(
                                'Error computing screen width; using system screen width %d',
                                w_sys)
                            w = w_sys
                        window_width = w - 300
                        window_height = 300
                        window_x = 300
                        window_y = h - 375
                        border_w = wx.SystemSettings_GetMetric(
                            wx.SYS_FRAMESIZE_X)
                        if border_w > 0:
                            window_width -= 4 * border_w
                            window_x += 2 * border_w
                        self.windowGeometry = (window_width, window_height,
                                               window_x, window_y)
                    if self.positionWindow.value == 'Justify Left':
                        options.append('-Xgeometry=%dx%d+%d+%d' %
                                       self.windowGeometry)
                    else:
                        options.append('-Xgeometry=%dx%d-%d+%d' %
                                       self.windowGeometry)
                except:
                    self.log.exception('Error calculating window placement')

            if self.profile:
                options.append("-X")
                options.append("site=%s" % self.profile.publicId)

            # Set number of columns to use for thumbnail display
            options.append("-Xtile=%s" % self.tiles.value)

            # Check whether the network location has a "type" attribute
            # Note: this condition is only to maintain compatibility between
            # older venue servers creating network locations without this attribute
            # and newer services relying on the attribute; it should be removed
            # when the incompatibility is gone
            if self.streamDescription.location.__dict__.has_key("type"):
                # use TTL from multicast locations only
                if self.streamDescription.location.type == MulticastNetworkLocation.TYPE:
                    options.append("-t")
                    options.append('%d' %
                                   (self.streamDescription.location.ttl))
            options.append('%s/%d' % (self.streamDescription.location.host,
                                      self.streamDescription.location.port))

            self.log.info("Starting VideoServiceH264")
            self.log.info(" executable = %s" % self.executable)
            self.log.info(" options = %s" % options)
            os.chdir(self.thepath)
            self._Start(options)
            #os.remove(startupfile)
        except:
            self.log.exception("Exception in VideoServiceH264.Start")
            raise Exception("Failed to start service")
Пример #47
0
 def testUsername(self):
     username = SystemConfig.instance().GetUsername()
     assert len(username) > 0
    def __init__(self):
        AGService.__init__(self)
        self.thepath = os.getcwd()

        if IsWindows():
            vic = "vic.exe"
        else:
            vic = "vic"

        self.executable = os.path.join(os.getcwd(), vic)
        if not os.path.isfile(self.executable):
            self.executable = vic

        proc = subprocess.Popen([self.executable, '-Q'],
                                stdin=subprocess.PIPE,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)
        self.deviceDOM = xml.dom.minidom.parse(proc.stdout)

        self.encodingOptions = []
        self.capabilities = []
        codecs = self.deviceDOM.getElementsByTagName("codec")
        for codec in codecs:
            if codec.childNodes[0].nodeType == xml.dom.minidom.Node.TEXT_NODE:
                if codec.childNodes[0].data in ['h263', 'h263+', 'raw', 'pvh']:
                    continue
                self.encodingOptions.append(codec.childNodes[0].data)
                self.capabilities.append(
                    Capability(Capability.CONSUMER, Capability.VIDEO,
                               codec.childNodes[0].data.upper(), 90000,
                               self.id))

                self.capabilities.append(
                    Capability(Capability.PRODUCER, Capability.VIDEO,
                               codec.childNodes[0].data.upper(), 90000,
                               self.id))

        self.sysConf = SystemConfig.instance()

        self.profile = None
        self.windowGeometry = None

        self.startPriority = '7'
        self.startPriorityOption.value = self.startPriority
        self.id = str(GUID())

        self.resolution = None

        # Set configuration parameters
        # note: the datatype of the port, standard and inputsize parameters change when a resource is set!
        self.streamname = TextParameter("Stream Name", "")
        self.port = TextParameter("port", "")
        self.encoding = OptionSetParameter("Encoding", "mpeg4",
                                           self.encodingOptions)
        self.standard = TextParameter("standard", "")
        self.tiles = OptionSetParameter("Thumbnail Columns", "4",
                                        VideoServiceH264.tileOptions)
        self.bandwidth = RangeParameter("Bandwidth", 2500, 0, 10240)
        self.framerate = RangeParameter("Frame Rate", 24, 1, 30)
        self.quality = RangeParameter("Quality", 75, 1, 100)
        self.transmitOnStart = OptionSetParameter(
            "Transmit on Startup", "On", VideoServiceH264.onOffOptions)
        self.muteSources = OptionSetParameter("Mute Sources", "Off",
                                              VideoServiceH264.onOffOptions)
        self.inputsize = TextParameter("inputsize", "")
        self.positionWindow = OptionSetParameter(
            'Position Window', 'Justify Left',
            ['Off', 'Justify Left', 'Justify Right'])
        self.encodingDeinterlacer = OptionSetParameter(
            "Encoding Deinterlacer", "Off", VideoServiceH264.onOffOptions)

        self.configuration.append(self.streamname)
        self.configuration.append(self.port)
        self.configuration.append(self.encoding)
        self.configuration.append(self.standard)
        self.configuration.append(self.tiles)
        self.configuration.append(self.bandwidth)
        self.configuration.append(self.framerate)
        self.configuration.append(self.quality)
        self.configuration.append(self.transmitOnStart)
        self.configuration.append(self.muteSources)
        self.configuration.append(self.inputsize)

        self.configuration.append(self.positionWindow)
        self.configuration.append(self.encodingDeinterlacer)
        if IsWindows():
            try:
                import win32api

                # get number of processors
                systemInfo = win32api.GetSystemInfo()
                numprocs = systemInfo[5]
                self.allProcsMask = 2**numprocs - 1

                self.procOptions = ['All']
                for i in range(numprocs):
                    self.procOptions.append(str(i + 1))

                self.processorUsage = OptionSetParameter(
                    "Processor usage", self.procOptions[0], self.procOptions)
                self.configuration.append(self.processorUsage)
            except:
                self.log.exception(
                    'Error initializing processor usage options')

        self.__GetResources()
        self.deviceDOM.unlink()
Пример #49
0
 def testGetResources(self):
     resources = SystemConfig.instance().GetResources()
     assert type(resources) == type([])
def WriteNodeConfig(configName, config):
    """
    Writes the given node config to the given node config name

    A 'config' is a dictionary

        keys:   service manager urls
        values: [ [servicename, resource name, serviceconfig], ... ]

        serviceconfig should be a list of name,value pairs
    """
    userNodeConfigDir = UserConfig.instance().GetNodeConfigDir()
    fileName = os.path.join(userNodeConfigDir, configName)
    hostname = SystemConfig.instance().GetHostname()

    # Catch inability to write config file
    if ((not os.path.exists(userNodeConfigDir))
            or (not os.access(userNodeConfigDir, os.W_OK)) or
        (os.path.exists(fileName) and not os.access(fileName, os.W_OK))):
        log.exception("Can't write config file %s" % (fileName))
        raise IOError(errno.EACCES, "Can't write config file %s" % (fileName))

    numServiceManagers = 0
    numServices = 0
    node_servicemanagers = ''

    configParser = ConfigParser.ConfigParser()
    configParser.optionxform = str
    for key in config.keys():

        builtin = 0
        url = key
        name = url

        servicemanager_services = ''

        #
        # Create Service Manager section
        #
        serviceManagerSection = 'servicemanager%d' % numServiceManagers
        configParser.add_section(serviceManagerSection)
        node_servicemanagers += serviceManagerSection + " "
        if url.find(hostname) >= 0:
            builtin = 1
        else:
            builtin = 0
        configParser.set(serviceManagerSection, 'builtin', builtin)
        if builtin:
            configParser.set(serviceManagerSection, "name", '')
            configParser.set(serviceManagerSection, "url", '')
        else:
            configParser.set(serviceManagerSection, "name", name)
            configParser.set(serviceManagerSection, "url", url)

        services = config[key]

        if not services:
            services = []

        for service in services:

            serviceName, resourceName, serviceConfig = service

            serviceSection = 'service%d' % numServices
            configParser.add_section(serviceSection)

            #
            # Create Resource section
            #

            if resourceName:
                log.debug('Storing resource: %s', resourceName)
                resourceSection = 'resource%d' % numServices
                configParser.add_section(resourceSection)
                configParser.set(resourceSection, "name", resourceName)
                configParser.set(serviceSection, "resource", resourceSection)
            else:
                log.debug('No resource specified')

            #
            # Create Service Config section
            #

            if serviceConfig:
                serviceConfigSection = 'serviceconfig%d' % numServices
                configParser.set(serviceSection, "serviceConfig",
                                 serviceConfigSection)
                configParser.add_section(serviceConfigSection)
                for k, v in serviceConfig:
                    configParser.set(serviceConfigSection, k, v)

            #
            # Create Service section
            #
            servicemanager_services += serviceSection + " "
            configParser.set(serviceSection, "packageName", serviceName)

            numServices += 1

        configParser.set(serviceManagerSection, "services",
                         servicemanager_services)
        numServiceManagers += 1

    configParser.add_section('node')
    configParser.set('node', "servicemanagers", node_servicemanagers)

    #
    # Write config file
    #
    fp = open(fileName, "w")
    fp.write("# AGTk %s node configuration\n" % (Version.GetVersion()))
    configParser.write(fp)
    fp.close()
   def GetHeight(self):
      return self.proxy.GetHeight()

   def GetDepth(self):
      return self.proxy.GetDepth()
   
if __name__ == '__main__':
   from AccessGrid.Toolkit import CmdlineApplication
   import pprint
   
   # Do env init
   app = CmdlineApplication()
   app.Initialize("DisplayServiceTest")
   
   # Create a local hosting environment
   hn = SystemConfig.instance().GetHostname()
   hn = 'localhost'
   server = Server((hn, int(sys.argv[1])))

   # Create the display service
   dispService = DisplayService()

   # Then it's interface
   dispServiceI = DisplayServiceI(dispService)

   # Then register the display service with the hosting environment
   service = server.RegisterObject(dispServiceI, path = "/DisplayService")

   # Get the url and print it
   url = server.FindURLForObject(dispService)
   print "Starting server at", url
Пример #52
0
 def testGetHostname(self):
     SystemConfig.instance().GetHostname()
Пример #53
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
Пример #54
0
 def __GetResources(self):
     self.resources = SystemConfig.instance().GetResources()
     return self.resources
Пример #55
0
    def __init__( self ):
        AGService.__init__( self )
        self.thepath = os.getcwd()

        if IsWindows():
            vic = "vic.exe"
        else:
            vic = "vic"

        self.executable = os.path.join(os.getcwd(),vic)
        if not os.path.isfile(self.executable):
            self.executable = vic

        proc = subprocess.Popen([self.executable, '-Q'],
                                stdin=subprocess.PIPE,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)
        self.deviceDOM = xml.dom.minidom.parse(proc.stdout)

        self.encodingOptions = []
        self.capabilities = []
        codecs = self.deviceDOM.getElementsByTagName("codec")
        for codec in codecs:
            if codec.childNodes[0].nodeType == xml.dom.minidom.Node.TEXT_NODE:
                if codec.childNodes[0].data in ['h263', 'h263+', 'raw', 'pvh']:
                    continue
                self.encodingOptions.append(codec.childNodes[0].data)
                self.capabilities.append(Capability( Capability.CONSUMER,
                                          Capability.VIDEO,
                                          codec.childNodes[0].data.upper(),
                                          90000, self.id))

                self.capabilities.append(Capability( Capability.PRODUCER,
                                          Capability.VIDEO,
                                          codec.childNodes[0].data.upper(),
                                          90000, self.id))

        self.sysConf = SystemConfig.instance()

        self.profile = None
        self.windowGeometry = None

        self.startPriority = '7'
        self.startPriorityOption.value = self.startPriority
        self.id = str(GUID())

        self.resolution = None

        # Set configuration parameters
        # note: the datatype of the port, standard and inputsize parameters change when a resource is set!
        self.streamname = TextParameter( "Stream Name", "" )
        self.port = TextParameter( "port", "" )
        self.encoding = OptionSetParameter( "Encoding", "mpeg4", self.encodingOptions )
        self.standard = TextParameter( "standard", "" )
        self.tiles = OptionSetParameter( "Thumbnail Columns", "4", VideoServiceH264.tileOptions )
        self.bandwidth = RangeParameter( "Bandwidth", 2500, 0, 10240 )
        self.framerate = RangeParameter( "Frame Rate", 24, 1, 30 )
        self.quality = RangeParameter( "Quality", 75, 1, 100 )
        self.transmitOnStart = OptionSetParameter( "Transmit on Startup", "On", VideoServiceH264.onOffOptions )
        self.muteSources = OptionSetParameter( "Mute Sources", "Off", VideoServiceH264.onOffOptions )
        self.inputsize = TextParameter( "inputsize", "" )
        self.positionWindow = OptionSetParameter( 'Position Window', 'Justify Left', ['Off', 'Justify Left', 'Justify Right'])
        self.encodingDeinterlacer = OptionSetParameter( "Encoding Deinterlacer", "Off", VideoServiceH264.onOffOptions )

        self.configuration.append( self.streamname )
        self.configuration.append( self.port )
        self.configuration.append( self.encoding )
        self.configuration.append( self.standard )
        self.configuration.append( self.tiles )
        self.configuration.append( self.bandwidth )
        self.configuration.append( self.framerate )
        self.configuration.append( self.quality )
        self.configuration.append( self.transmitOnStart )
        self.configuration.append( self.muteSources )
        self.configuration.append( self.inputsize )

        self.configuration.append( self.positionWindow )
        self.configuration.append( self.encodingDeinterlacer )
        if IsWindows():
            try:
                import win32api

                # get number of processors
                systemInfo = win32api.GetSystemInfo()
                numprocs = systemInfo[5]
                self.allProcsMask = 2**numprocs-1

                self.procOptions = ['All']
                for i in range(numprocs):
                    self.procOptions.append(str(i+1))

                self.processorUsage = OptionSetParameter( "Processor usage", self.procOptions[0], self.procOptions )
                self.configuration.append( self.processorUsage )
            except:
                self.log.exception('Error initializing processor usage options')

        self.__GetResources()
        self.deviceDOM.unlink()
Пример #56
0
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()
        except:
            pass