Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

[Bug] AttributeError: 'Namespace' object has no attribute 'silent' #127

Open
nerdneilsfield opened this issue May 23, 2023 · 10 comments
Open

Comments

@nerdneilsfield
Copy link

Describe the bug

can not run the HeroicBash Luancher, AttributeError: 'Namespace' object has no attribute 'silent'

Expected behavior

the script should run and add the games to Steam Library

Screenshots

log

(deck@steamdeck HeroicBashLauncher)$ ./HeroicBashLauncher 
Using Bash Launcher v3.2.2
NOTE - This is an independent project and not affiliated with Heroic Games Launcher.

3.32.0
Traceback (most recent call last):
  File "func/HeroicBashLauncher.py", line 69, in <module>
  File "func/listinstalled.py", line 50, in listinstalled
  File "func/createlaunchfile.py", line 17, in createlaunchfile
AttributeError: 'Namespace' object has no attribute 'silent'
[1321720] Failed to execute script 'HeroicBashLauncher' due to unhandled exception!

Details

  • Platform: Steam Deck
  • OS: Steam OS 3
  • Heroic Version: v2.7.1 flatpak
  • Bash Launcher Version: V3.2.2

Additional context
None

@redromnon
Copy link
Owner

This issue is the same as #125
Looking into it.

@nerdneilsfield
Copy link
Author

Thanks

@redromnon
Copy link
Owner

Hey @afwolfe, do you know a solution to this? I've not encountered it on my side but several users are complaining.
Linked a commit I made to kind of refactor it.

@redromnon
Copy link
Owner

@nerdneilsfield Can you check if this build works? Just replace the executable with the one in the Bash Launcher folder.

@afwolfe
Copy link
Contributor

afwolfe commented May 25, 2023

Hey @redromnon. It took some digging and trial and error but I think I was able to figure it out.

In order to debug with VS Code, I had to do the following to get HeroicBashLauncher to work without being bundled up by PyInstaller and being in the Games/Heroic/HeroicBashLauncher directory (please let me know if there's a better way to do this):

  1. Copying HeroicBashLauncher.py to the root of the repo (because it didn't like the func imports while it was in the same directory.)
  2. Using this launch.json: (replacing ${REPLACE_WITH_PATH_TO_HOME})
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "HeroicBashLauncher",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/HeroicBashLauncher.py",
            "cwd": "${REPLACE_WITH_PATH_TO_HOME}/Games/Heroic/HeroicBashLauncher/",
            "console": "integratedTerminal",
            "justMyCode": true
        }
    ]
}
  1. I set a breakpoint at createlaunchfile.py:11 and confirmed that args is None when imported. On the fix-args-parser branch args is a Namespace, but it looks like args.silent is still unset and will throw the AttributeError: 'Namespace' object has no attribute 'silent'.

After a bit more searching, I think this StackOverflow does a good job explaining the bug which seems to relate to the visibility of global variables in imported modules: https://stackoverflow.com/questions/15959534/visibility-of-global-variables-in-imported-modules
Especially this in the top answer from abarnert:

Don't use a from import unless the variable is intended to be a constant. from shared_stuff import a would create a new a variable initialized to whatever shared_stuff.a referred to at the time of the import, and this new a variable would not be affected by assignments to shared_stuff.a.

TL;DR: I think one solution could be to change createlaunchfile.py and anywhere else that's using from func.settings import args to from func import settings and changing any references from args to settings.args should resolve it and use the module's instance of the variable (with the parsed arguments) as we'd expect.

@redromnon
Copy link
Owner

Thanks a ton @afwolfe
Will look at the probable solution for this.
Did you also find out why this issue doesn't affect all users?

@redromnon
Copy link
Owner

redromnon commented May 25, 2023

This also explains why the bug doesn't pop in HeroicBashLauncher.py and listinstalled.py as from func import settings is being used.

@afwolfe
Copy link
Contributor

afwolfe commented May 25, 2023

No problem. It looks like around line 17 should be the timestamp.json not found. Looks like you haven't launched any game from Heroic at all. Please consider doing so." error. While it's not a great experience that users don't reach the Zenity dialog due to the bug, the HeroicBashLauncher.log should've contained it. Should the issue template be more explicit about requesting the log file? (I saw that it's mentioned in the linked section of the README.)

@redromnon
Copy link
Owner

HeroicBashLauncher must have contained it under HeroicBashLauncher.log. I'll make it a must to add the log file too.

@redromnon
Copy link
Owner

Made the changes and hopefully, it works fine. This is the updated build.

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

No branches or pull requests

3 participants