Python
September 2nd, 2021Lately I've written several Python programs. I'm going to document links to a number of general/common tasks here and try to add some degree of organization to them.
XML / BeautifulSoup4
set XML attribute value with BeautifulSoup4
How to Parse XML Files Using Python’s BeautifulSoup
Changing element value with BeautifulSoup returns empty element
RegEx
Python regex multiple search
Python SFTP
pysftp Cook Book
pysftp 0.2.9
How to check if a file exists in ftp with pysftp?
Verify host key with pysftp
PySFTP connection works but get() fails
Audio
Sound alarm when code finishes
Play a Sound with Python
Files
Copy / Move Directory - distutils.dir_util
Recursively copy an entire directory tree - shutil
Move, copy, delete and rename python files and folders
How to read a file line-by-line into a list?
Excel Files
Reading an excel file using Python openpyxl module
CSV Files
How to update rows in a CSV file
Zip Files
How to create a zip archive of a directory in Python?
Create (zip) archive using shutil
Config Files
configparser — Configuration file parser
Change value in ini file using ConfigParser Python
Command Line Arguments
Python argparse - the Perl Getopt equivalent
Argparse Tutorial
Database
Using Bind Variables
Executing a SQL Statement with bind variables on Oracle with Python
Oracle Database Connection in Python
export oracle query result set to excel sheet using python script in linux os
Oracle Pandas (dataframe)
CX_Oracle - import data from Oracle to Pandas dataframe
pandas-oracle 2.1.4
Pandas Oracle
Working with Python Pandas and XlsxWriter
Display the Pandas DataFrame in table style
Docker
Python Docker official image
Unicode / UTF8 / Language Codes
Python3 Chinese file read write method
How to auto detect text file encoding?
Character detection in a text file in Python using the Universal Encoding Detector (chardet)
python utf-8-sig BOM in the middle of the file when appending to the end
Unicode (UTF-8) reading and writing to files in Python
UnicodeDecodeError: 'charmap' codec can't decode byte X in position Y: character maps to <undefined>
UnicodeDecodeError: 'utf8' codec can't decode byte 0x9c
Unicode HOWTO
Strings
string — Common string operations
Python: Check if String Contains Substring
Converting from a string to boolean in Python?
Remove all special characters, punctuation and spaces from string
Tk/tkinter
Visual TK
General
Create object from class in separate file
Yes/No prompt in Python3 using strtobool
How to convert a file into a dictionary?
Python Dictionary – Create, Append, Update, Remove
What does a b prefix before a python string mean?
What does the if __name__ == “__main__”: do?
Understanding if __name__ == “__main__” in Python
How to print without newline or space?
How to install packages using pip through corporate proxy with configuration script?
How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31
Extract file name from path, no matter what the os/path format
How to Do Ternary Operator Assignment in Python
Ignore KeyError and continue program
Switch Case in Python (Replacement)
Check if a large file exists without downloading it
Handling Exceptions
NUT UPS Monitoring Software
August 27th, 2021I have a number of UPSes deployed throughout the house to mitigate power outages. Most of the UPSes supply power to more than one system so automated shutdown has been an issue. I recently found an article on setting up NUT (Network UPS Tools) on a Raspberry Pi to monitor a UPS and allow multiple clients to automate shutdown from a shared UPS. Additionally, I can now monitor the UPS state via a web page and even monitor and add automation via Home Assistant.
Note: there is some sort of issue with the USB timing on boot. The workaround is to unplug and replug the USB connections then restart the nut-driver service.
Network UPS Tools
How to Monitor UPS with Raspberry Pi
Monitor a UPS with a Raspberry Pi Zero W
Best NUT (Network UPS Tools) clients (for Windows)?
NUT UPS on Windows 10
Windows NUT client
Alert via SMS on power failure and hibernate the system
[Guide] Using NUT to power down multiple systems
How to hibernate Windows from command line
NUT
Configure NUT Sensor on Home Assistant
Windows 10 UPS NUT Client to Hibernate that actually works?
Network UPS Tools (NUT Server) Ultimate Guide
NUT Download Information
Please improve Windows port documentation/packaging #262
Detailed NUT Configuration
Network UPS Tools (NUT)
Raspberry Pi NUT Server
How to stop nut broadcast messages
Trouble starting Network UPS Tools with a Eaton 3S UPS
Problem to get data from UPS (nut "Error: Data stale")
Windows NUT client
NOTIFYCMD doesn't work from Windows service
Low Battery event not occurring
How to change battery low for ups in nut server
Modifying NUT UPS shutdown delay
HA SwitchPlate - HASPone
August 27th, 2021The HASPone is a DIY in-wall Touchscreen Home Assistant Controller. I've built one and haven't had a chance yet to figure out the best way to put it to use. Here are a number of links I used in the process.
HA SwitchPlate HASPone: DIY In-Wall Touchscreen Home Assistant Controller
HASPone Core Functionality Blueprint
HA SwitchPlate HASPone
Project Enclosure
3D Printable Models
Bill of Materials
Home Assistant Automation Example
Flash firmware to ESP8266
Automations for handling Scene select buttons on page 1
MineOS
August 27th, 2021I use MineOS to manage minecraft servers. Here is some information about installing, configuring and using MineOS:
Framing Information
August 27th, 2021Here is some information on house/shed framing:
Framing Shed Walls: The Only Guide You Need
California Corner and Energy Savings
Build Your Own Home as the General Contractor
How to Frame a Wall Corner
