Giter Site home page Giter Site logo

helper_scripts's People

Contributors

anaconda-renovate[bot] avatar caseneuve avatar conradho avatar dependabot[bot] avatar filiplajszczak avatar gpjt avatar hjwp avatar pythonanywherefts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

helper_scripts's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/tests.yaml
  • actions/checkout v4@a5ac7e51b41094c92402da3b24376905380afc29
  • zcong1993/setup-timezone master
  • actions/setup-python v5@82c7e631bb3cdc910f68e0081d67478d79c6982d
pip_requirements
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

  • Check this box to trigger a request for Renovate to run again on this repository

BUG FIX NEEDED: NameError: name 'os' is not defined when Pathlib is use as in Django 3.1

The following link contains the function which needs to be fixed to resolve this issue.

def update_settings_file(self):
print(snakesay('Updating settings.py'))
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:
new_settings += "\nSTATIC_ROOT = os.path.join(BASE_DIR, 'static')"
if re.search(r'^MEDIA_ROOT\s*=', settings, flags=re.MULTILINE) is None:
new_settings += "\nMEDIA_ROOT = os.path.join(BASE_DIR, 'media')"
with self.settings_path.open('w') as f:
f.write(new_settings)

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)

better readme

add sample code/usage, list all major functionality/scripts

Provide a single top level pythonanywhere command

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.

Action Required: Fix Renovate Configuration

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? Can this be avoided somehow?

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.

pa_create_webapp_with_virtualenv.py missing docopt arg <git-repo-url> -> KeyError

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.

BUGFIX NEEDED: NameError: name 'os' is not defined while using Django 3.1

BUG FIX NEEDED

ERROR

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

Reason

The following code is responsible for the error.

def update_settings_file(self):
print(snakesay('Updating settings.py'))
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:
new_settings += "\nSTATIC_ROOT = os.path.join(BASE_DIR, 'static')"
if re.search(r'^MEDIA_ROOT\s*=', settings, flags=re.MULTILINE) is None:
new_settings += "\nMEDIA_ROOT = os.path.join(BASE_DIR, 'media')"
with self.settings_path.open('w') as f:
f.write(new_settings)

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.

Solution:

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)

. . .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.