Skip to content

Instantly share code, notes, and snippets.

View jarvisms's full-sized avatar

Mark Jarvis jarvisms

View GitHub Profile
@jarvisms
jarvisms / gist:77acd910786b34b1e119adcb6bd45829
Last active March 27, 2024 19:17 — forked from jauderho/gist:6b7d42030e264a135450ecc0ba521bd8
HOWTO: Upgrade Raspberry Pi OS from Bullseye to Bookworm
### WARNING: READ CAREFULLY BEFORE ATTEMPTING ###
#
# Officially, this is not recommended. YMMV
# https://www.raspberrypi.com/news/bookworm-the-new-version-of-raspberry-pi-os/
#
# This mostly works if you are on 64bit. You are on your own if you are on 32bit or mixed 64/32bit
#
# Credit to anfractuosity and fgimenezm for figuring out additional details for kernels
#
@jarvisms
jarvisms / getSQLdata.py
Created February 28, 2020 18:11
pywws sqlite3 direct data access
import sqlite3
from datetime import datetime
# Connect directly with the database file and make a "connection" object
conn = sqlite3.connect(r"/home/pywws/weather-data/pywws.db")
start = datetime(2020,1,1).timestamp() # Timestamp in seconds 1577836800.0
end = datetime(2020,2,1).timestamp() # Timestamp in seconds 1580515200.0
# SQL query with named variables :start and :end which are supplied by a dictionary and substituted in place.
@jarvisms
jarvisms / PruneBackups.py
Last active November 5, 2019 15:04
rsync incremental backup time machine to remote server of entire root tree
#!/usr/bin/env python3
import datetime
import os
import os.path
import shutil
def striptime(dt):
try:
return datetime.datetime.strptime(dt,"%Y-%m-%dT%H-%M-%S") # Convert it
except ValueError: # If it doesn't look like a date, return None (boolean False)
@jarvisms
jarvisms / DCSBulkMeterRename.py
Last active June 15, 2019 20:21
Bulk rename DCS Meters according to a CSV file
# Note this uses advanced (and unsupported) features, hence pythondcsPRO
import pythondcspro as pythondcs # From https://github.com/jarvisms/pythondcs
import csv # Standard Library
dcs = pythondcs.DCSSession(DCSURL,USERNAME,PASSWORD) # Credentials as needed
backup={} # Keep original copies as backup
with open("input.csv", newline="") as inputcsv: # Adjust file as needed
# File format is literally just "<id>,<name>" on each row
csvreader = csv.reader(inputcsv)
for id,name in csvreader:
import pythondcs # From https://github.com/jarvisms/pythondcs
import csv # Standard Library
dcs = pythondcs.DCSSession(DCSURL,USERNAME,PASSWORD) # Credentials as needed
targets = [123,456,789] # List of meters you want details for
with open(r"MetersDetails.csv", "w", newline="") as outputcsv: # Adjust file as needed
csvwriter = csv.writer(outputcsv)
for id in targets:
meter = dcs.get_meters(id)
@jarvisms
jarvisms / DCStoCSV.py
Last active May 1, 2019 20:55
Downloading DCS meter readings to a CSV file
import pythondcs # From https://github.com/jarvisms/pythondcs
import csv # Standard Library
from datetime import date
dcs = pythondcs.DCSSession(DCSURL,USERNAME,PASSWORD) # Credentials as needed
targetmeters = [123,456,789] # List as many IDs as you need. In this case all assumed to be registers.
with open("output.csv", "w", newline="") as outputcsv: # Adjust file as needed
csvwriter = csv.writer(outputcsv)
### Output in "Periodic Channel Export" format as needed to import into TEAM Sigma aM&T software, coloumns are: