Пример #1
0
def download_avatars():

    DB = db.MyDB()
    ses = DB.make_session()
    cnt = 0

    for a in ses.query(db.FB_ARTICLE):
        cmts = json.loads(a.COMMENTS)
        for c in  cmts:
            u = c[0]
            if u == None:
                continue
            if 'headimg' in u:
                pass
            elif 'user-avatar' in u:
                pass
            else:
                if g_map.has_key(u):
                    pass
                else:
                    print cnt, c[1]
                    g_map[u] = 1
                    try:
                        download_img(u, u'head/{}.png'.format(c[1]))
                    except Exception:
                        print 'ERROR'
                    cnt += 1
Пример #2
0
def download_all_content():
    DB = db.MyDB()
    ses = DB.make_session()

    count = 0
    with open('freebuf-list.txt', 'r') as fp:
        for l in fp.readlines()[1951+397+7045:]:
            l = l.decode('utf-8')
            ww = l.split('-|-')
            url = ww[0]
            crt = download_article_routine(url)
            count += 1
            # for i, v in enumerate(crt):
            #     print i, v

            at = db.FB_ARTICLE()
            at.AUTHOR = crt[4]
            at.CMT_NUM = int(crt[3])
            at.COMMENTS = json.dumps(crt[8])
            at.DATE = crt[5]
            at.HTML = crt[6]
            at.LINKS = json.dumps(crt[7])
            at.TAGS = crt[9]
            at.VIEW = crt[2]
            at.TITLE = ww[1]
            at.ADDR = crt[0]

            ses.add(at)
            print count, at.TITLE

            ses.commit()
Пример #3
0
def process():
    print header
    form = cgi.FieldStorage()
    if form.has_key('personName'):
        name = form['personName'].value
        python_db = db.MyDB()
        python_db.update_status(name, 0)
        print reshtml % (name, url)
Пример #4
0
def connect_db():
    """ 建立SQL连接
    """
    mydb = db.MyDB(host="127.0.0.1",
                   user="******",
                   passwd="asdqwezxc@321",
                   db="vmware")
    mydb.db_connect()
    mydb.db_cursor()
    return mydb
Пример #5
0
def process():
    form = cgi.FieldStorage()
    if form.has_key('personName'):
        name = form['personName'].value
    else:
        name = ''
    if form.has_key('personPassword'):
        passwd = form['personPassword'].value
    else:
        passwd = ''
    if form.has_key('imageName'):
        upfile = form['imageName']
        if upfile.file:
            pic2 = name + '@' + passwd
            md5 = MyMd5(pic2)
            hash_pic1 = md5.get_hex()
            path = '/var/www/cgi-bin/image/%s.jpg' % (hash_pic1)
            file = open(path, 'wb+')
            file.write(upfile.file.read())
            upfile.file.close()
            file.close()

    python_db = db.MyDB()

    result = python_db.select_user(name, passwd)
    if result == 1:
        python_db.update_status(name, 1)
        pic = name + '@' + passwd
        md51 = MyMd5(pic)
        hash_pic = md51.get_hex()
        image = '<IMG SRC="/cgi-bin/image/%s.jpg" id=idImg width = "256" height = "256" style="display:block;"/>'\
                % (hash_pic)
        print header + reshtml % (name, passwd, hash_pic, image, name, passwd,\
                                  url, loginout_url, name, scripthtml)
    else:
        print header + errhtml % ("You passwd is error!")
Пример #6
0
 def checkDB(self):
     "check the Mysql if user name is exists"
     python_db = db.MyDB()
     result = python_db.check_name(self.user)
     return result
Пример #7
0
 def insertDB(self):
     "insert information for MySql"
     python_db = db.MyDB()
     python_db.insert_user(self.user, self.passwd)
Пример #8
0
import db

DB = db.MyDB()
SES = DB.make_session()


def put_links():
    with open('fb_links_common.txt', 'r') as fp:
        ll = fp.readlines()
        for l in ll:
            l = l.decode('utf-8')
            l = l.strip()
            ww = l.split(' ')
            link = db.FB_LINK()
            link.URL = ww[0]
            left = l[len(ww[0]):]
            left = left.strip()
            ww = left.split('*')
            if len(ww) > 0:
                link.NOTE = ww[0]

            link.FAV = len(l.split('*')) - 1

            SES.add(link)
            SES.commit()
from flask import Flask, request, Response, render_template
from flask_restful import Resource, Api
import db
import json

app = Flask(__name__)
api = Api(app)

my_db = db.MyDB()
my_db.connect()


@app.route('/')
def index():
    my_db.init_db()
    return render_template('index.html')


@app.route('/projects')
def projects():
    projects_table = my_db.show_table("projects")
    return render_template('projects.html', data=projects_table)


@app.route('/engineers', methods=['GET', 'POST', 'DELETE'])
def engineers():
    if request.method == 'GET':
        engineers_table = my_db.show_table("Engineers")
        return render_template('engineers.html', data=engineers_table)
    elif request.method == 'POST':
        data = request.json