Bug 7556 - Our pyxdg is out of date and requires Python 2
Summary: Our pyxdg is out of date and requires Python 2
Alias: None
Product: ThinLinc
Classification: Unclassified
Component: Misc (show other bugs)
Version: trunk
Hardware: PC Unknown
: P2 Normal
Target Milestone: 4.13.0
Assignee: Frida Flodin
Keywords: ossman_tester, prosaic
Depends on:
Blocks: 7554
  Show dependency treegraph
Reported: 2020-09-16 10:01 CEST by Frida Flodin
Modified: 2020-12-10 16:43 CET (History)
0 users

See Also:
Acceptance Criteria:


Description Frida Flodin cendio 2020-09-16 10:01:21 CEST
Our pyxdg has not been updated from upstream in many years. It is also written for only Python 2.
Comment 1 Frida Flodin cendio 2020-09-22 10:58:43 CEST
There are two changes between the last vendor drop and thinlinc code:

1) A quick fix to handle empty <include> blocks in menu files. See bug 7381.

2) New functionality to make it easier to create and read Exec-value in .desktop files using an argument vector. This is done with two new functions in xdg.DesktopEntry: getExecArgv and setExecArgv. See bug 3570.

By investigating the current upstream pyxdg v0.26, the conclusions are: 

1) The empty <include> is handled in pyxdg v0.26 without our fix. In other words, no need for our quick fix anymore.

2) Our new functionality for handling Exec/Argv has no equivalent in pyxdg v0.26. Therefore a merge request is made to upstream with our changes and some new unittests: 
Comment 18 Pierre Ossman cendio 2020-10-02 09:09:43 CEST
I can verify that tests are being run by Jenkins, and that they are run for both Python 2 and Python 3.

TLDC seems to read system .desktop files correctly.

Creating new files however breaks:

> 2020-10-02 09:04:52 ERROR tlwebadm[26906]: [::ffff:] code 500, message Internal error on page '/desktop/manapplications'
> 2020-10-02 09:04:52 INFO tlwebadm[26906]: [::ffff:] 'POST /desktop/manapplications HTTP/1.1' 500 -
> 2020-10-02 09:04:52 ERROR tlwebadm[26906]: [::ffff:] ----------------------------------------
> 2020-10-02 09:04:52 ERROR tlwebadm[26906]: [::ffff:] Traceback (most recent call last):
> 2020-10-02 09:04:52 ERROR tlwebadm[26906]: [::ffff:]   File "/opt/thinlinc/sbin/tlwebadm", line 174, in post_or_get
> 2020-10-02 09:04:52 ERROR tlwebadm[26906]: [::ffff:]     I1i1I1II , Oo0O0O0ooO0O = getattr ( OOOoO0O0o , action ) ( o0O , query , I1i1I1II )
> 2020-10-02 09:04:52 ERROR tlwebadm[26906]: [::ffff:]   File "/opt/thinlinc/modules/thinlinc/tlwebadm/main.py", line 131, in do_POST
> 2020-10-02 09:04:52 ERROR tlwebadm[26906]: [::ffff:]     self . _POST_METHODS . get ( page_name , self . error_404 ) ( query ) )
> 2020-10-02 09:04:52 ERROR tlwebadm[26906]: [::ffff:]   File "/opt/thinlinc/modules/thinlinc/tlwebadm/desktop.py", line 85, in manapplications
> 2020-10-02 09:04:52 ERROR tlwebadm[26906]: [::ffff:]     return self . applications ( query , sysapps = False )
> 2020-10-02 09:04:52 ERROR tlwebadm[26906]: [::ffff:]   File "/opt/thinlinc/modules/thinlinc/tlwebadm/desktop.py", line 105, in applications
> 2020-10-02 09:04:52 ERROR tlwebadm[26906]: [::ffff:]     ( Oooo0000 [ 'errors' ] , Oooo0000 [ 'details' ] ) = self . save_application ( query )
> 2020-10-02 09:04:52 ERROR tlwebadm[26906]: [::ffff:]   File "/opt/thinlinc/modules/thinlinc/tlwebadm/desktop.py", line 329, in save_application
> 2020-10-02 09:04:52 ERROR tlwebadm[26906]: [::ffff:]     trusted = True )
> 2020-10-02 09:04:52 ERROR tlwebadm[26906]: [::ffff:]   File "/opt/thinlinc/modules/xdg/IniFile.py", line 331, in write
> 2020-10-02 09:04:52 ERROR tlwebadm[26906]: [::ffff:]     fp.write(u("%s=%s\n") % (key, value))
> 2020-10-02 09:04:52 ERROR tlwebadm[26906]: [::ffff:] UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 6: ordinal not in range(128)
> 2020-10-02 09:04:52 ERROR tlwebadm[26906]: [::ffff:] ----------------------------------------
Comment 20 Pierre Ossman cendio 2020-10-06 16:15:19 CEST
It seems like (at least) xdg/Config.py was overlooked when reverting the namespace changes. It still uses Python 2's dodgy imports.
Comment 23 Pierre Ossman cendio 2020-10-09 13:06:01 CEST
Re-verified that tests are done by Jenkins, and that TLDC can read system .desktop files.

Creating new applications seem to work fine, even with Unicode in the fields. I note that % gets escaped, but I think that is as intended.

Menu entries are also properly created.

Tested activation with MATE on Ubuntu 18.04 and looks like it works fine.

Also checked that the profile chooser is correctly parsing things. It seems to pick up on all xsessions files properly, and it is setting $DESKTOP_SESSION, $XDG_DESKTOP_SESSION and $XDG_CURRENT_DESKTOP properly.
Comment 24 Pierre Ossman cendio 2020-12-10 16:43:04 CET
This upgrade breaks tl-select-profile (and tl-run-profile) if the user has any non-ASCII characters in their $PATH. One such scenario is if $HOME/bin is in $PATH and the user has a non-ASCII homedir (because the username is not ASCII).

What you get is this crash:

> Running /opt/thinlinc/etc/xstartup.d/20-tl-select-profile.sh (Choosing a profile)
> Traceback (most recent call last):
>   File "/opt/thinlinc/libexec/tl-select-profile", line 465, in <module>
>     OO = O00O0O0O0 ( OOoOoo )
>   File "/opt/thinlinc/libexec/tl-select-profile", line 124, in O00O0O0O0
>     if not which ( oOOO00o ) :
>   File "/opt/thinlinc/modules/thinlinc/which.py", line 20, in which
>     iIiiiI = os . path . join ( o0OOO , app )
>   File "/usr/lib64/python2.7/posixpath.py", line 73, in join
>     path += '/' + b
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 7: ordinal not in range(128)

The reason is that PyXDG now gives us a unicode string for the command in TryExec. And when we try to combine that with the str from os.environ['PATH'], then it first need to decode that str to unicode. Which then promptly fails as that default upgrade only supports ASCII.

Not reopening bug as this is a temporary problem until the profile commands are also converted to Python 3, which will happen before the next release. It is also a corner case and doesn't affect most use.

Note You need to log in before you can comment on or make changes to this bug.