Read more about the article pyconau 2018 call for proposals now open
hdr

pyconau 2018 call for proposals now open

The pyconau call for proposals is now open, and runs until 28 May. I took my teenagers to pyconau last year and they greatly enjoyed it. I hadn't been to a pyconau in ages, and ended up really enjoying thinking about things from topic areas I don't normally need to think about. I think expanding one's horizons is generally a good idea. Should I propose something for this year? I am unsure. Some random ideas that immediately spring to mind: something about privsep: I think a generalised way to make privileged calls in unprivileged code is quite interesting, especially in a language which is often used for systems management and integration tasks. That said, perhaps its too OpenStacky given how disinterested in OpenStack talks most python people seem to be. nova-warts: for a long time my hobby has been cleaning up historical mistakes made in OpenStack Nova that wont ever rate as a major feature change. What lessons can other projects learn from a well funded and heavily staffed project that still thought that exec() was a great way to do important work? There's definitely an overlap with the privsep talk above, but this would be more general. a talk…

Continue Readingpyconau 2018 call for proposals now open

A pythonic example of recording metrics about ephemeral scripts with prometheus

  • Post author:
  • Post category:Prometheus

In my previous post we talked about how to record information from short lived scripts (I call them ephemeral scripts by the way) with prometheus. The example there was a script which checked the SMART status of each of the disks in a machine and reported that via pushgateway. I now want to work through a slightly more complicated example. I think you hit the limits of reporting simple values in shell scripts via curl requests fairly quickly. For example with the SMART monitoring script, SMART is capable of returning a whole heap of metrics about the performance of a disk, but we boiled that down to a single "health" value. This is largely because writing a parser for all the other values that smartctl returns would be inefficient and fragile in shell. So for this post, we're going to work through an example of how to report a variety of values from a python script. Those values could be the parsed output of smartctl, but to mix things up a bit, I'm going to use a different script I wrote recently. This new script uses the Weather Underground API to lookup weather stations near my house, and then generate…

Continue ReadingA pythonic example of recording metrics about ephemeral scripts with prometheus

Terrible pong

The kids at coding club have decided that we should write an implementation of pong in python. I took a look at some options, and decided tkinter was the way to go. Thus, I present a pong game broken up into stages which are hopefully understandable to an 11 year old: Operation Terrible Pong.

Continue ReadingTerrible pong

Getting started with OpenStack development

  • Post author:
  • Post category:OpenStack

I just gave my presentation at the Havana Conference about how to get started with OpenStack development. A few people asked for my slide deck, so I am posting it here. The talk was taped, and I am sure some more formal release will happen in the future, but I wanted to get this out there for the people who had asked for it.

Continue ReadingGetting started with OpenStack development

On syncing with Google Contacts

  • Post author:
  • Post category:Google

So, I started with a new company a few weeks ago, and one of the things I missed from my previous company was having the entire corporate directory synced onto my phone. Its really handy as an on caller to be able to give people a call when something goes wrong, without having to dig around and find their details. Back in the good old days at Google the way you got this sort of data onto your phone was to run a script written by one of the guys on the gmail team. The script grabbed the LDAP directory, and pushed it into Google contacts, which you could then sync with your phone. Now I wanted something very similar -- especially as the contacts sync stuff with Android is pretty reasonable. However, I'd never coded with the Google public APIs before, and that turned out to be the hardest part of the problem. First off I wrote a little script which dumped the corporate directory into a text file. I mostly did this because I wanted other people to be able to run the script in as light weight a manner as possible -- for example, if we wanted…

Continue ReadingOn syncing with Google Contacts

Building a symlink tree for MythTV recordings

  • Post author:
  • Post category:Mythtv

I wanted to build a directory of symlinks that pointed to my MythTV recordings, so I wrote a little python script to do it for me. I figure someone else might find this useful too... #!/usr/bin/python # Copyright (C) Michael Still (mikal@stillhq.com) 2007 # Released under the terms of the GNU GPL import MySQLdb import os import re from socket import gethostname # Connect to the MythTV database based on the MythTV config config_values = {} home = os.environ.get('HOME') config = open(home + '/.mythtv/mysql.txt') for line in config.readlines(): if not line.startswith('#') and len(line) > 5: (key, value) = line.rstrip('\n').split('=') config_values[key] = value db_connection = MySQLdb.connect(host = config_values['DBHostName'], user = config_values['DBUserName'], passwd = config_values['DBPassword'], db = config_values['DBName']) cursor = db_connection.cursor(MySQLdb.cursors.DictCursor) # Regexp for what is allowed in the symlink name unsafe = re.compile('[^a-zA-Z0-9\-\:_]+') # Find the recordings directory -- this assumes you haven't used an # identifier string for this machine... cursor.execute('select * from settings where value="RecordFilePrefix" and ' 'hostname="%s";' % gethostname()) row = cursor.fetchone() basedir = row['data'] # Now find all the recordings we have at the moment cursor.execute('select title, subtitle, starttime, basename from recorded;') for i in range(cursor.rowcount): row = cursor.fetchone() title = row['title'] subtitle = row['subtitle'] if subtitle…

Continue ReadingBuilding a symlink tree for MythTV recordings

Getting Google Talk working with PyXMPP

  • Post author:
  • Post category:Google

Jacek Konieczny has written the wholly fantabulous PyXMPP, which implements Jabber clients and servers in Python. Now, Google Talk is a Jabber server, but it needs TLS support before it works. The code is all there, but the echobot example in the download (look in the examples directory) doesn't show you how. It's not that hard though -- here's the patch I needed to make it work: --- echobot.py 2005-12-26 07:25:55.000000000 -0800 +++ echobot2.py 2006-10-25 04:25:02.000000000 -0700 @@ -13,6 +13,7 @@ from pyxmpp.all import JID,Iq,Presence,Message,StreamError from pyxmpp.jabber.client import JabberClient +from pyxmpp import streamtls class Client(JabberClient): """Simple bot (client) example. Uses `pyxmpp.jabber.client.JabberClient` @@ -28,8 +29,12 @@ # setup client with provided connection information # and identity data + + tls = streamtls.TLSSettings(require=True, verify_peer=False) + auth = ['sasl:PLAIN'] JabberClient.__init__(self, jid, password, - disco_name="PyXMPP example: echo bot", disco_type="bot") + disco_name="PyXMPP example: echo bot", disco_type="bot", + tls_settings=tls, auth_methods=auth) # register features to be announced via Service Discovery self.disco_info.add_feature("jabber:iq:version") That makes the __init__ method for the client: def __init__(self, jid, password): # if bare JID is provided add a resource -- it is required if not jid.resource: jid=JID(jid.node, jid.domain, "Echobot") # setup client with provided connection information # and identity data tls = streamtls.TLSSettings(require=True, verify_peer=False)…

Continue ReadingGetting Google Talk working with PyXMPP

End of content

No more pages to load