Skip to content

Instantly share code, notes, and snippets.

Richard Case racitup

  • Warwickshire, UK
View GitHub Profile
@racitup
racitup / _progress.py
Last active Dec 19, 2017
Django db integrity check management command
View _progress.py
import sys
import time
class ProgressBase(object):
"""
An abstract class that helps to put text on the screen and erase it again.
"""
def __init__(self):
@racitup
racitup / setvmdate.sh
Created May 5, 2017
Set the date of a JLR SDD V145 Diagnostics Virtualbox VM to a known date using python3 script
View setvmdate.sh
#! /usr/bin/env python3
# Script to reset JLR SDD VM time back
# Note the limited install authentication access is only valid within a 24 hour period
# The VM date must be within this period, not before (system date tamper detected error)
# and not afterward (expired error)
import sys
from datetime import datetime, date
from subprocess import call
@racitup
racitup / html_to_text.py
Last active Jul 4, 2020
Extract text from html in python using BeautifulSoup4
View html_to_text.py
from bs4 import BeautifulSoup, NavigableString, Tag
def html_to_text(html):
"Creates a formatted text email message as a string from a rendered html template (page)"
soup = BeautifulSoup(html, 'html.parser')
# Ignore anything in head
body, text = soup.body, []
for element in body.descendants:
# We use type and not isinstance since comments, cdata, etc are subclasses that we don't want
if type(element) == NavigableString:
You can’t perform that action at this time.