def main(): from xpra.platform import program_context from xpra.platform.gui import ready as gui_ready with program_context("Start-New-Command", "Start New Command"): #logging init: if "-v" in sys.argv: enable_debug_for("util") 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() app = OpenRequestsWindow() def cb(accept): print("callback: %s" % (accept,)) app.add_request(cb, "1", "file", "someimage.png", 16384, False, True, 10) app.add_request(cb, "2", "file", "otherimage.png", 16384, False, True, 100) app.add_request(cb, "3", "file", "document.pdf", 32768, True, False, 200) app.add_request(cb, "4", "url", "https://xpra.org/", 0, False, True, 300) app.hide = app.quit 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: gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): # pragma: no cover from xpra.platform import program_context with program_context("AppIndicator-Test", "AppIndicator Test"): if "-v" in sys.argv: from xpra.log import enable_debug_for enable_debug_for("tray") from xpra.gtk_common.gobject_compat import register_os_signals from gi.repository import Gtk menu = Gtk.Menu() item = Gtk.MenuItem(label="Top Menu Item 1") submenu = Gtk.Menu() item.set_submenu(submenu) sub = Gtk.MenuItem(label="Sub Menu Item 1") subsubmenu = Gtk.Menu() sub.set_submenu(subsubmenu) subsubmenu.append(Gtk.MenuItem(label="Sub Sub Menu Item 1")) subsubmenu.append(Gtk.MenuItem(label="Sub Sub Menu Item 2")) submenu.append(sub) sub = Gtk.MenuItem(label="Sub Menu Item 2") submenu.append(sub) menu.append(item) item = Gtk.MenuItem(label="Top Menu Item 2") menu.append(item) menu.show_all() a = AppindicatorTray(None, None, menu, "test", "xpra.png", None, None, None, Gtk.main_quit) a.show() register_os_signals(Gtk.main_quit) Gtk.main()
def main(): from xpra.platform import init as platform_init from xpra.platform.gui import ready as gui_ready platform_init("Start-New-Command", "Start New Command") #logging init: if "-v" in sys.argv: enable_debug_for("util") 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() app = StartNewCommand() app.close = app.quit 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: gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): # pragma: no cover from xpra.platform import program_context from xpra.platform.gui import ready as gui_ready, init as gui_init gui_init() with program_context("Start-New-Command", "Start New Command"): #logging init: if "-v" in sys.argv: enable_debug_for("util") client = AdHocStruct() client.server_last_info_time = monotonic_time() commands_info = { 0: { 'returncode': None, 'name': 'xterm', 'pid': 542, 'dead': False, 'ignore': True, 'command': ('xterm', ), 'forget': False }, 'start-child': (), 'start-new': True, 'start-after-connect-done': True, 'start': ('xterm', ), 'start-after-connect': (), 'start-child-on-connect': (), 'exit-with-children': False, 'start-child-after-connect': (), 'start-on-connect': (), } client.server_last_info = {"commands": commands_info} client.server_start_new_commands = True client.server_commands_signals = ("SIGINT", "SIGTERM", "SIGUSR1") def noop(*_args): pass client.send_info_request = noop client.send = noop window1 = AdHocStruct() window1._metadata = {"pid": 542} client._id_to_window = {1: window1} def show_start_new_command(*_args): from xpra.client.gtk_base.start_new_command import getStartNewCommand getStartNewCommand(None).show() client.show_start_new_command = show_start_new_command app = ServerCommandsWindow(client) app.close = app.quit register_os_signals(app.quit) try: gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): from xpra.platform import program_context from xpra.platform.gui import init as gui_init, ready as gui_ready gui_init() with program_context("Start-New-Command", "Start New Command"): #logging init: if "-v" in sys.argv: from xpra.log import enable_debug_for enable_debug_for("util") from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() app = OpenRequestsWindow() def cb(accept): print("callback: %s" % (accept, )) app.add_request(cb, "1", "file", "someimage.png", 16384, False, True, 10) app.add_request(cb, "2", "file", "otherimage.png", 16384, False, True, 100) app.add_request(cb, "3", "file", "document.pdf", 32768, True, False, 200) app.add_request(cb, "4", "url", "https://xpra.org/", 0, False, True, 300) app.hide = app.quit register_os_signals(app.quit) try: gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
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(): 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.platform.gui import ready as gui_ready with program_context("Xpra-Version-Check", "Xpra Version Check"): #logging init: if "-v" in sys.argv: enable_debug_for("util") 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() app = UpdateStatusWindow() app.close = app.quit 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: gui_ready() app.show() app.check() 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(): 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 print_dict(d): for k in sorted(d.keys()): v = d[k] print("* %s : %s" % (k.ljust(32), nonl(pver(v)))) from xpra.platform import init, clean try: init("Printing", "Printing") if len(sys.argv) < 3: print_dict(get_printers()) else: printer = sys.argv[1] print_files(printer, sys.argv[2:], "Print Command", {}) finally: clean()
def main(argv): from xpra.util import xor from xpra.net.digest import get_salt, get_digests, gendigest from xpra.platform import program_context with program_context("LDAP-Password-Auth", "LDAP-Password-Authentication"): for x in list(argv): if x in ("-v", "--verbose"): enable_debug_for("auth") argv.remove(x) if len(argv) not in (3,4,5,6,7): sys.stderr.write("%s invalid arguments\n" % argv[0]) sys.stderr.write("usage: %s username password [host] [port] [tls] [username_format]\n" % argv[0]) return 1 username = argv[1] password = argv[2] kwargs = {} if len(argv)>=4: kwargs["host"] = argv[3] if len(argv)>=5: kwargs["port"] = argv[4] if len(argv)>=6: kwargs["tls"] = argv[5] if len(argv)>=7: kwargs["username_format"] = argv[6] a = Authenticator(username, **kwargs) server_salt, digest = a.get_challenge(["xor"]) salt_digest = a.choose_salt_digest(get_digests()) assert digest=="xor" client_salt = get_salt(len(server_salt)) combined_salt = gendigest(salt_digest, client_salt, server_salt) response = xor(password, combined_salt) r = a.authenticate(response, client_salt) print("success: %s" % r) return int(not r)
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(): from xpra.platform import program_context from xpra.platform.gui import ready as gui_ready with program_context("Start-New-Command", "Start New Command"): #logging init: if "-v" in sys.argv: enable_debug_for("util") 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() client = AdHocStruct() client.server_last_info_time = monotonic_time() commands_info = { 0: {'returncode': None, 'name': 'xterm', 'pid': 542, 'dead': False, 'ignore': True, 'command': ('xterm',), 'forget': False}, 'start-child' : (), 'start-new' : True, 'start-after-connect-done' : True, 'start' : ('xterm',), 'start-after-connect' : (), 'start-child-on-connect' : (), 'exit-with-children' : False, 'start-child-after-connect': (), 'start-on-connect' : (), } client.server_last_info = {"commands" : commands_info} client.server_start_new_commands = True client.server_commands_signals = ("SIGINT", "SIGTERM", "SIGUSR1") def noop(*_args): pass client.send_info_request = noop client.send = noop window1 = AdHocStruct() window1._metadata = {"pid" : 542} client._id_to_window = { 1 : window1 } def show_start_new_command(*_args): from xpra.client.gtk_base.start_new_command import getStartNewCommand getStartNewCommand(None).show() client.show_start_new_command = show_start_new_command app = ServerCommandsWindow(client) app.hide = app.quit 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: gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): 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 from xpra.platform.gui import ready as gui_ready platform_init("Xpra-Launcher", "Xpra Connection Launcher") gui_init() #logging init: 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) app = ApplicationWindow() def app_signal(signum, frame): print("") log("got signal %s" % SIGNAMES.get(signum, signum)) def show_signal(): app.show() app.client.cleanup() gobject.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) gobject.timeout_add(1000, app.set_info_color, True) #call from UI thread: gobject.idle_add(show_signal) 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]) 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) try: app.update_gui_from_config() if app.config.autoconnect: #file says we should connect, #do that only (not showing UI unless something goes wrong): gobject.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
def main(): from xpra.platform import program_context with program_context("Password-Input-Dialog", "Password Input Dialog"): if "-v" in sys.argv: from xpra.log import enable_debug_for enable_debug_for("util") try: return show_pass_dialog(sys.argv[1:]) except KeyboardInterrupt: return 1
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 main(): from xpra.platform import program_context with program_context("Confirm-Dialog", "Confirm Dialog"): #logging init: if "-v" in sys.argv: from xpra.log import enable_debug_for enable_debug_for("util") try: return show_confirm_dialog(sys.argv[1:]) except KeyboardInterrupt: return 1
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 enable_color, enable_debug_for with program_context("Keyboard-Tool", "Keyboard Tool"): #use the logger for the platform module we import from enable_color() verbose = "-v" in sys.argv or "--verbose" in sys.argv or \ (WIN32 and not ("-q" in sys.argv or "--quiet")) if verbose: enable_debug_for("keyboard") #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() #pylint: disable=not-callable 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'" % bytestostr(x) for x in (layouts or []))) print("Variant: '%s'" % bytestostr(variant or b"")) print("Variants: %s" % csv("'%s'" % bytestostr(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))) return 0
def run(self, *args): if len(args) == 1 and args[0] == "status": from xpra.log import get_all_loggers return "logging is enabled for: %s" % str( list([ str(x) for x in get_all_loggers() if x.is_debug_enabled() ])) if len(args) < 2: self.raise_error("not enough arguments") log_cmd = args[0] if log_cmd not in ("enable", "disable"): self.raise_error("only 'enable' and 'disable' verbs are supported") #support both separate arguments and csv: categories = [] for x in args[1:]: categories += [v.strip() for v in x.split(",")] from xpra.log import add_debug_category, add_disabled_category, enable_debug_for, disable_debug_for if log_cmd == "enable": add_debug_category(*categories) loggers = enable_debug_for(*categories) else: assert log_cmd == "disable" add_disabled_category(*categories) loggers = disable_debug_for(*categories) if not loggers: log.info("no loggers matching: %s", csv(categories)) else: log.info("%sd debugging for: %s", log_cmd, csv(loggers)) return "logging %sd for %s" % (log_cmd, csv(loggers))
def main(): from xpra.platform import init as platform_init from xpra.platform.gui import init as gui_init, ready as gui_ready platform_init("Xpra-Launcher", "Xpra Connection Launcher") gui_init() #logging init: from xpra.scripts.main import parse_cmdline _, options, args = parse_cmdline(sys.argv) if options.debug: from xpra.log import enable_debug_for enable_debug_for("all") app = ApplicationWindow() def app_signal(signum, frame): print("") log("got signal %s" % SIGNAMES.get(signum, signum)) def show_signal(): app.show() app.client.cleanup() gobject.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) gobject.timeout_add(1000, app.set_info_color, True) #call from UI thread: gobject.idle_add(show_signal) 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]) if app.config.debug: enable_debug_for("all") app.create_window() try: app.update_gui_from_config() if app.config.autoconnect: #file says we should connect, #do that only (not showing UI unless something goes wrong): gobject.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
def main(): from xpra.platform import program_context with program_context("AppIndicator-Test", "AppIndicator Test"): if "-v" in sys.argv: from xpra.log import enable_debug_for enable_debug_for("tray") from xpra.gtk_common.gobject_compat import import_gtk, register_os_signals gtk = import_gtk() menu = gtk.Menu() item = gtk.MenuItem("Some Menu Item Here") menu.append(item) menu.show_all() a = AppindicatorTray(None, None, menu, "test", "xpra.png", None, None, None, gtk.main_quit) a.show() register_os_signals(gtk.main_quit) gtk.main()
def main(): import sys if "-v" in sys.argv or "--verbose" in sys.argv: from xpra.log import add_debug_category, enable_debug_for enable_debug_for("webcam") add_debug_category("webcam") run = "-r" in sys.argv or "--run" in sys.argv if run: from xpra.gtk_common.gobject_compat import import_glib, import_gobject glib = import_glib() gobject = import_gobject() gobject.threads_init() from xpra.util import engs, print_nested_dict from xpra.platform import program_context with program_context("Webcam Info", "Webcam Info"): devices = get_virtual_video_devices() or {} log.info("Found %i virtual video device%s:", len(devices), engs(devices)) print_nested_dict(devices) all_devices = get_all_video_devices() or {} log.info("Found %i video device%s in total:", len(all_devices), engs(all_devices)) print_nested_dict(all_devices) if run: log.info("add watch for video device changes") def callback(added=None, device=None): if added is not None or device: log.info("video device %s: %s", ["removed", "added"][added], device) else: log.info("device change") log.info("starting main loop") main_loop = glib.MainLoop() glib.idle_add(add_video_device_change_callback, callback) try: main_loop.run() except KeyboardInterrupt: pass log.info("terminating, removing callback") remove_video_device_change_callback(callback)
def main(): # pragma: no cover from xpra.platform.gui import init as gui_init, ready as gui_ready from xpra.platform import program_context gui_init() with program_context("Start-New-Command", "Start New Command"): #logging init: if "-v" in sys.argv: enable_debug_for("util") app = StartNewCommand() app.hide = app.quit register_os_signals(app.quit) try: gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): from xpra.platform import program_context from xpra.platform.gui import ready as gui_ready with program_context("Xpra-Version-Check", "Xpra Version Check"): #logging init: if "-v" in sys.argv: enable_debug_for("util") from xpra.gtk_common.gobject_compat import register_os_signals app = UpdateStatusWindow() app.close = app.quit register_os_signals(app.quit, "Version Check") try: gui_ready() app.show() app.check() app.run() except KeyboardInterrupt: pass return 0
def main(argv): #pylint: disable=import-outside-toplevel from xpra.net.digest import get_salt, get_digests, gendigest from xpra.platform import program_context with program_context("LDAP-Password-Auth", "LDAP-Password-Authentication"): for x in list(argv): if x in ("-v", "--verbose"): enable_debug_for("auth") argv.remove(x) if len(argv) not in (3, 4, 5, 6, 7): sys.stderr.write("%s invalid arguments\n" % argv[0]) sys.stderr.write( "usage: %s username password [host] [port] [tls] [username_format]\n" % argv[0]) return 1 username = argv[1] password = argv[2] kwargs = {"username": username} if len(argv) >= 4: kwargs["host"] = argv[3] if len(argv) >= 5: kwargs["port"] = argv[4] if len(argv) >= 6: kwargs["tls"] = argv[5] if len(argv) >= 7: kwargs["username_format"] = argv[6] a = Authenticator(**kwargs) server_salt, digest = a.get_challenge(["xor"]) salt_digest = a.choose_salt_digest(get_digests()) assert digest == "xor" client_salt = get_salt(len(server_salt)) combined_salt = gendigest(salt_digest, client_salt, server_salt) assert digest == "xor" response = gendigest(digest, password, combined_salt) caps = typedict({ "challenge_response": response, "challenge_client_salt": client_salt, }) r = a.authenticate(caps) print("success: %s" % bool(r)) return int(not r)
def main(): from xpra.platform import program_context from xpra.log import enable_color, Logger, enable_debug_for log = Logger("win32") with program_context("LSA-Logon-Test", "LSA Logon Test"): enable_color() for x in ("-v", "--verbose"): if x in list(sys.argv): enable_debug_for("win32") sys.argv.remove(x) if len(sys.argv) != 2: log.warn("invalid number of arguments") log.warn("usage: %s [--verbose] username", sys.argv[0]) return 1 username = sys.argv[1] try: logon_msv1_s4u(username) return 0 except Exception as e: log.error("Logon failed: %s", e) return 1
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 Logger, enable_debug_for log = Logger("util") #logging init: if "-v" in 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(): import sys from xpra.net.net_util import 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:") for iface in get_interfaces(): if if_nametoindex: print("* %s (index=%s)" % (iface.ljust(20), if_nametoindex(iface))) else: print("* %s" % iface) print_iface(iface)
def run(self, *args): if len(args) == 1 and args[0] == "status": from xpra.log import get_all_loggers return "logging is enabled for: %s" % str( list([ str(x) for x in get_all_loggers() if x.is_debug_enabled() ])) log_cmd = args[0] if log_cmd == "mark": for _ in range(10): log.info("*" * 80) if len(args) > 1: log.info("mark: %s", " ".join(args[1:])) else: log.info("mark") for _ in range(10): log.info("*" * 80) return "mark inserted into logfile" if len(args) < 2: self.raise_error("not enough arguments") if log_cmd not in ("enable", "disable"): self.raise_error("only 'enable' and 'disable' verbs are supported") from xpra.log import add_debug_category, add_disabled_category, enable_debug_for, disable_debug_for #each argument is a group loggers = [] groups = args[1:] for group in groups: #and each group is a list of categories #preferably separated by "+", #but we support "," for backwards compatibility: categories = [ v.strip() for v in group.replace("+", ",").split(",") ] if log_cmd == "enable": add_debug_category(*categories) loggers += enable_debug_for(*categories) else: assert log_cmd == "disable" add_disabled_category(*categories) loggers += disable_debug_for(*categories) if not loggers: log.info("%s debugging, no new loggers matching: %s", log_cmd, csv(groups)) else: log.info("%sd debugging for:", log_cmd) for l in loggers: log.info(" - %s", l) return "logging %sd for %s" % (log_cmd, csv(loggers) or "<no match found")
def _process_control(self, packet): command = packet[1] if command == "show_session_info": args = packet[2:] log("calling show_session_info%s on server request", args) self.show_session_info(*args) elif command == "show_bug_report": self.show_bug_report() elif command in ("enable_%s" % x for x in compression.get_enabled_compressors()): compressor = command.split("_")[1] log.info("switching to %s on server request", compressor) self._protocol.enable_compressor(compressor) elif command in ("enable_%s" % x for x in packet_encoding.get_enabled_encoders()): pe = command.split("_")[1] log.info("switching to %s on server request", pe) self._protocol.enable_encoder(pe) elif command == "name": assert len(args) >= 3 self.server_session_name = args[2] log.info("session name updated from server: %s", self.server_session_name) #TODO: reset tray tooltip, session info title, etc.. elif command == "debug": args = packet[2:] if len(args) < 2: log.warn("not enough arguments for debug control command") return log_cmd = args[0] if log_cmd not in ("enable", "disable"): log.warn( "invalid debug control mode: '%s' (must be 'enable' or 'disable')", log_cmd) return categories = args[1:] from xpra.log import add_debug_category, add_disabled_category, enable_debug_for, disable_debug_for if log_cmd == "enable": add_debug_category(*categories) loggers = enable_debug_for(*categories) else: assert log_cmd == "disable" add_disabled_category(*categories) loggers = disable_debug_for(*categories) log.info("%sd debugging for: %s", log_cmd, loggers) return else: log.warn("received invalid control command from server: %s", command)