get app state

def get_app_state(app_id):
    """
    get app state
    """
    try:
        conn = get_conn()
        c = conn.cursor()
        c.execute("SELECT state FROM app WHERE id='{0}' ".format(app_id))
        result = c.fetchone()
        conn.close()

        if result:
            state = result[0]
            return state
        else:
            return None

    except Exception,e:
        raise RuntimeError('get app state failed! %s' % e)