Skip to content

Commit

Permalink
simplify code using super()
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@24174 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Oct 18, 2019
1 parent ebcdc21 commit 73ea98c
Show file tree
Hide file tree
Showing 60 changed files with 127 additions and 130 deletions.
9 changes: 3 additions & 6 deletions src/xpra/colorstreamhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,8 @@ def _get_color(cls, level):
return cls.DEBUG
return cls.DEFAULT

def __init__(self, stream=None):
logging.StreamHandler.__init__(self, stream)

def format(self, record):
text = logging.StreamHandler.format(self, record)
text = super().format(record)
color = self._get_color(record.levelno)
return color + text + self.DEFAULT

Expand Down Expand Up @@ -111,7 +108,7 @@ def _set_color(self, code):
ctypes.windll.kernel32.SetConsoleTextAttribute(self._outhdl, code) #@UndefinedVariable

def __init__(self, stream=None):
logging.StreamHandler.__init__(self, stream)
super().__init__(stream)
# get file handle for the stream
import ctypes.util
crtname = ctypes.util.find_msvcrt()
Expand All @@ -121,7 +118,7 @@ def __init__(self, stream=None):
def emit(self, record):
color = self._get_color(record.levelno)
self._set_color(color)
logging.StreamHandler.emit(self, record)
super().emit(record)
self._set_color(self.FOREGROUND_WHITE)

# select ColorStreamHandler based on platform
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def error(self, msg : str, *args, **kwargs):
class CaptureHandler(logging.Handler):

def __init__(self):
logging.Handler.__init__(self, logging.DEBUG)
super().__init__(logging.DEBUG)
self.records = []

def handle(self, record):
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/platform/darwin/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def do_ready():
class OSX_Notifier(NotifierBase):

def __init__(self, closed_cb=None, action_cb=None):
NotifierBase.__init__(self, closed_cb, action_cb)
super().__init__(closed_cb, action_cb)
self.notifications = {}
self.notification_center = NSUserNotificationCenter.defaultUserNotificationCenter()
assert self.notification_center
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/platform/darwin/keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def get_keymap_modifiers(self):
return {}, [], ["lock", "control"]

def set_modifier_mappings(self, mappings):
KeyboardBase.set_modifier_mappings(self, mappings)
super().set_modifier_mappings(mappings)
self.meta_modifier = self.modifier_keys.get("Meta_L") or self.modifier_keys.get("Meta_R")
self.control_modifier = self.modifier_keys.get("Control_L") or self.modifier_keys.get("Control_R") or "control"
self.super_modifier = self.modifier_keys.get("Super_L") or self.modifier_keys.get("Super_R")
Expand Down
6 changes: 3 additions & 3 deletions src/xpra/platform/darwin/osx_clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, *args, **kwargs):
raise Exception("cannot load Pasteboard, maybe not running from a GUI session?")
kwargs["clipboard.local"] = "CLIPBOARD"
kwargs["clipboards.local"] = ["CLIPBOARD"]
ClipboardTimeoutHelper.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)


def __repr__(self):
Expand All @@ -57,7 +57,7 @@ def make_proxy(self, clipboard):
def _munge_wire_selection_to_raw(self, encoding, dtype, dformat, data):
if encoding=="atoms":
return _filter_targets(data)
return ClipboardTimeoutHelper._munge_wire_selection_to_raw(self, encoding, dtype, dformat, data)
return super()._munge_wire_selection_to_raw(encoding, dtype, dformat, data)


class OSXClipboardProxy(ClipboardProxyCore):
Expand All @@ -66,7 +66,7 @@ def __init__(self, selection, pasteboard, send_clipboard_request_handler, send_c
self.pasteboard = pasteboard
self.send_clipboard_request_handler = send_clipboard_request_handler
self.send_clipboard_token_handler = send_clipboard_token_handler
ClipboardProxyCore.__init__(self, selection)
super().__init__(selection)
self.update_change_count()
#setup clipboard counter watcher:
w = get_UI_watcher(GLib.timeout_add, GLib.source_remove)
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/platform/darwin/osx_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class OSXMenuHelper(GTKTrayMenuBase):
"""

def __init__(self, client=None):
GTKTrayMenuBase.__init__(self, client)
super().__init__(client)
log("OSXMenuHelper(%s)", client)
self.menu_bar = None
self.hidden_window = None
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/platform/darwin/osx_tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class OSXTray(TrayBase):

def __init__(self, *args):
TrayBase.__init__(self, *args)
super().__init__(*args)
from xpra.platform.darwin.gui import get_OSXApplication
self.macapp = get_OSXApplication()
assert self.macapp, "cannot use OSX Tray without the native gtkosx_application bindings"
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/platform/darwin/shadow_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ def start_refresh(self, wid):
return
log.warn("Warning: CGRegisterScreenRefreshCallback failed with error %i", err)
log.warn(" using fallback timer method")
GTKShadowServerBase.start_refresh(self, wid)
super().start_refresh(wid)

def stop_refresh(self, wid):
log("stop_refresh(%i) mapped=%s, timer=%s", wid, self.mapped, self.refresh_timer)
#may stop the timer fallback:
GTKShadowServerBase.stop_refresh(self, wid)
super().stop_refresh(wid)
if self.refresh_registered and not self.mapped:
try:
err = CG.CGUnregisterScreenRefreshCallback(self.screen_refresh_callback, None)
Expand Down
8 changes: 4 additions & 4 deletions src/xpra/platform/win32/clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Win32Clipboard(ClipboardTimeoutHelper):
"""
def __init__(self, send_packet_cb, progress_cb=None, **kwargs):
self.init_window()
ClipboardTimeoutHelper.__init__(self, send_packet_cb, progress_cb, **kwargs)
super().__init__(send_packet_cb, progress_cb, **kwargs)

def init_window(self):
log("Win32Clipboard.init_window() creating clipboard window class and instance")
Expand Down Expand Up @@ -129,21 +129,21 @@ def make_proxy(self, selection):
def _munge_wire_selection_to_raw(self, encoding, dtype, dformat, data):
if encoding=="atoms":
return _filter_targets(data)
return ClipboardTimeoutHelper._munge_wire_selection_to_raw(self, encoding, dtype, dformat, data)
return super()._munge_wire_selection_to_raw(encoding, dtype, dformat, data)

def _munge_raw_selection_to_wire(self, target, dtype, dformat, data):
if dtype=="ATOM":
assert isinstance(data, (tuple, list))
return "atoms", _filter_targets(data)
return ClipboardTimeoutHelper._munge_raw_selection_to_wire(self, target, dtype, dformat, data)
return super()._munge_raw_selection_to_wire(target, dtype, dformat, data)


class Win32ClipboardProxy(ClipboardProxyCore):
def __init__(self, window, selection, send_clipboard_request_handler, send_clipboard_token_handler):
self.window = window
self.send_clipboard_request_handler = send_clipboard_request_handler
self.send_clipboard_token_handler = send_clipboard_token_handler
ClipboardProxyCore.__init__(self, selection)
super().__init__(selection)

def set_want_targets(self, want_targets):
self._want_targets = want_targets
Expand Down
8 changes: 4 additions & 4 deletions src/xpra/platform/win32/keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self):
KEY_TRANSLATIONS[("dead_grave", 65104, 55)] = "grave"

def set_modifier_mappings(self, mappings):
KeyboardBase.set_modifier_mappings(self, mappings)
super().set_modifier_mappings(mappings)
self.num_lock_modifier = self.modifier_keys.get("Num_Lock")
log("set_modifier_mappings found 'Num_Lock' with modifier value: %s", self.num_lock_modifier)
for x in ("ISO_Level3_Shift", "Mode_switch"):
Expand All @@ -66,7 +66,7 @@ def set_modifier_mappings(self, mappings):

def mask_to_names(self, mask):
""" Patch NUMLOCK and AltGr """
names = KeyboardBase.mask_to_names(self, mask)
names = super().mask_to_names(mask)
if EMULATE_ALTGR:
rmenu = GetKeyState(win32con.VK_RMENU)
#log("GetKeyState(VK_RMENU)=%s", rmenu)
Expand Down Expand Up @@ -207,7 +207,7 @@ def process_key_event(self, send_key_action_cb, wid, key_event):
key_event.keycode = -1
self.AltGr_modifiers(key_event.modifiers)
self.send_delayed_key()
KeyboardBase.process_key_event(self, send_key_action_cb, wid, key_event)
super().process_key_event(send_key_action_cb, wid, key_event)

def send_delayed_key(self):
#timeout: this must be a real one, send it now
Expand All @@ -218,4 +218,4 @@ def send_delayed_key(self):
rmenu = GetKeyState(win32con.VK_RMENU)
log("send_delayed_key() GetKeyState(VK_RMENU)=%s", rmenu)
if rmenu not in (0, 1):
KeyboardBase.process_key_event(self, *dk)
super().process_key_event(*dk)
2 changes: 1 addition & 1 deletion src/xpra/platform/win32/namedpipes/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
class NamedPipeConnection(Connection):
def __init__(self, name, pipe_handle, options):
log("NamedPipeConnection(%s, %#x)", name, pipe_handle, options)
Connection.__init__(self, name, "named-pipe", options=options)
super().__init__(name, "named-pipe", options=options)
self.pipe_handle = pipe_handle
self.read_buffer = (c_char*BUFSIZE)()
self.read_buffer_ptr = cast(addressof(self.read_buffer), c_void_p)
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/platform/win32/namedpipes/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(self, pipe_name, new_connection_cb=None):
self.pipe_name = pipe_name
self.new_connection_cb = new_connection_cb or self.new_connection
self.exit_loop = False
Thread.__init__(self, name="NamedPipeListener-%s" % pipe_name)
super().__init__(name="NamedPipeListener-%s" % pipe_name)
self.daemon = True
self.security_attributes = None
self.security_descriptor = None
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/platform/win32/shadow_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def init_capture(w, h, pixel_depth=32):
class SeamlessRootWindowModel(RootWindowModel):

def __init__(self, root, capture):
RootWindowModel.__init__(self, root, capture)
super().__init__(root, capture)
log("SeamlessRootWindowModel(%s, %s) SEAMLESS=%s", root, capture, SEAMLESS)
self.property_names.append("shape")
self.dynamic_property_names.append("shape")
Expand Down Expand Up @@ -333,7 +333,7 @@ def get_property(self, prop):
shape = {"Bounding.rectangles" : self.rectangles}
#provide clip rectangle? (based on workspace area?)
return shape
return RootWindowModel.get_property(self, prop)
return super().get_property(prop)


class ShadowServer(GTKShadowServerBase):
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/platform/win32/win32_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class Win32_Notifier(NotifierBase):

def __init__(self, *args):
NotifierBase.__init__(self, *args)
super().__init__(*args)
self.handles_actions = GTK_Notifier is not None
self.gtk_notifier = None
self.gtk_notifications = set()
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/platform/win32/win32_tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class Win32Tray(TrayBase):

def __init__(self, *args):
TrayBase.__init__(self, *args)
super().__init__(*args)
self.calculate_offset()
self.default_icon_extension = "ico"
icon_filename = get_icon_filename(self.default_icon_filename, "ico")
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/platform/xposix/appindicator_tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
DELETE_TEMP_FILE = envbool("XPRA_APPINDICATOR_DELETE_TEMP_FILE", True)

gi.require_version('AppIndicator3', '0.1')
from gi.repository import AppIndicator3, GdkPixbuf #pylint: disable=wrong-import-order
from gi.repository import AppIndicator3, GdkPixbuf #pylint: disable=wrong-import-order, wrong-import-position, ungrouped-imports

PASSIVE = AppIndicator3.IndicatorStatus.PASSIVE
ACTIVE = AppIndicator3.IndicatorStatus.ACTIVE
Expand All @@ -39,7 +39,7 @@ def Indicator(tooltip, filename, status):
class AppindicatorTray(TrayBase):

def __init__(self, *args, **kwargs):
TrayBase.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)
filename = get_icon_filename(self.default_icon_filename) or "xpra.png"
self._has_icon = False
self.tmp_filename = None
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class InitInfo(Exception):
class InitExit(Exception):
def __init__(self, status, msg):
self.status = status
Exception.__init__(self, msg)
super().__init__(msg)


DEBUG_CONFIG_PROPERTIES = os.environ.get("XPRA_DEBUG_CONFIG_PROPERTIES", "").split()
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/server/auth/env_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Authenticator(SysAuthenticator):

def __init__(self, username, **kwargs):
self.var_name = kwargs.pop("name", "XPRA_PASSWORD")
SysAuthenticator.__init__(self, username, **kwargs)
super().__init__(username, **kwargs)
self.authenticate = self.authenticate_hmac

def __repr__(self):
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/server/auth/exec_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, username, **kwargs):
log("exec connection info: %s", connection)
assert connection, "connection object is missing"
self.connection_str = str(connection)
SysAuthenticator.__init__(self, username, **kwargs)
super().__init__(username, **kwargs)

def requires_challenge(self) -> bool:
return False
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/server/auth/file_auth_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, username, **kwargs):
exec_cwd = kwargs.get("exec_cwd", os.getcwd())
password_file = os.path.join(exec_cwd, password_file)
log("FileAuthenticatorBase filename=%s", password_file)
SysAuthenticator.__init__(self, username, **kwargs)
super().__init__(username, **kwargs)
self.password_filename = password_file
self.password_filedata = None
self.password_filetime = None
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/server/auth/gss_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, username, **kwargs):
self.gid = parse_gid(kwargs.pop("gid", None))
username = kwargs.pop("username", username)
kwargs["prompt"] = kwargs.pop("prompt", "GSS token")
SysAuthenticatorBase.__init__(self, username, **kwargs)
super().__init__(username, **kwargs)
log("gss auth: service=%s, username=%s", self.service, username)

def get_uid(self):
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/server/auth/hosts_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, username, **kwargs):
raise
self.peername = peername
self.host = host
SysAuthenticator.__init__(self, username, **kwargs)
super().__init__(username, **kwargs)

def requires_challenge(self) -> bool:
return False
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/server/auth/kerberos_password_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, username, **kwargs):
self.uid = parse_uid(kwargs.pop("uid", None))
self.gid = parse_gid(kwargs.pop("gid", None))
username = kwargs.pop("username", username)
SysAuthenticatorBase.__init__(self, username, **kwargs)
super().__init__(username, **kwargs)
log("kerberos-password auth: service=%s, realm=%s, username=%s", self.service, self.realm, username)

def get_uid(self):
Expand All @@ -36,7 +36,7 @@ def get_challenge(self, digests):
if "xor" not in digests:
log.error("Error: kerberos authentication requires the 'xor' digest")
return None
return SysAuthenticatorBase.get_challenge(self, ["xor"])
return super().get_challenge(["xor"])

def check(self, password) -> bool:
try:
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/server/auth/kerberos_token_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, username, **kwargs):
self.gid = parse_gid(kwargs.pop("gid", None))
username = kwargs.pop("username", username)
kwargs["prompt"] = kwargs.pop("prompt", "kerberos token")
SysAuthenticatorBase.__init__(self, username, **kwargs)
super().__init__(username, **kwargs)
log("kerberos-token auth: service=%s, username=%s", self.service, username)

def get_uid(self):
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/server/auth/ldap3_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, username, **kwargs):
self.authentication = kwargs.pop("authentication", "NTLM").upper()
assert self.authentication in ("SIMPLE", "SASL", "NTLM"), "invalid authentication mechanism '%s'" % self.authentication
username = kwargs.pop("username", username)
SysAuthenticatorBase.__init__(self, username, **kwargs)
super().__init__(username, **kwargs)
log("ldap auth: host=%s, port=%i, tls=%s",
self.host, self.port, self.tls)

Expand All @@ -55,7 +55,7 @@ def get_challenge(self, digests):
if "xor" not in digests:
log.error("Error: ldap authentication requires the 'xor' digest")
return None
return SysAuthenticatorBase.get_challenge(self, ["xor"])
return super().get_challenge(["xor"])

def check(self, password) -> bool:
log("check(%s)", obsc(password))
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/server/auth/ldap_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, username, **kwargs):
self.port = int(kwargs.pop("port", default_port))
self.username_format = kwargs.pop("username_format", "cn=%username, o=%domain")
#self.username_format = kwargs.pop("username_format", "%username@%domain")
SysAuthenticatorBase.__init__(self, username, **kwargs)
super().__init__(username, **kwargs)
log("ldap auth: host=%s, port=%i, tls=%s, username_format=%s, cacert=%s, encoding=%s",
self.host, self.port, self.tls, self.username_format, self.cacert, self.encoding)

Expand All @@ -53,7 +53,7 @@ def get_challenge(self, digests):
if "xor" not in digests:
log.error("Error: ldap authentication requires the 'xor' digest")
return None
return SysAuthenticatorBase.get_challenge(self, ["xor"])
return super().get_challenge(["xor"])

def check(self, password) -> bool:
log("check(%s)", obsc(password))
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/server/auth/multifile_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def parse_auth_line(line):

class Authenticator(FileAuthenticatorBase):
def __init__(self, username, **kwargs):
FileAuthenticatorBase.__init__(self, username, **kwargs)
super().__init__(username, **kwargs)
self.sessions = None

def parse_filedata(self, data):
Expand Down
Loading

0 comments on commit 73ea98c

Please sign in to comment.