Skip to content

Commit

Permalink
#3978 cythonize more and automatically
Browse files Browse the repository at this point in the history
move win32 service to a more logical place so the automagic can do its thing
  • Loading branch information
totaam committed Sep 27, 2023
1 parent 97b28ba commit ab0c969
Show file tree
Hide file tree
Showing 29 changed files with 117 additions and 234 deletions.
241 changes: 60 additions & 181 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2002,7 +2002,7 @@ def noop(*_args, **_kwargs): # pylint: disable=function-redefined
scripts += ["fs/bin/xpra", "fs/bin/xpra_launcher"]
if not OSX and not WIN32:
scripts.append("fs/bin/run_scaled")
toggle_modules(WIN32, "xpra/scripts/win32_service")
toggle_modules(WIN32, "xpra/platform/win32/service")

if data_ENABLED:
if not is_openSUSE():
Expand Down Expand Up @@ -2275,207 +2275,86 @@ def bundle_tests():

if cythonize_more_ENABLED:
assert cython_version >= 3, "cannot use 'cythonize_more' with older Cython versions"
def ax(base):
dirname = base.replace(".", os.path.sep)
for x in glob.glob(f"{dirname}/*.py"):
if not x.endswith("__init__.py"):
mod = x[:-3].replace(os.path.sep, ".")
ace(mod)
if client_ENABLED:
ace("xpra.client.base.fileprint")
ace("xpra.client.base.top")
ace("xpra.client.base.gobject_client")
if client_ENABLED and gtk3_ENABLED:
ace("xpra.client.gtk3.cairo_backing")
ace("xpra.client.gtk3.client_base")
ace("xpra.client.gtk3.client")
ace("xpra.client.gtk3.window")
ace("xpra.client.gtk3.window_base")
ace("xpra.client.gui.window_backing_base")
ace("xpra.client.gui.window_base")
ace("xpra.client.gl.gl_window_backing_base")
ax("xpra.client.base")
if client_ENABLED:
if opengl_ENABLED:
ax("xpra.client.gl")
if gtk3_ENABLED:
ax("xpra.client.gtk3")
ax("xpra.client.gui")
ax("xpra.client.mixins")
if clipboard_ENABLED:
ax("xpra.clipboard")
if codecs_ENABLED:
ace("xpra.codecs.image_wrapper")
ace("xpra.codecs.rgb_transform")
ace("xpra.codecs.video_helper")
ax("xpra.codecs")
if gstreamer_ENABLED:
ax("xpra.gstreamer")
if gtk3_ENABLED:
ax("xpra.gtk_common")
if keyboard_ENABLED:
ax("xpra.keyboard")
if http_ENABLED:
ace("xpra.net.http.handler")
ace("xpra.net.protocol.header")
ace("xpra.net.protocol.socket_handler")
ax("xpra.net.http")
if mdns_ENABLED:
ax("xpra.net.mdns")
ax("xpra.net.protocol")
if qrencode_ENABLED and gtk3_ENABLED:
ace("xpra.net.qrcode.gtk_qr")
if quic_ENABLED:
ace("xpra.net.quic.client")
ace("xpra.net.quic.connection")
ace("xpra.net.quic.http")
ace("xpra.net.quic.listener")
ace("xpra.net.quic.websocket")
ax("xpra.net.quic")
if rfb_ENABLED:
ax("xpra.net.rfb")
if ssh_ENABLED:
ax("xpra.net.ssh")
if websockets_ENABLED:
ace("xpra.net.websockets.common")
ace("xpra.net.websockets.handler")
ace("xpra.net.websockets.header")
ace("xpra.net.websockets.protocol")
ace("xpra.net.bytestreams")
ace("xpra.net.common")
ace("xpra.net.compression")
ace("xpra.net.crypto")
ace("xpra.net.digest")
ace("xpra.net.file_transfer")
ace("xpra.net.libproxy")
ace("xpra.net.mmap_pipe")
ace("xpra.net.net_util")
ace("xpra.net.packet_encoding")
ace("xpra.net.socket_util")
ace("xpra.net.subprocess_wrapper")
ace("xpra.net.upnp")
ax("xpra.net.websockets.headers")
ax("xpra.net.websockets")
ax("xpra.net")
if notifications_ENABLED:
ax("xpra.notifications")
ace("xpra.platform.paths")
if LINUX:
ace("xpra.platform.posix.shadow_server")
if scripts_ENABLED:
ace("xpra.scripts.bug_report")
ace("xpra.scripts.config")
ace("xpra.scripts.fdproxy")
ace("xpra.scripts.gtk_info")
ace("xpra.scripts.main")
ace("xpra.scripts.parsing")
ace("xpra.scripts.pinentry_wrapper")
ace("xpra.scripts.server")
ace("xpra.scripts.splash")
ace("xpra.scripts.show_webcam")
ace("xpra.scripts.version")
if WIN32:
ace("xpra.scripts.win32_service")
ax("xpra.scripts")
if WIN32:
ace("xpra.platform.win32.service")
if server_ENABLED:
ax("xpra.server.auth")
if dbus_ENABLED:
ace("xpra.server.dbus.common")
ace("xpra.server.dbus.server")
ace("xpra.server.dbus.server_base")
ace("xpra.server.dbus.source")
ace("xpra.server.dbus.start")
ace("xpra.server.mixins.audio")
ace("xpra.server.mixins.child_command")
ace("xpra.server.mixins.clipboard")
ace("xpra.server.mixins.controlcommands")
ace("xpra.server.mixins.display")
ace("xpra.server.mixins.encoding")
ace("xpra.server.mixins.fileprint")
ace("xpra.server.mixins.input")
ace("xpra.server.mixins.logging")
ace("xpra.server.mixins.mmap")
ace("xpra.server.mixins.networkstate")
ace("xpra.server.mixins.notification")
ace("xpra.server.mixins.shell")
ace("xpra.server.mixins.stub_server_mixin")
ace("xpra.server.mixins.webcam")
ace("xpra.server.mixins.window")
ax("xpra.server.dbus")
ax("xpra.server.mixins")
if proxy_ENABLED:
ace("xpra.server.proxy.instance_base")
ace("xpra.server.proxy.instance_process")
ace("xpra.server.proxy.instance_thread")
ace("xpra.server.proxy.proxy_dbus_server")
ace("xpra.server.proxy.queue_scheduler")
ace("xpra.server.proxy.server")
ax("xpra.server.proxy")
if rfb_ENABLED:
ace("xpra.server.rfb.protocol")
ace("xpra.server.rfb.server")
ace("xpra.server.rfb.source")
ax("xpra.server.rfb")
if shadow_ENABLED:
ace("xpra.server.shadow.gtk_root_window_model")
ace("xpra.server.shadow.gtk_shadow_server_base")
ace("xpra.server.shadow.root_window_model")
ace("xpra.server.shadow.shadow_dbus_server")
ace("xpra.server.shadow.shadow_server_base")
ace("xpra.server.source.audio")
ace("xpra.server.source.avsync")
ace("xpra.server.source.client_connection")
ace("xpra.server.source.client_connection_factory")
ace("xpra.server.source.clientinfo")
ace("xpra.server.source.clipboard")
ace("xpra.server.source.dbus")
ace("xpra.server.source.display")
ace("xpra.server.source.encodings")
ace("xpra.server.source.fileprint")
ace("xpra.server.source.idle_mixin")
ace("xpra.server.source.input")
ace("xpra.server.source.mmap")
ace("xpra.server.source.networkstate")
ace("xpra.server.source.notification")
ace("xpra.server.source.shell")
ace("xpra.server.source.source_stats")
ace("xpra.server.source.stub_source_mixin")
ace("xpra.server.source.webcam")
ace("xpra.server.source.windows")
ace("xpra.server.window.batch_config")
ace("xpra.server.window.batch_delay_calculator")
ace("xpra.server.window.content_guesser")
ace("xpra.server.window.filters")
ace("xpra.server.window.metadata")
ace("xpra.server.window.perfstats")
ace("xpra.server.window.video_scoring")
ace("xpra.server.window.video_subregion")
ace("xpra.server.window.compress")
ace("xpra.server.window.video_compress")
ace("xpra.server.window.windowicon")
ace("xpra.server.background_worker")
ace("xpra.server.control_command")
ace("xpra.server.gtk_server_base")
ace("xpra.server.keyboard_config_base")
ace("xpra.server.menu_provider")
ace("xpra.server.server_base")
ace("xpra.server.server_core")
ace("xpra.server.features")
ace("xpra.server.server_uuid")
ace("xpra.server.ssh")
ace("xpra.server.util")
ax("xpra.server.shadow")
ax("xpra.server.source")
ax("xpra.server.window")
ax("xpra.server")
if gtk_x11_ENABLED:
ax("xpra.x11.gtk_x11")
if x11_ENABLED:
ace("xpra.x11.desktop.desktop_model")
ace("xpra.x11.desktop.desktop_server")
ace("xpra.x11.desktop.base")
ace("xpra.x11.desktop.model_base")
ace("xpra.x11.desktop.monitor_model")
ace("xpra.x11.desktop.monitor_server")
ace("xpra.x11.gtk_x11.clipboard")
ace("xpra.x11.gtk_x11.composite")
ace("xpra.x11.gtk_x11.damage")
ace("xpra.x11.gtk_x11.keys")
ace("xpra.x11.gtk_x11.prop")
ace("xpra.x11.gtk_x11.selection")
ace("xpra.x11.gtk_x11.tray")
ace("xpra.x11.gtk_x11.wm")
ace("xpra.x11.gtk_x11.wm_check")
ace("xpra.x11.gtk_x11.world_window")
ace("xpra.x11.models.base")
ace("xpra.x11.models.core")
ace("xpra.x11.models.model_stub")
ace("xpra.x11.models.or_window")
ace("xpra.x11.models.size_hints_util")
ace("xpra.x11.models.systray")
ace("xpra.x11.models.window")
ax("xpra.x11")
ax("xpra.x11.desktop")
ax("xpra.x11.models")
if server_ENABLED:
ace("xpra.x11.server.base")
ace("xpra.x11.server.core")
ace("xpra.x11.server.expand")
ace("xpra.x11.server.seamless")
ace("xpra.x11.server.shadow")
ace("xpra.x11.common")
ace("xpra.x11.prop_conv")
ace("xpra.x11.uinput_device")
ace("xpra.x11.vfb_util")
ace("xpra.x11.window_filters")
ace("xpra.x11.window_info")
ace("xpra.x11.xroot_props")
ace("xpra.x11.xsettings")
ace("xpra.x11.xsettings_prop")
ace("xpra.util.child_reaper")
ace("xpra.util.colorstreamhandler")
ace("xpra.util.env")
ace("xpra.util.parsing")
ace("xpra.util.pysystem")
ace("xpra.util.screen")
ace("xpra.util.stats")
ace("xpra.util.str_fn")
ace("xpra.util.thread")
ace("xpra.util.types")
ace("xpra.util.version")
ax("xpra.x11.server")
ax("xpra.util")
ace("xpra.common")
ace("xpra.exit_codes")
ace("xpra.log")
ace("xpra.os_util")
if gstreamer_ENABLED:
ace("xpra.gstreamer.gst_common")
ace("xpra.gstreamer.gst_pipeline")
ax("xpra.gstreamer")


if ext_modules:
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/unit/client/mixins/serverinfo_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import unittest

from xpra.util.types import typedict, AdHocStruct
from xpra.client.base.serverinfo_mixin import ServerInfoMixin
from xpra.client.base.serverinfo import ServerInfoMixin
from unit.client.mixins.clientmixintest_util import ClientMixinTest


Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/unit/client/mixins/window_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class WindowManagerTest(ClientMixinTest):

def test_windowmanager(self):
with DisplayContext():
from xpra.client.mixins.window_manager import WindowClient
from xpra.client.mixins.windows import WindowClient
def _WindowClient():
def get_mouse_position():
return 0, 0
Expand Down
18 changes: 9 additions & 9 deletions xpra/client/base/client_base.py → xpra/client/base/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
from xpra.util.str_fn import std, nonl, obsc, csv, ellipsizer, repr_ellipsized, print_nested_dict
from xpra.util.parsing import parse_simple_dict
from xpra.util.env import envint, envbool
from xpra.client.base.serverinfo_mixin import ServerInfoMixin
from xpra.client.base.serverinfo import ServerInfoMixin
from xpra.client.base.fileprint import FilePrintMixin
from xpra.exit_codes import ExitCode, ExitValue, exit_str

Expand Down Expand Up @@ -252,10 +252,10 @@ def may_notify(self, nid:int, summary:str, body:str, *args, **kwargs):
notifylog.info(" %s", x)


def handle_deadly_signal(self, signum:int, _frame=None):
def handle_deadly_signal(self, signum, _frame=None):
stderr_print("\ngot deadly signal %s, exiting" % SIGNAMES.get(signum, signum))
self.cleanup()
force_quit(128 + signum)
force_quit(128 + int(signum))

def handle_app_signal(self, signum:int, _frame=None):
try:
Expand All @@ -281,7 +281,7 @@ def os_signal(signum, _frame=None):
signal.signal(signal.SIGTERM, os_signal)
register_SIGUSR_signals(self.idle_add)

def signal_disconnect_and_quit(self, exit_code:int, reason:str) -> None:
def signal_disconnect_and_quit(self, exit_code:int|ExitCode, reason:str) -> None:
log("signal_disconnect_and_quit(%s, %s) exit_on_signal=%s", exit_code, reason, self.exit_on_signal)
if not self.exit_on_signal:
#if we get another signal, we'll try to exit without idle_add...
Expand All @@ -294,14 +294,14 @@ def signal_disconnect_and_quit(self, exit_code:int, reason:str) -> None:
self.disconnect_and_quit(exit_code, reason)
self.quit(exit_code)
self.exit()
force_quit(exit_code)
force_quit(int(exit_code))

def signal_cleanup(self) -> None:
#placeholder for stuff that can be cleaned up from the signal handler
#(non UI thread stuff)
pass

def disconnect_and_quit(self, exit_code:int, reason:str) -> None:
def disconnect_and_quit(self, exit_code:int|ExitCode, reason:str|ConnectionMessage) -> None:
#make sure that we set the exit code early,
#so the protocol shutdown won't set a different one:
if self.exit_code is None:
Expand All @@ -316,7 +316,7 @@ def protocol_closed():
log("disconnect_and_quit: protocol_closed()")
self.idle_add(self.quit, exit_code)
if p:
p.send_disconnect([reason], done_callback=protocol_closed)
p.send_disconnect([str(reason)], done_callback=protocol_closed)
self.timeout_add(1000, self.quit, exit_code)

def exit(self) -> None:
Expand Down Expand Up @@ -659,10 +659,10 @@ def start_protocol(self) -> None:
if self._protocol:
self._protocol.start()

def quit(self, exit_code:int=0) -> None:
def quit(self, exit_code:int|ExitCode=0) -> None:
raise NotImplementedError()

def warn_and_quit(self, exit_code:int, message:str):
def warn_and_quit(self, exit_code:int|ExitCode, message:str):
log.warn(message)
self.quit(exit_code)

Expand Down
12 changes: 6 additions & 6 deletions xpra/client/base/gobject_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)
from xpra.net.common import PacketType
from xpra.util.stats import std_unit
from xpra.client.base.client_base import XpraClientBase, EXTRA_TIMEOUT
from xpra.client.base.client import XpraClientBase, EXTRA_TIMEOUT
from xpra.exit_codes import ExitCode, ExitValue
from xpra.log import Logger

Expand Down Expand Up @@ -104,7 +104,7 @@ def make_hello(self) -> dict[str,Any]:
capabilities["keyboard"] = False
return capabilities

def quit(self, exit_code=0) -> None:
def quit(self, exit_code:int|ExitCode=0) -> None:
log("quit(%s) current exit_code=%s", exit_code, self.exit_code)
if self.exit_code is None:
self.exit_code = exit_code
Expand Down Expand Up @@ -425,11 +425,11 @@ def run(self) -> ExitValue:
self.cleanup()
return v

def signal_handler(self, signum, *args) -> None:
self.log("exit_code=%s" % self.exit_code)
self.log("signal_handler({}, {})".format(signum, args))
def signal_handler(self, signum : int, *args) -> None:
self.log(f"exit_code={self.exit_code}")
self.log(f"signal_handler({signum}, {args})")
self.quit(128+signum)
self.log("exit_code=%s" % self.exit_code)
self.log(f"exit_code={self.exit_code}")

def log(self, message) -> None:
#this method is overridden in top client to use a log file
Expand Down
File renamed without changes.
Loading

0 comments on commit ab0c969

Please sign in to comment.