Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow non-ASCII characters in shortcut AppName. #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ryochan7
Copy link

This change was mainly to work around problems with a custom shortcut for Star Wars: Dark Forces purchased from GOG. The name has a Registerted Sign (U+00AE) in it which would make the name fail to convert to ascii and cause the script to stop. The change seems to work fine for my other non-Steam app shortcuts as well.

This was mainly to work around problems with a custom
shortcut for Star Wars: Dark Forces from GOG.
The name has a Registerted Sign (U+00AE) in it
which would make the name fail to convert to ascii and
cause the script to stop.
@scottrice
Copy link
Owner

Sweet, thanks for doing this! Could you explain more about why you changed the lines you did? I'm not super familiar with character encodings, but I see changes to the shortcut generator but not the shortcut parser. It may just be early in the morning, but what was causing the error before and why do these lines fix it?

@Ryochan7
Copy link
Author

python reads the shortcuts.vdf file fine and the name is encoded as a byte string. The problem was occurring while attempting to convert that byte string to unicode in ShortcutGenerator.generate_keyvalue_pair and also for the conversion when writing the new shortcuts.vdf file in shortcuts.write_shortcuts. Here is the output of the main error:

=========== User: 10238787 ===========
[ERROR] An exception occurred while running Ice
Traceback (most recent call last):
  File "/usr/share/games/ice/runners/ice_engine.py", line 153, in run
    self.main(dry_run=dry_run)
  File "/usr/share/games/ice/runners/ice_engine.py", line 133, in main
    self.run_for_user(user_context, dry_run=dry_run)
  File "/usr/share/games/ice/runners/ice_engine.py", line 145, in run_for_user
    self._create_backup(user, dry_run=dry_run)
  File "/usr/share/games/ice/runners/ice_engine.py", line 167, in _create_backup
    shortcuts.write_shortcuts(backup_path, shortcuts.get_shortcuts(user))
  File "/usr/lib/python2.7/dist-packages/pysteam/shortcuts.py", line 30, in write_shortcuts
    vdf_contents = ShortcutGenerator().to_string(shortcuts)
  File "/usr/lib/python2.7/dist-packages/pysteam/_shortcut_generator.py", line 20, in to_string
    string = x00 + 'shortcuts' + x00 + self.generate_array_string(shortcuts) + x08 + x08 + x0a
  File "/usr/lib/python2.7/dist-packages/pysteam/_shortcut_generator.py", line 29, in generate_array_string
    string += x00 + str(i) + x00 + self.generate_shortcut_string(shortcut)
  File "/usr/lib/python2.7/dist-packages/pysteam/_shortcut_generator.py", line 34, in generate_shortcut_string
    string += self.generate_keyvalue_pair("AppName",shortcut.name)
  File "/usr/lib/python2.7/dist-packages/pysteam/_shortcut_generator.py", line 52, in generate_keyvalue_pair
    return x01 + key + x00 + value + (x00 if more else x08)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 9: ordinal not in range(128)

@mdeguzis
Copy link
Contributor

@Ryochan7 @scottrice , this is very similar to in an old commit for Ice (b1b1f08), when the structure of Ice was a bit different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants