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@24172 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Oct 18, 2019
1 parent 457eb1c commit 0aac1cd
Show file tree
Hide file tree
Showing 32 changed files with 51 additions and 58 deletions.
4 changes: 2 additions & 2 deletions src/xpra/client/client_tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ClientTray(ClientWidgetBase):

def __init__(self, client, wid, w, h, metadata, tray_widget, mmap_enabled, mmap_area):
log("ClientTray%s", (client, wid, w, h, tray_widget, mmap_enabled, mmap_area))
ClientWidgetBase.__init__(self, client, 0, wid, True)
super().__init__(client, 0, wid, True)
self._metadata = metadata
self.title = metadata.strget("title", "")
self.tray_widget = tray_widget
Expand Down Expand Up @@ -205,7 +205,7 @@ class TrayBacking(WindowBackingBase):

def __init__(self, wid, _w, _h, _has_alpha, data=None):
self.data = data
WindowBackingBase.__init__(self, wid, True)
super().__init__(wid, True)
self._backing = object() #pretend we have a backing structure

def get_encoding_properties(self):
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/client/client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, client, group_leader, watcher_pid, wid,
wx, wy, ww, wh, bw, bh,
metadata, override_redirect, client_properties,
border, max_window_size, default_cursor_data, pixel_depth))
ClientWidgetBase.__init__(self, client, watcher_pid, wid, metadata.boolget("has-alpha"))
super().__init__(client, watcher_pid, wid, metadata.boolget("has-alpha"))
self._override_redirect = override_redirect
self.group_leader = group_leader
self._pos = (wx, wy)
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/client/gl/gl_window_backing_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def __init__(self, wid, window_alpha, pixel_depth=0):
self.last_flush = monotonic_time()
self.last_present_fbo_error = None

WindowBackingBase.__init__(self, wid, window_alpha and self.HAS_ALPHA)
super().__init__(wid, window_alpha and self.HAS_ALPHA)
self.init_gl_config(self._alpha_enabled)
self.init_backing()
self.bit_depth = self.get_bit_depth(pixel_depth)
Expand Down Expand Up @@ -1002,7 +1002,7 @@ def paint_webp(self, img_data, x, y, width, height, options, callbacks):
flush = options.intget("flush", 0)
self.idle_add(self.gl_paint_planar, YUV2RGB_SHADER, flush, "webp", img, x, y, width, height, width, height, callbacks)
return
WindowBackingBase.paint_webp(self, img_data, x, y, width, height, options, callbacks)
super().paint_webp(img_data, x, y, width, height, options, callbacks)

def do_paint_rgb(self, rgb_format, img_data, x, y, width, height, rowstride, options, callbacks):
log("%s.do_paint_rgb(%s, %s bytes, x=%d, y=%d, width=%d, height=%d, rowstride=%d, options=%s)",
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/client/gl/gtk3/gl_client_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ def do_configure_event(self, event):

def destroy(self):
self.remove_backing()
GTK3ClientWindow.destroy(self)
super().destroy()

def new_backing(self, bw, bh):
widget = GTK3ClientWindow.new_backing(self, bw, bh)
widget = super().new_backing(bw, bh)
if self.drawing_area:
self.remove(self.drawing_area)
self.init_widget_events(widget)
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/client/gtk_base/cairo_backing_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CairoBackingBase(WindowBackingBase):
HAS_ALPHA = GTK_ALPHA_SUPPORTED

def __init__(self, wid, window_alpha, _pixel_depth=0):
WindowBackingBase.__init__(self, wid, window_alpha and self.HAS_ALPHA)
super().__init__(wid, window_alpha and self.HAS_ALPHA)
self.idle_add = GLib.idle_add

def init(self, ww, wh, bw, bh):
Expand Down
4 changes: 0 additions & 4 deletions src/xpra/client/gtk_base/gtk_client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ class GTKClientWindowBase(ClientWindowBase, Gtk.Window):
#maximum size of the backing pixel buffer:
MAX_BACKING_DIMS = 16*1024, 16*1024

def __init__(self, *args, **kwargs):
ClientWindowBase.__init__(self, *args, **kwargs)
#Gtk.Window.__init__() is called from do_init_window()

def init_window(self, metadata):
self.init_max_window_size()
if self._is_popup(metadata):
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/client/gtk_base/mdns_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class mdns_sessions(SessionsGUI):

def __init__(self, options):
SessionsGUI.__init__(self, options)
super().__init__(options)
listener_class = get_listener_class()
assert listener_class
self.listener = listener_class(XPRA_MDNS_TYPE,
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/client/gtk_base/statusicon_tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
class GTKStatusIconTray(TrayBase):

def __init__(self, *args, **kwargs):
TrayBase.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)
self.tray_widget = Gtk.StatusIcon()
self.tray_widget.set_tooltip_text(self.tooltip or "Xpra")
self.tray_widget.connect('activate', self.activate_menu)
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/client/top_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class TopClient(MonitorXpraClient):

def __init__(self, *args):
MonitorXpraClient.__init__(self, *args)
super().__init__(*args)
self.info_request_pending = False
self.server_last_info = typedict()
#curses init:
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/clipboard/clipboard_timeout_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ClipboardTimeoutHelper(ClipboardProtocolHelperCore):

#a clipboard superclass that handles timeouts
def __init__(self, send_packet_cb, progress_cb=None, **kwargs):
ClipboardProtocolHelperCore.__init__(self, send_packet_cb, progress_cb, **kwargs)
super().__init__(send_packet_cb, progress_cb, **kwargs)
self._clipboard_outstanding_requests = {}

def cleanup(self):
Expand All @@ -43,7 +43,7 @@ def _get_proxy(self, selection):
return proxy

def set_want_targets_client(self, want_targets):
ClipboardProtocolHelperCore.set_want_targets_client(self, want_targets)
super().set_want_targets_client(want_targets)
#pass it on to the ClipboardProxy instances:
for proxy in self._clipboard_proxies.values():
proxy.set_want_targets(want_targets)
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/codecs/codec_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def __init__(self, encoding, input_colorspace, output_colorspaces, has_lossless_
self.input_colorspace = input_colorspace
self.output_colorspaces = output_colorspaces #ie: ["YUV420P" : "YUV420P", ...]
self.has_lossless_mode = has_lossless_mode
_codec_spec.__init__(self, codec_class, codec_type, **kwargs)
super().__init__(codec_class, codec_type, **kwargs)
self._exported_fields += ["encoding", "input_colorspace", "output_colorspaces", "has_lossless_mode"]

def __repr__(self):
Expand All @@ -175,7 +175,7 @@ class csc_spec(_codec_spec):
def __init__(self, input_colorspace, output_colorspace, codec_class, codec_type, **kwargs):
self.input_colorspace = input_colorspace
self.output_colorspace = output_colorspace
_codec_spec.__init__(self, codec_class, codec_type, **kwargs)
super().__init__(codec_class, codec_type, **kwargs)
self._exported_fields += ["input_colorspace", "output_colorspace"]

def __repr__(self):
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/codecs/nvenc/encoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ class NVENCException(Exception):
self.function = fn
self.code = code
msg = "%s - returned %s" % (fn, nvencStatusInfo(code))
Exception.__init__(self, msg)
super().__init__(msg)

cdef inline raiseNVENC(NVENCSTATUS ret, msg):
if DEBUG_API:
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/codecs/nvfbc/cuda_image_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class CUDAImageWrapper(ImageWrapper):

def __init__(self, *args):
ImageWrapper.__init__(self, *args)
super().__init__(*args)
self.stream = None
self.cuda_device_buffer = None
self.cuda_context = None
Expand Down Expand Up @@ -68,7 +68,7 @@ def clone_pixel_data(self):

def get_sub_image(self, x, y, w, h):
self.may_download()
return ImageWrapper.get_sub_image(self, x, y, w, h)
return super().get_sub_image(x, y, w, h)

def free_cuda_device_buffer(self):
cdb = self.cuda_device_buffer
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/codecs/nvfbc/fbc_capture_win.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ class NvFBCException(Exception):
self.function = fn
self.code = code
msg = "%s - returned %s" % (fn, ERRORS.get(code, code))
Exception.__init__(self, msg)
super().__init__(msg)

cdef inline raiseNvFBC(NVFBCRESULT ret, msg):
if ret!=0:
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/dbus/notifications_forwarder.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, bus, notify_callback=None, close_callback=None):
self.support_actions = True
self.dbus_id = os.environ.get("DBUS_SESSION_BUS_ADDRESS", "")
bus_name = dbus.service.BusName(BUS_NAME, bus=bus)
dbus.service.Object.__init__(self, bus_name, BUS_PATH)
super().__init__(bus_name, BUS_PATH)

def get_info(self) -> dict:
return {
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/gtk_common/gtk_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def get_pixbuf(icon_name):
class GTK_Notifier(NotifierBase):

def __init__(self, closed_cb=None, action_cb=None, size_x=DEFAULT_WIDTH, size_y=DEFAULT_HEIGHT, timeout=5):
NotifierBase.__init__(self, closed_cb, action_cb)
super().__init__(closed_cb, action_cb)
self.handles_actions = True
"""
Create a new notification stack. The recommended way to create Popup instances.
Expand Down
6 changes: 3 additions & 3 deletions src/xpra/net/bytestreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def get_info(self) -> dict:
# socket (if it exists)
class TwoFileConnection(Connection):
def __init__(self, writeable, readable, abort_test=None, target=None, socktype="", close_cb=None, info=None):
Connection.__init__(self, target, socktype, info)
super().__init__(target, socktype, info)
self._writeable = writeable
self._readable = readable
self._read_fd = self._readable.fileno()
Expand Down Expand Up @@ -271,7 +271,7 @@ def get_info(self) -> dict:
class SocketConnection(Connection):
def __init__(self, sock, local, remote, target, socktype, info=None, socket_options=None):
log("SocketConnection%s", (sock, local, remote, target, socktype, info))
Connection.__init__(self, target, socktype, info, socket_options)
super().__init__(target, socktype, info, socket_options)
self._socket = sock
self.local = local
self.remote = remote
Expand Down Expand Up @@ -544,7 +544,7 @@ def can_retry(self, e) -> bool:
code = getattr(e, "code", None)
if code in SSLSocketConnection.SSL_TIMEOUT_MESSAGES:
return True
return SocketConnection.can_retry(self, e)
return super().can_retry(e)

def enable_peek(self):
assert not isinstance(self._socket, SSLSocketWrapper)
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/net/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def __repr__(self):

class LevelCompressed(Compressed):
def __init__(self, datatype, data, level, algo, can_inline):
Compressed.__init__(self, datatype, data, can_inline)
super().__init__(datatype, data, can_inline)
self.level = level
self.algorithm = algo
def __repr__(self):
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/net/file_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class FileTransferHandler(FileTransferAttributes):
"""

def init_attributes(self, *args):
FileTransferAttributes.init_attributes(self, *args)
super().init_attributes(*args)
self.remote_file_transfer = False
self.remote_file_transfer_ask = False
self.remote_printing = False
Expand Down
8 changes: 4 additions & 4 deletions src/xpra/net/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def input_pass(prompt):
class SSHSocketConnection(SocketConnection):

def __init__(self, ssh_channel, sock, sockname, peername, target, info=None):
SocketConnection.__init__(self, ssh_channel, sockname, peername, target, "ssh", info)
super().__init__(ssh_channel, sockname, peername, target, "ssh", info)
self._raw_socket = sock

def start_stderr_reader(self):
Expand Down Expand Up @@ -199,7 +199,7 @@ def get_info(self) -> dict:

class SSHProxyCommandConnection(SSHSocketConnection):
def __init__(self, ssh_channel, peername, target, info):
SSHSocketConnection.__init__(self, ssh_channel, None, None, peername, target, info)
super().__init__(ssh_channel, None, None, peername, target, info)
self.process = None

def error_is_closed(self, e):
Expand All @@ -209,7 +209,7 @@ def error_is_closed(self, e):
#then the connection must be closed:
if p[0].poll() is not None:
return True
return SSHSocketConnection.error_is_closed(self, e)
return super().error_is_closed(e)

def get_socket_info(self):
p = self.process
Expand Down Expand Up @@ -362,7 +362,7 @@ def ssh_paramiko_connect_to(display_desc):
class nogssapi_context(nomodule_context):

def __init__(self):
nomodule_context.__init__(self, "gssapi")
super().__init__("gssapi")


def do_ssh_paramiko_connect_to(transport, host, username, password, host_config=None, keyfiles=None):
Expand Down
15 changes: 6 additions & 9 deletions src/xpra/net/udp_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class UDPProtocol(Protocol):
"""

def __init__(self, *args, **kwargs):
Protocol.__init__(self, *args)
super().__init__(*args)
self.mtu = 0
self.last_sequence = -1 #the most recent packet sequence we processed in full
self.highest_sequence = -1
Expand Down Expand Up @@ -419,7 +419,7 @@ def _send_async(self, packet, sync=False, fail_cb=None):
log("_send_async(%s, %s)", packet, sync)
chunks = self.encode(packet)
if len(chunks)>1:
return Protocol.send_now(self, packet)
return super().send_now(packet)
proto_flags,index,level,data = chunks[0]
from xpra.net.header import pack_header
payload_size = len(data)
Expand All @@ -433,7 +433,7 @@ def raw_write(self, items, start_cb=None, end_cb=None, fail_cb=None, synchronous
""" make sure we don't enable asynchronous mode until the other end is read """
if not self.asynchronous_send_enabled:
synchronous = True
Protocol.raw_write(self, items, start_cb, end_cb, fail_cb, synchronous)
super().raw_write(items, start_cb, end_cb, fail_cb, synchronous)

def write_buffers(self, buf_data, fail_cb, synchronous):
"""
Expand Down Expand Up @@ -492,7 +492,7 @@ def write_buf(self, seqno, data, fail_cb, synchronous):


def get_info(self, alias_info=True):
i = Protocol.get_info(self, alias_info)
i = super().get_info(alias_info)
i.update({
"mtu" : {
"" : clamp_mtu(self.mtu),
Expand All @@ -513,11 +513,11 @@ def _read_thread_loop(self):
class UDPClientProtocol(UDPProtocol):

def __init__(self, *args, **kwargs):
UDPProtocol.__init__(self, *args, uuid = random.randint(0, 2**64-1))
super().__init__(*args, uuid = random.randint(0, 2**64-1))

def con_write(self, data, fail_cb):
""" After successfully writing some data, update the mtu value """
r = UDPProtocol.con_write(self, data, fail_cb)
r = super().con_write(data, fail_cb)
if r>0 and LINUX:
IP_MTU = 14
con = self._conn
Expand Down Expand Up @@ -549,9 +549,6 @@ class UDPSocketConnection(SocketConnection):
they do not call connect() and so we have to specify the remote target every time)
"""

def __init__(self, *args):
SocketConnection.__init__(self, *args)

def write(self, buf):
#log("UDPSocketConnection: sending %i bytes to %s", len(buf), self.remote)
try:
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/net/websockets/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, sock, addr, new_websocket_client,
http_headers_dir="/usr/share/xpra/http-headers", script_paths=None):
self.new_websocket_client = new_websocket_client
self.only_upgrade = WEBSOCKET_ONLY_UPGRADE
HTTPRequestHandler.__init__(self, sock, addr, web_root, http_headers_dir, script_paths)
super().__init__(sock, addr, web_root, http_headers_dir, script_paths)

def handle_websocket(self):
log("handle_websocket() calling %s, request=%s (%s)",
Expand Down
8 changes: 4 additions & 4 deletions src/xpra/net/websockets/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class WebSocketProtocol(Protocol):
TYPE = "websocket"

def __init__(self, *args, **kwargs):
Protocol.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)
self.ws_data = b""
self.ws_payload = []
self.ws_payload_opcode = 0
Expand All @@ -61,13 +61,13 @@ def close(self):


def get_info(self, alias_info=True):
info = Protocol.get_info(self, alias_info)
info = super().get_info(alias_info)
info["legacy-frames"] = self.legacy_frame_per_chunk
return info


def parse_remote_caps(self, caps):
Protocol.parse_remote_caps(self, caps)
super().parse_remote_caps(caps)
if LEGACY_FRAME_PER_CHUNK is None:
may_have_bug = caps.strget("client_type", "")=="HTML5"
self.legacy_frame_per_chunk = not caps.boolget("websocket.multi-packet", not may_have_bug)
Expand All @@ -87,7 +87,7 @@ def parse_remote_caps(self, caps):
self.make_frame_header = self.make_wsframe_header

def make_wschunk_header(self, packet_type, proto_flags, level, index, payload_size):
header = Protocol.make_xpra_header(self, packet_type, proto_flags, level, index, payload_size)
header = super().make_xpra_header(packet_type, proto_flags, level, index, payload_size)
log("make_wschunk_header(%s)", (packet_type, proto_flags, level, index, payload_size))
return encode_hybi_header(OPCODE_BINARY, payload_size+len(header))+header

Expand Down
2 changes: 1 addition & 1 deletion src/xpra/notifications/dbus_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def DBUS_Notifier_factory(*args):
class DBUS_Notifier(NotifierBase):

def __init__(self, *args):
NotifierBase.__init__(self, *args)
super().__init__(*args)
self.app_name_format = NOTIFICATION_APP_NAME
self.last_notification = None
self.actual_notification_id = {}
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/platform/darwin/shadow_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(self):
GTKShadowServerBase.__init__(self)

def init(self, opts):
GTKShadowServerBase.init(self, opts)
super().init(opts)
self.keycodes = {}
#printing fails silently on OSX
self.printing = False
Expand Down
Loading

0 comments on commit 0aac1cd

Please sign in to comment.