Skip to content

Instantly share code, notes, and snippets.

View JohnCEarls's full-sized avatar

John C. Earls JohnCEarls

View GitHub Profile
@JohnCEarls
JohnCEarls / mpi4py_logger.py
Created December 29, 2013 17:45
Creates a file handler that uses a shared mpi file for logging using the base python logging module. Based on Lisandro's post at https://groups.google.com/forum/#!topic/mpi4py/SaNzc8bdj6U in the mpi4py newsgroup.
import logging
from mpi4py import MPI
class MPIFileHandler(logging.FileHandler):
def __init__(self,filename, mode=MPI.MODE_WRONLY|MPI.MODE_CREATE|MPI.MODE_APPEND , encoding=None, delay=0, comm=MPI.COMM_WORLD ):
encoding = None
self.baseFilename = os.path.abspath(filename)
self.mode = mode
self.encoding = encoding
self.comm = comm
@JohnCEarls
JohnCEarls / get_region.py
Created December 29, 2013 22:25
Get the regions by name for ec2 connection Also a script to rsync with other nodes in starcluster using the alias tag.
import boto.ec2
def get_region(region_name):
for region in boto.ec2.regions():
if region_name == region.name:
return region
conn = boto.connect_ec2(region=get_region( 'us-east-1'))