<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_app_list(region_name=None,filter_name=None):
 """ get local app list """

    try:
        conn = get_conn()
        c = conn.cursor()

        cond = []
        where_clause = ""
        if region_name:
            cond.append( "region='{0}' ".format(region_name) )
        if filter_name:
            cond.append( "lower(name) like '%{0}%' ".format(filter_name.lower()) )
        if len(cond) > 0:
            where_clause = 'and ' + 'and '.join( cond )

        sqlcmd = "SELECT name,source_id,region,state,create_at,change_at FROM app where state<>'Terminated' %s " % where_clause
        log = logging.getLogger(__name__)
        log.debug('> sql : %s' % sqlcmd)

        c.execute(sqlcmd)
        rlt = c.fetchall()
        conn.commit()
        conn.close()

        return rlt
    except Exception,e:
        raise RuntimeError('list app failed! %s ' % e)