#55 Improve prismedia.genconfig process and verbosity

Closed
opened 3 years ago by LecygneNoir · 4 comments
Owner

Hello,

When running python -m prismedia.genconfig from a brand new install as documented, we got an error

/home/victor/.pyenv/versions/3.9.1/lib/python3.9/runpy.py:127: RuntimeWarning: 'prismedia.genconfig' found in sys.modules after import of package 'prismedia', but prior to execution of 'prismedia.genconfig'; this may result in unpredictable behaviour
  warn(RuntimeWarning(msg))

It appears that it's just a warning, as the files are created, but it misleading and confusing, especially as it's the first thing new user see :-/

After some research, it come from a problem in python3. The module (genconfig.py) and the function inside (genconfig()) have the exact same name, so python throw this warning.

We should update the function name to avoid this.

Hello, When running `python -m prismedia.genconfig` from a brand new install as documented, we got an error ``` /home/victor/.pyenv/versions/3.9.1/lib/python3.9/runpy.py:127: RuntimeWarning: 'prismedia.genconfig' found in sys.modules after import of package 'prismedia', but prior to execution of 'prismedia.genconfig'; this may result in unpredictable behaviour warn(RuntimeWarning(msg)) ``` It appears that it's just a warning, as the files are created, but it misleading and confusing, especially as it's the first thing new user see :-/ After some research, it come from a problem in python3. The module (genconfig.py) and the function inside (genconfig()) have the exact same name, so python throw this warning. We should update the function name to avoid this.
Poster
Owner

Thanks @zykino for the report!

Thanks @zykino for the report!
LecygneNoir added the
bug
label 3 years ago
LecygneNoir added the
Work in Progress
label 3 years ago
Poster
Owner

Ok it's a little different from what I thought.

The exact problem is in fact that __init__.py import genconfig, while using python with -m already import it as a .py in the root of the project!

So, it's imported two times, which is a problem for python. It was an old behaviour from python 2.6, we may drop it.

Removing the import from init.py avoid the warning, and explicitely calling prismedia.genconfig still works

❯ ls  # No files present
❯ python -m prismedia.genconfig # No warning displayed
❯ ls # Files are here
peertube_secret.sample  youtube_secret.json.sample
Ok it's a little different from what I thought. The exact problem is in fact that `__init__.py` import genconfig, while using python with `-m` already import it as a .py in the root of the project! So, it's imported two times, which is a problem for python. It was an old behaviour from python 2.6, we may drop it. Removing the import from init.py avoid the warning, and explicitely calling `prismedia.genconfig` still works ``` ❯ ls # No files present ❯ python -m prismedia.genconfig # No warning displayed ❯ ls # Files are here peertube_secret.sample youtube_secret.json.sample ```
Poster
Owner

While I am on it, I'll improve this genconfig process.

For the moment it's hard to use, not very clear (2 lines of doc between all the others), it creates files with .sample which is confusing if the user miss the "rename them" info, ...

Target:

  • Improve documentation, more space, more details
  • Improve function, more verbosity, creates file with no .sample and check if files exist
While I am on it, I'll improve this genconfig process. For the moment it's hard to use, not very clear (2 lines of doc between all the others), it creates files with `.sample` which is confusing if the user miss the "rename them" info, ... Target: * Improve documentation, more space, more details * Improve function, more verbosity, creates file with no .sample and check if files exist
LecygneNoir changed title from prismedia.genconfig sends a warning to Improve prismedia.genconfig process and verbosity 3 years ago
LecygneNoir added the
enhancement
label 3 years ago
Poster
Owner

Close by #59

Close by #59
LecygneNoir closed this issue 3 years ago
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.