July 2010
M T W T F S S
« May    
 1234
567891011
12131415161718
19202122232425
262728293031  

Check to Make Sure a Process is Running and Restart it if its Not: A Recipe in Python

Sometimes processes can be stopped because a machine is rebooted or for some reason the process has stopped running. This short little Python program will check to see if the process is running, and if not, it restarts the process automatically. Its meant to be ran automatically with as part of a cron job. I’m also using “NOHUP” so it continues to live on like a daemon process. It works by looking at the output of the “ps” command, therefore it will only work on Unix, Linux, and Mac. Sorry Windows people. Just change the “process_name” variable’s value to the name of your process. I hope you find this a useful little Python recipe.

restarter.py

#!/usr/bin/env python
"""
Check to see if an process is running. If not, restart.
Run this in a cron job
"""
import os
process_name= "foobot.py" # change this to the name of your process

tmp = os.popen("ps -Af").read()

if process_name not in tmp[:]:
    print "The process is not running. Let's restart."
    """"Use nohup to make sure it runs like a daemon"""
    newprocess="nohup python %s &" % (process_name)
    os.system(newprocess)
else:
    print "The process is running."

An Enhanced Timeout Function for Python: timeout.py

This python class is designed to timeout a function if something it hangs for too long. It was originally created by Speno’s Pythonic Avocado (I think so anyhow because I found it in multiple places on the net). I made some simple modification so you can pass arbitrary key word arguments (**kwagrs) into the the functions.  This is handy if your dealing with someone else’s unruly code or unpredictable networks. I tested this with Ubuntu 10 and Python 2.6.5. I hope you find it helpful:

timeout.py:

import signal
TIMEOUT=5

class TimeoutFunctionException(Exception):
    """Exception to raise on a timeout"""
    pass 

class TimeoutFunction: 

    def __init__(self, function, timeout):
        self.timeout = timeout
        self.function = function 

    def handle_timeout(self, signum, frame):
        raise TimeoutFunctionException()

    def __call__(self, *args, **kwargs):
        old = signal.signal(signal.SIGALRM, self.handle_timeout)
        signal.alarm(self.timeout)
        try:
            result = self.function(*args, **kwargs)
        finally:
            signal.signal(signal.SIGALRM, old)
        signal.alarm(0)
        return result 

if __name__ == '__main__':
    import sys
    stdin_read = TimeoutFunction(sys.stdin.readline, TIMEOUT)
    try:
        line = stdin_read()
    except TimeoutFunctionException:
        print 'Too slow!'
    else:
        print 'You made it!'

How to Ignore Compiled Python (.pyc files) and other Files in Subversion

1.) Create the file ‘.svnignore’ in you projects root directory. Use your favourite text editor: nano, vi, vim, emacs, etc to create and edit the file.


nano .svnignore

2.)Add the following filter rules to the file and save.


*.pyc
*~
*.db

3.) Tell subversion about it. Run this command in the projects root directory:


svn -R propset svn:ignore -F .svnignore .

4.) Commit the new rules to subversion. (Note this won’t remove .pyc files or other ignored files that already exist.)


svn commit

That’s it! Hope it helps.

OMHE: Open Mobile Health Exchange – Health Microsyntax Nirvana

OMHE: Open Mobile Health Exchange – Health Microsyntax Nirvana:  here is a screen cast I put together to explain OMHE.

VIDEO: Use Videntity to Monitor & Communicate Blood Pressure

Here is a screen cast showing OMHE Microsyntax in action.  It also illustrates identity verification and sending information to your physician.

-Alan

Taking Your Blood Pressure at Home – Use Case, Best Practices, and Discussion

Dr. Ted Eytan  MD/MS/MPH recently contributed this wiki page to the OMHE Microsyntax Project on measuring blood pressure at home. Good evidence exists to support home blood pressure monitoring. His article discusses the “why” and the “how” of home blood pressure monitoring.

http://code.google.com/p/omhe/wiki/bp

Dr. Eytan works for Kaiser Permanente and lives in Washington D.C., the epicenter of health care transformation and mHealth innovation.  His personal blog is www.tedeytan.com and his Twitter name is: @tedeytan

Nepali Cooking

If you know me well, then you know that I love to cook (and eat) Indian, Nepali, and Thai cuisine.  I really like Nepali achars (pickles) as well as momos.  Momos are like Chinese dumplings but stuffed with Nepali goodness and served with tomato or timur achar.  I’ve found this website very helpful and tried many of the recipes here:

http://nepalicooking.tripod.com/

One important tip: timur is hard to find and you probably won’t find it in an Indian grocery store; however, it’s a very important ingredient in many Nepali achars.  The trick is knowing that it is the same as “Szechuan pepper”,  which is not really a pepper at all.  Look for it in the herb section of a large well-stocked Asian grocery store.   On a side note, timur can also be used as a rub for fish and meats.  Try grinding the timur seeds in a coffee grinder and then coating a steak with them and a little Kosher salt and grill.  Yummm!

Jimbu is another hard to find spice used in Nepali cooking.  I only have some because our friend (Shana) brought it back for us the last time she went to Nepal.  If anyone knows of  where you can get in the States, please let me know.

Namaste,

-Alan

A Few of the Great Places to Eat in Baltimore

My sister asked me to compile a list of some of the best places to eat in Baltimore for her friend.  I thought a blog post would be better in case someone else asks.  Check this blog in the future for  great places to eat in  Morgantown WV,  Monterey & Carmel CA, and Washington D.C.

Here is the Baltimore “it” list  in no particular order.

The Black Olive ($$$$ – Fells Point):

Greek seafood. This is my favorite…and everyone else loves it, too!  Specializes in whole fish. Very, very good. Make sure to try the baklava ice cream!

814 South Bond Street
Baltimore, MD 21231-3346
(410) 276-7141

http://www.theblackolive.com/

The Helmand ($$$ – Mt. Vernon) :

If you’ve never tried Afghan food, you’ll love it after going here.  Both the veg and meat dishes are great.  Apps are also awesome.  Make sure to try the bread.  Desserts are also good. Hamid Karzai’s cousin owns this place and it’s considered the best Afghan in U.S.  Kind of fancy, but not too expensive. You need a reservation!

806 North Charles Street
Baltimore, MD 21201-5349
(410) 752-0311

http://www.helmand.com/

Lumbini ($$ – Charles St., Mt. Vernon):

Nepali/Indian.  I especially like going for their lunch buffet.  They have momos on the Saturday buffet, which must be tried.  I also really enjoy the goat curry, radish pickle, and the carrot dessert. No reservation necessary.

322 North Charles Street
Baltimore, MD 21201-4302
(410) 244-5556

http://www.lumbinirestaurant.com/

The Woodberry Kitchen ($$$$ – Woodbury):

Great food.  Almost everything is local and/or organic. I first saw this place on the Food Network. You need a reservation.

2010 Clipper Park Road, No. 126
Baltimore, MD 21211

http://www.woodberrykitchen.com/

The Brewer’s Art ($$$ – Mt. Vernon):

The pub fare in the basement is great…try the garlic fries with a Resurrection Ale.  Yes they make the beer. More formal American/Belgian menu available upstairs in the restaurant. Reservations recommended if eating upstairs.

1106 North Charles Street
Baltimore, MD 21201-5557
(410) 547-9310

http://www.thebrewersart.com/

The Waterfront Hotel ($$$ – Fell’s Point):

It’s not actually a hotel.  Downstairs is a bar, but if you go upstairs there is a nice dining room and lounge.  Go for brunch on the weekend.  $1 raw oysters all the time.  Try the crab hash. Reservations highly recommended.

1710 Thymes St Baltimore (Fell’s Point)
Baltimore, MD 21231-3416
(410) 537-5055

http://www.waterfronthotel.us/

Tamber’s ($$ – Charles Village) :

This is a regular American diner, but with an India menu in the back.  We didn’t try anything but the Indian food, which was great!  We had the mushroom dish and the eggplant dish and both were top notch.  Right beside Homewood Johns Hopkins Campus. Reservations not needed.

3327 Saint Paul Street
Baltimore, MD 21218-3254
(410) 243-5777

http://www.tambersrestaurant.com/

Jack’s Bistro ($$$$ – Canton):

American/contemporary food, steaks, seafood, etc.  Very good.  Reservations needed.

3123 Elliott Street
Baltimore, MD 21224-4911
(410) 878-6542

http://www.jacksbistro.net/

Sip & Bite ($ – Fells Point):

Classic diner with Greek food.  Great crab cakes….try them grilled.  Open 24 hours.  No reservation needed.

2200 Boston St
Baltimore, MD 21231

(410) 675-7077

Faidley’s Seafood at Lexington Market ($$$ – Downtown):

Try a Jumbo lump crab cake at Faidley’s!  Wow!  You can eat there but you have to stand.  Great place for lunch.  Lexington market has a little of everything.

400 West Lexington Street
Baltimore, MD 21201-1752
(410) 685-6169

http://www.faidleyscrabcakes.com/

http://www.lexingtonmarket.com/

Give us our ‘Darn Data’ – Accesing your medical records is hard

I was mentioned in this article on cnn.com posted January 12 a part of the “Empowered Patient” series.  Also mentioned in the article are  my sister Leslie Crytser, e-patient Dave, Jen McCabe, and Regina Holiday.

Here is the link:

http://www.cnn.com/2010/HEALTH/01/14/medical.records/

Twitter IDs are:

@aviars (me)

@ePatientDave

@JenSMccabe

@ReginaHolilday

Access to Your Medical Records

Hello all. I wrote this article about my father’s heart surgery and the struggles we went through. It was published on e-patients.net here:

http://e-patients.net/archives/2010/01/my-father%E2%80%99s-medical-record-fiasco.html

-Alan