Exemplo n.º 1
0
def login_session():
    if request.method == 'GET':
        return redirect(url_for('login'))
    if request.method == 'POST':
        loginID = request.form['inputLoginID']
        password = request.form['inputPassword']
        a = se.login(mongo, loginID, password)
        if a['status'] == True:
            session['loggedin'] = True
            session['username'] = a['username']
            return redirect(url_for("index"))
        else:
            return render_template("login.html", error="Invalid Login	")
Exemplo n.º 2
0
def login_session():
	if request.method=='GET':
		return redirect(url_for('login'))
	if request.method=='POST':
		loginID=request.form['inputLoginID']
		password=request.form['inputPassword']
		a=se.login(mongo,loginID,password)
		if a['status'] == True:
			session['loggedin'] = True
			session['username'] = a['username']
			return redirect(url_for("index"))
		else:
			return render_template("login.html", error="Invalid Login	")
Exemplo n.º 3
0
class MyFactory(Factory):
    """ La classe fabrique de server """
    protocol = None
    fp = None
    shutdown = False

    def __init__(self, options=None):
        self.options = options
        self.ficlog = options.FICLOG
        self.cnx = Sessions()      # Les sessions

    def startFactory(self):
        """ Demarrage du serveur """
        if self.ficlog:
            self.fp = open(self.ficlog, 'a')
        self.log("SRV", "Init du serveur")

    def stopFactory(self):
        """ Arret du serveur """
        self.log("SRV", "Arret du serveur")
        if self.ficlog:
            self.fp.close()

    ## ----------------------------
    ## Shutdown Utilise cnx
    ## ----------------------------
    def shutdown(self):
        """ Demande de shutdown 
        on coupe la connexion de toutes les sessions
        """
        self.log("SRV", "Shutdown demande ...")
        self.shutdown = True
        for c in self.cnx.all_session():
            c.transport.loseConnection()
        reactor.stop()

    def log(self, origine, msg):
        """ Log => envoi de message sur le fichier de log """
        msg = "%s :  %s \n" % (origine, msg)
        if self.options.VERBOSE:
            print msg,
        if not self.shutdown:
            self.fp.write(msg)
Exemplo n.º 4
0
class SessionManager:
    def __init__(self):
        self.MasterSessionList = Sessions()

    def getSessions(self):
        return self.MasterSessionList

    def openSession(self, name=''):
        self.MasterSessionList._addSession(name)
        return self.MasterSessionList.item(name)

    def closeSession(self, name=''):
        session = self.MasterSessionList.item(name)
        self.MasterSessionList._delSession(name)

    def refresh(self):
Exemplo n.º 5
0
class SessionManager:
    def __init__(self):
Exemplo n.º 6
0
import shutil
import sys
import threading

from flask import Flask, request, send_from_directory, send_file, make_response, jsonify

sys.path.append('..')
import chorderator as cdt
from Sessions import Sessions
from construct_midi_seg import construct_midi_seg

app = Flask(__name__, static_url_path='')
app.secret_key = 'AccoMontage2-GUI'
saved_data = cdt.load_data()
APP_ROUTE = '/api'
sessions = Sessions()


def resp(msg=None, session_id=None, more=()):
    body = {'status': 'ok' if not msg else msg}
    for item in more:
        body[item[0]] = item[1]
    r = make_response(jsonify(body))
    if session_id:
        r.set_cookie('session', session_id, max_age=3600)
    return r


def send_file_from_session(file, name=None):
    return send_file(io.BytesIO(file),
                     as_attachment=True,
Exemplo n.º 7
0
sessionsList = []
 
# # All (Triticum, Aegilops)
# sessions = ["jabot_1401883308", "JLG_1403680581", "vincent_1404990765", "jabot_1402514361", "JLG_1403686426", "vincent_1404477069", "jabot_1402515589", "JLG_1403882200", "_1404479484", "jabot_1402518917", "JLG_1403689151", "Vincent_1404826194", "jabot_1402520518", "JLG_1403690081", "Vincent_1404826450", "jabot_1402521471", "JLG_1404379085", "Vincent_1404830338"]
# sess = Sessions("All", sessions, n)
# sessionsList.append(sess)
#  
# # All (Triticum, Aegilops) Without Vincent
# sessions = ["jabot_1401883308", "JLG_1403680581", "jabot_1402514361", "JLG_1403686426", "jabot_1402515589", "JLG_1403882200", "jabot_1402518917", "JLG_1403689151", "jabot_1402520518", "JLG_1403690081", "jabot_1402521471", "JLG_1404379085"]
# sess = Sessions("All_WithoutVincent", sessions, nWithoutVincent)
# sessionsList.append(sess)
#  
 
#All Triticum
sessions = ["jabot_1401883308", "JLG_1403680581", "vincent_1404990765", "jabot_1402514361", "JLG_1403686426", "vincent_1404477069", "jabot_1402515589", "JLG_1403882200", "_1404479484"]
sess = Sessions("All_Triticum", sessions, n)
sess.saveMongoDB("triticumValid")
sess.saveRelationMongoDB("triticumRelationValid")
sess.saveTypeMongoDB("triticumTypeValid")
sess.saveLabelsMongoDB("triticumLabelsValid")
exit
sessionsList.append(sess)
 
 
# # All without Vincent Triticum
# sessions = ["jabot_1401883308", "JLG_1403680581", "jabot_1402514361", "JLG_1403686426", "jabot_1402515589", "JLG_1403882200"]
# sess = Sessions("All_WithoutVincent_Triticum", sessions, nWithoutVincent)
# sessionsList.append(sess)
#  
#    
# # Only Agrovoc Triticum
Exemplo n.º 8
0
 def __init__(self, options=None):
     self.options = options
     self.ficlog = options.FICLOG
     self.cnx = Sessions()      # Les sessions