xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Opened 5 years ago

Closed 5 years ago

Last modified 3 months ago

#1185 closed defect (fixed)

UnboundLocalError: local variable 'scriptfile' referenced before assignment

Reported by: urzds Owned by: urzds
Priority: major Milestone: 0.17
Component: server Version: trunk
Keywords: Cc:

Description

xpra main error:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/xpra/scripts/main.py", line 126, in main
    return run_mode(script_file, err, options, args, mode, defaults)
  File "/usr/lib64/python2.7/site-packages/xpra/scripts/main.py", line 1003, in run_mode
    return run_server(error_cb, options, mode, script_file, args, current_display)
  File "/usr/lib64/python2.7/site-packages/xpra/scripts/server.py", line 1038, in run_server
    write_runner_shell_scripts(script)
  File "/usr/lib64/python2.7/site-packages/xpra/scripts/server.py", line 234, in write_runner_shell_scripts
    sys.stderr.write("Error: failed to write script file '%s':\n" % scriptfile)
UnboundLocalError: local variable 'scriptfile' referenced before assignment

Environment variables:

ENV \
        PORT=30000 \
        XPRA_HOME=/home/xpra \
        XDG_RUNTIME_DIR=$XPRA_HOME/.xpra \
        XPRA_USE_RUNTIME_DIR=1 \
        XPRA_LOG_DIR=$XDG_RUNTIME_DIR \
        XPRA_SCRIPT_BIN_DIR=$XDG_RUNTIME_DIR \
        XPRA_SOCKET_DIRS=$XDG_RUNTIME_DIR

Which means XPRA_SCRIPT_BIN_DIR is set, but empty, while XDG_RUNTIME_DIR contains /.xpra.

Command line:

exec xpra start :100 --exit-with-children --daemon=no --mdns=no --pulseaudio=no --webcam=no --tcp-auth=env --tcp-encryption=AES --bind-tcp=0.0.0.0:$PORT --start-child="xterm"

All this can also be found in the Dockerfile and entrypoint.sh: https://github.com/urzds/xpra-docker/tree/fedora

Change History (8)

comment:1 Changed 5 years ago by urzds

This is actually independent of the bad values of XPRA_SCRIPT_BIN_DIR and XDG_RUNTIME_DIR:

sh-4.3$ whoami
xpra
sh-4.3$ echo $XDG_RUNTIME_DIR 
/home/xpra/.xpra
sh-4.3$ xpra start :100 --exit-with-children --daemon=no --mdns=no --pulseaudio=no --webcam=no --tcp-auth=env --tcp-encryption=AES --bind-tcp=0.0.0.0:30000 --start-child="xterm"
xpra main error:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/xpra/scripts/main.py", line 126, in main
    return run_mode(script_file, err, options, args, mode, defaults)
  File "/usr/lib64/python2.7/site-packages/xpra/scripts/main.py", line 1003, in run_mode
    return run_server(error_cb, options, mode, script_file, args, current_display)
  File "/usr/lib64/python2.7/site-packages/xpra/scripts/server.py", line 1038, in run_server
    write_runner_shell_scripts(script)
  File "/usr/lib64/python2.7/site-packages/xpra/scripts/server.py", line 234, in write_runner_shell_scripts
    sys.stderr.write("Error: failed to write script file '%s':\n" % scriptfile)
UnboundLocalError: local variable 'scriptfile' referenced before assignment

comment:2 Changed 5 years ago by urzds

It is also independent of XPRA_USE_RUNTIME_DIR:

sh-4.3$ whoami
xpra
sh-4.3$ echo $XPRA_USE_RUNTIME_DIR

sh-4.3$ echo $XDG_RUNTIME_DIR
/home/xpra/.xpra
sh-4.3$ echo $XPRA_SCRIPT_BIN_DIR 
/home/xpra/.xpra
sh-4.3$ xpra start :100 --exit-with-children --daemon=no --mdns=no --pulseaudio=no --webcam=no --tcp-auth=env --tcp-encryption=AES --bind-tcp=0.0.0.0:$PORT --start-child="xterm"
xpra main error:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/xpra/scripts/main.py", line 126, in main
    return run_mode(script_file, err, options, args, mode, defaults)
  File "/usr/lib64/python2.7/site-packages/xpra/scripts/main.py", line 1003, in run_mode
    return run_server(error_cb, options, mode, script_file, args, current_display)
  File "/usr/lib64/python2.7/site-packages/xpra/scripts/server.py", line 1038, in run_server
    write_runner_shell_scripts(script)
  File "/usr/lib64/python2.7/site-packages/xpra/scripts/server.py", line 234, in write_runner_shell_scripts
    sys.stderr.write("Error: failed to write script file '%s':\n" % scriptfile)
UnboundLocalError: local variable 'scriptfile' referenced before assignment

comment:3 Changed 5 years ago by urzds

P.S: I'm running r12466 of the 0.17.x tag.

comment:4 Changed 5 years ago by urzds

This is actually quite simple, when reading the code:

        scriptpath = os.path.join(scriptdir, "run-xpra")
        [...]
        except Exception as e:
            sys.stderr.write("Error: failed to write script file '%s':\n" % scriptfile)
            sys.stderr.write(" %s\n" % (scriptfile, e))

The logging code should print scriptpath instead of scriptfile and then output e instead of (scriptfile, e) in the second line.

Following sed makes it work:

# sed -i '/Error: failed to write script file/s/scriptfile/scriptpath/' /usr/lib64/python2.7/site-packages/xpra/scripts/server.py
# sed -i 's/(scriptfile, e)/e/' /usr/lib64/python2.7/site-packages/xpra/scripts/server.py

comment:5 Changed 5 years ago by urzds

Component: androidserver

comment:6 Changed 5 years ago by Antoine Martin

Owner: changed from Antoine Martin to urzds

Good find! This should be fixed in r12470. (will apply to v0.17.x)

comment:7 Changed 5 years ago by Antoine Martin

Resolution: fixed
Status: newclosed

Not heard back, closing.

comment:8 Changed 3 months ago by migration script

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/1185

Note: See TracTickets for help on using tickets.