예제 #1
0
def get_articles():
    #
    keywords = WEIXIN_CHECK.get_keywords(fs)
    #
    urls = get_urls()
    unquoted_urls = list()
    for each_url in urls:
        unquoted_urls.append(urllib.unquote(each_url))
    #
    res = dict()
    #
    try:
        conn, cur = ADMIN_WEIXIN_CHECK.get_conn_for_mysql_art()
        table = ADMIN_WEIXIN_CHECK.get_table()
        #
        update_sql = "update " + table +" set keywords='%s' where url in (%s)"
        in_clause = ', '.join(list(map(lambda x: '%s', unquoted_urls)))
        update_sql = update_sql % (keywords, in_clause)
        #
        #print update_sql
        cur.execute(update_sql, unquoted_urls)
        #
        cur.close()
        conn.close()
        #
        UTIL.append_result_ok(res)
    except Exception, e:
        #
        UTIL.append_result_error(res, e)
예제 #2
0
def get_articles():
    #
    sql_where = ADMIN_WEIXIN_CHECK.get_where_from_fs(fs)
    sql_limit = ADMIN_WEIXIN_CHECK.get_limit_from_fs(fs)
    #
    res = dict()
    res["articles"] = list()
    #
    try:
        conn, cur = ADMIN_WEIXIN_CHECK.get_conn_for_mysql_art()
        table = ADMIN_WEIXIN_CHECK.get_table()
        sql_select = "select * from " + table
        #
        sql_select += sql_where
        sql_select += " order by pub_time desc"
        sql_select += sql_limit
        #print sql_select
        #
        cur.execute(sql_select)
        all_data = cur.fetchall()
        for row in all_data:
            temp_row = copy.deepcopy(row)
            #
            res["articles"].append(UTIL.get_dict_in_utf8(temp_row))
        #
        '''
        '''
        cur.close()
        conn.close()
        #
        UTIL.append_result_ok(res)
    except Exception, e:
        #
        UTIL.append_result_error(res, e)
예제 #3
0
def get_articles():
    #
    sql_where = ADMIN_WEIXIN_CHECK.get_where_from_fs(fs)
    #
    res = dict()
    res["articles"] = list()
    #
    try:
        conn, cur = ADMIN_WEIXIN_CHECK.get_conn_for_mysql_art()
        table = ADMIN_WEIXIN_CHECK.get_table()
        #
        sql_select = "select count(*) as total_num from " + table 
        sql_select += sql_where
        #
        #print sql_where
        #print sql_select
        cur.execute(sql_select)
        all_data = cur.fetchall()
        res["count"] = all_data
        #
        cur.close()
        conn.close()
        #
        UTIL.append_result_ok(res)
    except Exception, e:
        #
        UTIL.append_result_error(res, e)
예제 #4
0
def get_articles():
    #
    enable_time = \
        datetime.datetime.fromtimestamp(
            int(WEIXIN_CHECK.get_enable_time(fs)) / 1000
        )
    disable_time = \
        datetime.datetime.fromtimestamp(
            int(WEIXIN_CHECK.get_disable_time(fs)) / 1000
        )
    #print enable_time.strftime('%Y-%m-%d %H:%M:%S')
    #print disable_time.strftime('%Y-%m-%d %H:%M:%S')
    enable_time = enable_time.strftime('%Y-%m-%d %H:%M:%S')
    disable_time = disable_time.strftime('%Y-%m-%d %H:%M:%S')
    modify_time = UTIL.get_styled_today()
    #
    title = WEIXIN_CHECK.get_title(fs)
    readnum = WEIXIN_CHECK.get_readnum(fs)
    status = WEIXIN_CHECK.get_status(fs)
    type = WEIXIN_CHECK.get_type(fs)
    #
    title = UTIL.get_str_in_gbk(title)
    type = UTIL.get_str_in_gbk(type)
    keywords = WEIXIN_CHECK.get_keywords(fs)
    #
    urls = WEIXIN_CHECK.get_urls(fs)
    unquoted_urls = list()
    for each_url in urls:
        unquoted_urls.append(urllib.unquote(each_url))
    #
    res = dict()
    #
    try:
        conn, cur = ADMIN_WEIXIN_CHECK.get_conn_for_mysql_art()
        table = ADMIN_WEIXIN_CHECK.get_table()
        #
        update_sql = "update " + table + " set keywords='%s', title='%s', read_num='%s', topic1='%s', status=%s, start_time='%s', end_time='%s', modify_time='%s' where url in (%s)"
        in_clause = ', '.join(list(map(lambda x: '%s', unquoted_urls)))
        update_sql = update_sql % (keywords, title, readnum, type, status, enable_time, disable_time, modify_time, in_clause)
        #
        #print update_sql
        cur.execute(update_sql, unquoted_urls)
        #
        cur.close()
        conn.close()
        #
        UTIL.append_result_ok(res)
        #
        res["appendix"] = {}
        res["appendix"]["start_time"] = enable_time
        res["appendix"]["end_time"] = disable_time
        res["appendix"]["modify_time"] = modify_time
    except Exception, e:
        #
        UTIL.append_result_error(res, e)
예제 #5
0
def get_articles():
    #
    res = dict()
    res["all_types"] = list()
    #
    try:
        conn, cur = ADMIN_WEIXIN_CHECK.get_conn_for_mysql_art()
        table = ADMIN_WEIXIN_CHECK.get_table()
        #
        select_sql = "select topic1 from " + table + " group by(topic1)"
        cur.execute(select_sql)
        #
        all_data = cur.fetchall()
        for row in all_data:
            res["all_types"].append(UTIL.get_dict_in_utf8(row))
        #
        cur.close()
        conn.close()
        #
        UTIL.append_result_ok(res)
    except Exception, e:
        #
        UTIL.append_result_error(res, e)