Skip to content

Instantly share code, notes, and snippets.

@dizzythinks
dizzythinks / managePom.py
Created November 10, 2017 10:48
Read a pom.xml and get version or update it in Python
def managePom(update=False):
from xml.etree import ElementTree as et
ns = "http://maven.apache.org/POM/4.0.0"
et.register_namespace('', ns)
tree = et.ElementTree()
tree.parse('pom.xml')
p = tree.getroot().find("{%s}version" % ns)
if update:
p.text = update
tree.write('pom.xml')
@dizzythinks
dizzythinks / get_private_ec2_ip
Last active August 31, 2016 13:58
Boto functional programming example: get private ip
#!/usr/bin/env python
from __future__ import print_function
import boto3
def get_instances(r):
return r['Instances']
def private_ip(i):
if i[0].has_key('PrivateIpAddress'):
return i[0]['PrivateIpAddress']