From f6cd59c08b083b5a6189c09a3546f2dfc6354054 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sat, 9 Mar 2024 21:17:47 +0700 Subject: [PATCH] use wrappers to ensure the environment is configured before trying to import the gi bindings --- fs/libexec/xpra/auth_dialog | 6 ++++-- packaging/MSWindows/MINGW_BUILD.sh | 3 ++- packaging/MSWindows/tools/events_test.py | 20 +++++++++++++++++++ packaging/MSWindows/tools/gtk_info.py | 20 +++++++++++++++++++ .../MSWindows/tools/gtk_keyboard_test.py | 20 +++++++++++++++++++ packaging/MSWindows/tools/screenshot.py | 20 +++++++++++++++++++ packaging/MSWindows/tools/systemtray_test.py | 20 +++++++++++++++++++ setup.py | 8 ++++---- xpra/scripts/bug_report.py | 2 +- 9 files changed, 111 insertions(+), 8 deletions(-) create mode 100755 packaging/MSWindows/tools/events_test.py create mode 100755 packaging/MSWindows/tools/gtk_info.py create mode 100755 packaging/MSWindows/tools/gtk_keyboard_test.py create mode 100755 packaging/MSWindows/tools/screenshot.py create mode 100755 packaging/MSWindows/tools/systemtray_test.py diff --git a/fs/libexec/xpra/auth_dialog b/fs/libexec/xpra/auth_dialog index 8a7807d676..20c732943c 100755 --- a/fs/libexec/xpra/auth_dialog +++ b/fs/libexec/xpra/auth_dialog @@ -2,5 +2,7 @@ import sys -from xpra.gtk_common.auth_dialog import main -sys.exit(main()) +from xpra.platform import program_context +with program_context("Authentication", "Authentication"): + from xpra.gtk_common.auth_dialog import main + sys.exit(main()) diff --git a/packaging/MSWindows/MINGW_BUILD.sh b/packaging/MSWindows/MINGW_BUILD.sh index 41d6e2665f..2e7cc24b01 100644 --- a/packaging/MSWindows/MINGW_BUILD.sh +++ b/packaging/MSWindows/MINGW_BUILD.sh @@ -412,7 +412,7 @@ rm -f ./libjasper* # Python modules: rm -fr ./lib2to3* ./xdg* ./olefile* ./pygtkcompat* keyring/testing ./jaraco* ./p11-kit* ./lz4 #remove codecs we don't need: -rm -f ./libSvt* ./libx265* ./libjxl* ./libde265* ./libkvazaar* +rm -f ./libde265* ./libkvazaar* if [ "${DO_FULL}" == "0" ]; then # kerberos / gss libs: rm -f ./libshishi* ./libgss* @@ -430,6 +430,7 @@ if [ "${DO_FULL}" == "0" ]; then rm -f ./libmp3* ./libwavpack* ./libmpdec* ./libspeex* ./libFLAC* ./libmpg123* ./libfaad* ./libfaac* # ffmpeg: rm -f ./avcodec* ./avformat* ./avutil* ./xvidcore* ./swscale* ./libzvbi* ./libbluray* ./libva* + rm -f ./libSvt* ./libx265* ./libjxl* # matching gstreamer modules: pushd ./gstreamer-1.0 rm -f ./libgstflac* ./libgstwavpack* ./libgstspeex* ./libgstwavenc* ./libgstlame* ./libgstmpg123* ./libgstfaac* ./libgstfaad* ./libgstwav* diff --git a/packaging/MSWindows/tools/events_test.py b/packaging/MSWindows/tools/events_test.py new file mode 100755 index 0000000000..d7743220cf --- /dev/null +++ b/packaging/MSWindows/tools/events_test.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# This file is part of Xpra. +# Copyright (C) 2024 Antoine Martin +# Xpra is released under the terms of the GNU GPL v2, or, at your option, any +# later version. See the file COPYING for details. + +import sys + + +def main(): + # pylint: disable=import-outside-toplevel + from xpra.platform import program_context + with program_context("GTK-Info", "GTK Info"): + from xpra.platform.win32 import gui + return gui.main() + + +if __name__ == "__main__": + v = main() + sys.exit(v) diff --git a/packaging/MSWindows/tools/gtk_info.py b/packaging/MSWindows/tools/gtk_info.py new file mode 100755 index 0000000000..4333f3e3e1 --- /dev/null +++ b/packaging/MSWindows/tools/gtk_info.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# This file is part of Xpra. +# Copyright (C) 2024 Antoine Martin +# Xpra is released under the terms of the GNU GPL v2, or, at your option, any +# later version. See the file COPYING for details. + +import sys + + +def main(): + # pylint: disable=import-outside-toplevel + from xpra.platform import program_context + with program_context("GTK-Info", "GTK Info"): + from xpra.gtk import info + return info.main() + + +if __name__ == "__main__": + v = main() + sys.exit(v) diff --git a/packaging/MSWindows/tools/gtk_keyboard_test.py b/packaging/MSWindows/tools/gtk_keyboard_test.py new file mode 100755 index 0000000000..a0617f909b --- /dev/null +++ b/packaging/MSWindows/tools/gtk_keyboard_test.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# This file is part of Xpra. +# Copyright (C) 2024 Antoine Martin +# Xpra is released under the terms of the GNU GPL v2, or, at your option, any +# later version. See the file COPYING for details. + +import sys + + +def main(): + # pylint: disable=import-outside-toplevel + from xpra.platform import program_context + with program_context("GTK-Keyboard-Test", "GTK Keyboard Test"): + from xpra.gtk_common import gtk_view_keyboard + return gtk_view_keyboard.main() + + +if __name__ == "__main__": + v = main() + sys.exit(v) diff --git a/packaging/MSWindows/tools/screenshot.py b/packaging/MSWindows/tools/screenshot.py new file mode 100755 index 0000000000..185e2edc2c --- /dev/null +++ b/packaging/MSWindows/tools/screenshot.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# This file is part of Xpra. +# Copyright (C) 2024 Antoine Martin +# Xpra is released under the terms of the GNU GPL v2, or, at your option, any +# later version. See the file COPYING for details. + +import sys + + +def main(argv=()): + # pylint: disable=import-outside-toplevel + from xpra.platform import program_context + with program_context("Screenshot", "Screenshot"): + from xpra.platform.win32 import gdi_screen_capture + return gdi_screen_capture.main() + + +if __name__ == "__main__": + v = main() + sys.exit(v) diff --git a/packaging/MSWindows/tools/systemtray_test.py b/packaging/MSWindows/tools/systemtray_test.py new file mode 100755 index 0000000000..0143b748b9 --- /dev/null +++ b/packaging/MSWindows/tools/systemtray_test.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# This file is part of Xpra. +# Copyright (C) 2024 Antoine Martin +# Xpra is released under the terms of the GNU GPL v2, or, at your option, any +# later version. See the file COPYING for details. + +import sys + + +def main(): + # pylint: disable=import-outside-toplevel + from xpra.platform import program_context + with program_context("SystemTray-Test", "SystemTray Test"): + from xpra.client.gtk3.example import tray + return tray.main() + + +if __name__ == "__main__": + v = main() + sys.exit(v) diff --git a/setup.py b/setup.py index 9d2ae8f4d6..84f3da575f 100755 --- a/setup.py +++ b/setup.py @@ -1606,12 +1606,12 @@ def add_service_exe(script, icon, base_name): add_gui_exe("fs/bin/xpra_launcher", "xpra.ico", "Xpra-Launcher") if win32_tools_ENABLED: add_console_exe("fs/bin/xpra_launcher", "xpra.ico", "Xpra-Launcher-Debug") - add_gui_exe("xpra/gtk_common/gtk_view_keyboard.py", "keyboard.ico", "GTK_Keyboard_Test") + add_gui_exe("packaging/MSWindows/tools/gtk_keyboard_test.py", "keyboard.ico", "GTK_Keyboard_Test") add_gui_exe("xpra/scripts/bug_report.py", "bugs.ico", "Bug_Report") if shadow_ENABLED: add_gui_exe("xpra/platform/win32/scripts/shadow_server.py", "server-notconnected.ico", "Xpra-Shadow") if win32_tools_ENABLED: - add_gui_exe("xpra/platform/win32/gdi_screen_capture.py", "screenshot.ico", "Screenshot") + add_gui_exe("packaging/MSWindows/tools/screenshot.py", "screenshot.ico", "Screenshot") if win32_tools_ENABLED and server_ENABLED: add_gui_exe("fs/libexec/xpra/auth_dialog", "authentication.ico", "Auth_Dialog") # Console: provide an Xpra_cmd.exe we can run from the cmd.exe shell @@ -1632,7 +1632,7 @@ def add_service_exe(script, icon, base_name): add_console_exe("xpra/scripts/gtk_info.py", "gtk.ico", "GTK_info") add_console_exe("xpra/gtk_common/keymap.py", "keymap.ico", "Keymap_info") add_console_exe("xpra/platform/keyboard.py", "keymap.ico", "Keyboard_info") - add_gui_exe("xpra/client/gtk3/example/tray.py", "xpra.ico", "SystemTray_Test") + add_gui_exe("packaging/MSWindows/tools/systemtray_test.py", "xpra.ico", "SystemTray_Test") add_gui_exe("xpra/client/gtk3/u2f_tool.py", "authentication.ico", "U2F_Tool") if client_ENABLED or server_ENABLED: add_console_exe("xpra/platform/win32/scripts/execfile.py", "python.ico", "Python_execfile_cmd") @@ -1653,7 +1653,7 @@ def add_service_exe(script, icon, base_name): add_console_exe("xpra/platform/features.py", "features.ico", "Feature_info") if client_ENABLED: add_console_exe("xpra/platform/gui.py", "browse.ico", "NativeGUI_info") - add_console_exe("xpra/platform/win32/gui.py", "loop.ico", "Events_Test") + add_console_exe("packaging/MSWindows/tools/events_test.py", "loop.ico", "Events_Test") if audio_ENABLED: add_console_exe("xpra/audio/gstreamer_util.py", "gstreamer.ico", "GStreamer_info") add_console_exe("xpra/platform/win32/directsound.py", "speaker.ico", "Audio_Devices") diff --git a/xpra/scripts/bug_report.py b/xpra/scripts/bug_report.py index c4656d37e6..e19c21c476 100755 --- a/xpra/scripts/bug_report.py +++ b/xpra/scripts/bug_report.py @@ -11,10 +11,10 @@ def main(argv=()): # pylint: disable=import-outside-toplevel from xpra.platform import program_context from xpra.platform.gui import init, set_default_icon - from xpra.gtk_common.gtk_util import init_display_source with program_context("Xpra-Bug-Report", "Xpra Bug Report"): from xpra.log import enable_color enable_color() + from xpra.gtk_common.gtk_util import init_display_source init_display_source() set_default_icon("bugs.png") init()