示例#1
0
 def save_profile(self, data):
     inst = ToxES.get_instance()
     if inst.has_password():
         data = inst.pass_encrypt(data)
     with open(self._path, 'wb') as fl:
         fl.write(data)
     print('Profile saved successfully')
示例#2
0
 def __init__(self, name):
     Singleton.__init__(self)
     self.path = ProfileHelper.get_path() + str(name) + '.json'
     self.name = name
     if os.path.isfile(self.path):
         with open(self.path, 'rb') as fl:
             data = fl.read()
         inst = ToxES.get_instance()
         try:
             if inst.is_data_encrypted(data):
                 data = inst.pass_decrypt(data)
             info = json.loads(str(data, 'utf-8'))
         except Exception as ex:
             info = Settings.get_default_settings()
             log('Parsing settings error: ' + str(ex))
         super(Settings, self).__init__(info)
         self.upgrade()
     else:
         super(Settings, self).__init__(Settings.get_default_settings())
         self.save()
     smileys.SmileyLoader(self)
     self.locked = False
     self.closing = False
     self.unlockScreen = False
     p = pyaudio.PyAudio()
     input_devices = output_devices = 0
     for i in range(p.get_device_count()):
         device = p.get_device_info_by_index(i)
         if device["maxInputChannels"]:
             input_devices += 1
         if device["maxOutputChannels"]:
             output_devices += 1
     self.audio = {'input': p.get_default_input_device_info()['index'] if input_devices else -1,
                   'output': p.get_default_output_device_info()['index'] if output_devices else -1,
                   'enabled': input_devices and output_devices}
示例#3
0
 def save_profile(self, data):
     inst = ToxES.get_instance()
     if inst.has_password():
         data = inst.pass_encrypt(data)
     with open(self._path, 'wb') as fl:
         fl.write(data)
     print('Profile saved successfully')
示例#4
0
 def save(self):
     text = json.dumps(self)
     inst = ToxES.get_instance()
     if inst.has_password():
         text = bytes(inst.pass_encrypt(bytes(text, 'utf-8')))
     else:
         text = bytes(text, 'utf-8')
     with open(self.path, 'wb') as fl:
         fl.write(text)
示例#5
0
 def save(self):
     text = json.dumps(self)
     inst = ToxES.get_instance()
     if inst.has_password():
         text = bytes(inst.pass_encrypt(bytes(text, 'utf-8')))
     else:
         text = bytes(text, 'utf-8')
     with open(self.path, 'wb') as fl:
         fl.write(text)
示例#6
0
 def save(self):
     encr = ToxES.get_instance()
     if encr.has_password():
         path = settings.ProfileHelper.get_path() + self._name + '.hstr'
         with open(path, 'rb') as fin:
             data = fin.read()
         data = encr.pass_encrypt(bytes(data))
         with open(path, 'wb') as fout:
             fout.write(data)
示例#7
0
 def save(self):
     encr = ToxES.get_instance()
     if encr.has_password():
         path = settings.ProfileHelper.get_path() + self._name + '.hstr'
         with open(path, 'rb') as fin:
             data = fin.read()
         data = encr.pass_encrypt(bytes(data))
         with open(path, 'wb') as fout:
             fout.write(data)
示例#8
0
 def export(self, directory):
     path = settings.ProfileHelper.get_path() + self._name + '.hstr'
     new_path = directory + self._name + '.hstr'
     with open(path, 'rb') as fin:
         data = fin.read()
     encr = ToxES.get_instance()
     if encr.has_password():
         data = encr.pass_encrypt(data)
     with open(new_path, 'wb') as fout:
         fout.write(data)
示例#9
0
 def export(self, directory):
     path = settings.ProfileHelper.get_path() + self._name + '.hstr'
     new_path = directory + self._name + '.hstr'
     with open(path, 'rb') as fin:
         data = fin.read()
     encr = ToxES.get_instance()
     if encr.has_password():
         data = encr.pass_encrypt(data)
     with open(new_path, 'wb') as fout:
         fout.write(data)
示例#10
0
 def __init__(self, name):
     Singleton.__init__(self)
     self.path = ProfileHelper.get_path() + str(name) + '.json'
     self.name = name
     if os.path.isfile(self.path):
         with open(self.path, 'rb') as fl:
             data = fl.read()
         inst = ToxES.get_instance()
         try:
             if inst.is_data_encrypted(data):
                 data = inst.pass_decrypt(data)
             info = json.loads(str(data, 'utf-8'))
         except Exception as ex:
             info = Settings.get_default_settings()
             log('Parsing settings error: ' + str(ex))
         super(Settings, self).__init__(info)
         self.upgrade()
     else:
         super(Settings, self).__init__(Settings.get_default_settings())
         self.save()
     smileys.SmileyLoader(self)
     self.locked = False
     self.closing = False
     self.unlockScreen = False
     p = pyaudio.PyAudio()
     input_devices = output_devices = 0
     for i in range(p.get_device_count()):
         device = p.get_device_info_by_index(i)
         if device["maxInputChannels"]:
             input_devices += 1
         if device["maxOutputChannels"]:
             output_devices += 1
     self.audio = {
         'input':
         p.get_default_input_device_info()['index']
         if input_devices else -1,
         'output':
         p.get_default_output_device_info()['index']
         if output_devices else -1,
         'enabled':
         input_devices and output_devices
     }
     self.video = {
         'device': -1,
         'width': 640,
         'height': 480,
         'x': 0,
         'y': 0
     }
示例#11
0
 def __init__(self, name):
     self._name = name
     chdir(settings.ProfileHelper.get_path())
     path = settings.ProfileHelper.get_path() + self._name + '.hstr'
     if os.path.exists(path):
         decr = ToxES.get_instance()
         try:
             with open(path, 'rb') as fin:
                 data = fin.read()
             if decr.is_data_encrypted(data):
                 data = decr.pass_decrypt(data)
                 with open(path, 'wb') as fout:
                     fout.write(data)
         except:
             os.remove(path)
     db = connect(name + '.hstr', timeout=TIMEOUT)
     cursor = db.cursor()
     cursor.execute('CREATE TABLE IF NOT EXISTS friends('
                    '    tox_id TEXT PRIMARY KEY'
                    ')')
     db.close()
示例#12
0
 def __init__(self, name):
     self._name = name
     chdir(settings.ProfileHelper.get_path())
     path = settings.ProfileHelper.get_path() + self._name + '.hstr'
     if os.path.exists(path):
         decr = ToxES.get_instance()
         try:
             with open(path, 'rb') as fin:
                 data = fin.read()
             if decr.is_data_encrypted(data):
                 data = decr.pass_decrypt(data)
                 with open(path, 'wb') as fout:
                     fout.write(data)
         except:
             os.remove(path)
     db = connect(name + '.hstr', timeout=TIMEOUT)
     cursor = db.cursor()
     cursor.execute('CREATE TABLE IF NOT EXISTS friends('
                    '    tox_id TEXT PRIMARY KEY'
                    ')')
     db.close()