def main(argv=()): from xpra.os_util import POSIX, OSX from xpra.platform import program_context from xpra.platform.gui import init, set_default_icon with program_context("Xpra-Bug-Report", "Xpra Bug Report"): from xpra.log import enable_color enable_color() if POSIX and not OSX: from xpra.x11.gtk_x11.gdk_display_source import init_gdk_display_source init_gdk_display_source() set_default_icon("bugs.png") init() from xpra.log import enable_debug_for #logging init: if "-v" in argv: enable_debug_for("util") from xpra.client.gtk_base.bug_report import BugReport from xpra.gtk_common.gobject_compat import register_os_signals app = BugReport() app.close = app.quit app.init(True) register_os_signals(app.quit, "Bug Report") try: from xpra.platform.gui import ready as gui_ready gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): global pygst_version, gst_version, gst_vinfo from xpra.platform import program_context from xpra.log import enable_color with program_context("GStreamer-Info", "GStreamer Information"): enable_color() if "-v" in sys.argv or "--verbose" in sys.argv: log.enable_debug() import_gst() print("Loaded Python GStreamer version %s for Python %s.%s" % (gst_vinfo, sys.version_info[0], sys.version_info[1])) apn = get_all_plugin_names() print("GStreamer plugins found: %s" % csv(apn)) print("") print("GStreamer version: %s" % ".".join([str(x) for x in gst_version])) print("PyGStreamer version: %s" % ".".join([str(x) for x in pygst_version])) print("") encs = [x for x in CODEC_ORDER if has_encoder(x)] decs = [x for x in CODEC_ORDER if has_decoder(x)] print("encoders supported: %s" % csv(encs)) print("decoders supported: %s" % csv(decs)) print("muxers supported: %s" % csv(get_muxers())) print("demuxers supported: %s" % csv(get_demuxers())) print("source plugins: %s" % csv([x for x in get_source_plugins() if x in apn])) print("sink plugins: %s" % csv([x for x in get_sink_plugins() if x in apn])) print("default sink: %s" % get_default_sink())
def main(): global pygst_version, gst_version, gst_vinfo from xpra.platform import init, clean from xpra.log import enable_color try: init("GStreamer-Info", "GStreamer Information") enable_color() if "-v" in sys.argv or "--verbose" in sys.argv: log.enable_debug() import_gst() print("Loaded Python GStreamer version %s for Python %s.%s" % (gst_vinfo, sys.version_info[0], sys.version_info[1])) print("GStreamer plugins found: %s" % ", ".join(get_all_plugin_names())) print("") print("GStreamer version: %s" % ".".join([str(x) for x in gst_version])) print("PyGStreamer version: %s" % ".".join([str(x) for x in pygst_version])) print("") encs = [x for x in CODEC_ORDER if has_encoder(x)] decs = [x for x in CODEC_ORDER if has_decoder(x)] print("encoders supported: %s" % ", ".join(encs)) print("decoders supported: %s" % ", ".join(decs)) finally: clean()
def main(): from xpra.platform import init as platform_init, clean from xpra.util import nonl from xpra.log import enable_color try: platform_init("GUI-Properties") enable_color() init() verbose = "-v" in sys.argv or "--verbose" in sys.argv if verbose: from xpra.log import get_all_loggers for x in get_all_loggers(): x.enable_debug() # naughty, but how else can I hook this up? import os if os.name == "posix": try: from xpra.x11.bindings import posix_display_source # @UnusedImport except: pass # maybe running on OSX? hope for the best.. i = get_info() for k in sorted(i.keys()): v = i[k] print("* %s : %s" % (k.ljust(32), nonl(v))) finally: clean()
def main(_args): from xpra.platform import program_context from xpra.log import enable_color with program_context("GTK-Menu Info"): enable_color() if "-q" in sys.argv: sys.argv.remove("-q") elif "--quiet" in sys.argv: sys.argv.remove("--quiet") else: log.enable_debug() from xpra.dbus.gtk_menuactions import log as gtkmalog gtkmalog.enable_debug() try: from xpra.x11.gtk2.gdk_display_source import display #@UnresolvedImport wid = sys.argv[1] if wid.startswith("0x"): xid = int(wid[2:], 16) else: xid = int(wid) except Exception as e: log.error("Error: invalid window id: %s", e) log.error("usage:") log.error(" %s WINDOWID", sys.argv[0]) else: #beware: this import has side-effects: import dbus.glib assert dbus.glib from xpra.dbus.common import loop_init loop_init() import gobject loop = gobject.MainLoop() v = dump_menuactions(display, xid) loop.run() del v
def main(): for arg in list(sys.argv): if arg in ("-v", "--verbose"): from xpra.log import add_debug_category, enable_debug_for add_debug_category("printing") enable_debug_for("printing") sys.argv.remove(arg) from xpra.platform import program_context from xpra.log import enable_color with program_context("PyCUPS Printing"): enable_color() validate_setup() log.info("") log.info("printer definitions:") for k,v in get_printer_definitions().items(): log.info("* %-32s: %s", k, v) log.info("") log.info("local printers:") try: printers = get_printers() except RuntimeError as e: log.error("Error accessing the printing system") log.error(" %s", e) else: for k,d in get_all_printers().items(): log.info("* %s%s", k, [" (NOT EXPORTED)", ""][int(k in printers)]) for pk, pv in d.items(): if pk=="printer-state" and pv in PRINTER_STATE: pv = "%s (%s)" % (pv, PRINTER_STATE.get(pv)) log.info(" %-32s: %s", pk, pv)
def main(): from xpra.platform import program_context from xpra.log import enable_color with program_context("Keyboard-Test", "Keyboard Test Tool"): enable_color() KeyboardStateInfoWindow() gtk.main()
def main(force_enable=False): from xpra.platform import program_context from xpra.platform.gui import init as gui_init from xpra.util import print_nested_dict from xpra.log import enable_color with program_context("OpenGL-Check"): gui_init() enable_color() verbose = "-v" in sys.argv or "--verbose" in sys.argv if verbose: log.enable_debug() from xpra.client.gl.gtk_base.gtk_compat import log as clog clog.enable_debug() #replace ImportError with a log message: global gl_check_error errors = [] def log_error(msg): log.error("ERROR: %s", msg) errors.append(msg) gl_check_error = log_error props = check_support(force_enable, verbose) log.info("") if len(errors) > 0: log.info("OpenGL errors:") for e in errors: log.info(" %s", e) log.info("") log.info("OpenGL properties:") print_nested_dict(props) return len(errors)
def main(): from xpra.platform import program_context from xpra.log import enable_color with program_context("GStreamer-Info", "GStreamer Information"): enable_color() if "-v" in sys.argv or "--verbose" in sys.argv: log.enable_debug() import_gst() v = get_gst_version() if v[-1]==0: v = v[:-1] gst_vinfo = ".".join((str(x) for x in v)) print("Loaded Python GStreamer version %s for Python %s.%s" % ( gst_vinfo, sys.version_info[0], sys.version_info[1]) ) apn = get_all_plugin_names() print("GStreamer plugins found: %s" % csv(apn)) print("") print("GStreamer version: %s" % ".".join([str(x) for x in get_gst_version()])) print("PyGStreamer version: %s" % ".".join([str(x) for x in get_pygst_version()])) print("") encs = [x for x in CODEC_ORDER if has_encoder(x)] decs = [x for x in CODEC_ORDER if has_decoder(x)] print("encoders: %s" % csv(encs)) print("decoders: %s" % csv(decs)) print("muxers: %s" % csv(get_muxers())) print("demuxers: %s" % csv(get_demuxers())) print("stream compressors: %s" % csv(get_stream_compressors())) print("source plugins: %s" % csv([x for x in get_source_plugins() if x in apn])) print("sink plugins: %s" % csv([x for x in get_sink_plugins() if x in apn])) print("default sink: %s" % get_default_sink_plugin())
def main(): from xpra.util import nonl def print_options(o): for k,ot in sorted(OPTION_TYPES.items()): v = getattr(o, name_to_field(k), "") if ot==bool and v is None: v = "Auto" if type(v)==list: v = ", ".join(str(x) for x in v) print("* %-32s : %s" % (k, nonl(v))) from xpra.platform import program_context from xpra.log import enable_color with program_context("Config-Info", "Config Info"): enable_color() args = list(sys.argv[1:]) if "-v" in args or "--verbose" in sys.argv: global debug def debug(*args): print(args[0] % args[1:]) args.remove("-v") print("Default Configuration:") print_options(make_defaults_struct()) if len(args)>0: for filename in args: print("") print("Configuration file '%s':" % filename) if not os.path.exists(filename): print(" Error: file not found") continue d = read_config(filename) config = dict_to_validated_config(d) print_options(config)
def main(): from xpra.platform import init, clean from xpra.log import enable_color try: init("Loader", "Encoding Info") enable_color() verbose = "-v" in sys.argv or "--verbose" in sys.argv if verbose: log.enable_debug() load_codecs() print("codecs and csc modules found:") #print("codec_status=%s" % codecs) for name in sorted(ALL_CODECS): mod = codecs.get(name, "") f = mod if mod and hasattr(mod, "__file__"): f = mod.__file__ if f.startswith(os.getcwd()): f = f[len(os.getcwd()):] if f.startswith(os.path.sep): f = f[1:] print("* %s : %s" % (name.ljust(20), f)) if mod and verbose: try: if name.find("csc") >= 0: cs = list(mod.get_input_colorspaces()) for c in list(cs): cs += list(mod.get_output_colorspaces(c)) print(" colorspaces: %s" % ", ".join(list(set(cs)))) elif name.find("enc") >= 0 or name.find("dec") >= 0: encodings = mod.get_encodings() print(" encodings: %s" % ", ".join(encodings)) try: i = mod.get_info() for k, v in sorted(i.items()): print(" %s = %s" % (k, v)) except: pass except Exception as e: print("error getting extra information on %s: %s" % (name, e)) print("") print("codecs versions:") def pver(v): if type(v) == tuple: return ".".join([str(x) for x in v]) elif type(v) in (str, unicode) and v.startswith("v"): return v[1:] return str(v) for name in sorted(codec_versions.keys()): version = codec_versions[name] print("* %s : %s" % (name.ljust(20), pver(version))) finally: #this will wait for input on win32: clean()
def main(): if "-v" in sys.argv or "--verbose" in sys.argv: from xpra.log import add_debug_category, enable_debug_for add_debug_category("printing") enable_debug_for("printing") try: sys.argv.remove("-v") except: pass try: sys.argv.remove("--verbose") except: pass from xpra.platform import program_context from xpra.log import enable_color with program_context("PyCUPS Printing"): enable_color() validate_setup() log.info("") log.info("printer definitions:") for k, v in get_printer_definitions().items(): log.info("* %-32s: %s", k, v) log.info("") log.info("local printers:") printers = get_printers() for k, d in get_all_printers().items(): log.info("* %s%s", k, [" (NOT EXPORTED)", ""][int(k in printers)]) for pk, pv in d.items(): if pk == "printer-state" and pv in PRINTER_STATE: pv = "%s (%s)" % (pv, PRINTER_STATE.get(pv)) log.info(" %-32s: %s", pk, pv)
def main(force_enable=False): from xpra.platform import program_context from xpra.platform.gui import init as gui_init from xpra.util import print_nested_dict from xpra.log import enable_color with program_context("OpenGL-Check"): gui_init() enable_color() verbose = "-v" in sys.argv or "--verbose" in sys.argv if verbose: log.enable_debug() from xpra.client.gl.gtk_compat import log as clog clog.enable_debug() # replace ImportError with a log message: global gl_check_error errors = [] def log_error(msg): log.error("ERROR: %s", msg) errors.append(msg) gl_check_error = log_error props = check_support(force_enable, verbose) log.info("") if len(errors) > 0: log.info("OpenGL errors:") for e in errors: log.info(" %s", e) log.info("") log.info("OpenGL properties:") print_nested_dict(props) return len(errors)
def main(): from xpra.platform import program_context from xpra.util import print_nested_dict from xpra.log import enable_color with program_context("GUI-Properties"): enable_color() init() verbose = "-v" in sys.argv or "--verbose" in sys.argv if verbose: from xpra.log import get_all_loggers for x in get_all_loggers(): x.enable_debug() # naughty, but how else can I hook this up? import os if os.name == "posix": try: from xpra.x11.bindings import posix_display_source # @UnusedImport except: pass # maybe running on OSX? hope for the best.. i = get_info() print_nested_dict(i)
def main(): from xpra.platform import init as platform_init, clean from xpra.util import nonl from xpra.log import enable_color try: platform_init("GUI-Properties") enable_color() init() verbose = "-v" in sys.argv or "--verbose" in sys.argv if verbose: from xpra.log import get_all_loggers for x in get_all_loggers(): x.enable_debug() #naughty, but how else can I hook this up? import os if os.name == "posix": try: from xpra.x11.bindings import posix_display_source #@UnusedImport except: pass #maybe running on OSX? hope for the best.. i = get_info() for k in sorted(i.keys()): v = i[k] print("* %s : %s" % (k.ljust(32), nonl(v))) finally: clean()
def main(): from xpra.platform import program_context from xpra.log import enable_color with program_context("GTK-Version-Info", "GTK Version Info"): enable_color() print("%s" % get_gtk_version_info()) get_screen_sizes()
def main(args): from xpra.platform import program_context from xpra.log import enable_color with program_context("GTK-Menu Info"): enable_color() if "-q" in sys.argv: sys.argv.remove("-q") elif "--quiet" in sys.argv: sys.argv.remove("--quiet") else: log.enable_debug() from xpra.dbus.gtk_menuactions import log as gtkmalog gtkmalog.enable_debug() try: from xpra.x11.gtk2.gdk_display_source import display #@UnresolvedImport wid = sys.argv[1] if wid.startswith("0x"): xid = int(wid[2:], 16) else: xid = int(wid) except Exception as e: log.error("Error: invalid window id: %s", e) log.error("usage:") log.error(" %s WINDOWID", sys.argv[0]) else: #beware: this import has side-effects: import dbus.glib assert dbus.glib from xpra.dbus.common import loop_init loop_init() import gobject loop = gobject.MainLoop() v = dump_menuactions(display, xid) loop.run() del v
def main(argv=()): from xpra.platform import program_context with program_context("Xpra-Bug-Report", "Xpra Bug Report"): from xpra.log import enable_color enable_color() from xpra.log import enable_debug_for #logging init: if "-v" in argv: enable_debug_for("util") from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() from xpra.client.gtk_base.bug_report import BugReport from xpra.gtk_common.gobject_compat import register_os_signals app = BugReport() app.close = app.quit app.init(True) register_os_signals(app.quit) try: from xpra.platform.gui import ready as gui_ready gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): if "-v" in sys.argv or "--verbose" in sys.argv: from xpra.log import add_debug_category, enable_debug_for add_debug_category("printing") enable_debug_for("printing") try: sys.argv.remove("-v") except: pass try: sys.argv.remove("--verbose") except: pass from xpra.platform import init, clean from xpra.log import enable_color try: init("PyCUPS Printing") enable_color() validate_setup() log.info("") log.info("printer definitions:") for k, v in get_printer_definitions().items(): log.info("* %-32s: %s", k, v) log.info("") log.info("local printers:") printers = get_printers() for k, d in get_all_printers().items(): log.info("* %s%s", k, [" (NOT EXPORTED)", ""][int(k in printers)]) for pk, pv in d.items(): if pk == "printer-state" and pv in PRINTER_STATE: pv = "%s (%s)" % (pv, PRINTER_STATE.get(pv)) log.info(" %-32s: %s", pk, pv) finally: clean()
def main(): from xpra.platform import program_context from xpra.log import enable_color with program_context("Clipboard-Test", "Clipboard Test Tool"): enable_color() ClipboardStateInfoWindow() gtk.main()
def main(args): from xpra.platform import program_context from xpra.log import enable_color, LOG_FORMAT, NOPREFIX_FORMAT from xpra.util import print_nested_dict, pver with program_context("Loader", "Encoding Info"): verbose = "-v" in args or "--verbose" in args args = [x for x in args if x not in ("-v", "--verbose")] format_string = NOPREFIX_FORMAT if verbose: format_string = LOG_FORMAT log.enable_debug() enable_color(format_string) if len(args)>1: for x in args[1:]: load_codec(x) list_codecs = args[1:] else: load_codecs() list_codecs = ALL_CODECS #not really a codec, but gets used by codecs, so include version info: add_codec_version("numpy", "numpy") print("codecs and csc modules found:") #print("codec_status=%s" % codecs) for name in sorted(list_codecs): mod = codecs.get(name, "") f = mod if mod and hasattr(mod, "__file__"): f = mod.__file__ if f.startswith(os.getcwd()): f = f[len(os.getcwd()):] if f.startswith(os.path.sep): f = f[1:] print("* %s : %s" % (name.ljust(20), f)) if mod and verbose: try: if name.find("csc")>=0: cs = list(mod.get_input_colorspaces()) for c in list(cs): cs += list(mod.get_output_colorspaces(c)) print(" colorspaces: %s" % csv(list(set(cs)))) elif name.find("enc")>=0 or name.find("dec")>=0: encodings = mod.get_encodings() print(" encodings: %s" % csv(encodings)) try: i = mod.get_info() for k,v in sorted(i.items()): print(" %s = %s" % (k,v)) except Exception: pass except Exception as e: print("error getting extra information on %s: %s" % (name, e)) print("") print("codecs versions:") def forcever(v): return pver(v, numsep=".", strsep=".").lstrip("v") print_nested_dict(codec_versions, vformat=forcever) return 0
def do_main(opts): from xpra.platform import program_context from xpra.log import enable_color with program_context("Xpra-Session-Browser", "Xpra Session Browser"): enable_color() gui = SessionsGUI(opts) gtk_main() log.info("do_main() gui.exit_code=%i", gui.exit_code) return gui.exit_code
def main(): from xpra.platform import program_context from xpra.log import enable_color with program_context("Pulseaudio-Info"): enable_color() if "-v" in sys.argv or "--verbose" in sys.argv: log.enable_debug() i = get_info() for k in sorted(i): log.info("%s : %s", k.ljust(64), i[k])
def main(): from xpra.platform import program_context from xpra.log import enable_color from xpra.util import print_nested_dict with program_context("Pulseaudio-Info"): enable_color() if "-v" in sys.argv or "--verbose" in sys.argv: log.enable_debug() i = get_info() print_nested_dict(i)
def do_main(opts): from xpra.platform import program_context from xpra.log import enable_color with program_context("Xpra-Session-Browser", "Xpra Session Browser"): enable_color() gui = SessionsGUI(opts) register_os_signals(gui.app_signal) Gtk.main() log("do_main() gui.exit_code=%i", gui.exit_code) return gui.exit_code
def main(): from xpra.platform import init, clean from xpra.log import enable_color try: init("Keyboard-Test", "Keyboard Test Tool") enable_color() KeyboardStateInfoWindow() gtk.main() finally: clean()
def main(): from xpra.platform import init, clean from xpra.log import enable_color try: init("Clipboard-Test", "Clipboard Test Tool") enable_color() ClipboardStateInfoWindow() gtk.main() finally: clean()
def main(): from xpra.platform import init, clean from xpra.log import enable_color try: init("Loader", "Encoding Info") enable_color() verbose = "-v" in sys.argv or "--verbose" in sys.argv if verbose: log.enable_debug() load_codecs() print("codecs and csc modules found:") #print("codec_status=%s" % codecs) for name in sorted(ALL_CODECS): mod = codecs.get(name, "") f = mod if mod and hasattr(mod, "__file__"): f = mod.__file__ if f.startswith(os.getcwd()): f = f[len(os.getcwd()):] if f.startswith(os.path.sep): f = f[1:] print("* %s : %s" % (name.ljust(20), f)) if mod and verbose: try: if name.find("csc")>=0: cs = list(mod.get_input_colorspaces()) for c in list(cs): cs += list(mod.get_output_colorspaces(c)) print(" colorspaces: %s" % ", ".join(list(set(cs)))) elif name.find("enc")>=0 or name.find("dec")>=0: encodings = mod.get_encodings() print(" encodings: %s" % ", ".join(encodings)) try: i = mod.get_info() for k,v in sorted(i.items()): print(" %s = %s" % (k,v)) except: pass except Exception as e: print("error getting extra information on %s: %s" % (name, e)) print("") print("codecs versions:") def pver(v): if type(v)==tuple: return ".".join([str(x) for x in v]) elif type(v) in (str, unicode) and v.startswith("v"): return v[1:] return str(v) for name in sorted(codec_versions.keys()): version = codec_versions[name] print("* %s : %s" % (name.ljust(20), pver(version))) finally: #this will wait for input on win32: clean()
def main(): import sys from xpra.os_util import WIN32, OSX, POSIX, bytestostr from xpra.util import print_nested_dict, csv from xpra.platform import program_context from xpra.log import Logger, enable_color with program_context("Keyboard-Tool", "Keyboard Tool"): #use the logger for the platform module we import from global log log = None platform_import(globals(), "keyboard", True, "log") if log is None: log = Logger("keyboard") enable_color() verbose = "-v" in sys.argv or "--verbose" in sys.argv or \ (WIN32 and not ("-q" in sys.argv or "--quiet")) if verbose: log.enable_debug() #naughty, but how else can I hook this up? if POSIX and not OSX: try: from xpra.x11.bindings.posix_display_source import init_posix_display_source #@UnresolvedImport init_posix_display_source() except Exception as e: print("failed to connect to the X11 server:") print(" %s" % e) #hope for the best.. keyboard = Keyboard() mod_meanings, mod_managed, mod_pointermissing = keyboard.get_keymap_modifiers( ) print("Modifiers:") print_nested_dict(mod_meanings) print("") print("Server Managed : %s" % (csv(mod_managed) or "None")) print("Missing from pointer events : %s" % (csv(mod_pointermissing) or "None")) print("") layout, layouts, variant, variants, options = keyboard.get_layout_spec( ) print("Layout: '%s'" % bytestostr(layout or b"")) print("Layouts: %s" % csv("'%s'" % x for x in (layouts or []))) print("Variant: '%s'" % bytestostr(variant or b"")) print("Variants: %s" % csv("'%s'" % x for x in (variants or []))) print("Options: %s" % (options)) print("") print("Repeat: %s" % csv(keyboard.get_keyboard_repeat())) if verbose and POSIX: keysyms = keyboard.get_x11_keymap() if keysyms: print("Keysyms:") for keycode, keysyms in keysyms.items(): print(" %3i : %s" % (keycode, csv(keysyms)))
def do_main(opts): from xpra.platform import program_context, command_error from xpra.log import enable_color with program_context("Xpra-Session-Browser", "Xpra Session Browser"): enable_color() if not get_listener_class(): command_error("no mDNS support in this build") return 1 gui = mdns_sessions(opts) gtk_main() return gui.exit_code
def main(): import sys import socket from xpra.os_util import POSIX from xpra.util import print_nested_dict from xpra.net.net_util import import_netifaces, get_interfaces, if_nametoindex from xpra.platform import program_context from xpra.log import Logger, enable_color, add_debug_category, enable_debug_for log = Logger("network") with program_context("Network-Device-Info", "Network Device Info"): enable_color() verbose = "-v" in sys.argv or "--verbose" in sys.argv if verbose: enable_debug_for("network") add_debug_category("network") log.enable_debug() print("Network interfaces found:") netifaces = import_netifaces() for iface in get_interfaces(): if if_nametoindex: print("* %s (index=%s)" % (iface.ljust(20), if_nametoindex(iface))) else: print("* %s" % iface) addresses = netifaces.ifaddresses(iface) #@UndefinedVariable for addr, defs in addresses.items(): if addr in (socket.AF_INET, socket.AF_INET6): for d in defs: ip = d.get("addr") if ip: stype = { socket.AF_INET: "IPv4", socket.AF_INET6: "IPv6", }[addr] print(" * %s: %s" % (stype, ip)) if POSIX: from xpra.net.socket_util import create_tcp_socket try: sock = create_tcp_socket(ip, 0) sockfd = sock.fileno() info = get_interface_info(sockfd, iface) if info: print_nested_dict(info, prefix=" ", lchar="-") finally: sock.close() if not POSIX: info = get_interface_info(0, iface) if info: print(" %s" % info)
def do_main(opts): from xpra.platform import program_context from xpra.log import enable_color with program_context("Xpra-Session-Browser", "Xpra Session Browser"): enable_color() gui = SessionsGUI(opts) import signal signal.signal(signal.SIGINT, gui.app_signal) signal.signal(signal.SIGTERM, gui.app_signal) gtk_main() log("do_main() gui.exit_code=%i", gui.exit_code) return gui.exit_code
def main(): from xpra.log import enable_color from xpra.platform.gui import init, set_default_icon with program_context("Clipboard-Test", "Clipboard Test Tool"): enable_color() set_default_icon("clipboard.png") init() w = ClipboardStateInfoWindow() GLib.idle_add(w.show_with_focus) Gtk.main()
def main(): from xpra.platform import program_context from xpra.log import enable_color from xpra.platform.gui import init, set_default_icon with program_context("Clipboard-Test", "Clipboard Test Tool"): enable_color() set_default_icon("clipboard.png") init() ClipboardStateInfoWindow() gtk.main()
def main(): from xpra.platform import init, clean from xpra.log import enable_color try: init("Pulseaudio-Info") enable_color() if "-v" in sys.argv or "--verbose" in sys.argv: log.enable_debug() i = get_info() for k in sorted(i): log.info("%s : %s", k.ljust(64), i[k]) finally: clean()
def main(): from xpra.platform import program_context from xpra.log import enable_color with program_context("GTK-Version-Info", "GTK Version Info"): enable_color() print("%s" % get_gtk_version_info()) if POSIX and not OSX: from xpra.x11.bindings.posix_display_source import init_posix_display_source #@UnresolvedImport init_posix_display_source() import warnings warnings.simplefilter("ignore") print(get_screen_sizes()[0]) print_nested_dict(get_screens_info()[0])
def main(): from xpra.platform import program_context from xpra.log import enable_color from xpra.util import print_nested_dict, pver with program_context("Loader", "Encoding Info"): enable_color() verbose = "-v" in sys.argv or "--verbose" in sys.argv if verbose: log.enable_debug() load_codecs() print("codecs and csc modules found:") #print("codec_status=%s" % codecs) for name in sorted(ALL_CODECS): mod = codecs.get(name, "") f = mod if mod and hasattr(mod, "__file__"): f = mod.__file__ if f.startswith(os.getcwd()): f = f[len(os.getcwd()):] if f.startswith(os.path.sep): f = f[1:] print("* %s : %s" % (name.ljust(20), f)) if mod and verbose: try: if name.find("csc") >= 0: cs = list(mod.get_input_colorspaces()) for c in list(cs): cs += list(mod.get_output_colorspaces(c)) print(" colorspaces: %s" % ", ".join(list(set(cs)))) elif name.find("enc") >= 0 or name.find("dec") >= 0: encodings = mod.get_encodings() print(" encodings: %s" % ", ".join(encodings)) try: i = mod.get_info() for k, v in sorted(i.items()): print(" %s = %s" % (k, v)) except: pass except Exception as e: print("error getting extra information on %s: %s" % (name, e)) print("") print("codecs versions:") def forcever(v): return pver(v, numsep=".", strsep=".").lstrip("v") print_nested_dict(codec_versions, vformat=forcever)
def main(): import sys from xpra.platform import program_context from xpra.log import enable_color with program_context("Keymap-Tool", "Keymap Information Tool"): enable_color() if "-v" in sys.argv or "--verbose" in sys.argv: log.enable_debug() gtk_keymap = get_gtk_keymap() sizes = [16, 28, 8, 8, 8] def pkey(*entries): print(("".join([str(x).ljust(sizes[i]) for i,x in enumerate(entries)])).strip()) pkey("keyval", "name", "keycode", "group", "level") for x in gtk_keymap: pkey(*x)
def main(): from xpra.codecs.loader import log as loader_log, load_codecs from xpra.util import print_nested_dict from xpra.log import enable_color from xpra.platform import program_context with program_context("Video Helper"): enable_color() if "-v" in sys.argv or "--verbose" in sys.argv: loader_log.enable_debug() log.enable_debug() load_codecs() vh = getVideoHelper() vh.set_modules(ALL_VIDEO_ENCODER_OPTIONS, ALL_CSC_MODULE_OPTIONS, ALL_VIDEO_DECODER_OPTIONS) vh.init() info = vh.get_info() print_nested_dict(info)
def main(): from xpra.platform import program_context from xpra.log import enable_color from xpra.util import print_nested_dict, pver with program_context("Loader", "Encoding Info"): enable_color() verbose = "-v" in sys.argv or "--verbose" in sys.argv if verbose: log.enable_debug() load_codecs() print("codecs and csc modules found:") #print("codec_status=%s" % codecs) for name in sorted(ALL_CODECS): mod = codecs.get(name, "") f = mod if mod and hasattr(mod, "__file__"): f = mod.__file__ if f.startswith(os.getcwd()): f = f[len(os.getcwd()):] if f.startswith(os.path.sep): f = f[1:] print("* %s : %s" % (name.ljust(20), f)) if mod and verbose: try: if name.find("csc")>=0: cs = list(mod.get_input_colorspaces()) for c in list(cs): cs += list(mod.get_output_colorspaces(c)) print(" colorspaces: %s" % ", ".join(list(set(cs)))) elif name.find("enc")>=0 or name.find("dec")>=0: encodings = mod.get_encodings() print(" encodings: %s" % ", ".join(encodings)) try: i = mod.get_info() for k,v in sorted(i.items()): print(" %s = %s" % (k,v)) except: pass except Exception as e: print("error getting extra information on %s: %s" % (name, e)) print("") print("codecs versions:") def forcever(v): return pver(v, numsep=".", strsep=".").lstrip("v") print_nested_dict(codec_versions, vformat=forcever)
def main(): from xpra.codecs.loader import log as loader_log, load_codecs from xpra.util import print_nested_dict from xpra.log import enable_color from xpra.platform import program_context with program_context("Video Helper"): enable_color() if "-v" in sys.argv or "--verbose" in sys.argv: loader_log.enable_debug() log.enable_debug() load_codecs() vh = getVideoHelper() vh.set_modules(ALL_VIDEO_ENCODER_OPTIONS, ALL_CSC_MODULE_OPTIONS, ALL_VIDEO_DECODER_OPTIONS) vh.init() log.info("VideoHelper.get_info():") info = vh.get_info() print_nested_dict(info)
def main(): from xpra.platform import init, clean from xpra.log import enable_color try: init("Network-Info", "Network Info") enable_color() verbose = "-v" in sys.argv or "--verbose" in sys.argv if verbose: log.enable_debug() print("Network interfaces found:") for iface in get_interfaces(): if if_nametoindex: print("* %s (index=%s)" % (iface.ljust(20), if_nametoindex(iface))) else: print("* %s" % iface) def pver(v): if type(v) in (tuple, list): s = "" for i in range(len(v)): if i>0: #dot seperated numbers if type(v[i-1])==int: s += "." else: s += ", " s += str(v[i]) return s elif type(v)==str and v.startswith("v"): return v[1:] return str(v) print("") print("Protocol Capabilities:") from xpra.net.protocol import get_network_caps netcaps = get_network_caps() if netifaces_version: netcaps["netifaces.version"] = netifaces_version for k in sorted(netcaps.keys()): print("* %s : %s" % (str(k).ljust(20), pver(netcaps[k]))) finally: #this will wait for input on win32: clean()
def main(): from xpra.platform import init as platform_init platform_init("Xpra-Bug-Report", "Xpra Bug Report") from xpra.log import enable_color enable_color() from xpra.log import Logger, enable_debug_for log = Logger("util") #logging init: if "-v" in sys.argv: enable_debug_for("util") from xpra.gtk_common.gobject_compat import import_gobject gobject = import_gobject() gobject.threads_init() from xpra.os_util import SIGNAMES from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() from xpra.client.gtk_base.bug_report import BugReport app = BugReport() app.close = app.quit app.init(True) def app_signal(signum, frame): print("") log.info("got signal %s", SIGNAMES.get(signum, signum)) app.quit() signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) try: from xpra.platform.gui import ready as gui_ready gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): from xpra.codecs.loader import log as loader_log, load_codecs from xpra.log import enable_color from xpra.platform import init, clean try: init("Video Helper") enable_color() if "-v" in sys.argv or "--verbose" in sys.argv: loader_log.enable_debug() log.enable_debug() load_codecs() vh = getVideoHelper() vh.set_modules(ALL_VIDEO_ENCODER_OPTIONS, ALL_CSC_MODULE_OPTIONS, ALL_VIDEO_DECODER_OPTIONS) vh.init() log.info("VideoHelper.get_info():") info = vh.get_info() for k in sorted(info.keys()): v = info.get(k) if type(v) in (list, tuple): v = csv(v) log.info("%s=%s", k, v) finally: clean()
def main(): from xpra.platform import init,clean from xpra.platform.gui import init as gui_init from xpra.util import pver from xpra.log import enable_color try: init("OpenGL-Check") gui_init() enable_color() verbose = "-v" in sys.argv or "--verbose" in sys.argv if verbose: log.enable_debug() from xpra.client.gl.gtk_compat import log as clog clog.enable_debug() #replace ImportError with a log message: global gl_check_error errors = [] def log_error(msg): log.error("ERROR: %s", msg) errors.append(msg) gl_check_error = log_error props = check_support(True, verbose) log.info("") if len(errors)>0: log.info("OpenGL errors:") for e in errors: log.info(" %s", e) log.info("") log.info("OpenGL properties:") for k in sorted(props.keys()): v = props[k] #skip not human readable: if k not in ("extensions", "glconfig"): log.info("* %s : %s", str(k).ljust(24), pver(v)) return len(errors) finally: clean()
def main(args): from xpra.platform import program_context from xpra.log import enable_color with program_context("GTK-Menu Info"): enable_color() log.enable_debug() try: from xpra.x11.gtk2.gdk_display_source import display #@UnresolvedImport assert display xid = 0 if len(sys.argv)>1: wid = sys.argv[1] if wid.startswith("0x"): xid = int(wid[2:], 16) else: xid = int(wid) except Exception as e: log.error("Error: invalid window id: %s", e) log.error("usage:") log.error(" %s WINDOWID", sys.argv[0]) else: import gtk from gtk import gdk def get_frame_extents(window): from xpra.x11.gtk_x11.prop import prop_get, log as x11log x11log.enable_debug() def pget(key, etype): return prop_get(window, key, etype, ignore_errors=False, raise_xerrors=True) return pget("_NET_FRAME_EXTENTS", ["u32"]) if xid>0: #show for an existing window: w = gdk.window_foreign_new(xid) log.info("_NET_FRAME_EXTENTS=%s", get_frame_extents(w)) else: #create a window an send the request: root = gdk.get_default_root_window() from xpra.gtk_common.gtk_util import WINDOW_TOPLEVEL, get_xwindow #code ripped from gtk_client_base: from xpra.gtk_common.error import xsync from xpra.x11.gtk_x11.send_wm import send_wm_request_frame_extents window = gtk.Window(WINDOW_TOPLEVEL) window.set_title("Xpra-FRAME_EXTENTS") window.connect("destroy", gtk.main_quit) window.realize() win = window.get_window() vbox = gtk.VBox(False, 0) btn = gtk.Button("request frame extents") def request_frame_extents(*args): with xsync: log("request_frame_extents() window=%#x", get_xwindow(win)) send_wm_request_frame_extents(root, win) btn.connect("clicked", request_frame_extents) vbox.pack_start(btn, expand=False, fill=False, padding=10) label = gtk.Label() vbox.add(label) window.add(vbox) label.set_text(str(get_frame_extents(win))) import glib def refresh_label(): v = get_frame_extents(win) label.set_text(str(v)) log.info("_NET_FRAME_EXTENTS=%s", v) return True window.realize() request_frame_extents() glib.timeout_add(5000, window.show_all) glib.timeout_add(1000, refresh_label) gtk.main()
def main(): from xpra.os_util import SIGNAMES from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() from xpra.platform import init as platform_init, clean as platform_clean from xpra.platform.gui import ready as gui_ready from xpra.log import enable_color try: platform_init("Xpra-Launcher", "Xpra Connection Launcher") enable_color() gui_init() try: from xpra.scripts.main import parse_cmdline, fixup_debug_option options, args = parse_cmdline(sys.argv) debug = fixup_debug_option(options.debug) if debug: for x in debug.split(","): enable_debug_for(x) except Exception: exception_dialog("Error parsing command line") return 1 try: app = ApplicationWindow() def app_signal(signum, frame): print("") log("got signal %s" % SIGNAMES.get(signum, signum)) def show_signal(): app.show() app.client.cleanup() glib.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) glib.timeout_add(1000, app.set_info_color, True) #call from UI thread: glib.idle_add(show_signal) if sys.version_info[0]<3: #breaks GTK3.. signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) has_file = len(args) == 1 if has_file: app.update_options_from_file(args[0]) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) debug = fixup_debug_option(app.config.debug) if debug: for x in debug.split(","): enable_debug_for(x) #suspend tray workaround for our window widgets: try: set_use_tray_workaround(False) app.create_window() finally: set_use_tray_workaround(True) app.update_gui_from_config() except Exception: exception_dialog("Error creating launcher form") return 1 try: if app.config.autoconnect: #file says we should connect, #do that only (not showing UI unless something goes wrong): glib.idle_add(app.do_connect) if not has_file: app.reset_errors() gui_ready() if not app.config.autoconnect or app.config.debug: app.show() app.run() except KeyboardInterrupt: pass return 0 finally: platform_clean()
def main(): from xpra.util import print_nested_dict from xpra.platform import program_context from xpra.log import enable_color with program_context("Network-Info", "Network Info"): enable_color() verbose = "-v" in sys.argv or "--verbose" in sys.argv if verbose: log.enable_debug() print("Network interfaces found:") for iface in get_interfaces(): if if_nametoindex: print("* %s (index=%s)" % (iface.ljust(20), if_nametoindex(iface))) else: print("* %s" % iface) def pver(v): if type(v) in (tuple, list): s = "" for i in range(len(v)): if i>0: #dot seperated numbers if type(v[i-1])==int: s += "." else: s += ", " s += str(v[i]) return s if type(v)==bytes: from xpra.os_util import bytestostr v = bytestostr(v) if type(v)==str and v.startswith("v"): return v[1:] return str(v) print("Gateways found:") print_nested_dict(get_gateways()) print("") print("Protocol Capabilities:") from xpra.net.protocol import get_network_caps netcaps = get_network_caps() netif = {"" : has_netifaces} if netifaces_version: netif["version"] = netifaces_version netcaps["netifaces"] = netif print_nested_dict(netcaps) print("") print("Network Config:") print_nested_dict(get_net_config()) net_sys = get_net_sys_config() if net_sys: print("") print("Network System Config:") print_nested_dict(net_sys) print("") print("SSL:") print_nested_dict(get_ssl_info()) try: from xpra.net.crypto import crypto_backend_init, get_crypto_caps crypto_backend_init() ccaps = get_crypto_caps() if ccaps: print("") print("Crypto Capabilities:") print_nested_dict(ccaps) except Exception as e: print("No Crypto:") print(" %s" % e)
def main(): from xpra.os_util import SIGNAMES from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() from xpra.platform import program_context from xpra.platform.gui import ready as gui_ready from xpra.log import enable_color with program_context("Xpra-Launcher", "Xpra Connection Launcher"): enable_color() gui_init() try: from xpra.scripts.main import parse_cmdline, fixup_debug_option options, args = parse_cmdline(sys.argv) debug = fixup_debug_option(options.debug) if debug: for x in debug.split(","): enable_debug_for(x) except Exception: exception_dialog("Error parsing command line") return 1 try: app = ApplicationWindow() def app_signal(signum, frame): print("") log("got signal %s" % SIGNAMES.get(signum, signum)) def show_signal(): app.show() app.client.cleanup() glib.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) glib.timeout_add(1000, app.set_info_color, True) #call from UI thread: glib.idle_add(show_signal) if sys.version_info[0]<3: #breaks GTK3.. signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) has_file = len(args) == 1 if has_file: app.update_options_from_file(args[0]) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) debug = fixup_debug_option(app.config.debug) if debug: for x in debug.split(","): enable_debug_for(x) #suspend tray workaround for our window widgets: try: set_use_tray_workaround(False) app.create_window() finally: set_use_tray_workaround(True) app.update_gui_from_config() except Exception: exception_dialog("Error creating launcher form") return 1 try: if app.config.autoconnect: #file says we should connect, #do that only (not showing UI unless something goes wrong): glib.idle_add(app.do_connect) if not has_file: app.reset_errors() gui_ready() if not app.config.autoconnect or app.config.debug: #FIXME: this is ugly as hell #We have to wait for the main loop to be running #to get the NSApplicationOpneFile signal, #so we end up duplicating some of the logic from just above #maybe we should always run this code from the main loop instead if sys.platform.startswith("darwin"): #wait a little bit for the "openFile" signal app.__osx_open_file = False def do_open_file(filename): app.__osx_open_file = True app.update_options_from_file(filename) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() if app.config.autoconnect: glib.idle_add(app.do_connect) def open_file(_, filename): log("open_file(%s)", filename) glib.idle_add(do_open_file, filename) from xpra.platform.darwin.gui import get_OSXApplication get_OSXApplication().connect("NSApplicationOpenFile", open_file) def may_show(): log("may_show() osx open file=%s", app.__osx_open_file) if not app.__osx_open_file: app.show() glib.timeout_add(500, may_show) else: app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): if "-v" in sys.argv or "--verbose" in sys.argv: from xpra.log import add_debug_category, enable_debug_for add_debug_category("printing") enable_debug_for("printing") try: sys.argv.remove("-v") except: pass try: sys.argv.remove("--verbose") except: pass from xpra.util import nonl, pver def dump_dict(d): pk = None try: for pk,pv in d.items(): try: if type(pv)==unicode: sv = pv.encode("utf8") else: sv = nonl(pver(pv)) except Exception as e: sv = repr(pv) print(" %s : %s" % (pk.ljust(32), sv)) except Exception as e: print(" error on %s: %s" % (pk, e)) print(" raw attributes: " % d) def dump_info(d): print("System Configuration:") dump_dict(d) def dump_printers(d): for k in sorted(d.keys()): v = d[k] print("* %s" % k) dump_dict(v) attr = get_printer_attributes(k) if attr: print(" attributes:") for a in attr: print(" %s" % a) from xpra.platform import program_context from xpra.log import enable_color from xpra.util import csv with program_context("Printing", "Printing"): enable_color() init_printing() if len(sys.argv)<=1: dump_printers(get_printers()) dump_info(get_info()) return 0 printers = get_printers() if len(printers)==0: print("Cannot print: no printers found") return 1 if len(sys.argv)==2: filename = sys.argv[1] if not os.path.exists(filename): print("Cannot print file '%s': file does not exist" % filename) return 1 printer = get_default_printer() if not printer: printer = printers.keys()[0] if len(printers)>1: print("More than one printer found: %s", csv(printer.keys())) print("Using printer '%s'" % printer) filenames = [filename] if len(sys.argv)>2: printer = sys.argv[1] if printer not in printers: print("Invalid printer '%s'" % printer) return 1 filenames = sys.argv[2:] for filename in filenames: if not os.path.exists(filename): print("File '%s' does not exist" % filename) return 1 print("Printing: %s" % csv(filenames)) print_files(printer, filenames, "Print Command", {}) return 0