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

2to3 run

parent 77035393
#!/usr/bin/python2
#!/usr/bin/python3
import os
import sys
......
......@@ -88,9 +88,7 @@ class IPAddressMonitor(object):
self.greenlet = None
class Blink(QApplication):
__metaclass__ = QSingleton
class Blink(QApplication, metaclass=QSingleton):
implements(IObserver)
def __init__(self):
......@@ -214,6 +212,6 @@ class Blink(QApplication):
@run_in_gui_thread
def _NH_SIPApplicationGotFatalError(self, notification):
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)
......@@ -34,16 +34,14 @@ credits_text = """
ui_class, base_class = uic.loadUiType(Resources.get('about_panel.ui'))
class AboutPanel(base_class, ui_class):
__metaclass__ = QSingleton
class AboutPanel(base_class, ui_class, metaclass=QSingleton):
def __init__(self, parent=None):
super(AboutPanel, self).__init__(parent)
with Resources.directory:
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
self.credits_text.setFixedWidth(credits_width)
......
......@@ -3,8 +3,8 @@ import cjson
import os
import re
import sys
import urllib
import urllib2
import urllib.request, urllib.parse, urllib.error
import urllib.request, urllib.error, urllib.parse
from PyQt5 import uic
from PyQt5.QtCore import Qt, QAbstractListModel, QModelIndex, QSortFilterProxyModel, QUrl, QUrlQuery
......@@ -68,7 +68,7 @@ class AccountInfo(object):
@property
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
def icon(self):
......@@ -80,7 +80,7 @@ class AccountInfo(object):
return self.inactive_icon
def __eq__(self, other):
if isinstance(other, basestring):
if isinstance(other, str):
return self.name == other
elif isinstance(other, (Account, BonjourAccount)):
return self.account == other
......@@ -234,9 +234,7 @@ class AccountSelector(QComboBox):
ui_class, base_class = uic.loadUiType(Resources.get('add_account.ui'))
class AddAccountDialog(base_class, ui_class):
__metaclass__ = QSingleton
class AddAccountDialog(base_class, ui_class, metaclass=QSingleton):
implements(IObserver)
def __init__(self, parent=None):
......@@ -256,7 +254,7 @@ class AddAccountDialog(base_class, ui_class):
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
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.panel_view.setCurrentWidget(self.add_account_panel)
self.new_password_editor.textChanged.connect(self._SH_PasswordTextChanged)
......@@ -362,7 +360,7 @@ class AddAccountDialog(base_class, ui_class):
self.accept_button.setEnabled(all(input.text_valid for input in inputs))
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):
red = '#cc0000'
......@@ -401,11 +399,11 @@ class AddAccountDialog(base_class, ui_class):
def _initialize(self):
self.display_name = user_info.fullname
self.username = user_info.username.lower().replace(u' ', u'.')
self.sip_address = u''
self.password = u''
self.verify_password = u''
self.email_address = u''
self.username = user_info.username.lower().replace(' ', '.')
self.sip_address = ''
self.password = ''
self.verify_password = ''
self.email_address = ''
@run_in_thread('network-io')
def _create_sip_account(self, username, password, email_address, display_name, timezone=None):
......@@ -425,7 +423,7 @@ class AddAccountDialog(base_class, ui_class):
tzinfo=timezone)
try:
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 = defaultdict(lambda: None, response_data)
if response_data['success']:
......@@ -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))
except (cjson.DecodeError, KeyError):
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))
finally:
call_in_gui_thread(self.setEnabled, True)
......@@ -476,7 +474,7 @@ class AddAccountDialog(base_class, ui_class):
makedirs(ApplicationData.get('tls'))
certificate_path = ApplicationData.get(os.path.join('tls', sip_address+'.crt'))
certificate_file = open(certificate_path, 'w')
os.chmod(certificate_path, 0600)
os.chmod(certificate_path, 0o600)
certificate_file.write(crt+key)
certificate_file.close()
ca_path = ApplicationData.get(os.path.join('tls', 'ca.crt'))
......@@ -585,7 +583,7 @@ class ServerToolsWebView(QWebView):
@property
def query_items(self):
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):
return self.__dict__['account']
......@@ -670,9 +668,7 @@ class ServerToolsWebView(QWebView):
ui_class, base_class = uic.loadUiType(Resources.get('server_tools.ui'))
class ServerToolsWindow(base_class, ui_class):
__metaclass__ = QSingleton
class ServerToolsWindow(base_class, ui_class, metaclass=QSingleton):
implements(IObserver)
def __init__(self, model, parent=None):
......@@ -755,12 +751,12 @@ class ServerToolsWindow(base_class, ui_class):
self._update_navigation_buttons()
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):
menu = self.account_button.menu()
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)
action = menu.addAction(account_info.name)
action.setData(account_info.account)
......
This diff is collapsed.
......@@ -34,8 +34,8 @@ class PresenceSettingsExtension(PresenceSettings):
class PSTNSettings(SettingsGroup):
idd_prefix = Setting(type=unicode, default=None, nillable=True)
prefix = Setting(type=unicode, default=None, nillable=True)
idd_prefix = Setting(type=str, default=None, nillable=True)
prefix = Setting(type=str, default=None, nillable=True)
class RTPSettingsExtension(RTPSettings):
......@@ -71,7 +71,7 @@ class XCAPSettingsExtension(XCAPSettings):
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
msrp = MSRPSettingsExtension
pstn = PSTNSettings
......
......@@ -13,8 +13,8 @@ SharedSetting.set_namespace('ag-projects:blink')
class PresenceSettingsExtension(PresenceSettings):
state = RuntimeSetting(type=unicode, nillable=True, default=None)
note = RuntimeSetting(type=unicode, nillable=True, default=None)
state = RuntimeSetting(type=str, nillable=True, default=None)
note = RuntimeSetting(type=str, nillable=True, default=None)
class ContactExtension(ContactExtension):
......
......@@ -3,9 +3,8 @@
import os
import re
from urllib import pathname2url, url2pathname
from urlparse import urlparse
from urllib.request import pathname2url, url2pathname
from urllib.parse import urlparse
from application.python.types import MarkerType
from sipsimple.configuration.datatypes import Hostname, List
......@@ -16,12 +15,12 @@ from blink.resources import ApplicationData
__all__ = ['ApplicationDataPath', 'DefaultPath', 'SoundFile', 'CustomSoundFile', 'HTTPURL', 'FileURL', 'IconDescriptor', 'PresenceState', 'PresenceStateList', 'GraphTimeScale']
class ApplicationDataPath(unicode):
class ApplicationDataPath(str):
def __new__(cls, path):
path = os.path.normpath(path)
if path.startswith(ApplicationData.directory+os.path.sep):
path = path[len(ApplicationData.directory+os.path.sep):]
return unicode.__new__(cls, path)
return str.__new__(cls, path)
@property
def normalized(self):
......@@ -36,11 +35,11 @@ class SoundFile(object):
raise ValueError('illegal volume level: %d' % self.volume)
def __getstate__(self):
return u'%s,%s' % (self.__dict__['path'], self.volume)
return '%s,%s' % (self.__dict__['path'], self.volume)
def __setstate__(self, state):
try:
path, volume = state.rsplit(u',', 1)
path, volume = state.rsplit(',', 1)
except ValueError:
self.__init__(state)
else:
......@@ -60,7 +59,7 @@ class SoundFile(object):
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
......@@ -72,9 +71,9 @@ class CustomSoundFile(object): # check if this data type is still needed -Dan
def __getstate__(self):
if self.path is DefaultPath:
return u'default'
return 'default'
else:
return u'file:%s,%s' % (self.__dict__['path'], self.volume)
return 'file:%s,%s' % (self.__dict__['path'], self.volume)
def __setstate__(self, 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
del _get_path, _set_path
class HTTPURL(unicode):
class HTTPURL(str):
def __new__(cls, value):
value = unicode(value)
value = str(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)
Hostname(url.hostname)
if url.port is not None and not (0 < url.port < 65536):
......@@ -114,14 +113,14 @@ class HTTPURL(unicode):
return value
class FileURL(unicode):
class FileURL(str):
def __new__(cls, value):
if not value.startswith('file:'):
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)
netloc = property(lambda self: self.__parsed__.netloc)
params = property(lambda self: self.__parsed__.params)
......@@ -140,13 +139,13 @@ class IconDescriptor(object):
def __getstate__(self):
if self.etag is None:
return unicode(self.url)
return str(self.url)
else:
return u'%s,%s' % (self.url, self.etag)
return '%s,%s' % (self.url, self.etag)
def __setstate__(self, state):
try:
url, etag = state.rsplit(u',', 1)
url, etag = state.rsplit(',', 1)
except ValueError:
self.__init__(state)
else:
......@@ -167,18 +166,18 @@ class IconDescriptor(object):
class PresenceState(object):
def __init__(self, state, note=None):
self.state = unicode(state)
self.state = str(state)
self.note = note
def __getstate__(self):
if not self.note:
return unicode(self.state)
return str(self.state)
else:
return u'%s,%s' % (self.state, self.note)
return '%s,%s' % (self.state, self.note)
def __setstate__(self, data):
try:
state, note = data.split(u',', 1)
state, note = data.split(',', 1)
except ValueError:
self.__init__(data)
else:
......
......@@ -41,7 +41,7 @@ class ChatSettingsExtension(ChatSettings):
class GoogleContactsSettings(SettingsGroup):
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):
......@@ -111,7 +111,7 @@ class BlinkScreenSharingSettings(SettingsGroup):
class BlinkPresenceSettings(SettingsGroup):
current_state = Setting(type=PresenceState, default=PresenceState('Available'))
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)
......
This diff is collapsed.
......@@ -13,9 +13,7 @@ class EventMeta(type(QEvent)):
cls.id = QEvent.registerEventType() if name != 'EventBase' else None
class EventBase(QEvent):
__metaclass__ = EventMeta
class EventBase(QEvent, metaclass=EventMeta):
def __new__(cls, *args, **kw):
if cls is EventBase:
raise TypeError("EventBase cannot be directly instantiated")
......
......@@ -66,9 +66,9 @@ class FileTransferWindow(base_class, ui_class):
def update_status(self):
total = len(self.model.items)
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:
text += u' (%d active)' % active
text += ' (%d active)' % active
self.status_label.setText(text)
def handle_notification(self, notification):
......
import bisect
import cPickle as pickle
import pickle as pickle
import re
from PyQt5.QtGui import QIcon
......@@ -24,8 +24,7 @@ from blink.util import run_in_gui_thread
__all__ = ['HistoryManager']
class HistoryManager(object):
__metaclass__ = Singleton
class HistoryManager(object, metaclass=Singleton):
implements(IObserver)
history_size = 20
......@@ -149,7 +148,7 @@ class HistoryEntry(object):
@property
def text(self):
result = unicode(self.name or self.uri)
result = str(self.name or self.uri)
if self.call_time:
call_time = self.call_time.astimezone(tzlocal())
call_date = call_time.date()
......@@ -195,6 +194,6 @@ class HistoryEntry(object):
display_name = session.remote_identity.display_name
else:
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):
file.close()
class LogManager(object):
__metaclass__ = Singleton
class LogManager(object, metaclass=Singleton):
implements(IObserver)
def __init__(self):
......
This diff is collapsed.
This diff is collapsed.
......@@ -112,7 +112,7 @@ class BlinkPresenceState(object):
device = pidf.Device('DID-%s' % instance_id, device_id=pidf.DeviceID(instance_id))
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)
return doc
......@@ -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()):
# Our current state is the winning one
return
status = unicode(service.status.extended).title()
note = None if not service.notes else unicode(list(service.notes)[0])
status = str(service.status.extended).title()
note = None if not service.notes else str(list(service.notes)[0])
if status == 'Offline':
status = 'Invisible'
note = None
......@@ -304,12 +304,12 @@ class ContactIcon(object):
@classmethod
def fetch(cls, url, etag=None, descriptor_etag=None):
headers = {'If-None-Match': etag} if etag else {}
req = urllib2.Request(url, headers=headers)
req = urllib.request.Request(url, headers=headers)
try:
response = urllib2.urlopen(req)
response = urllib.request.urlopen(req)
content = response.read()
info = response.info()
except (ConnectionLost, urllib2.URLError, urllib2.HTTPError):
except (ConnectionLost, urllib.error.URLError, urllib.error.HTTPError):
return None
content_type = info.getheader('content-type')
etag = info.getheader('etag')
......@@ -352,7 +352,7 @@ class PresenceSubscriptionHandler(object):
notification_center.remove_observer(self, name='SIPAccountGotPresenceWinfo')
self._pidf_map.clear()
self._winfo_map.clear()
for timer in self._winfo_timers.values():
for timer in list(self._winfo_timers.values()):
if timer.active():
timer.cancel()
self._winfo_timers.clear()
......@@ -375,9 +375,9 @@ class PresenceSubscriptionHandler(object):
# If no URIs were provided, process all of them
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)
for uri in uris:
......@@ -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)):
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:
state = note = icon = None
else:
......@@ -393,11 +393,11 @@ class PresenceSubscriptionHandler(object):
services.sort(key=service_sort_key, reverse=True)
service = services[0]
if service.status.extended:
state = unicode(service.status.extended)
state = str(service.status.extended)
else:
state = 'available' if service.status.basic == 'open' else 'offline'
note = unicode(next(iter(service.notes))) if service.notes else None
icon_url = unicode(service.icon) if service.icon else None
note = str(next(iter(service.notes))) if service.notes else None
icon_url = str(service.icon) if service.icon else None
if icon_url:
url, token, icon_hash = icon_url.partition('#blink-icon')
......@@ -456,12 +456,12 @@ class PresenceSubscriptionHandler(object):
def _NH_SIPAccountGotPresenceState(self, notification):
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, {})
if notification.data.full_state:
account_map.clear()
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):
addressbook_manager = addressbook.AddressbookManager()
......@@ -535,7 +535,7 @@ class PendingWatcherDialog(base_class, ui_class):
icon = icon_manager.get(self.contact.id)
if icon is not None:
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.uri_label.setText(uri)
self.accept_button.released.connect(self._accept_watcher)
......
......@@ -21,9 +21,9 @@ from blink.util import run_in_gui_thread
__all__ = ['ApplicationData', 'Resources', 'IconManager']
class DirectoryContextManager(unicode):
class DirectoryContextManager(str):
def __enter__(self):
self.directory = os.getcwdu()
self.directory = os.getcwd()
os.chdir(self)
def __exit__(self, type, value, traceback):
......@@ -40,11 +40,11 @@ class ApplicationData(object):
if cls._cached_directory is None:
if platform.system() == 'Darwin':
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':
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:
cls._cached_directory = Path(u'~/.blink').normalized
cls._cached_directory = Path('~/.blink').normalized
return DirectoryContextManager(cls._cached_directory)
@classmethod
......@@ -83,9 +83,7 @@ class Resources(object):
return os.path.join(cls.directory, os.path.normpath(resource))
class IconManager(object):
__metaclass__ = Singleton
class IconManager(object, metaclass=Singleton):
max_size = 256
def __init__(self):
......
......@@ -22,7 +22,7 @@ class RFBSettings(object):
def __init__(self, depth, quality, compression, encodings):
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)
allowed_levels = range(10)
allowed_levels = list(range(10))
if quality not in allowed_levels:
raise ValueError("invalid quality value: %r (should be between 0..9)" % quality)
if compression not in allowed_levels:
......@@ -83,7 +83,7 @@ class VNCClient(QObject):
imageSizeChanged = pyqtSignal(QSize)
imageChanged = pyqtSignal(int, int, int, int)
passwordRequested = pyqtSignal(bool)
textCut = pyqtSignal(unicode)
textCut = pyqtSignal(str)
def __init__(self, host, port, settings, parent=None):
super(VNCClient, self).__init__(parent)
......
from __future__ import division
import os
import platform
......@@ -401,7 +401,7 @@ class ScreensharingDialog(base_class, ui_class):
return False
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_editor.show()
self.username_editor.clear()
......@@ -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)
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_editor.hide()
self.username_editor.clear()
......
This diff is collapsed.
......@@ -90,7 +90,7 @@ class FunctionExecutor(object):
def wait(self):
self.event.wait()
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:
return self.result
......
......@@ -28,8 +28,8 @@ class ConferenceButton(ToolButton):
def __init__(self, parent=None):
super(ConferenceButton, self).__init__(parent)
self.make_conference_action = QAction(u'Conference all single sessions', self, triggered=self.makeConference.emit)
self.break_conference_action = QAction(u'Break selected conference', self, triggered=self.breakConference.emit)
self.make_conference_action = QAction('Conference all single sessions', self, triggered=self.makeConference.emit)
self.break_conference_action = QAction('Break selected conference', self, triggered=self.breakConference.emit)
self.toggled.connect(self._SH_Toggled)
self.addAction(self.make_conference_action)
......@@ -105,8 +105,7 @@ class SegmentTypeMeta(type):
return cls.__name__
class SegmentType(object):
__metaclass__ = SegmentTypeMeta
class SegmentType(object, metaclass=SegmentTypeMeta):
style_sheet = ''
......@@ -260,8 +259,8 @@ class SwitchViewButton(QPushButton):
viewChanged = pyqtSignal(int)
button_text = {ContactView: u'Switch to Calls', SessionView: u'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_text = {ContactView: 'Switch to Calls', SessionView: 'Switch to Contacts'}
button_dnd_text = {ContactView: 'Drag here to add to a conference', SessionView: 'Drag here to go back to contacts'}
dnd_style_sheet1 = """
QPushButton {
......
......@@ -16,7 +16,7 @@ class SlidingStackedWidget(QStackedWidget):
animationFinished = pyqtSignal()
LeftToRight, RightToLeft, TopToBottom, BottomToTop, Automatic = range(5)
LeftToRight, RightToLeft, TopToBottom, BottomToTop, Automatic = list(range(5))
def __init__(self, parent=None):
super(SlidingStackedWidget, self).__init__(parent)
......
......@@ -11,8 +11,8 @@ __all__ = ['BackgroundFrame']
class BackgroundFrame(QFrame):
backgroundColor = QtDynamicProperty('backgroundColor', unicode)
backgroundImage = QtDynamicProperty('backgroundImage', unicode)
backgroundColor = QtDynamicProperty('backgroundColor', str)
backgroundImage = QtDynamicProperty('backgroundImage', str)
imageGeometry = QtDynamicProperty('imageGeometry', QRect)
def __init__(self, parent=None):
......
......@@ -16,9 +16,7 @@ from blink.widgets.util import QtDynamicProperty
__all__ = ['Graph', 'GraphWidget', 'HeightScaler', 'LogarithmicScaler', 'MaxScaler', 'SoftScaler']
class HeightScaler(object):
__metaclass__ = ABCMeta
class HeightScaler(object, metaclass=ABCMeta):
@abstractmethod
def get_height(self, max_value):
raise NotImplementedError
......@@ -91,7 +89,7 @@ class GraphWidget(QWidget, ColorHelperMixin):
fillEnvelope = QtDynamicProperty('fillEnvelope', type=bool)
fillTransparency = QtDynamicProperty('fillTransparency', type=int)
EnvelopeStyle, BarStyle = range(2)
EnvelopeStyle, BarStyle = list(range(2))
AutomaticHeight = 0
updated = pyqtSignal()
......
......@@ -22,13 +22,13 @@ class IconSelector(QLabel):
default_icon = QtDynamicProperty('default_icon', QIcon)
icon_size = QtDynamicProperty('icon_size', int)
class NotSelected: __metaclass__ = MarkerType
class NotSelected(metaclass=MarkerType): pass
def __init__(self, parent=None):
super(IconSelector, self).__init__(parent)
self.actions = ContextMenuActions()
self.actions.select_icon = QAction(u'Select icon...', self, triggered=self._SH_ChangeIconActionTriggered)
self.actions.remove_icon = QAction(u'Use contact provided icon', self, triggered=self._SH_RemoveIconActionTriggered)
self.actions.select_icon = QAction('Select icon...', self, triggered=self._SH_ChangeIconActionTriggered)
self.actions.remove_icon = QAction('Use contact provided icon', self, triggered=self._SH_RemoveIconActionTriggered)
self.icon_size = 48
self.default_icon = None
self.contact_icon = None
......@@ -107,7 +107,7 @@ class IconSelector(QLabel):
super(IconSelector, self).mouseReleaseEvent(event)
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:
self.filename = filename
......@@ -147,11 +147,11 @@ class StreamInfoLabel(QLabel):
def update_content(self):
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):
text = self.session_type
else:
text = self.session_type or u''
text = self.session_type or ''
self.setText(text)
......@@ -168,7 +168,7 @@ class DurationLabel(QLabel):
seconds = value.seconds % 60
minutes = value.seconds // 60 % 60
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)
del _get_value, _set_value
......@@ -186,7 +186,7 @@ class LatencyLabel(QLabel):
def _set_value(self, value):
self.__dict__['value'] = value
if value > self.threshold:
text = u'Latency %sms' % value
text = 'Latency %sms' % value
self.setMinimumWidth(QFontMetrics(self.font()).width(text))
self.setText(text)
self.show()
......@@ -209,7 +209,7 @@ class PacketLossLabel(QLabel):
def _set_value(self, value):
self.__dict__['value'] = value
if value > self.threshold:
text = u'Packet loss %s%%' % value
text = 'Packet loss %s%%' % value
self.setMinimumWidth(QFontMetrics(self.font()).width(text))
self.setText(text)
self.show()
......@@ -220,7 +220,7 @@ class PacketLossLabel(QLabel):
del _get_value, _set_value
class Status(unicode):
class Status(str):
def __new__(cls, value, color='black', context=None):
instance = super(Status, cls).__new__(cls, value)
instance.color = color
......@@ -230,7 +230,7 @@ class Status(unicode):
def __eq__(self, other):
if isinstance(other, Status):
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 NotImplemented
......@@ -256,9 +256,9 @@ class StatusLabel(QLabel):
palette.setColor(QPalette.Inactive, QPalette.WindowText, color)
palette.setColor(QPalette.Inactive, QPalette.Text, color)
self.setPalette(palette)
self.setText(unicode(value))
self.setText(str(value))
else:
self.setText(u'')
self.setText('')
value = property(_get_value, _set_value)
del _get_value, _set_value
......@@ -301,7 +301,7 @@ class StateColorMapping(dict):
class ContactState(QLabel, ColorHelperMixin):
state = QtDynamicProperty('state', unicode)
state = QtDynamicProperty('state', str)
def __init__(self, parent=None):
super(ContactState, self).__init__(parent)
......
......@@ -25,13 +25,13 @@ class SideWidget(QWidget):
class LineEdit(QLineEdit):
inactiveText = QtDynamicProperty('inactiveText', unicode)
inactiveText = QtDynamicProperty('inactiveText', str)
widgetSpacing = QtDynamicProperty('widgetSpacing', int)
def __init__(self, parent=None, contents=u""):
def __init__(self, parent=None, contents=""):
super(LineEdit, self).__init__(contents, parent)
box_direction = QBoxLayout.RightToLeft if self.isRightToLeft() else QBoxLayout.LeftToRight
self.inactiveText = u""
self.inactiveText = ""
self.left_widget = SideWidget(self)
self.left_widget.resize(0, 0)
self.left_layout = QHBoxLayout(self.left_widget)
......@@ -211,7 +211,7 @@ class ClearButton(QAbstractButton):
super(ClearButton, self).__init__(parent)
self.setCursor(Qt.ArrowCursor)
self.setFocusPolicy(Qt.NoFocus)
self.setToolTip(u"Clear")
self.setToolTip("Clear")
self.setVisible(False)
self.setMinimumSize(size+2, size+2)
pixmap = QPixmap()
......@@ -274,7 +274,7 @@ class SearchBox(LineEdit):
self.clear_button.hide()
self.clear_button.clicked.connect(self.clear)
self.textChanged.connect(self._SH_TextChanged)
self.inactiveText = u"Search"
self.inactiveText = "Search"
def keyPressEvent(self, event):
if event.key() == Qt.Key_Escape:
......
......@@ -56,10 +56,10 @@ class OTRWidget(base_class, ui_class):
@peer_verified.setter
def peer_verified(self, 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.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)
@property
......@@ -93,13 +93,13 @@ class OTRWidget(base_class, ui_class):
@property
def smp_status_text(self):
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:
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:
return u'<span style="color: {[orange]};">Failed</span>'.format(self.color_table)
return '<span style="color: {[orange]};">Failed</span>'.format(self.color_table)
else:
return u'{}'.format(self.smp_status.value)
return '{}'.format(self.smp_status.value)
def hideEvent(self, event):
if not event.spontaneous():
......
from __future__ import division
from PyQt5.QtCore import QEvent, QRectF, QSize
from PyQt5.QtSvg import QSvgWidget
......@@ -12,7 +12,7 @@ __all__ = ['Spinner']
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_crop = QtDynamicProperty('icon_crop', type=int)
......
......@@ -4,7 +4,7 @@ __all__ = ['QtDynamicProperty', 'ContextMenuActions']
class QtDynamicProperty(object):
def __init__(self, name, type=unicode):
def __init__(self, name, type=str):
self.name = name
self.type = type
......
from __future__ import division
from PyQt5.QtCore import Qt, QMetaObject, QPoint, QRect, QTimer, pyqtSignal
from PyQt5.QtGui import QColor, QCursor, QIcon, QImage, QPainter, QPixmap, QTransform
......@@ -37,10 +37,10 @@ class InteractionState(object):
class VideoSurface(QWidget):
class TopLeftCorner: __metaclass__ = MarkerType
class TopRightCorner: __metaclass__ = MarkerType
class BottomLeftCorner: __metaclass__ = MarkerType
class BottomRightCorner: __metaclass__ = MarkerType
class TopLeftCorner(metaclass=MarkerType): pass
class TopRightCorner(metaclass=MarkerType): pass
class BottomLeftCorner(metaclass=MarkerType): pass
class BottomRightCorner(metaclass=MarkerType): pass
adjusted = pyqtSignal(QRect, QRect) # the widget was adjusted by the user (if interactive)
......
......@@ -43,11 +43,11 @@ class ZRTPWidget(base_class, ui_class):
def _set_peer_verified(self, verified):
self.__dict__['peer_verified'] = verified
if verified:
self.validate_button.setText(u'Invalidate')
self.status_value.setText(u'<span style="color: hsv(100, 85%, 100%);">Verified</span>')
self.validate_button.setText('Invalidate')
self.status_value.setText('<span style="color: hsv(100, 85%, 100%);">Verified</span>')
else:
self.validate_button.setText(u'Validate')
self.status_value.setText(u'<span style="color: hsv(20, 85%, 100%);">Not verified</span>')
self.validate_button.setText('Validate')
self.status_value.setText('<span style="color: hsv(20, 85%, 100%);">Not verified</span>')
self.validate_button.setChecked(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