Fixing Manningtree

Category: TheShed
#blog #tools #python

Manningtree has been around almost as long as c r o s s o a k. It's been through two iterations and is now onto its third. The first was as a blogger site (you can see the remnants as pages exported from blogger like this one). Then it moved …

Analysing Crossoak

Category: TheShed
#blog #python #SysAdmin

A friend had a theory that photography, and therefore by extension c r o s s o a k is a window into my mental well being. So I did some digging which I'm capturing here (and which is in all probability a much bigger insight into my head...). If …

More on MPD

Category: TheShed
#SysAdmin #music #mpd #python

More jottings on MPD (previously on m a n n i n g t r e e)

OneDrive from Python

Category: TheShed
#programming #python #onedrive #tools #SysAdmin

A nice commandline tool (based on a Python wrapper for the OneDrive REST API) for working with OneDrive.

pywin32 0. Setup a Python Virtual Environment 1. On Windows, install pywin32 . From the venv use easy_install (with …

Send to Kindle

Category: TheShed
#python #Kindle #SysAdmin #tools

A nice little Python Script to send documents to Amazon Kindle via a command line.

(It works too :-)

Virtual Python

Category: TheShed
#python #Programming

A quick starter on Python Virtual Environment


mkdir workingdir
cd workingdir
virtualenv venv

On Unix/Mac OS X use:

source venv/bin/activate

On Windows use:




To move the environment somewhere else:

  1. In existing (active) environment; grab a list of dependencies with pip …

Python on Unix

Category: TheShed
#python #Programming

A fragment to let Unix boxes (and Mac OS X) know that this is a python script:

#!/usr/bin/env python

Add at the start of the script.

Make sure the script is executable with:

chmod +x

Executing a process on Windows

Category: TheShed
#Python #Programming

A fragment to execute a process on Windows:

from subprocess import Popen
proc = Popen("vi \"" + filename + "\"", shell=True )

Which opens filename with vi (whatever that might be on a Windows box). Note that while Python is pretty good from a crossplatform perspective, it's not the best when it …

Writing to a file in Python

Category: TheShed
#Python #filesystem #Programming

A fragment for writing to a file in Python:

f = open(filename,'w')
f.write('Hey, I'm saying Hello file! \n')

Note that this will overwrite an existing file. Use open(filename,'a') to open in append mode. The Python documentation has details.

Python DateTime

Category: TheShed
#Python #Dates #Programming

A fragment for formatting dates and time in Python:

import datetime
date =
sDate = date.strftime("%Y%m%d")
sDateTime =  date.strftime("%Y%m%d %H:%M:%S")

See see for formatting for details of string formatting for dates …