def __SetRTPDefaults(self, profile):
        """
        Set values used by rat for identification
        """
        if profile == None:
            self.log.exception("Invalid profile (None)")
            raise Exception, "Can't set RTP Defaults without a valid profile."

        if Platform.isLinux() or Platform.isFreeBSD() or Platform.isOSX():
            try:
                rtpDefaultsFile = os.path.join(os.environ["HOME"],
                                               ".RTPdefaults")
                rtpDefaultsText = "*rtpName: %s\n*rtpEmail: %s\n*rtpLoc: %s\n*rtpPhone: \
                                 %s\n*rtpNote: %s\n"

                rtpDefaultsFH = open(rtpDefaultsFile, "w")
                rtpDefaultsFH.write(
                    rtpDefaultsText %
                    (profile.name, profile.email, profile.location,
                     profile.phoneNumber, profile.publicId))
                rtpDefaultsFH.close()
            except:
                self.log.exception("Error writing RTP defaults file: %s",
                                   rtpDefaultsFile)

        elif Platform.isWindows():
            try:
                # Set RTP defaults according to the profile
                k = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER,
                                      r"Software\Mbone Applications\common")

                # Rat reads these (without '*')
                _winreg.SetValueEx(k, "rtpName", 0, _winreg.REG_SZ,
                                   profile.name)
                _winreg.SetValueEx(k, "rtpEmail", 0, _winreg.REG_SZ,
                                   profile.email)
                _winreg.SetValueEx(k, "rtpPhone", 0, _winreg.REG_SZ,
                                   profile.phoneNumber)
                _winreg.SetValueEx(k, "rtpLoc", 0, _winreg.REG_SZ,
                                   profile.location)
                _winreg.SetValueEx(k, "rtpNote", 0, _winreg.REG_SZ,
                                   str(profile.publicId))
                _winreg.CloseKey(k)
            except:
                self.log.exception("Error writing RTP defaults to registry")
Пример #2
0
    def __SetRTPDefaults(self, profile):
        """
        Set values used by rat for identification
        """
        if profile == None:
            self.log.exception("Invalid profile (None)")
            raise Exception, "Can't set RTP Defaults without a valid profile."

        if Platform.isLinux() or Platform.isFreeBSD() or Platform.isOSX():
            try:
                rtpDefaultsFile=os.path.join(os.environ["HOME"], ".RTPdefaults")
                rtpDefaultsText="*rtpName: %s\n*rtpEmail: %s\n*rtpLoc: %s\n*rtpPhone: \
                                 %s\n*rtpNote: %s\n"
                rtpDefaultsFH=open( rtpDefaultsFile,"w")
                rtpDefaultsFH.write( rtpDefaultsText % ( profile.name,
                                       profile.email,
                                       profile.location,
                                       profile.phoneNumber,
                                       profile.publicId ) )
                rtpDefaultsFH.close()
            except:
                self.log.exception("Error writing RTP defaults file: %s", rtpDefaultsFile)

        elif Platform.isWindows():
            try:
                # Set RTP defaults according to the profile
                k = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER,
                                    r"Software\Mbone Applications\common")

                # Rat reads these (without '*')
                _winreg.SetValueEx(k, "rtpName", 0,
                                   _winreg.REG_SZ, profile.name)
                _winreg.SetValueEx(k, "rtpEmail", 0,
                                   _winreg.REG_SZ, profile.email)
                _winreg.SetValueEx(k, "rtpPhone", 0,
                                   _winreg.REG_SZ, profile.phoneNumber)
                _winreg.SetValueEx(k, "rtpLoc", 0,
                                   _winreg.REG_SZ, profile.location)
                _winreg.SetValueEx(k, "rtpNote", 0,
                                   _winreg.REG_SZ, str(profile.publicId) )
                _winreg.CloseKey(k)
            except:
                self.log.exception("Error writing RTP defaults to registry")
Пример #3
0
 def testIWindows(self):
     Platform.isWindows()
    def WriteRatDefaults(self):
        if Platform.isWindows():
            # Write defaults into registry
            try:
                key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER,
                                        "Software\\Mbone Applications\\rat")
                if self.talk.value == "On":
                    mute = 0
                else:
                    mute = 1

                _winreg.SetValueEx(key, "audioInputMute", 0, _winreg.REG_DWORD,
                                   mute)
                _winreg.SetValueEx(key, "audioInputGain", 0, _winreg.REG_DWORD,
                                   self.inputGain.value)
                _winreg.SetValueEx(key, "audioOutputGain", 0,
                                   _winreg.REG_DWORD, self.outputGain.value)
                _winreg.SetValueEx(key, "audioSilence", 0, _winreg.REG_SZ,
                                   self.silenceSuppression.value)

                _winreg.CloseKey(key)
            except:
                self.log.exception("Couldn't put rat defaults in registry.")

        elif Platform.isLinux() or Platform.isOSX() or Platform.isFreeBSD():

            ratDefaultsFile = os.path.join(os.environ["HOME"], ".RATdefaults")
            ratDefaults = dict()

            # Read file first, to preserve settings therein
            if os.access(ratDefaultsFile, os.R_OK):
                f = open(ratDefaultsFile, "r")
                lines = f.readlines()
                for line in lines:
                    line = line.strip()
                    if line:
                        try:
                            k, v = line.split(':', 1)
                            ratDefaults[k] = v
                        except:
                            self.log.exception(
                                'Error processing rat defaults line: %s', line)
                f.close()

            # Update settings
            if self.talk.value == "On":
                mute = 0
            else:
                mute = 1

            ratDefaults["*audioInputMute"] = str(mute)
            ratDefaults["*audioInputGain"] = str(self.inputGain.value)
            ratDefaults["*audioOutputGain"] = str(self.outputGain.value)
            ratDefaults["*audioSilence"] = str(self.silenceSuppression.value)

            # Write file with these settings
            f = open(ratDefaultsFile, "w")
            for k, v in ratDefaults.items():
                f.write("%s: %s\n" % (k, v))
            f.close()

        else:
            raise Exception("Unknown platform: %s" % sys.platform)
Пример #5
0
 def testIWindows(self):
     Platform.isWindows()
Пример #6
0
    def WriteRatDefaults(self):
        if Platform.isWindows():
            # Write defaults into registry
            try:
                key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER,
                                        "Software\\Mbone Applications\\rat")
                if self.talk.value == "On":
                    mute = 0
                else:
                    mute = 1
                    
                _winreg.SetValueEx(key, "audioInputMute", 0, _winreg.REG_DWORD,
                                   mute)
                _winreg.SetValueEx(key, "audioInputGain", 0, _winreg.REG_DWORD,
                                   self.inputGain.value )
                _winreg.SetValueEx(key, "audioOutputGain", 0,
                                   _winreg.REG_DWORD, self.outputGain.value )
                _winreg.SetValueEx(key, "audioSilence", 0,
                                   _winreg.REG_SZ, self.silenceSuppression.value )

                _winreg.CloseKey(key)
            except:
                self.log.exception("Couldn't put rat defaults in registry.")

        elif Platform.isLinux() or Platform.isOSX() or Platform.isFreeBSD():

            ratDefaultsFile = os.path.join(os.environ["HOME"],".RATdefaults")
            ratDefaults = dict()

            # Read file first, to preserve settings therein
            if os.access(ratDefaultsFile, os.R_OK):
                f = open(ratDefaultsFile,"r")
                lines = f.readlines()
                for line in lines:
                    line = line.strip()
                    if line:
                        try:
                            k,v = line.split(':',1)
                            ratDefaults[k] = v
                        except:
                            self.log.exception('Error processing rat defaults line: %s', line)
                f.close()

            # Update settings
            if self.talk.value == "On":
                mute = 0
            else:
                mute = 1

            ratDefaults["*audioInputMute"] = str(mute)
            ratDefaults["*audioInputGain"] = str(self.inputGain.value )
            ratDefaults["*audioOutputGain"] = str(self.outputGain.value )
            ratDefaults["*audioSilence"] = str(self.silenceSuppression.value )

            # Write file with these settings
            f = open(ratDefaultsFile, "w")
            for k,v in ratDefaults.items():
                f.write("%s: %s\n" % (k,v) )
            f.close()

        else:
            raise Exception("Unknown platform: %s" % sys.platform)