Skip to content

Commit

Permalink
fix more pylint warnings
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@21727 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Feb 19, 2019
1 parent ed7ba2a commit 854bc99
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
7 changes: 5 additions & 2 deletions src/xpra/platform/shadow_server.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# This file is part of Xpra.
# Copyright (C) 2010 Nathaniel Smith <njs@pobox.com>
# Copyright (C) 2011-2013 Antoine Martin <antoine@xpra.org>
# Copyright (C) 2011-2019 Antoine Martin <antoine@xpra.org>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

ShadowServer = None
from xpra.platform import platform_import

def ShadowServer():
raise NotImplementedError()

platform_import(globals(), "shadow_server", True, "ShadowServer")
41 changes: 24 additions & 17 deletions src/xpra/scripts/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
# http://lists.partiwm.org/pipermail/parti-discuss/2008-September/000041.html
# http://lists.partiwm.org/pipermail/parti-discuss/2008-September/000042.html
# (also do not import anything that imports gtk)
import subprocess
import sys
import os.path
import atexit
import signal
import socket
import traceback
from subprocess import Popen, PIPE

from xpra.scripts.main import info, warn, error, no_gtk, validate_encryption, parse_env, configure_env
from xpra.scripts.config import InitException, TRUE_OPTIONS, FALSE_OPTIONS
Expand Down Expand Up @@ -171,12 +170,14 @@ def display_name_check(display_name):
n = display_name[1:].split(".")[0] #ie: ":0.0" -> "0"
try:
dno = int(n)
if dno>=0 and dno<10:
if 0<=dno<10:
warn("WARNING: low display number: %s" % dno)
warn(" You are attempting to run the xpra server against a low X11 display number: '%s'." % display_name)
warn(" You are attempting to run the xpra server")
warn(" against a low X11 display number: '%s'." % (display_name,))
warn(" This is generally not what you want.")
warn(" You should probably use a higher display number just to avoid any confusion (and also this warning message).")
except:
warn(" You should probably use a higher display number")
warn(" just to avoid any confusion and this warning message.")
except IOError:
pass

def close_gtk_display():
Expand Down Expand Up @@ -310,7 +311,7 @@ def guess_xpra_display(socket_dir, socket_dirs):
dotxpra = DotXpra(socket_dir, socket_dirs)
results = dotxpra.sockets()
live = [display for state, display in results if state==DotXpra.LIVE]
if len(live)==0:
if not live:
raise InitException("no existing xpra servers found")
if len(live)>1:
raise InitException("too many existing xpra servers found, cannot guess which one to use")
Expand All @@ -325,8 +326,8 @@ def preexec():
assert POSIX
os.setsid()
close_fds()
proc = subprocess.Popen(dbus_launch, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, preexec_fn=preexec)
out,_ = proc.communicate()
proc = Popen(dbus_launch, stdin=PIPE, stdout=PIPE, shell=True, preexec_fn=preexec)
out = proc.communicate()[0]
assert proc.poll()==0, "exit code is %s" % proc.poll()
#parse and add to global env:
dbus_env = {}
Expand Down Expand Up @@ -560,7 +561,7 @@ def run_server(error_cb, opts, mode, xpra_file, extra_args, desktop_display=None
def do_run_server(error_cb, opts, mode, xpra_file, extra_args, desktop_display=None):
try:
cwd = os.getcwd()
except:
except OSError:
cwd = os.path.expanduser("~")
warn("current working directory does not exist, using '%s'\n" % cwd)
validate_encryption(opts)
Expand Down Expand Up @@ -591,15 +592,15 @@ def do_run_server(error_cb, opts, mode, xpra_file, extra_args, desktop_display=N
opts.pulseaudio = False

#get the display name:
if shadowing and len(extra_args)==0:
if shadowing and not extra_args:
if WIN32 or OSX:
#just a virtual name for the only display available:
display_name = ":0"
else:
from xpra.scripts.main import guess_X11_display
dotxpra = DotXpra(opts.socket_dir, opts.socket_dirs)
display_name = guess_X11_display(dotxpra, desktop_display)
elif upgrading and len(extra_args)==0:
elif upgrading and not extra_args:
display_name = guess_xpra_display(opts.socket_dir, opts.socket_dirs)
else:
if len(extra_args) > 1:
Expand Down Expand Up @@ -638,7 +639,13 @@ def do_run_server(error_cb, opts, mode, xpra_file, extra_args, desktop_display=N

# Generate the script text now, because os.getcwd() will
# change if/when we daemonize:
from xpra.server.server_util import xpra_runner_shell_script, write_runner_shell_scripts, write_pidfile, find_log_dir, create_input_devices
from xpra.server.server_util import (
xpra_runner_shell_script,
write_runner_shell_scripts,
write_pidfile,
find_log_dir,
create_input_devices,
)
script = xpra_runner_shell_script(xpra_file, cwd, opts.socket_dir)

uid = int(opts.uid)
Expand Down Expand Up @@ -769,7 +776,7 @@ def do_run_server(error_cb, opts, mode, xpra_file, extra_args, desktop_display=N
stderr.write("Entering daemon mode; "
+ "any further errors will be reported to:\n"
+ (" %s\n" % log_filename0))
except:
except IOError:
#we tried our best, logging another error won't help
pass

Expand All @@ -794,7 +801,7 @@ def do_run_server(error_cb, opts, mode, xpra_file, extra_args, desktop_display=N
else:
try:
del os.environ["DISPLAY"]
except:
except KeyError:
pass
os.environ.update(protected_env)
log("env=%s", os.environ)
Expand Down Expand Up @@ -853,7 +860,7 @@ def check_xvfb():
del e
try:
os.close(displayfd)
except:
except IOError:
pass

kill_display = None
Expand Down Expand Up @@ -987,7 +994,7 @@ def impcheck(*modules):
for mod in modules:
try:
__import__("xpra.%s" % mod, {}, {}, [])
except ImportError as e:
except ImportError:
if mod not in impwarned:
impwarned.append(mod)
log = get_util_logger()
Expand Down

0 comments on commit 854bc99

Please sign in to comment.