예제 #1
0
파일: main.py 프로젝트: hdg700/gTimebot
def main():
    models.initModels()
    xmpp_conn = timebot.Connection(config.CONF_GMAIL_LOGIN, config.CONF_GMAIL_PASS)
    if not xmpp_conn.connect():
        exit(2)

    bot = timebot.Timebot(xmpp_conn)

    socklist = [xmpp_conn.getSock()]
    while True:
        (i, o, e) = select.select(socklist, [], [], 2)
        if not i:
            continue

        for sock in i:
            if sock == xmpp_conn.getSock():
                xmpp_conn.client.Process(1)
예제 #2
0
파일: app.py 프로젝트: strattonbrazil/pyaha
    if request.method == 'POST':
        fileName = secure_filename(urlparse.unquote(request.headers['X-File-Name']))
        if allowed_file(fileName):
            filePath = os.path.join(app.config['UPLOAD_FOLDER'], fileName)
            with open(filePath, 'w') as fd:
                fd.write(request.data)

            # delete existing header
            dbSession.query(ImageTag).filter(ImageTag.tag == "header").delete()

            tag = ImageTag(hash=md5(filePath), tag='header', path=fileName)
            dbSession.add(tag)
            dbSession.commit()

        return 'done'
    else:
        imageTag = dbSession.query(ImageTag).filter(ImageTag.tag == "header").first()
        data = { 'url' : _getHeaderUrl() }

        return flask.jsonify(**data)

# Custom static data
@app.route('/uploads/<path:filename>')
def custom_static(filename):
    return send_from_directory(app.config['UPLOAD_FOLDER'], filename)

if __name__ == '__main__':
    initModels()
    app.run(host='0.0.0.0')