• Communicating with HomePlugAV Devices using Python

    I've got a couple of pairs of ON Networks' PL 500 HomePlugAV Powerline Adapters and have been playing around with them to see how they compare to the Computrend 902 devices I played around with 5 years ago.

    I'm still playing around with the kit, but thought I'd document a very basic example of how to send commands to the devices using Python - the instructions should work for any kit based on Qualcomm's INT6x00 and AR7x00 chipsets (mine use the AR7420/QCA7420) - we'll be changing one of the encryption keys (the NMK) that the devices use

  • Python3 - TypeError: encoding without a string argument

    I thought I'd document this as although the cause/fix is fairly simple, searching for the error string encoding without a string argument gives a lot of hits for a similarly structured but different error - string argument without an encoding.

    An example backtrace might be:

    Traceback (most recent call last):
      File "./profiler.py", line 346, in 
        meta['config_files']['pdns'] = zip_and_compress(read_file_content('/etc/powerdns/pdns.conf'))
      File "./profiler.py", line 289, in zip_and_compress
        gz = gzip.compress(bytes(s,"utf-8"))
    TypeError: encoding without a string argument
    

    With the example code being fairly simple

    def read_file_content(path):
        ''' Read the entirety of a file into a variable
        '''
        file_content = None
        with open(path, 'rb') as content_file:
            file_content = content_file.read()
    
        return file_content
    
    def zip_and_compress(s):
        ''' Config files can get quite sizeable. To keep the size of our output DB down
        we gzip and then ascii armour them
        '''
        gz = gzip.compress(bytes(s,"utf-8"))
        return base64.b64encode(gz).decode("utf-8")
    
    
    zip_and_compress(read_file_content('/etc/powerdns/pdns.conf'))
    
  • Sending commit notifications using Git post-receive hooks

    I make heavy use of Git, and have plugins that allow me to view my commits when viewing issues in JIRA. Unfortunately these plugins rely on Lucene indexes which has proven to be a bit of an issue when archiving projects (or maintaining a HTML fallback).

    There are various post-receive hooks out there for sending mail notifications out whenever someone runs 'git push', however they're generally tailored towards notifying a group of developers.

    I simply wanted the equivalent of 'git log' to appear within my JIRA activity flow on any issue which is mentioned in the commit message.

    This documentation provides a python based post-receive hook intended to do just that, and also documents exactly how to go about applying that hook to all existing and future repos on your server.