def RemoveSubject(self, subject): """ This method removes the specified subject from the role. @param subject: the subject to be removed. @type subject: AccessGrid.Security.Subject object @raises InvalidSubject: when the subject passed in not a subclass of the AccessGrid.Security.Subject base class. """ if not isinstance(subject, Subject): raise InvalidSubject if Toolkit.GetDefaultSubject() == subject and self.requireDefaultId: raise DefaultIdentityNotRemovable(subject) if subject not in self.subjects: raise InvalidSubject("Subject %s does not exist in role %s" % (subject.name, self.name)) self.subjects.remove(subject)
def Start(self): """Start service""" try: # Enable firewall self.sysConf.AppFirewallConfig(self.executable, 1) # Resolve assigned resource to a device understood by vic print "self.resource = ", type(self.resource), self.resource print "res = ", self.resource.resource if self.resource == "None": vicDevice = "None" else: vicDevice = self.resource.resource if IsLinux() and vicDevice.startswith('/dev/video'): # Translate vic device name to a name understood # by openmash (linux only) vicDeviceNum = vicDevice[-1] vicDevice = 'VideoCapture/V4l' + vicDeviceNum vicDevice = vicDevice.replace("[", "\[") vicDevice = vicDevice.replace("]", "\]") if IsWindows(): try: self.MapWinDevice(self.resource.resource) except: self.log.exception("Exception mapping device") # # Write vic startup file # startupfile = os.path.join( UserConfig.instance().GetTempDir(), 'VideoProducerService_%d.vic' % (os.getpid())) 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") # 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("headlessVideo.mash") #options.append( "-u" ) #options.append( startupfile ) #options.append( "-C" ) #options.append( '"' + self.streamname.value + '"' ) 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"): # 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('-F') options.append(self.framerate.value) options.append('-bps') options.append(self.bandwidth.value) options.append('-q') options.append(self.quality.value) options.append('-f') options.append(self.encoding.value) #options.append(' '); options.append(self.standard.value) #options.append('-D'); options.append(vicDevice) options.append('-D') options.append('VideoCapture/Test') options.append('-p') options.append('blue_passion') #options.append('-p'); options.append(portstr) options.append('-name') options.append("%s(%s)" % (name, self.streamname.value)) options.append('-email') options.append(email) options.append('-omft') options.append(self.standard.value) # Address/port is last option 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")
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")
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")