Skip to content

Commit

Permalink
#888 showconfig subcommand
Browse files Browse the repository at this point in the history
constify DEFAULT_SSH_COMMAND properly (remove older DEFAULT_SSH_CMD)
use coloured logger to make it easy to parse
fixup auto-refresh-delay so the default value matches the one in the config file


git-svn-id: https://xpra.org/svn/Xpra/trunk@9809 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jul 2, 2015
1 parent d24d974 commit ca249b0
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 16 deletions.
7 changes: 7 additions & 0 deletions src/man/xpra.1
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ xpra \- viewer for remote, persistent X applications
.HP
\fBxpra\fP \fBinitenv\fP [\fB\-\-socket\-dir\fP=\fIDIR\fP]
.HP
\fBxpra\fP \fBshowconfig\fP
.HP
\fBxpra\fP \fBlist\fP [\fB\-\-socket\-dir\fP=\fIDIR\fP]
.HP
\fBxpra\fP \fBupgrade\fP \fI:[DISPLAY]\fP [...any options accepted by
Expand Down Expand Up @@ -231,6 +233,11 @@ appear until you attach with \fBxpra attach\fP.
\fBxpra list\fP
Show a list of xpra servers you have running on the current host.
.TP
\fBxpra showconfig\fP
Shows the configuration that would be used with other sub-commands,
taking into account the global defaults, per-user defaults and command
line arguments.
.TP
\fBxpra attach\fP \fI:7\fP
Attach to the xpra server that is using local display number \fI:7\fP.
Any apps running on that server will appear on your screen.
Expand Down
7 changes: 2 additions & 5 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,10 +780,6 @@ def build_xpra_conf(install_dir):
xvfb_command, has_displayfd, _ = detect_xorg_setup(install_dir)
with open("etc/xpra/xpra.conf.in", "r") as f_in:
template = f_in.read()
if WIN32:
ssh_command = "plink -ssh -agent"
else:
ssh_command = "ssh -x"
env_strs = []
if os.name=="posix":
env_strs += [
Expand All @@ -803,11 +799,12 @@ def bstr(b):
return ["no", "yes"][int(b)]
env = "\n".join(envstr(*x) for x in env_strs)
conf_dir = get_conf_dir(install_dir)
from xpra.platform.features import DEFAULT_SSH_COMMAND
from xpra.platform.paths import get_socket_dirs, get_default_log_dir
#remove build paths and user specific paths with UID ("/run/user/UID/Xpra"):
socket_dirs = get_socket_dirs()
SUBS = {'xvfb_command' : xvfb_command,
'ssh_command' : ssh_command,
'ssh_command' : DEFAULT_SSH_COMMAND,
'remote_logging' : bstr(OSX or WIN32),
'env' : env,
'has_displayfd' : bstr(has_displayfd),
Expand Down
1 change: 1 addition & 0 deletions src/xpra/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

LOG_PREFIX = os.environ.get("XPRA_LOG_PREFIX", "")
LOG_FORMAT = os.environ.get("XPRA_LOG_FORMAT", "%(asctime)s %(message)s")
NOPREFIX_FORMAT = "%(message)s"

logging.basicConfig(format=LOG_FORMAT)
logging.root.setLevel(logging.INFO)
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/platform/darwin/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

UI_THREAD_POLLING = 500 #poll every 500 ms

DEFAULT_SSH_CMD = "ssh"
DEFAULT_SSH_COMMAND = "ssh"
GOT_PASSWORD_PROMPT_SUGGESTION = "Perhaps you need to set up your ssh agent?\n"
4 changes: 2 additions & 2 deletions src/xpra/platform/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
UI_THREAD_POLLING = 0
OPEN_COMMAND = "xdg-open"

DEFAULT_SSH_COMMAND = "ssh -x"
DEFAULT_PULSEAUDIO_COMMAND = "pulseaudio --start --daemonize=false --system=false " + \
"--exit-idle-time=-1 -n --load=module-suspend-on-idle " + \
"--load=module-null-sink --load=module-native-protocol-unix "+ \
"--log-level=2 --log-target=stderr"
DEFAULT_XVFB_COMMAND = "Xvfb +extension Composite -screen 0 3840x2560x24+32 -nolisten tcp -noreset -auth $XAUTHORITY"
DEFAULT_SSH_CMD = False
GOT_PASSWORD_PROMPT_SUGGESTION = ""


Expand All @@ -34,9 +34,9 @@
"CAN_DAEMONIZE",
"MMAP_SUPPORTED",
"SYSTEM_TRAY_SUPPORTED",
"DEFAULT_SSH_CMD",
"DEFAULT_PULSEAUDIO_COMMAND",
"DEFAULT_XVFB_COMMAND",
"DEFAULT_SSH_COMMAND",
"GOT_PASSWORD_PROMPT_SUGGESTION",
"CLIPBOARDS",
"CLIPBOARD_WANT_TARGETS",
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/platform/win32/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
CAN_DAEMONIZE = False
MMAP_SUPPORTED = False
SYSTEM_TRAY_SUPPORTED = True
DEFAULT_SSH_CMD = "plink"

GOT_PASSWORD_PROMPT_SUGGESTION = \
'Perhaps you need to set up Pageant, or (less secure) use --ssh="plink -pw YOUR-PASSWORD"?\n'
Expand All @@ -20,3 +19,4 @@
DEFAULT_PULSEAUDIO_COMMAND = ""
DEFAULT_XVFB_COMMAND = ""
PRINT_COMMAND = ""
DEFAULT_SSH_COMMAND="plink -ssh -agent"
14 changes: 7 additions & 7 deletions src/xpra/scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def get_defaults():
global GLOBAL_DEFAULTS
if GLOBAL_DEFAULTS is not None:
return GLOBAL_DEFAULTS
from xpra.platform.features import DEFAULT_SSH_CMD, OPEN_COMMAND, DEFAULT_PULSEAUDIO_COMMAND, DEFAULT_XVFB_COMMAND
from xpra.platform.features import DEFAULT_SSH_COMMAND, OPEN_COMMAND, DEFAULT_PULSEAUDIO_COMMAND, DEFAULT_XVFB_COMMAND
from xpra.platform.paths import get_download_dir, get_default_log_dir
try:
from xpra.platform.info import get_username
Expand All @@ -378,7 +378,7 @@ def get_defaults():
"tcp-encryption" : "",
"encryption-keyfile": "",
"tcp-encryption-keyfile": "",
"ssh" : DEFAULT_SSH_CMD,
"ssh" : DEFAULT_SSH_COMMAND,
"xvfb" : DEFAULT_XVFB_COMMAND,
"socket-dir" : "",
"log-dir" : get_default_log_dir(),
Expand All @@ -405,7 +405,7 @@ def get_defaults():
"file-size-limit" : 10,
"idle-timeout" : 0,
"server-idle-timeout" : 0,
"auto-refresh-delay": 0.25,
"auto-refresh-delay": 0.15,
"daemon" : True,
"use-display" : False,
"displayfd" : False,
Expand Down Expand Up @@ -456,10 +456,10 @@ def get_defaults():
"Meta+Shift+F8:magic_key",
"Meta+Shift+F11:show_session_info"
],
"bind-tcp" : None,
"start" : None,
"start-child" : None,
"env" : None,
"bind-tcp" : [],
"start" : [],
"start-child" : [],
"env" : [],
}
return GLOBAL_DEFAULTS
#fields that got renamed:
Expand Down
30 changes: 30 additions & 0 deletions src/xpra/scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ def do_parse_cmdline(cmdline, defaults):
"\t%prog control DISPLAY command [arg1] [arg2]..\n",
"\t%prog print DISPLAY filename",
"\t%prog version [DISPLAY]\n"
"\t%prog showconfig\n"
]
server_modes = []
if supports_server:
Expand Down Expand Up @@ -961,6 +962,8 @@ def run_mode(script_file, error_cb, options, args, mode, defaults):
script = xpra_runner_shell_script(script_file, os.getcwd(), options.socket_dir)
write_runner_shell_script(script, False)
return 0
elif mode == "showconfig":
return run_showconfig(options, args)
else:
error_cb("invalid mode '%s'" % mode)
return 1
Expand Down Expand Up @@ -1711,6 +1714,33 @@ def run_list(error_cb, opts, extra_args):
may_cleanup_socket(state, display, sockpath, clean_states=clean_states)
return 0

def run_showconfig(options, args):
from xpra.colorstreamhandler import ColorStreamHandler
from xpra.log import Logger, NOPREFIX_FORMAT
from logging import Formatter
csh = ColorStreamHandler(sys.stdout)
csh.setFormatter(Formatter(NOPREFIX_FORMAT))
setloghandler(csh)
log = Logger("util")
if args:
log.warn("extra command arguments ignored")
log.info("Default Configuration:")
from xpra.scripts.config import get_defaults
d = get_defaults()
NODEFAULTS = ["socket-dirs", "env", "xvfb"]
marker = object()
for k in sorted(d.keys()):
dv = d[k]
cv = getattr(options, name_to_field(k), marker)
if cv==marker:
continue #virtual field with no command line equivallent, don't show it
if cv!=dv and k not in NODEFAULTS:
if dv==["all"]:
dv = "all"
log.warn("%-20s= %-32s (default=%s)", k, cv, dv)
else:
log.info("%-20s= %s", k, cv)


if __name__ == "__main__":
code = main("xpra.exe", sys.argv)
Expand Down

0 comments on commit ca249b0

Please sign in to comment.