コード例 #1
0
    def onEncrypt(self, checked=False):
        if self.lastDirectory is None:
            return

        self.edit.setPlainText('')
        self.edit.insertPlainText('Encrypting ini files\n')
        self.edit.insertPlainText('------------------------------\n')
        for root, dirs, files in os.walk(self.lastDirectory):
            self.edit.insertPlainText('Enter directory: %s\n' % root)
            for name in files:
                myName, ext = os.path.splitext(name)
                if ext.lower() != '.ini': continue
                if not myName.endswith(self.Magic): continue

                fileName = os.path.join(root, name)
                with open(fileName, 'r') as fp:
                    data = fp.read()
                    try:
                        data = PokerStarsIniDecrypter.encryptString(data)
                    except PokerStarsIniDecrypter.Error, d:
                        self.edit.insertPlainText(
                            'Error: could not encrypt: %s\n' % name)
                        continue

                myName = myName[:len(myName) - len(self.Magic)] + ext
                fileName = os.path.join(root, myName)
                with open(fileName, 'wb') as fp:
                    fp.write(data)
                self.edit.insertPlainText('Encrypted: %s --> %s\n' %
                                          (name, myName))
コード例 #2
0
	def onEncrypt(self, checked=False):
		if self.lastDirectory is None:
			return

		self.edit.setPlainText('')
		self.edit.insertPlainText('Encrypting ini files\n')
		self.edit.insertPlainText('------------------------------\n')
		for root, dirs, files in os.walk(self.lastDirectory):
			self.edit.insertPlainText('Enter directory: %s\n' % root)
			for name in files:
				myName, ext = os.path.splitext(name)
				if ext.lower() != '.ini': continue
				if not myName.endswith(self.Magic): continue

				fileName = os.path.join(root, name)
				with open(fileName, 'r') as fp:
					data = fp.read()
					try:
						data = PokerStarsIniDecrypter.encryptString(data)
					except PokerStarsIniDecrypter.Error, d:
						self.edit.insertPlainText('Error: could not encrypt: %s\n' % name)
						continue

				myName = myName[:len(myName)-len(self.Magic)] + ext
				fileName = os.path.join(root, myName)
				with open(fileName, 'wb') as fp:
					fp.write(data)
				self.edit.insertPlainText('Encrypted: %s --> %s\n' % (name, myName) )
コード例 #3
0
    def onDecrypt(self, checked):

        dlg = QtGui.QFileDialog(self)
        dlg.setWindowTitle('Chosse directory to decrypt ini files..')
        dlg.setFileMode(dlg.Directory)
        dlg.restoreState(
            Tc2Config.settingsValue(self.SettingsKeyDialogDecryptState,
                                    QtCore.QByteArray()).toByteArray())
        if dlg.exec_() == dlg.Rejected:
            return
        Tc2Config.settingsSetValue(self.SettingsKeyDialogDecryptState,
                                   dlg.saveState())
        directory = dlg.directory().canonicalPath()
        directory = directory.toUtf8()
        directory = unicode(directory, 'utf-8')

        self.edit.setPlainText('')
        self.edit.insertPlainText('Decrypting ini files\n')
        self.edit.insertPlainText('------------------------------\n')
        for root, dirs, files in os.walk(directory):
            self.edit.insertPlainText('Enter directory: %s\n' % root)
            for name in files:
                myName, ext = os.path.splitext(name)
                if ext.lower() != '.ini': continue
                if myName.endswith(self.Magic): continue

                fileName = os.path.join(root, name)
                with open(fileName, 'rb') as fp:
                    data = fp.read()
                    try:
                        data = PokerStarsIniDecrypter.decryptString(data)
                    except PokerStarsIniDecrypter.Error, d:
                        self.edit.insertPlainText(
                            'Error: could not decrypt: %s\n' % name)
                        continue

                print '\r\n' in data
                myName = myName + self.Magic + ext
                fileName = os.path.join(root, myName)
                with open(fileName, 'wb') as fp:
                    fp.write(data)
                self.edit.insertPlainText('Decrypted: %s --> %s\n' %
                                          (name, myName))
コード例 #4
0
	def onDecrypt(self, checked):

		dlg = QtGui.QFileDialog(self)
		dlg.setWindowTitle('Chosse directory to decrypt ini files..')
		dlg.setFileMode(dlg.Directory)
		dlg.restoreState( Tc2Config.settingsValue(self.SettingsKeyDialogDecryptState, QtCore.QByteArray()).toByteArray() )
		if dlg.exec_() == dlg.Rejected:
			return
		Tc2Config.settingsSetValue(self.SettingsKeyDialogDecryptState, dlg.saveState() )
		directory = dlg.directory().canonicalPath()
		directory = directory.toUtf8()
		directory = unicode(directory, 'utf-8')

		self.edit.setPlainText('')
		self.edit.insertPlainText('Decrypting ini files\n')
		self.edit.insertPlainText('------------------------------\n')
		for root, dirs, files in os.walk(directory):
			self.edit.insertPlainText('Enter directory: %s\n' % root)
			for name in files:
				myName, ext = os.path.splitext(name)
				if ext.lower() != '.ini': continue
				if myName.endswith(self.Magic): continue

				fileName = os.path.join(root, name)
				with open(fileName, 'rb') as fp:
					data = fp.read()
					try:
						data = PokerStarsIniDecrypter.decryptString(data)
					except PokerStarsIniDecrypter.Error, d:
						self.edit.insertPlainText('Error: could not decrypt: %s\n' % name)
						continue

				print '\r\n' in data
				myName = myName + self.Magic + ext
				fileName = os.path.join(root, myName)
				with open(fileName, 'wb') as fp:
					fp.write(data)
				self.edit.insertPlainText('Decrypted: %s --> %s\n' % (name, myName) )