jejellyroll-fr / fpdb-3

GNU Affero General Public License v3.0
8 stars 2 forks source link

[ISSUE] FileNotFoundError: [Errno 2] No such file or directory: '/home/bruno/.fpdb/HUD_config.xml' on first launch #22

Open brunetton opened 2 months ago

brunetton commented 2 months ago

Describe the bug (on Linux)

Running from Git repo for the first time, config dir is not initialized, and program crash with an exception trying to find ~/.fpdb/HUD_config.xml

To Reproduce Steps to reproduce the behavior:

  1. clone the repo & install deps
  2. run fpdb.pyw

Expected behavior Config dir containing config files needed to run program should be initialized when not existing (user should be aware of the fact the the app is running for the first time although)

Additional information

For now only log dir exists in ~/.fpdb, it's created by the call to Configuration.set_logfile("fpdb-log.txt") of import Hand in GuiHandViewer init (called by GuiSessionViewer) (took me some time to figure it out)

Proposal

Are you opened to a PR to add the configuration init at the beginning of fpdb.pyw ? For me, it's no use to start loading any UI before make sure that basic needs to start are met. Something like:

if __name__ == "__main__":
    # Init config
    Configuration.Config().initialize()

    from qt_material import apply_stylesheet
    app = QApplication([])
    apply_stylesheet(app, theme='dark_purple.xml')
    me = fpdb()

Configuration should be a singleton, isn't it ? (not sure, I didn't explored the code deep for now)

Thanks !

brunetton commented 2 months ago

Forgot to mention: I "fixed" it by manually copying HUD_config.xml to ~/.fpdb folder, and it seems to be OK

jejellyroll-fr commented 2 months ago

hi Bruno,

tx for your structured post, i'll keep your suggestion, i will add it in my next push, by simply adding, it solves the issue:

if __name__ == "__main__":
    Configuration.get_config("HUD_config.xml", True)
    from qt_material import apply_stylesheet
    app = QApplication([])
    apply_stylesheet(app, theme='dark_purple.xml')
    me = fpdb()
    app.exec_()

Jejellyroll

brunetton commented 2 months ago

Indeed, but I'm not sure reading Configuration.get_config("HUD_config.xml", True) clearly indicates the dev who reads the code that this call "initialize" the configuration if inexistant. I know that kind of remark can be kind of boring, but I think that a project have to be the clearer possible if you want other people to easily participate without breaking things on each PR. But yeah it's more time consuming at the beginning to think of code clarity !

jejellyroll-fr commented 2 months ago

hello Bruno

I'm in line with what you said, but before making a PR, to add your proposal, I need to define a gitflow more standard to our practices (here, I make a proposal: https://github.com/jejellyroll-fr/fpdb-3/discussions/26)

And the second point, which I'd also like to address, is code coverage and non-regression testing, which today is almost non-existent.

Let's keep your proposal, as an improvement to be implemented via a PR, in the meantime, I'll do a quick and dirty fix ;)

I also have other issues such as the python binding of the poker-eval lib c, or the project architecture ... which I don't like, or the web version of the project ;)

Your help will be invaluable, because even though I've learned a lot about python in the last few months, I'm still not expert enough ;)