def logout(): id = request.cookies.get('key') resp = make_response(render_template('logout.html')) if 'key' in request.cookies and id in session: resp.set_cookie('key', '', expires=0) if (session[id]['calcy_alp_gcc']): #delete_calc.delete_calc(session[id]['calcy_alp_gcc']['name']) port_manage.setPort([session[id]['calcy_alp_gcc']['op']]) if (session[id]['calcy_alp_py']): #delete_calc.delete_calc(session[id]['calcy_alp_py']['name']) port_manage.setPort([session[id]['calcy_alp_py']['op']]) if (session[id]['calcy_alp_cplus']): #delete_calc.delete_calc(session[id]['calcy_alp_cplus']['name']) port_manage.setPort([session[id]['calcy_alp_cplus']['op']]) if (session[id]['calcy_alp_java']): #delete_calc.delete_calc(session[id]['calcy_alp_java']['name']) port_manage.setPort([session[id]['calcy_alp_java']['op']]) del_con() session.pop(id, None) return resp return render_template('no_login.html')
def db_delete_app(pid): db = MySQLdb.connect("localhost",db_details.db_user,db_details.db_pass,db_details.db_name ) db_pid = int(pid) cursor = db.cursor() sql = "DELETE FROM app WHERE pid = '%s'" % (db_pid) try: a = db_get_details(pid) port_manage.setPort(a[3]) cursor.execute(sql) db.commit() except: db.rollback() db.close()
def del_con(): id = request.cookies.get('key') if (session[id]['calcy_alp_gcc']): if (session[id]['calcy_alp_gcc']['back'] == 'false'): delete_calc.delete_calc(session[id]['calcy_alp_gcc']['name']) port_manage.setPort([session[id]['calcy_alp_gcc']['op']]) session[id]['calcy_alp_gcc'] = False else: connection = mysql.connect() cursor = connection.cursor() query = 'INSERT INTO calcy (mis,con_name,port,con_type) VALUES ("' + session[ id]['mis'] + '","' + session[id]['calcy_alp_gcc'][ 'name'] + '","' + session[id]['calcy_alp_gcc'][ 'op'] + '","gcc")' cursor.execute(query) connection.commit() if (session[id]['calcy_alp_py']): if (session[id]['calcy_alp_py']['back'] == 'false'): delete_calc.delete_calc(session[id]['calcy_alp_py']['name']) port_manage.setPort([session[id]['calcy_alp_py']['op']]) session[id]['calcy_alp_py'] = False else: connection = mysql.connect() cursor = connection.cursor() query = 'INSERT INTO calcy (mis,con_name,port,con_type) VALUES ("' + session[ id]['mis'] + '","' + session[id]['calcy_alp_py'][ 'name'] + '","' + session[id]['calcy_alp_py'][ 'op'] + '","py")' cursor.execute(query) connection.commit() if (session[id]['calcy_alp_cplus']): if (session[id]['calcy_alp_cplus']['back'] == 'false'): delete_calc.delete_calc(session[id]['calcy_alp_cplus']['name']) port_manage.setPort([session[id]['calcy_alp_cplus']['op']]) session[id]['calcy_alp_cplus'] = False else: connection = mysql.connect() cursor = connection.cursor() query = 'INSERT INTO calcy (mis,con_name,port,con_type) VALUES ("' + session[ id]['mis'] + '","' + session[id]['calcy_alp_cplus'][ 'name'] + '","' + session[id]['calcy_alp_cplus'][ 'op'] + '","cplus")' cursor.execute(query) connection.commit() if (session[id]['calcy_alp_java']): if (session[id]['calcy_alp_java']['back'] == 'false'): delete_calc.delete_calc(session[id]['calcy_alp_java']['name']) port_manage.setPort([session[id]['calcy_alp_java']['op']]) session[id]['calcy_alp_java'] = False else: connection = mysql.connect() cursor = connection.cursor() query = 'INSERT INTO calcy (mis,con_name,port,con_type) VALUES ("' + session[ id]['mis'] + '","' + session[id]['calcy_alp_java'][ 'name'] + '","' + session[id]['calcy_alp_java'][ 'op'] + '","java")' cursor.execute(query) connection.commit() return json.dumps({'status': 'success'})