Commit 50f0b68b authored by Adrian Georgescu's avatar Adrian Georgescu

2to3 run

parent 77035393
#!/usr/bin/python2 #!/usr/bin/python3
import os import os
import sys import sys
......
...@@ -88,9 +88,7 @@ class IPAddressMonitor(object): ...@@ -88,9 +88,7 @@ class IPAddressMonitor(object):
self.greenlet = None self.greenlet = None
class Blink(QApplication): class Blink(QApplication, metaclass=QSingleton):
__metaclass__ = QSingleton
implements(IObserver) implements(IObserver)
def __init__(self): def __init__(self):
...@@ -214,6 +212,6 @@ class Blink(QApplication): ...@@ -214,6 +212,6 @@ class Blink(QApplication):
@run_in_gui_thread @run_in_gui_thread
def _NH_SIPApplicationGotFatalError(self, notification): def _NH_SIPApplicationGotFatalError(self, notification):
log.error('Fatal error:\n{}'.format(notification.data.traceback)) log.error('Fatal error:\n{}'.format(notification.data.traceback))
QMessageBox.critical(self.main_window, u"Fatal Error", u"A fatal error occurred, {} will now exit.".format(self.applicationName())) QMessageBox.critical(self.main_window, "Fatal Error", "A fatal error occurred, {} will now exit.".format(self.applicationName()))
sys.exit(1) sys.exit(1)
...@@ -34,16 +34,14 @@ credits_text = """ ...@@ -34,16 +34,14 @@ credits_text = """
ui_class, base_class = uic.loadUiType(Resources.get('about_panel.ui')) ui_class, base_class = uic.loadUiType(Resources.get('about_panel.ui'))
class AboutPanel(base_class, ui_class): class AboutPanel(base_class, ui_class, metaclass=QSingleton):
__metaclass__ = QSingleton
def __init__(self, parent=None): def __init__(self, parent=None):
super(AboutPanel, self).__init__(parent) super(AboutPanel, self).__init__(parent)
with Resources.directory: with Resources.directory:
self.setupUi(self) self.setupUi(self)
self.version.setText(u'Version %s\n%s' % (__version__, __date__)) self.version.setText('Version %s\n%s' % (__version__, __date__))
credits_width = self.credits_text.fontMetrics().width("NLnet Foundation" + "http://sipsimpleclient.org") + 40 credits_width = self.credits_text.fontMetrics().width("NLnet Foundation" + "http://sipsimpleclient.org") + 40
self.credits_text.setFixedWidth(credits_width) self.credits_text.setFixedWidth(credits_width)
......
...@@ -3,8 +3,8 @@ import cjson ...@@ -3,8 +3,8 @@ import cjson
import os import os
import re import re
import sys import sys
import urllib import urllib.request, urllib.parse, urllib.error
import urllib2 import urllib.request, urllib.error, urllib.parse
from PyQt5 import uic from PyQt5 import uic
from PyQt5.QtCore import Qt, QAbstractListModel, QModelIndex, QSortFilterProxyModel, QUrl, QUrlQuery from PyQt5.QtCore import Qt, QAbstractListModel, QModelIndex, QSortFilterProxyModel, QUrl, QUrlQuery
...@@ -68,7 +68,7 @@ class AccountInfo(object): ...@@ -68,7 +68,7 @@ class AccountInfo(object):
@property @property
def name(self): def name(self):
return u'Bonjour' if self.account is BonjourAccount() else unicode(self.account.id) return 'Bonjour' if self.account is BonjourAccount() else str(self.account.id)
@property @property
def icon(self): def icon(self):
...@@ -80,7 +80,7 @@ class AccountInfo(object): ...@@ -80,7 +80,7 @@ class AccountInfo(object):
return self.inactive_icon return self.inactive_icon
def __eq__(self, other): def __eq__(self, other):
if isinstance(other, basestring): if isinstance(other, str):
return self.name == other return self.name == other
elif isinstance(other, (Account, BonjourAccount)): elif isinstance(other, (Account, BonjourAccount)):
return self.account == other return self.account == other
...@@ -234,9 +234,7 @@ class AccountSelector(QComboBox): ...@@ -234,9 +234,7 @@ class AccountSelector(QComboBox):
ui_class, base_class = uic.loadUiType(Resources.get('add_account.ui')) ui_class, base_class = uic.loadUiType(Resources.get('add_account.ui'))
class AddAccountDialog(base_class, ui_class): class AddAccountDialog(base_class, ui_class, metaclass=QSingleton):
__metaclass__ = QSingleton
implements(IObserver) implements(IObserver)
def __init__(self, parent=None): def __init__(self, parent=None):
...@@ -256,7 +254,7 @@ class AddAccountDialog(base_class, ui_class): ...@@ -256,7 +254,7 @@ class AddAccountDialog(base_class, ui_class):
font_metrics = self.create_status_label.fontMetrics() font_metrics = self.create_status_label.fontMetrics()
self.create_status_label.setMinimumHeight(font_metrics.height() + 2*(font_metrics.height() + font_metrics.leading())) # reserve space for 3 lines self.create_status_label.setMinimumHeight(font_metrics.height() + 2*(font_metrics.height() + font_metrics.leading())) # reserve space for 3 lines
font_metrics = self.email_note_label.fontMetrics() font_metrics = self.email_note_label.fontMetrics()
self.email_note_label.setMinimumWidth(font_metrics.width(u'The E-mail address is used when sending voicemail')) # hack to make text justification look nice everywhere self.email_note_label.setMinimumWidth(font_metrics.width('The E-mail address is used when sending voicemail')) # hack to make text justification look nice everywhere
self.add_account_button.setChecked(True) self.add_account_button.setChecked(True)
self.panel_view.setCurrentWidget(self.add_account_panel) self.panel_view.setCurrentWidget(self.add_account_panel)
self.new_password_editor.textChanged.connect(self._SH_PasswordTextChanged) self.new_password_editor.textChanged.connect(self._SH_PasswordTextChanged)
...@@ -362,7 +360,7 @@ class AddAccountDialog(base_class, ui_class): ...@@ -362,7 +360,7 @@ class AddAccountDialog(base_class, ui_class):
self.accept_button.setEnabled(all(input.text_valid for input in inputs)) self.accept_button.setEnabled(all(input.text_valid for input in inputs))
def _SH_PasswordTextChanged(self, text): def _SH_PasswordTextChanged(self, text):
self.verify_password_editor.regexp = re.compile(u'^%s$' % re.escape(text)) self.verify_password_editor.regexp = re.compile('^%s$' % re.escape(text))
def _SH_ValidityStatusChanged(self): def _SH_ValidityStatusChanged(self):
red = '#cc0000' red = '#cc0000'
...@@ -401,11 +399,11 @@ class AddAccountDialog(base_class, ui_class): ...@@ -401,11 +399,11 @@ class AddAccountDialog(base_class, ui_class):
def _initialize(self): def _initialize(self):
self.display_name = user_info.fullname self.display_name = user_info.fullname
self.username = user_info.username.lower().replace(u' ', u'.') self.username = user_info.username.lower().replace(' ', '.')
self.sip_address = u'' self.sip_address = ''
self.password = u'' self.password = ''
self.verify_password = u'' self.verify_password = ''
self.email_address = u'' self.email_address = ''
@run_in_thread('network-io') @run_in_thread('network-io')
def _create_sip_account(self, username, password, email_address, display_name, timezone=None): def _create_sip_account(self, username, password, email_address, display_name, timezone=None):
...@@ -425,7 +423,7 @@ class AddAccountDialog(base_class, ui_class): ...@@ -425,7 +423,7 @@ class AddAccountDialog(base_class, ui_class):
tzinfo=timezone) tzinfo=timezone)
try: try:
settings = SIPSimpleSettings() settings = SIPSimpleSettings()
response = urllib2.urlopen(settings.server.enrollment_url, urllib.urlencode(dict(enrollment_data))) response = urllib.request.urlopen(settings.server.enrollment_url, urllib.parse.urlencode(dict(enrollment_data)))
response_data = cjson.decode(response.read().replace(r'\/', '/')) response_data = cjson.decode(response.read().replace(r'\/', '/'))
response_data = defaultdict(lambda: None, response_data) response_data = defaultdict(lambda: None, response_data)
if response_data['success']: if response_data['success']:
...@@ -460,7 +458,7 @@ class AddAccountDialog(base_class, ui_class): ...@@ -460,7 +458,7 @@ class AddAccountDialog(base_class, ui_class):
call_in_gui_thread(setattr, self.create_status_label, 'value', Status(response_data['error_message'], color=red)) call_in_gui_thread(setattr, self.create_status_label, 'value', Status(response_data['error_message'], color=red))
except (cjson.DecodeError, KeyError): except (cjson.DecodeError, KeyError):
call_in_gui_thread(setattr, self.create_status_label, 'value', Status('Illegal server response', color=red)) call_in_gui_thread(setattr, self.create_status_label, 'value', Status('Illegal server response', color=red))
except urllib2.URLError, e: except urllib.error.URLError as e:
call_in_gui_thread(setattr, self.create_status_label, 'value', Status('Failed to contact server: %s' % e.reason, color=red)) call_in_gui_thread(setattr, self.create_status_label, 'value', Status('Failed to contact server: %s' % e.reason, color=red))
finally: finally:
call_in_gui_thread(self.setEnabled, True) call_in_gui_thread(self.setEnabled, True)
...@@ -476,7 +474,7 @@ class AddAccountDialog(base_class, ui_class): ...@@ -476,7 +474,7 @@ class AddAccountDialog(base_class, ui_class):
makedirs(ApplicationData.get('tls')) makedirs(ApplicationData.get('tls'))
certificate_path = ApplicationData.get(os.path.join('tls', sip_address+'.crt')) certificate_path = ApplicationData.get(os.path.join('tls', sip_address+'.crt'))
certificate_file = open(certificate_path, 'w') certificate_file = open(certificate_path, 'w')
os.chmod(certificate_path, 0600) os.chmod(certificate_path, 0o600)
certificate_file.write(crt+key) certificate_file.write(crt+key)
certificate_file.close() certificate_file.close()
ca_path = ApplicationData.get(os.path.join('tls', 'ca.crt')) ca_path = ApplicationData.get(os.path.join('tls', 'ca.crt'))
...@@ -585,7 +583,7 @@ class ServerToolsWebView(QWebView): ...@@ -585,7 +583,7 @@ class ServerToolsWebView(QWebView):
@property @property
def query_items(self): def query_items(self):
all_items = ('user_agent', 'tab', 'task', 'realm') all_items = ('user_agent', 'tab', 'task', 'realm')
return [(name, value) for name, value in self.__dict__.iteritems() if name in all_items and value is not None] return [(name, value) for name, value in self.__dict__.items() if name in all_items and value is not None]
def _get_account(self): def _get_account(self):
return self.__dict__['account'] return self.__dict__['account']
...@@ -670,9 +668,7 @@ class ServerToolsWebView(QWebView): ...@@ -670,9 +668,7 @@ class ServerToolsWebView(QWebView):
ui_class, base_class = uic.loadUiType(Resources.get('server_tools.ui')) ui_class, base_class = uic.loadUiType(Resources.get('server_tools.ui'))
class ServerToolsWindow(base_class, ui_class): class ServerToolsWindow(base_class, ui_class, metaclass=QSingleton):
__metaclass__ = QSingleton
implements(IObserver) implements(IObserver)
def __init__(self, model, parent=None): def __init__(self, model, parent=None):
...@@ -755,12 +751,12 @@ class ServerToolsWindow(base_class, ui_class): ...@@ -755,12 +751,12 @@ class ServerToolsWindow(base_class, ui_class):
self._update_navigation_buttons() self._update_navigation_buttons()
def _SH_WebViewTitleChanged(self, title): def _SH_WebViewTitleChanged(self, title):
self.window().setWindowTitle(u'Blink Server Tools: {}'.format(title)) self.window().setWindowTitle('Blink Server Tools: {}'.format(title))
def _SH_ModelChanged(self, parent_index, start, end): def _SH_ModelChanged(self, parent_index, start, end):
menu = self.account_button.menu() menu = self.account_button.menu()
menu.clear() menu.clear()
for row in xrange(self.model.rowCount()): for row in range(self.model.rowCount()):
account_info = self.model.data(self.model.index(row, 0), Qt.UserRole) account_info = self.model.data(self.model.index(row, 0), Qt.UserRole)
action = menu.addAction(account_info.name) action = menu.addAction(account_info.name)
action.setData(account_info.account) action.setData(account_info.account)
......
This diff is collapsed.
...@@ -34,8 +34,8 @@ class PresenceSettingsExtension(PresenceSettings): ...@@ -34,8 +34,8 @@ class PresenceSettingsExtension(PresenceSettings):
class PSTNSettings(SettingsGroup): class PSTNSettings(SettingsGroup):
idd_prefix = Setting(type=unicode, default=None, nillable=True) idd_prefix = Setting(type=str, default=None, nillable=True)
prefix = Setting(type=unicode, default=None, nillable=True) prefix = Setting(type=str, default=None, nillable=True)
class RTPSettingsExtension(RTPSettings): class RTPSettingsExtension(RTPSettings):
...@@ -71,7 +71,7 @@ class XCAPSettingsExtension(XCAPSettings): ...@@ -71,7 +71,7 @@ class XCAPSettingsExtension(XCAPSettings):
class AccountExtension(SettingsObjectExtension): class AccountExtension(SettingsObjectExtension):
display_name = Setting(type=unicode, default=user_info.fullname, nillable=True) display_name = Setting(type=str, default=user_info.fullname, nillable=True)
message_summary = MessageSummarySettingsExtension message_summary = MessageSummarySettingsExtension
msrp = MSRPSettingsExtension msrp = MSRPSettingsExtension
pstn = PSTNSettings pstn = PSTNSettings
......
...@@ -13,8 +13,8 @@ SharedSetting.set_namespace('ag-projects:blink') ...@@ -13,8 +13,8 @@ SharedSetting.set_namespace('ag-projects:blink')
class PresenceSettingsExtension(PresenceSettings): class PresenceSettingsExtension(PresenceSettings):
state = RuntimeSetting(type=unicode, nillable=True, default=None) state = RuntimeSetting(type=str, nillable=True, default=None)
note = RuntimeSetting(type=unicode, nillable=True, default=None) note = RuntimeSetting(type=str, nillable=True, default=None)
class ContactExtension(ContactExtension): class ContactExtension(ContactExtension):
......
...@@ -3,9 +3,8 @@ ...@@ -3,9 +3,8 @@
import os import os
import re import re
from urllib.request import pathname2url, url2pathname
from urllib import pathname2url, url2pathname from urllib.parse import urlparse
from urlparse import urlparse
from application.python.types import MarkerType from application.python.types import MarkerType
from sipsimple.configuration.datatypes import Hostname, List from sipsimple.configuration.datatypes import Hostname, List
...@@ -16,12 +15,12 @@ from blink.resources import ApplicationData ...@@ -16,12 +15,12 @@ from blink.resources import ApplicationData
__all__ = ['ApplicationDataPath', 'DefaultPath', 'SoundFile', 'CustomSoundFile', 'HTTPURL', 'FileURL', 'IconDescriptor', 'PresenceState', 'PresenceStateList', 'GraphTimeScale'] __all__ = ['ApplicationDataPath', 'DefaultPath', 'SoundFile', 'CustomSoundFile', 'HTTPURL', 'FileURL', 'IconDescriptor', 'PresenceState', 'PresenceStateList', 'GraphTimeScale']
class ApplicationDataPath(unicode): class ApplicationDataPath(str):
def __new__(cls, path): def __new__(cls, path):
path = os.path.normpath(path) path = os.path.normpath(path)
if path.startswith(ApplicationData.directory+os.path.sep): if path.startswith(ApplicationData.directory+os.path.sep):
path = path[len(ApplicationData.directory+os.path.sep):] path = path[len(ApplicationData.directory+os.path.sep):]
return unicode.__new__(cls, path) return str.__new__(cls, path)
@property @property
def normalized(self): def normalized(self):
...@@ -36,11 +35,11 @@ class SoundFile(object): ...@@ -36,11 +35,11 @@ class SoundFile(object):
raise ValueError('illegal volume level: %d' % self.volume) raise ValueError('illegal volume level: %d' % self.volume)
def __getstate__(self): def __getstate__(self):
return u'%s,%s' % (self.__dict__['path'], self.volume) return '%s,%s' % (self.__dict__['path'], self.volume)
def __setstate__(self, state): def __setstate__(self, state):
try: try:
path, volume = state.rsplit(u',', 1) path, volume = state.rsplit(',', 1)
except ValueError: except ValueError:
self.__init__(state) self.__init__(state)
else: else:
...@@ -60,7 +59,7 @@ class SoundFile(object): ...@@ -60,7 +59,7 @@ class SoundFile(object):
del _get_path, _set_path del _get_path, _set_path
class DefaultPath: __metaclass__ = MarkerType class DefaultPath(metaclass=MarkerType): pass
class CustomSoundFile(object): # check if this data type is still needed -Dan class CustomSoundFile(object): # check if this data type is still needed -Dan
...@@ -72,9 +71,9 @@ class CustomSoundFile(object): # check if this data type is still needed -Dan ...@@ -72,9 +71,9 @@ class CustomSoundFile(object): # check if this data type is still needed -Dan
def __getstate__(self): def __getstate__(self):
if self.path is DefaultPath: if self.path is DefaultPath:
return u'default' return 'default'
else: else:
return u'file:%s,%s' % (self.__dict__['path'], self.volume) return 'file:%s,%s' % (self.__dict__['path'], self.volume)
def __setstate__(self, state): def __setstate__(self, state):
match = re.match(r'^(?P<type>default|file:)(?P<path>.+?)?(,(?P<volume>\d+))?$', state) match = re.match(r'^(?P<type>default|file:)(?P<path>.+?)?(,(?P<volume>\d+))?$', state)
...@@ -102,11 +101,11 @@ class CustomSoundFile(object): # check if this data type is still needed -Dan ...@@ -102,11 +101,11 @@ class CustomSoundFile(object): # check if this data type is still needed -Dan
del _get_path, _set_path del _get_path, _set_path
class HTTPURL(unicode): class HTTPURL(str):
def __new__(cls, value): def __new__(cls, value):
value = unicode(value) value = str(value)
url = urlparse(value) url = urlparse(value)
if url.scheme not in (u'http', u'https'): if url.scheme not in ('http', 'https'):
raise ValueError("illegal HTTP URL scheme (http and https only): %s" % url.scheme) raise ValueError("illegal HTTP URL scheme (http and https only): %s" % url.scheme)
Hostname(url.hostname) Hostname(url.hostname)
if url.port is not None and not (0 < url.port < 65536): if url.port is not None and not (0 < url.port < 65536):
...@@ -114,14 +113,14 @@ class HTTPURL(unicode): ...@@ -114,14 +113,14 @@ class HTTPURL(unicode):
return value return value
class FileURL(unicode): class FileURL(str):
def __new__(cls, value): def __new__(cls, value):
if not value.startswith('file:'): if not value.startswith('file:'):
value = 'file:' + pathname2url(os.path.abspath(value).encode('utf-8')).decode('utf-8') value = 'file:' + pathname2url(os.path.abspath(value).encode('utf-8')).decode('utf-8')
return unicode.__new__(cls, value) return str.__new__(cls, value)
class ParsedURL(unicode): class ParsedURL(str):
fragment = property(lambda self: self.__parsed__.fragment) fragment = property(lambda self: self.__parsed__.fragment)
netloc = property(lambda self: self.__parsed__.netloc) netloc = property(lambda self: self.__parsed__.netloc)
params = property(lambda self: self.__parsed__.params) params = property(lambda self: self.__parsed__.params)
...@@ -140,13 +139,13 @@ class IconDescriptor(object): ...@@ -140,13 +139,13 @@ class IconDescriptor(object):
def __getstate__(self): def __getstate__(self):
if self.etag is None: if self.etag is None:
return unicode(self.url) return str(self.url)
else: else:
return u'%s,%s' % (self.url, self.etag) return '%s,%s' % (self.url, self.etag)
def __setstate__(self, state): def __setstate__(self, state):
try: try:
url, etag = state.rsplit(u',', 1) url, etag = state.rsplit(',', 1)
except ValueError: except ValueError:
self.__init__(state) self.__init__(state)
else: else:
...@@ -167,18 +166,18 @@ class IconDescriptor(object): ...@@ -167,18 +166,18 @@ class IconDescriptor(object):
class PresenceState(object): class PresenceState(object):
def __init__(self, state, note=None): def __init__(self, state, note=None):
self.state = unicode(state) self.state = str(state)
self.note = note self.note = note
def __getstate__(self): def __getstate__(self):
if not self.note: if not self.note:
return unicode(self.state) return str(self.state)
else: else:
return u'%s,%s' % (self.state, self.note) return '%s,%s' % (self.state, self.note)
def __setstate__(self, data): def __setstate__(self, data):
try: try:
state, note = data.split(u',', 1) state, note = data.split(',', 1)
except ValueError: except ValueError:
self.__init__(data) self.__init__(data)
else: else:
......
...@@ -41,7 +41,7 @@ class ChatSettingsExtension(ChatSettings): ...@@ -41,7 +41,7 @@ class ChatSettingsExtension(ChatSettings):
class GoogleContactsSettings(SettingsGroup): class GoogleContactsSettings(SettingsGroup):
enabled = Setting(type=bool, default=False) enabled = Setting(type=bool, default=False)
username = Setting(type=unicode, default=None, nillable=True) username = Setting(type=str, default=None, nillable=True)
class LogsSettingsExtension(LogsSettings): class LogsSettingsExtension(LogsSettings):
...@@ -111,7 +111,7 @@ class BlinkScreenSharingSettings(SettingsGroup): ...@@ -111,7 +111,7 @@ class BlinkScreenSharingSettings(SettingsGroup):
class BlinkPresenceSettings(SettingsGroup): class BlinkPresenceSettings(SettingsGroup):
current_state = Setting(type=PresenceState, default=PresenceState('Available')) current_state = Setting(type=PresenceState, default=PresenceState('Available'))
state_history = Setting(type=PresenceStateList, default=PresenceStateList()) state_history = Setting(type=PresenceStateList, default=PresenceStateList())
offline_note = Setting(type=unicode, nillable=True) offline_note = Setting(type=str, nillable=True)
icon = Setting(type=IconDescriptor, nillable=True) icon = Setting(type=IconDescriptor, nillable=True)
......
This diff is collapsed.
...@@ -13,9 +13,7 @@ class EventMeta(type(QEvent)): ...@@ -13,9 +13,7 @@ class EventMeta(type(QEvent)):
cls.id = QEvent.registerEventType() if name != 'EventBase' else None cls.id = QEvent.registerEventType() if name != 'EventBase' else None
class EventBase(QEvent): class EventBase(QEvent, metaclass=EventMeta):
__metaclass__ = EventMeta
def __new__(cls, *args, **kw): def __new__(cls, *args, **kw):
if cls is EventBase: if cls is EventBase:
raise TypeError("EventBase cannot be directly instantiated") raise TypeError("EventBase cannot be directly instantiated")
......
...@@ -66,9 +66,9 @@ class FileTransferWindow(base_class, ui_class): ...@@ -66,9 +66,9 @@ class FileTransferWindow(base_class, ui_class):
def update_status(self): def update_status(self):
total = len(self.model.items) total = len(self.model.items)
active = len([item for item in self.model.items if not item.ended]) active = len([item for item in self.model.items if not item.ended])
text = u'%d %s' % (total, 'transfer' if total == 1 else 'transfers') text = '%d %s' % (total, 'transfer' if total == 1 else 'transfers')
if active > 0: if active > 0:
text += u' (%d active)' % active text += ' (%d active)' % active
self.status_label.setText(text) self.status_label.setText(text)
def handle_notification(self, notification): def handle_notification(self, notification):
......
import bisect import bisect
import cPickle as pickle import pickle as pickle
import re import re
from PyQt5.QtGui import QIcon from PyQt5.QtGui import QIcon
...@@ -24,8 +24,7 @@ from blink.util import run_in_gui_thread ...@@ -24,8 +24,7 @@ from blink.util import run_in_gui_thread
__all__ = ['HistoryManager'] __all__ = ['HistoryManager']
class HistoryManager(object): class HistoryManager(object, metaclass=Singleton):
__metaclass__ = Singleton
implements(IObserver) implements(IObserver)
history_size = 20 history_size = 20
...@@ -149,7 +148,7 @@ class HistoryEntry(object): ...@@ -149,7 +148,7 @@ class HistoryEntry(object):
@property @property
def text(self): def text(self):
result = unicode(self.name or self.uri) result = str(self.name or self.uri)
if self.call_time: if self.call_time:
call_time = self.call_time.astimezone(tzlocal()) call_time = self.call_time.astimezone(tzlocal())
call_date = call_time.date() call_date = call_time.date()
...@@ -195,6 +194,6 @@ class HistoryEntry(object): ...@@ -195,6 +194,6 @@ class HistoryEntry(object):
display_name = session.remote_identity.display_name display_name = session.remote_identity.display_name
else: else:
display_name = contact.name display_name = contact.name
return cls(session.direction, display_name, remote_uri, unicode(session.account.id), call_time, duration) return cls(session.direction, display_name, remote_uri, str(session.account.id), call_time, duration)
...@@ -70,9 +70,7 @@ class LogFile(object): ...@@ -70,9 +70,7 @@ class LogFile(object):
file.close() file.close()
class LogManager(object): class LogManager(object, metaclass=Singleton):
__metaclass__ = Singleton
implements(IObserver) implements(IObserver)
def __init__(self): def __init__(self):
......
This diff is collapsed.
This diff is collapsed.
...@@ -112,7 +112,7 @@ class BlinkPresenceState(object): ...@@ -112,7 +112,7 @@ class BlinkPresenceState(object):
device = pidf.Device('DID-%s' % instance_id, device_id=pidf.DeviceID(instance_id)) device = pidf.Device('DID-%s' % instance_id, device_id=pidf.DeviceID(instance_id))
device.timestamp = timestamp device.timestamp = timestamp
device.notes.add(u'%s at %s' % (settings.user_agent, hostname)) device.notes.add('%s at %s' % (settings.user_agent, hostname))
doc.add(device) doc.add(device)
return doc return doc
...@@ -226,8 +226,8 @@ class PresencePublicationHandler(object): ...@@ -226,8 +226,8 @@ class PresencePublicationHandler(object):
if service.id in ('SID-%s' % uuid.UUID(SIPSimpleSettings().instance_id), 'SID-%s' % hashlib.md5(notification.sender.id).hexdigest()): if service.id in ('SID-%s' % uuid.UUID(SIPSimpleSettings().instance_id), 'SID-%s' % hashlib.md5(notification.sender.id).hexdigest()):
# Our current state is the winning one # Our current state is the winning one
return return
status = unicode(service.status.extended).title() status = str(service.status.extended).title()
note = None if not service.notes else unicode(list(service.notes)[0]) note = None if not service.notes else str(list(service.notes)[0])
if status == 'Offline': if status == 'Offline':
status = 'Invisible' status = 'Invisible'
note = None note = None
...@@ -304,12 +304,12 @@ class ContactIcon(object): ...@@ -304,12 +304,12 @@ class ContactIcon(object):
@classmethod @classmethod
def fetch(cls, url, etag=None, descriptor_etag=None): def fetch(cls, url, etag=None, descriptor_etag=None):
headers = {'If-None-Match': etag} if etag else {} headers = {'If-None-Match': etag} if etag else {}
req = urllib2.Request(url, headers=headers) req = urllib.request.Request(url, headers=headers)
try: try:
response = urllib2.urlopen(req) response = urllib.request.urlopen(req)
content = response.read() content = response.read()
info = response.info() info = response.info()
except (ConnectionLost, urllib2.URLError, urllib2.HTTPError): except (ConnectionLost, urllib.error.URLError, urllib.error.HTTPError):
return None return None
content_type = info.getheader('content-type') content_type = info.getheader('content-type')
etag = info.getheader('etag') etag = info.getheader('etag')
...@@ -352,7 +352,7 @@ class PresenceSubscriptionHandler(object): ...@@ -352,7 +352,7 @@ class PresenceSubscriptionHandler(object):
notification_center.remove_observer(self, name='SIPAccountGotPresenceWinfo') notification_center.remove_observer(self, name='SIPAccountGotPresenceWinfo')
self._pidf_map.clear() self._pidf_map.clear()
self._winfo_map.clear() self._winfo_map.clear()
for timer in self._winfo_timers.values(): for timer in list(self._winfo_timers.values()):
if timer.active(): if timer.active():
timer.cancel() timer.cancel()
self._winfo_timers.clear() self._winfo_timers.clear()
...@@ -375,9 +375,9 @@ class PresenceSubscriptionHandler(object): ...@@ -375,9 +375,9 @@ class PresenceSubscriptionHandler(object):
# If no URIs were provided, process all of them # If no URIs were provided, process all of them
if not uris: if not uris:
uris = list(chain(*(item.iterkeys() for item in self._pidf_map.itervalues()))) uris = list(chain(*(iter(item.keys()) for item in self._pidf_map.values())))
for uri, pidf_list in chain(*(x.iteritems() for x in self._pidf_map.itervalues())): for uri, pidf_list in chain(*(iter(x.items()) for x in self._pidf_map.values())):
current_pidf_map.setdefault(uri, []).extend(pidf_list) current_pidf_map.setdefault(uri, []).extend(pidf_list)
for uri in uris: for uri in uris:
...@@ -385,7 +385,7 @@ class PresenceSubscriptionHandler(object): ...@@ -385,7 +385,7 @@ class PresenceSubscriptionHandler(object):
for contact in (contact for contact in addressbook_manager.get_contacts() if uri in (self.sip_prefix_re.sub('', contact_uri.uri) for contact_uri in contact.uris)): for contact in (contact for contact in addressbook_manager.get_contacts() if uri in (self.sip_prefix_re.sub('', contact_uri.uri) for contact_uri in contact.uris)):
contact_pidf_map.setdefault(contact, []).extend(pidf_list) contact_pidf_map.setdefault(contact, []).extend(pidf_list)
for contact, pidf_list in contact_pidf_map.iteritems(): for contact, pidf_list in contact_pidf_map.items():
if not pidf_list: if not pidf_list:
state = note = icon = None state = note = icon = None
else: else:
...@@ -393,11 +393,11 @@ class PresenceSubscriptionHandler(object): ...@@ -393,11 +393,11 @@ class PresenceSubscriptionHandler(object):
services.sort(key=service_sort_key, reverse=True) services.sort(key=service_sort_key, reverse=True)
service = services[0] service = services[0]
if service.status.extended: if service.status.extended:
state = unicode(service.status.extended) state = str(service.status.extended)
else: else:
state = 'available' if service.status.basic == 'open' else 'offline' state = 'available' if service.status.basic == 'open' else 'offline'
note = unicode(next(iter(service.notes))) if service.notes else None note = str(next(iter(service.notes))) if service.notes else None
icon_url = unicode(service.icon) if service.icon else None icon_url = str(service.icon) if service.icon else None
if icon_url: if icon_url:
url, token, icon_hash = icon_url.partition('#blink-icon') url, token, icon_hash = icon_url.partition('#blink-icon')
...@@ -456,12 +456,12 @@ class PresenceSubscriptionHandler(object): ...@@ -456,12 +456,12 @@ class PresenceSubscriptionHandler(object):
def _NH_SIPAccountGotPresenceState(self, notification): def _NH_SIPAccountGotPresenceState(self, notification):
account = notification.sender account = notification.sender
new_pidf_map = dict((self.sip_prefix_re.sub('', uri), resource.pidf_list) for uri, resource in notification.data.resource_map.iteritems()) new_pidf_map = dict((self.sip_prefix_re.sub('', uri), resource.pidf_list) for uri, resource in notification.data.resource_map.items())
account_map = self._pidf_map.setdefault(account.id, {}) account_map = self._pidf_map.setdefault(account.id, {})
if notification.data.full_state: if notification.data.full_state:
account_map.clear() account_map.clear()
account_map.update(new_pidf_map) account_map.update(new_pidf_map)
self._process_presence_data(new_pidf_map.keys()) self._process_presence_data(list(new_pidf_map.keys()))
def _NH_SIPAccountGotPresenceWinfo(self, notification): def _NH_SIPAccountGotPresenceWinfo(self, notification):
addressbook_manager = addressbook.AddressbookManager() addressbook_manager = addressbook.AddressbookManager()
...@@ -535,7 +535,7 @@ class PendingWatcherDialog(base_class, ui_class): ...@@ -535,7 +535,7 @@ class PendingWatcherDialog(base_class, ui_class):
icon = icon_manager.get(self.contact.id) icon = icon_manager.get(self.contact.id)
if icon is not None: if icon is not None:
self.user_icon.setPixmap(icon.pixmap(48)) self.user_icon.setPixmap(icon.pixmap(48))
self.description_label.setText(u'Wants to subscribe to your availability information at {}'.format(account.id)) self.description_label.setText('Wants to subscribe to your availability information at {}'.format(account.id))
self.name_label.setText(display_name or uri) self.name_label.setText(display_name or uri)
self.uri_label.setText(uri) self.uri_label.setText(uri)
self.accept_button.released.connect(self._accept_watcher) self.accept_button.released.connect(self._accept_watcher)
......
...@@ -21,9 +21,9 @@ from blink.util import run_in_gui_thread ...@@ -21,9 +21,9 @@ from blink.util import run_in_gui_thread
__all__ = ['ApplicationData', 'Resources', 'IconManager'] __all__ = ['ApplicationData', 'Resources', 'IconManager']
class DirectoryContextManager(unicode): class DirectoryContextManager(str):
def __enter__(self): def __enter__(self):
self.directory = os.getcwdu() self.directory = os.getcwd()
os.chdir(self) os.chdir(self)
def __exit__(self, type, value, traceback): def __exit__(self, type, value, traceback):
...@@ -40,11 +40,11 @@ class ApplicationData(object): ...@@ -40,11 +40,11 @@ class ApplicationData(object):
if cls._cached_directory is None: if cls._cached_directory is None:
if platform.system() == 'Darwin': if platform.system() == 'Darwin':
from Foundation import NSApplicationSupportDirectory, NSSearchPathForDirectoriesInDomains, NSUserDomainMask from Foundation import NSApplicationSupportDirectory, NSSearchPathForDirectoriesInDomains, NSUserDomainMask
cls._cached_directory = os.path.join(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0], u'Blink') cls._cached_directory = os.path.join(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0], 'Blink')
elif platform.system() == 'Windows': elif platform.system() == 'Windows':
cls._cached_directory = os.path.join(os.environ['APPDATA'].decode(sys.getfilesystemencoding()), u'Blink') cls._cached_directory = os.path.join(os.environ['APPDATA'].decode(sys.getfilesystemencoding()), 'Blink')
else: else:
cls._cached_directory = Path(u'~/.blink').normalized cls._cached_directory = Path('~/.blink').normalized
return DirectoryContextManager(cls._cached_directory) return DirectoryContextManager(cls._cached_directory)
@classmethod @classmethod
...@@ -83,9 +83,7 @@ class Resources(object): ...@@ -83,9 +83,7 @@ class Resources(object):
return os.path.join(cls.directory, os.path.normpath(resource)) return os.path.join(cls.directory, os.path.normpath(resource))
class IconManager(object): class IconManager(object, metaclass=Singleton):
__metaclass__ = Singleton
max_size = 256 max_size = 256
def __init__(self): def __init__(self):
......
...@@ -22,7 +22,7 @@ class RFBSettings(object): ...@@ -22,7 +22,7 @@ class RFBSettings(object):
def __init__(self, depth, quality, compression, encodings): def __init__(self, depth, quality, compression, encodings):
if depth not in (8, 16, 24, 32, None): if depth not in (8, 16, 24, 32, None):
raise ValueError("invalid depth value: %r (should be one of 8, 16, 24, 32 or None)" % depth) raise ValueError("invalid depth value: %r (should be one of 8, 16, 24, 32 or None)" % depth)
allowed_levels = range(10) allowed_levels = list(range(10))
if quality not in allowed_levels: if quality not in allowed_levels:
raise ValueError("invalid quality value: %r (should be between 0..9)" % quality) raise ValueError("invalid quality value: %r (should be between 0..9)" % quality)
if compression not in allowed_levels: if compression not in allowed_levels:
...@@ -83,7 +83,7 @@ class VNCClient(QObject): ...@@ -83,7 +83,7 @@ class VNCClient(QObject):
imageSizeChanged = pyqtSignal(QSize) imageSizeChanged = pyqtSignal(QSize)
imageChanged = pyqtSignal(int, int, int, int) imageChanged = pyqtSignal(int, int, int, int)
passwordRequested = pyqtSignal(bool) passwordRequested = pyqtSignal(bool)
textCut = pyqtSignal(unicode) textCut = pyqtSignal(str)
def __init__(self, host, port, settings, parent=None): def __init__(self, host, port, settings, parent=None):
super(VNCClient, self).__init__(parent) super(VNCClient, self).__init__(parent)
......
from __future__ import division
import os import os
import platform import platform
...@@ -401,7 +401,7 @@ class ScreensharingDialog(base_class, ui_class): ...@@ -401,7 +401,7 @@ class ScreensharingDialog(base_class, ui_class):
return False return False
def get_credentials(self): def get_credentials(self):
self.message_label.setText(u'Screen sharing requires authentication') self.message_label.setText('Screen sharing requires authentication')
self.username_label.show() self.username_label.show()
self.username_editor.show() self.username_editor.show()
self.username_editor.clear() self.username_editor.clear()
...@@ -413,7 +413,7 @@ class ScreensharingDialog(base_class, ui_class): ...@@ -413,7 +413,7 @@ class ScreensharingDialog(base_class, ui_class):
return (self.username_editor.text(), self.password_editor.text()) if result == self.Accepted else (None, None) return (self.username_editor.text(), self.password_editor.text()) if result == self.Accepted else (None, None)
def get_password(self): def get_password(self):
self.message_label.setText(u'Screen sharing requires a password') self.message_label.setText('Screen sharing requires a password')
self.username_label.hide() self.username_label.hide()
self.username_editor.hide() self.username_editor.hide()
self.username_editor.clear() self.username_editor.clear()
......
This diff is collapsed.
...@@ -90,7 +90,7 @@ class FunctionExecutor(object): ...@@ -90,7 +90,7 @@ class FunctionExecutor(object):
def wait(self): def wait(self):
self.event.wait() self.event.wait()
if self.exception is not None: if self.exception is not None:
raise type(self.exception), self.exception, self.traceback raise type(self.exception)(self.exception).with_traceback(self.traceback)
else: else:
return self.result return self.result
......
...@@ -28,8 +28,8 @@ class ConferenceButton(ToolButton): ...@@ -28,8 +28,8 @@ class ConferenceButton(ToolButton):
def __init__(self, parent=None): def __init__(self, parent=None):
super(ConferenceButton, self).__init__(parent) super(ConferenceButton, self).__init__(parent)
self.make_conference_action = QAction(u'Conference all single sessions', self, triggered=self.makeConference.emit) self.make_conference_action = QAction('Conference all single sessions', self, triggered=self.makeConference.emit)
self.break_conference_action = QAction(u'Break selected conference', self, triggered=self.breakConference.emit) self.break_conference_action = QAction('Break selected conference', self, triggered=self.breakConference.emit)
self.toggled.connect(self._SH_Toggled) self.toggled.connect(self._SH_Toggled)
self.addAction(self.make_conference_action) self.addAction(self.make_conference_action)
...@@ -105,8 +105,7 @@ class SegmentTypeMeta(type): ...@@ -105,8 +105,7 @@ class SegmentTypeMeta(type):
return cls.__name__ return cls.__name__
class SegmentType(object): class SegmentType(object, metaclass=SegmentTypeMeta):
__metaclass__ = SegmentTypeMeta
style_sheet = '' style_sheet = ''
...@@ -260,8 +259,8 @@ class SwitchViewButton(QPushButton): ...@@ -260,8 +259,8 @@ class SwitchViewButton(QPushButton):
viewChanged = pyqtSignal(int) viewChanged = pyqtSignal(int)
button_text = {ContactView: u'Switch to Calls', SessionView: u'Switch to Contacts'} button_text = {ContactView: 'Switch to Calls', SessionView: 'Switch to Contacts'}
button_dnd_text = {ContactView: u'Drag here to add to a conference', SessionView: u'Drag here to go back to contacts'} button_dnd_text = {ContactView: 'Drag here to add to a conference', SessionView: 'Drag here to go back to contacts'}
dnd_style_sheet1 = """ dnd_style_sheet1 = """
QPushButton { QPushButton {
......
...@@ -16,7 +16,7 @@ class SlidingStackedWidget(QStackedWidget): ...@@ -16,7 +16,7 @@ class SlidingStackedWidget(QStackedWidget):
animationFinished = pyqtSignal() animationFinished = pyqtSignal()
LeftToRight, RightToLeft, TopToBottom, BottomToTop, Automatic = range(5) LeftToRight, RightToLeft, TopToBottom, BottomToTop, Automatic = list(range(5))
def __init__(self, parent=None): def __init__(self, parent=None):
super(SlidingStackedWidget, self).__init__(parent) super(SlidingStackedWidget, self).__init__(parent)
......
...@@ -11,8 +11,8 @@ __all__ = ['BackgroundFrame'] ...@@ -11,8 +11,8 @@ __all__ = ['BackgroundFrame']
class BackgroundFrame(QFrame): class BackgroundFrame(QFrame):
backgroundColor = QtDynamicProperty('backgroundColor', unicode) backgroundColor = QtDynamicProperty('backgroundColor', str)
backgroundImage = QtDynamicProperty('backgroundImage', unicode) backgroundImage = QtDynamicProperty('backgroundImage', str)
imageGeometry = QtDynamicProperty('imageGeometry', QRect) imageGeometry = QtDynamicProperty('imageGeometry', QRect)
def __init__(self, parent=None): def __init__(self, parent=None):
......
...@@ -16,9 +16,7 @@ from blink.widgets.util import QtDynamicProperty ...@@ -16,9 +16,7 @@ from blink.widgets.util import QtDynamicProperty
__all__ = ['Graph', 'GraphWidget', 'HeightScaler', 'LogarithmicScaler', 'MaxScaler', 'SoftScaler'] __all__ = ['Graph', 'GraphWidget', 'HeightScaler', 'LogarithmicScaler', 'MaxScaler', 'SoftScaler']
class HeightScaler(object): class HeightScaler(object, metaclass=ABCMeta):
__metaclass__ = ABCMeta
@abstractmethod @abstractmethod
def get_height(self, max_value): def get_height(self, max_value):
raise NotImplementedError raise NotImplementedError
...@@ -91,7 +89,7 @@ class GraphWidget(QWidget, ColorHelperMixin): ...@@ -91,7 +89,7 @@ class GraphWidget(QWidget, ColorHelperMixin):
fillEnvelope = QtDynamicProperty('fillEnvelope', type=bool) fillEnvelope = QtDynamicProperty('fillEnvelope', type=bool)
fillTransparency = QtDynamicProperty('fillTransparency', type=int) fillTransparency = QtDynamicProperty('fillTransparency', type=int)
EnvelopeStyle, BarStyle = range(2) EnvelopeStyle, BarStyle = list(range(2))
AutomaticHeight = 0 AutomaticHeight = 0
updated = pyqtSignal() updated = pyqtSignal()
......
...@@ -22,13 +22,13 @@ class IconSelector(QLabel): ...@@ -22,13 +22,13 @@ class IconSelector(QLabel):
default_icon = QtDynamicProperty('default_icon', QIcon) default_icon = QtDynamicProperty('default_icon', QIcon)
icon_size = QtDynamicProperty('icon_size', int) icon_size = QtDynamicProperty('icon_size', int)
class NotSelected: __metaclass__ = MarkerType class NotSelected(metaclass=MarkerType): pass
def __init__(self, parent=None): def __init__(self, parent=None):
super(IconSelector, self).__init__(parent) super(IconSelector, self).__init__(parent)
self.actions = ContextMenuActions() self.actions = ContextMenuActions()
self.actions.select_icon = QAction(u'Select icon...', self, triggered=self._SH_ChangeIconActionTriggered) self.actions.select_icon = QAction('Select icon...', self, triggered=self._SH_ChangeIconActionTriggered)
self.actions.remove_icon = QAction(u'Use contact provided icon', self, triggered=self._SH_RemoveIconActionTriggered) self.actions.remove_icon = QAction('Use contact provided icon', self, triggered=self._SH_RemoveIconActionTriggered)
self.icon_size = 48 self.icon_size = 48
self.default_icon = None self.default_icon = None
self.contact_icon = None self.contact_icon = None
...@@ -107,7 +107,7 @@ class IconSelector(QLabel): ...@@ -107,7 +107,7 @@ class IconSelector(QLabel):
super(IconSelector, self).mouseReleaseEvent(event) super(IconSelector, self).mouseReleaseEvent(event)
def _SH_ChangeIconActionTriggered(self): def _SH_ChangeIconActionTriggered(self):
filename = QFileDialog.getOpenFileName(self, u'Select Icon', self.last_icon_directory, u"Images (*.png *.tiff *.jpg *.xmp *.svg)")[0] filename = QFileDialog.getOpenFileName(self, 'Select Icon', self.last_icon_directory, "Images (*.png *.tiff *.jpg *.xmp *.svg)")[0]
if filename: if filename:
self.filename = filename self.filename = filename
...@@ -147,11 +147,11 @@ class StreamInfoLabel(QLabel): ...@@ -147,11 +147,11 @@ class StreamInfoLabel(QLabel):
def update_content(self): def update_content(self):
if self.session_type and self.codec_info: if self.session_type and self.codec_info:
text = u'%s (%s)' % (self.session_type, self.codec_info) text = '%s (%s)' % (self.session_type, self.codec_info)
if self.width() < QFontMetrics(self.font()).width(text): if self.width() < QFontMetrics(self.font()).width(text):
text = self.session_type text = self.session_type
else: else:
text = self.session_type or u'' text = self.session_type or ''
self.setText(text) self.setText(text)
...@@ -168,7 +168,7 @@ class DurationLabel(QLabel): ...@@ -168,7 +168,7 @@ class DurationLabel(QLabel):
seconds = value.seconds % 60 seconds = value.seconds % 60
minutes = value.seconds // 60 % 60 minutes = value.seconds // 60 % 60
hours = value.seconds//3600 + value.days*24 hours = value.seconds//3600 + value.days*24
self.setText(u'%d:%02d:%02d' % (hours, minutes, seconds)) self.setText('%d:%02d:%02d' % (hours, minutes, seconds))
value = property(_get_value, _set_value) value = property(_get_value, _set_value)
del _get_value, _set_value del _get_value, _set_value
...@@ -186,7 +186,7 @@ class LatencyLabel(QLabel): ...@@ -186,7 +186,7 @@ class LatencyLabel(QLabel):
def _set_value(self, value): def _set_value(self, value):
self.__dict__['value'] = value self.__dict__['value'] = value
if value > self.threshold: if value > self.threshold:
text = u'Latency %sms' % value text = 'Latency %sms' % value
self.setMinimumWidth(QFontMetrics(self.font()).width(text)) self.setMinimumWidth(QFontMetrics(self.font()).width(text))
self.setText(text) self.setText(text)
self.show() self.show()
...@@ -209,7 +209,7 @@ class PacketLossLabel(QLabel): ...@@ -209,7 +209,7 @@ class PacketLossLabel(QLabel):
def _set_value(self, value): def _set_value(self, value):
self.__dict__['value'] = value self.__dict__['value'] = value
if value > self.threshold: if value > self.threshold:
text = u'Packet loss %s%%' % value text = 'Packet loss %s%%' % value
self.setMinimumWidth(QFontMetrics(self.font()).width(text)) self.setMinimumWidth(QFontMetrics(self.font()).width(text))
self.setText(text) self.setText(text)
self.show() self.show()
...@@ -220,7 +220,7 @@ class PacketLossLabel(QLabel): ...@@ -220,7 +220,7 @@ class PacketLossLabel(QLabel):
del _get_value, _set_value del _get_value, _set_value
class Status(unicode): class Status(str):
def __new__(cls, value, color='black', context=None): def __new__(cls, value, color='black', context=None):
instance = super(Status, cls).__new__(cls, value) instance = super(Status, cls).__new__(cls, value)
instance.color = color instance.color = color
...@@ -230,7 +230,7 @@ class Status(unicode): ...@@ -230,7 +230,7 @@ class Status(unicode):
def __eq__(self, other): def __eq__(self, other):
if isinstance(other, Status): if isinstance(other, Status):
return super(Status, self).__eq__(other) and self.color == other.color and self.context == other.context return super(Status, self).__eq__(other) and self.color == other.color and self.context == other.context
elif isinstance(other, basestring): elif isinstance(other, str):
return super(Status, self).__eq__(other) return super(Status, self).__eq__(other)
return NotImplemented return NotImplemented
...@@ -256,9 +256,9 @@ class StatusLabel(QLabel): ...@@ -256,9 +256,9 @@ class StatusLabel(QLabel):
palette.setColor(QPalette.Inactive, QPalette.WindowText, color) palette.setColor(QPalette.Inactive, QPalette.WindowText, color)
palette.setColor(QPalette.Inactive, QPalette.Text, color) palette.setColor(QPalette.Inactive, QPalette.Text, color)
self.setPalette(palette) self.setPalette(palette)
self.setText(unicode(value)) self.setText(str(value))
else: else:
self.setText(u'') self.setText('')
value = property(_get_value, _set_value) value = property(_get_value, _set_value)
del _get_value, _set_value del _get_value, _set_value
...@@ -301,7 +301,7 @@ class StateColorMapping(dict): ...@@ -301,7 +301,7 @@ class StateColorMapping(dict):
class ContactState(QLabel, ColorHelperMixin): class ContactState(QLabel, ColorHelperMixin):
state = QtDynamicProperty('state', unicode) state = QtDynamicProperty('state', str)
def __init__(self, parent=None): def __init__(self, parent=None):
super(ContactState, self).__init__(parent) super(ContactState, self).__init__(parent)
......
...@@ -25,13 +25,13 @@ class SideWidget(QWidget): ...@@ -25,13 +25,13 @@ class SideWidget(QWidget):
class LineEdit(QLineEdit): class LineEdit(QLineEdit):
inactiveText = QtDynamicProperty('inactiveText', unicode) inactiveText = QtDynamicProperty('inactiveText', str)
widgetSpacing = QtDynamicProperty('widgetSpacing', int) widgetSpacing = QtDynamicProperty('widgetSpacing', int)
def __init__(self, parent=None, contents=u""): def __init__(self, parent=None, contents=""):
super(LineEdit, self).__init__(contents, parent) super(LineEdit, self).__init__(contents, parent)
box_direction = QBoxLayout.RightToLeft if self.isRightToLeft() else QBoxLayout.LeftToRight box_direction = QBoxLayout.RightToLeft if self.isRightToLeft() else QBoxLayout.LeftToRight
self.inactiveText = u"" self.inactiveText = ""
self.left_widget = SideWidget(self) self.left_widget = SideWidget(self)
self.left_widget.resize(0, 0) self.left_widget.resize(0, 0)
self.left_layout = QHBoxLayout(self.left_widget) self.left_layout = QHBoxLayout(self.left_widget)
...@@ -211,7 +211,7 @@ class ClearButton(QAbstractButton): ...@@ -211,7 +211,7 @@ class ClearButton(QAbstractButton):
super(ClearButton, self).__init__(parent) super(ClearButton, self).__init__(parent)
self.setCursor(Qt.ArrowCursor) self.setCursor(Qt.ArrowCursor)
self.setFocusPolicy(Qt.NoFocus) self.setFocusPolicy(Qt.NoFocus)
self.setToolTip(u"Clear") self.setToolTip("Clear")
self.setVisible(False) self.setVisible(False)
self.setMinimumSize(size+2, size+2) self.setMinimumSize(size+2, size+2)
pixmap = QPixmap() pixmap = QPixmap()
...@@ -274,7 +274,7 @@ class SearchBox(LineEdit): ...@@ -274,7 +274,7 @@ class SearchBox(LineEdit):
self.clear_button.hide() self.clear_button.hide()
self.clear_button.clicked.connect(self.clear) self.clear_button.clicked.connect(self.clear)
self.textChanged.connect(self._SH_TextChanged) self.textChanged.connect(self._SH_TextChanged)
self.inactiveText = u"Search" self.inactiveText = "Search"
def keyPressEvent(self, event): def keyPressEvent(self, event):
if event.key() == Qt.Key_Escape: if event.key() == Qt.Key_Escape:
......
...@@ -56,10 +56,10 @@ class OTRWidget(base_class, ui_class): ...@@ -56,10 +56,10 @@ class OTRWidget(base_class, ui_class):
@peer_verified.setter @peer_verified.setter
def peer_verified(self, verified): def peer_verified(self, verified):
self.__dict__['peer_verified'] = verified self.__dict__['peer_verified'] = verified
self.validate_button.setText(u'Invalidate' if verified else u'Validate') self.validate_button.setText('Invalidate' if verified else 'Validate')
self.validate_button.setChecked(verified) self.validate_button.setChecked(verified)
self.validate_button.setEnabled(verified or self.verification_stack.currentWidget() is not self.smp_panel or self.smp_status is SMPVerification.Succeeded) self.validate_button.setEnabled(verified or self.verification_stack.currentWidget() is not self.smp_panel or self.smp_status is SMPVerification.Succeeded)
self.peer_fingerprint_value.setStyleSheet(u'QLabel {{ color: {}; }}'.format(self.color_table['green'] if verified else self.color_table['orange'])) self.peer_fingerprint_value.setStyleSheet('QLabel {{ color: {}; }}'.format(self.color_table['green'] if verified else self.color_table['orange']))
self.smp_status_value.setText(self.smp_status_text) self.smp_status_value.setText(self.smp_status_text)
@property @property
...@@ -93,13 +93,13 @@ class OTRWidget(base_class, ui_class): ...@@ -93,13 +93,13 @@ class OTRWidget(base_class, ui_class):
@property @property
def smp_status_text(self): def smp_status_text(self):
if self.peer_verified: if self.peer_verified:
return u'<span style="color: {[green]};">Verified</span>'.format(self.color_table) return '<span style="color: {[green]};">Verified</span>'.format(self.color_table)
elif self.smp_status is SMPVerification.Succeeded: elif self.smp_status is SMPVerification.Succeeded:
return u'<span style="color: {[green]};">Succeeded</span>'.format(self.color_table) return '<span style="color: {[green]};">Succeeded</span>'.format(self.color_table)
elif self.smp_status is SMPVerification.Failed: elif self.smp_status is SMPVerification.Failed:
return u'<span style="color: {[orange]};">Failed</span>'.format(self.color_table) return '<span style="color: {[orange]};">Failed</span>'.format(self.color_table)
else: else:
return u'{}'.format(self.smp_status.value) return '{}'.format(self.smp_status.value)
def hideEvent(self, event): def hideEvent(self, event):
if not event.spontaneous(): if not event.spontaneous():
......
from __future__ import division
from PyQt5.QtCore import QEvent, QRectF, QSize from PyQt5.QtCore import QEvent, QRectF, QSize
from PyQt5.QtSvg import QSvgWidget from PyQt5.QtSvg import QSvgWidget
...@@ -12,7 +12,7 @@ __all__ = ['Spinner'] ...@@ -12,7 +12,7 @@ __all__ = ['Spinner']
class Spinner(QSvgWidget): class Spinner(QSvgWidget):
icon_file = QtDynamicProperty('icon_file', type=unicode) icon_file = QtDynamicProperty('icon_file', type=str)
icon_size = QtDynamicProperty('icon_size', type=QSize) icon_size = QtDynamicProperty('icon_size', type=QSize)
icon_crop = QtDynamicProperty('icon_crop', type=int) icon_crop = QtDynamicProperty('icon_crop', type=int)
......
...@@ -4,7 +4,7 @@ __all__ = ['QtDynamicProperty', 'ContextMenuActions'] ...@@ -4,7 +4,7 @@ __all__ = ['QtDynamicProperty', 'ContextMenuActions']
class QtDynamicProperty(object): class QtDynamicProperty(object):
def __init__(self, name, type=unicode): def __init__(self, name, type=str):
self.name = name self.name = name
self.type = type self.type = type
......
from __future__ import division
from PyQt5.QtCore import Qt, QMetaObject, QPoint, QRect, QTimer, pyqtSignal from PyQt5.QtCore import Qt, QMetaObject, QPoint, QRect, QTimer, pyqtSignal
from PyQt5.QtGui import QColor, QCursor, QIcon, QImage, QPainter, QPixmap, QTransform from PyQt5.QtGui import QColor, QCursor, QIcon, QImage, QPainter, QPixmap, QTransform
...@@ -37,10 +37,10 @@ class InteractionState(object): ...@@ -37,10 +37,10 @@ class InteractionState(object):
class VideoSurface(QWidget): class VideoSurface(QWidget):
class TopLeftCorner: __metaclass__ = MarkerType class TopLeftCorner(metaclass=MarkerType): pass
class TopRightCorner: __metaclass__ = MarkerType class TopRightCorner(metaclass=MarkerType): pass
class BottomLeftCorner: __metaclass__ = MarkerType class BottomLeftCorner(metaclass=MarkerType): pass
class BottomRightCorner: __metaclass__ = MarkerType class BottomRightCorner(metaclass=MarkerType): pass
adjusted = pyqtSignal(QRect, QRect) # the widget was adjusted by the user (if interactive) adjusted = pyqtSignal(QRect, QRect) # the widget was adjusted by the user (if interactive)
......
...@@ -43,11 +43,11 @@ class ZRTPWidget(base_class, ui_class): ...@@ -43,11 +43,11 @@ class ZRTPWidget(base_class, ui_class):
def _set_peer_verified(self, verified): def _set_peer_verified(self, verified):
self.__dict__['peer_verified'] = verified self.__dict__['peer_verified'] = verified
if verified: if verified:
self.validate_button.setText(u'Invalidate') self.validate_button.setText('Invalidate')
self.status_value.setText(u'<span style="color: hsv(100, 85%, 100%);">Verified</span>') self.status_value.setText('<span style="color: hsv(100, 85%, 100%);">Verified</span>')
else: else:
self.validate_button.setText(u'Validate') self.validate_button.setText('Validate')
self.status_value.setText(u'<span style="color: hsv(20, 85%, 100%);">Not verified</span>') self.status_value.setText('<span style="color: hsv(20, 85%, 100%);">Not verified</span>')
self.validate_button.setChecked(verified) self.validate_button.setChecked(verified)
peer_verified = property(_get_peer_verified, _set_peer_verified) peer_verified = property(_get_peer_verified, _set_peer_verified)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment