pythonanywhere / helper_scripts Goto Github PK
View Code? Open in Web Editor NEWHelper scripts provided to PythonAnywhere users (designed to be run from a PythonAnywhere console)
License: MIT License
Helper scripts provided to PythonAnywhere users (designed to be run from a PythonAnywhere console)
License: MIT License
This is possible? I could send a PR to improve that.
django_project.update_settings_file is confused by custom settings. It should let user know about the problem.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
.github/workflows/tests.yaml
actions/checkout v4@a5ac7e51b41094c92402da3b24376905380afc29
zcong1993/setup-timezone master
actions/setup-python v5@82c7e631bb3cdc910f68e0081d67478d79c6982d
requirements.txt
python-dateutil ==2.9.0.post0
click ==8.1.7
docopt ==0.6.2
importlib-metadata ==7.1.0
psutil ==5.9.8
pytest ==8.2.1
pytest-cov ==5.0.0
pytest-mock ==3.14.0
pytest-mypy ==0.10.3
requests ==2.32.3
responses ==0.25.0
tabulate ==0.9.0
typer ==0.12.3
urllib3 ==2.2.1
virtualenvwrapper ==6.1.0
The following link contains the function which needs to be fixed to resolve this issue.
helper_scripts/pythonanywhere/django_project.py
Lines 61 to 78 in 24b428d
This issue can be resolved using following changes in that method.
from modulefinder import ModuleFinder
. . .
def update_settings_file(self):
print(snakesay('Updating settings.py'))
finder = ModuleFinder()
finder.run_script(self.settings_path)
with self.settings_path.open() as f:
settings = f.read()
new_settings = settings.replace(
'ALLOWED_HOSTS = []',
f'ALLOWED_HOSTS = [{self.domain!r}]'
)
if re.search(r'^MEDIA_ROOT\s*=', settings, flags=re.MULTILINE) is None:
new_settings += "\nMEDIA_URL = '/media/'"
if re.search(r'^STATIC_ROOT\s*=', settings, flags=re.MULTILINE) is None:
if 'pathlib' in finder.modules:
new_settings += "\nSTATIC_ROOT = BASE_DIR / 'static'"
else:
new_settings += "\nSTATIC_ROOT = os.path.join(BASE_DIR, 'static')"
if re.search(r'^MEDIA_ROOT\s*=', settings, flags=re.MULTILINE) is None:
if 'pathlib' in finder.modules:
new_settings += "\nMEDIA_ROOT = BASE_DIR / 'media'"
else:
new_settings += "\nMEDIA_ROOT = os.path.join(BASE_DIR, 'media')"
with self.settings_path.open('w') as f:
f.write(new_settings)
On my bash console, I have [email protected]
and [email protected]
.
I needed the latest version to support some packages which need at least Node 10+.
I did:
npm install -g npm
which did not work since I am not root/Administrator.
How to update both of them to latest?
add sample code/usage, list all major functionality/scripts
Like many application (git, django-admin etc) it'd be nice to have a single pythonanywhere
top level command. Then for example: pythonanywhere newsite --django=1.11 <git-url>
Another option is to implement pythonanywhere setup
which configures the API token etc, will open a browser at the correct URL and request the shown API token.
A command to run git pull and restart the application would also be great. pythonanywhere update
perhaps?
This keeps the global $PATH cleaner and is more intuitive for the user since pythonanywhere --help
can list all the available commands.
I've had good experiences with click to implement these kind of interfaces.
There's a hack in the DjangoProject class to install Django 1.x by default while Django Girls upgrades to 2.x. (https://github.com/pythonanywhere/helper_scripts/blob/master/pythonanywhere/django_project.py#L34) This has happened now - see DjangoGirls/tutorial#1282 so the hack is not needed any more.
(This caught us out at a workshop today when we had an incorrectly named requirements.txt and ended up with 1.x in our venv)
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Error type: Cannot find preset's package (github>anaconda/renovate-config)
Should pa_autoconfigure_django.py
make modifications to settings.py
when used as layed out in the Django Girls tutorial?
TL;DR: The process there is to run on PythonAnywhere
pip3.6 install --user pythonanywhere
pa_autoconfigure_django.py --python=3.6 ${URL_OF_OWN_REPO}.git
Can this modification of files in the repo be avoided somehow?
This came up in DjangoGirls/tutorial#1640 and I think I've also had participants of the DjangoGirls workshops experience unexpected changes to their repo on PythonAnywhere.
where files are, link to web tab
maybe cowsay some intermittent bits of progress?
pa_create_webapp_with_virtualenv.py is expecting a <git-repo-url>
like the Django script, but it's not docopt
specified, so a KeyError
ensues:
Traceback (most recent call last):
File "scripts/pa_create_webapp_with_virtualenv.py", line 51, in <module>
main(arguments['<git-repo-url>'], arguments['--domain'], arguments['--python'], nuke=arguments.get('--nuke'))
KeyError: '<git-repo-url>'
Even if <git-repo-url>
is added to the docopt
spec, the variable isn't currently used for checkout like it is in the Django version.
File "/home/user/user.pythonanywhere.com/mysite/settings.py", line 126, in <module>
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
NameError: name 'os' is not defined
The following code is responsible for the error.
helper_scripts/pythonanywhere/django_project.py
Lines 61 to 78 in 24b428d
New Django 3.0+ versions comes with pathlib module instead of the old os.path to refer path. This is not reflected in the pythonanywhere script. So it is inject MEDIA
settings as os.path without checking if settings.py is using pathlib or os module to refer path.
from modulefinder import ModuleFinder
. . .
def update_settings_file(self):
print(snakesay('Updating settings.py'))
finder = ModuleFinder()
finder.run_script(self.settings_path)
with self.settings_path.open() as f:
settings = f.read()
new_settings = settings.replace(
'ALLOWED_HOSTS = []',
f'ALLOWED_HOSTS = [{self.domain!r}]'
)
if re.search(r'^MEDIA_ROOT\s*=', settings, flags=re.MULTILINE) is None:
new_settings += "\nMEDIA_URL = '/media/'"
if re.search(r'^STATIC_ROOT\s*=', settings, flags=re.MULTILINE) is None:
if 'pathlib' in finder.modules:
new_settings += "\nSTATIC_ROOT = BASE_DIR / 'static'"
else:
new_settings += "\nSTATIC_ROOT = os.path.join(BASE_DIR, 'static')"
if re.search(r'^MEDIA_ROOT\s*=', settings, flags=re.MULTILINE) is None:
if 'pathlib' in finder.modules:
new_settings += "\nMEDIA_ROOT = BASE_DIR / 'media'"
else:
new_settings += "\nMEDIA_ROOT = os.path.join(BASE_DIR, 'media')"
with self.settings_path.open('w') as f:
f.write(new_settings)
. . .
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.