-
Notifications
You must be signed in to change notification settings - Fork 66
Ensure update_sp.py is executable from any directory not just docs/ #424
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
base: main
Are you sure you want to change the base?
Conversation
|
Thanks, @network-charles. While you're at it, could you please consider also fixing the with open("requirements.txt", "r") as file:which fails when run from anywhere but |
|
Aaand, another similar thing with the with open("NEWFILES.txt", "w") as f:so it ends up in the directory from which the script is run. I.e. it can end up anywhere, which is not desirable. |
Alright |
|
Troubleshooting this script isn't intuitive because the logging levels aren't properly used. I found it challenging to distinguish between the script's actions and the outputs it generates. I had this issue when outputting the In an old PR, one of the maintainers said, Using a print "... is intended to provide specific information on what the script is doing. Logging is to debug issues." However, this statement isn't entirely accurate. Logging works beyond debugging issues. There are parts where a banner-like warning is outputted, for example, at Lines 153-157. It would have made more sense to use a one-line warning log level there and not just several print outputs. So, while troubleshooting, you know that this is a log-related warning and not just a banner. Sometimes, if you aren't careful, you might have assumed the banner was outputted from what you are troubleshooting. I don't want to address this issue immediately in this PR because I want to solve the current issue. However, this will be great to address in a new PR. |
Thanks. I'd suggest filing an issue about it first, so that if ppl have opinions, it can be resolved before a PR is submitted. |
|
Alright |
The script was initially only able to run when executed from the
docs/directory. Hence, the error @rkratky was experiencing in this issue #420.SPHINX_DIR = os.path.join(os.getcwd(), ".sphinx")os.getcwd()retrieves the current working directory and joins.sphinxto it. This makes it only executable from thedocs/directory. A more efficient way is to make it executable from any directory.So, I opted to use
os.path.dirname(__file__)to retrieve the file path to theupdate_sp.pyscript.os.path.abspathensures that the path joined later in the script uses the full directory from root, where the script is stored locally.