Coder Social home page Coder Social logo

seanbreckenridge / pythonanywhere-3-months Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 4.0 20 KB

clicks the 'Run until 3 months from today' button on pythonanywhere, so your website doesn't deactivate automatically

License: The Unlicense

Python 100.00%
autologin pythonanywhere chromedriver selenium

pythonanywhere-3-months's Introduction

pythonanywhere-3-months

Logs into your pythonanywhere account and clicks the 'Run until 3 months from today' button, so your website doesn't deactivate automatically.

Requires: Python 3.6+ and a chromedriver binary. See here for chromedriver.

Install and Run:

python3 -m pip install git+https://github.com/seanbreckenridge/pythonanywhere-3-months
pythonanywhere_3_months -Hc /usr/local/bin/chromedriver

As long as no visible errors are thrown, the script succeeded. You can run it without the -H flag to watch it log in and click the relevant links/buttons.

usage: pythonanywhere_3_months [-h] [-H] [-c CHROMEDRIVER_PATH] [-d]

Clicks the 'Run until 3 months from today' on pythonanywhere

options:
  -h, --help            show this help message and exit
  -H, --hidden          Hide the ChromeDriver.
  -c CHROMEDRIVER_PATH, --chromedriver-path CHROMEDRIVER_PATH
                        Provides the location of ChromeDriver. Should probably
                        be the full path.
  -d, --debug           Prints debug logs

Put pythonanywhere credentials in your home directory; at $XDG_DATA_HOME/pythonanywhere_credentials.yaml (~/.local/share/pythonanywhere_credentials.yaml) with contents like:

username: yourusername
password: 2UGArHcjfKz@9GCGuNXN

This also installs a command line script called pythonanywhere_check_since which prints nothing if pythonanywhere_3_months has been run in the last 2 months, but prints a reminder to run it otherwise. I have pythonanywhere_check_since in my ~/.zshrc (equivalent to ~/.bashrc or ~/.bash_profile) file; it checks whenever I open a shell.

pythonanywhere-3-months's People

Contributors

seanbreckenridge avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pythonanywhere-3-months's Issues

ModuleNotFoundError - Latest version

Updated to the latest version and now receiving module not found errors.

Tested on Ubuntu 20.04, Debian 10/11

Using run command pythonanywhere_3_months -Hc $(which chromedriver)

All produce the same error.

ERROR

 Traceback (most recent call last):
  File "/home/runner/.local/bin/pythonanywhere_3_months", line 33, in <module>
    sys.exit(load_entry_point('pythonanywhere-3-months==0.1.0', 'console_scripts', 'pythonanywhere_3_months')())
  File "/home/runner/.local/bin/pythonanywhere_3_months", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'pythonanywhere_3_months.driver'

Reverting to 4b48807 seems to fix part of the issue and login works, but eventually fails as find_element_by_id is now removed in Selenium 4.3.0

 Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.10/site-packages/pythonanywhere_3_months/driver.py", line 82, in main
    email_input = driver.find_element_by_id("id_auth-username")
AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'

Temp Solution

I used GitHub actions to fix this, It means pulling from the old commit and using an old version of Selenium

FILE: pythonanywhere-3-months/.github/workflows/python-app.yml

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on:
  # runs on the first of every month and midnight
  schedule:
    - cron: '0 0 1 * *'
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]

permissions:
  contents: read

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - name: Update & Upgrade
      run: |
        sudo apt update
    - uses: actions/checkout@v3
      with:
        ref: '4b488074cabfc1405cb4bbdd6bf1892ba22073ef'
    - name: Set up Python 3.10
      uses: actions/setup-python@v3
      with:
        python-version: "3.10"
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install flake8 pytest
        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
    - name: Lint with flake8
      run: |
        # stop the build if there are Python syntax errors or undefined names
        flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
        # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
        flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
    - name: Install Chromium-driver
      run: |
        sudo apt-get install chromium-chromedriver
    - name: Run Python3month
      run: |
        python3 -m pip install --user ./
        export XDG_DATA_HOME=/home/runner
        sudo echo "username: ${{ secrets.USERNAME }}" >> "$XDG_DATA_HOME/pythonanywhere_credentials.yaml"
        sudo echo "password: ${{ secrets.PASSWORD }}" >> "$XDG_DATA_HOME/pythonanywhere_credentials.yaml"
        cat "$XDG_DATA_HOME/pythonanywhere_credentials.yaml"
        python3 -m pip uninstall -y selenium
        python3 -m pip install --user selenium==3.14.0
        pythonanywhere_3_months -Hc $(which chromedriver) >/dev/null 2>&1

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.