Exemple #1
0
 def startprotocol(self):
     config.dbconnect()
     if config.PROTO.lower() == "p10server":
             import p10server
             boot_time = int(time.time())
             config.confproto.connect(boot_time)
             config.confproto.loadclient(0, boot_time, config.BOT_NAME, config.BOT_HOST, config.BOT_MODE, config.SERVER_NUMERIC, config.BOT_DESC)
             config.confproto.joinchannel(boot_time, "A", config.DEBUG_CHANNEL)
             config.confproto.eob()
             config.confproto.startbuffer()
Exemple #2
0
 def startprotocol(self):
     config.dbconnect()
     if config.PROTO.lower() == "p10server":
         import p10server
         boot_time = int(time.time())
         config.confproto.connect(boot_time)
         config.confproto.loadclient(0, boot_time, config.BOT_NAME,
                                     config.BOT_HOST, config.BOT_MODE,
                                     config.SERVER_NUMERIC, config.BOT_DESC)
         config.confproto.joinchannel(boot_time, "A", config.DEBUG_CHANNEL)
         config.confproto.eob()
         config.confproto.startbuffer()
Exemple #3
0
def record_link_event(token):
    '''
    Records a link event or updates an existing link event with a new timestamp
    '''
    with config.dbconnect() as cursor:
        ip = get_ip()
        current_time = int(time.time())
        cursor.execute(INSERT_LINK_EVENT, (ip, token, current_time, current_time))
Exemple #4
0
def drop_old_logs():
    '''
    Drops expired logs (logs older than timeout)
    '''
    with config.dbconnect() as cursor:
        current_time = int(time.time())
        bounded_time = current_time - TIMEOUT
        cursor.execute(DROP_OLD_LOGS, (bounded_time,))
Exemple #5
0
def linkage(link):
    conn = config.dbconnect()
    getLink = "SELECT dest FROM links WHERE id = %s;"
    with conn.cursor() as cursor:
        cursor.execute(getLink, (link, ))
        res = cursor.fetchone()
        conn.close()
    if (res is None):
        return redirect('/', code=302)
    else:
        record_link_event(link)
        destination = res['dest']
        return redirect(destination, code=302)
Exemple #6
0
    def inner_wrapper(*args, **kwargs):
        # Conveniently drop old logs on an access.
        drop_old_logs()

        ip = get_ip()
        access_time = int(time.time())
        bounded_time = access_time - TIMEOUT

        with config.dbconnect() as cursor:
            cursor.execute(GET_TIMEBOUND_LINK_EVENTS, (ip, bounded_time))
            result = cursor.fetchone()

            if result["count"] < MAX_LINK:
                # All good!
                return func(*args, **kwargs)
            else:
                # Rate limit!
                return Response("You're attempting to access too many unique shortened links.", status=429)
def sql_handler(environ, start_response) :
  global db
  global dbtime
  (sql,), method = xmlrpclib.loads(environ["wsgi.input"].read())

  logger.debug(logtime() + ": method: %s" % method)
  logger.debug(logtime() + ": sql: ( %s )" % sql)

  if not re.search('sql_execute$', method) :
    logger.debug("bad method: %s" % method)
    raise Exception("Unhandled method: %s" % method)

  if (config.DB_RECONNECT_SECONDS and ((time.time() - config.DB_RECONNECT_SECONDS) > dbtime)) :
    db.close()
    db = config.dbconnect()
    dbtime = time.time()
  cur = db.cursor()
  cur.execute(sql)
  res = xmlrpclib.dumps((tuple(tuple(base64.b64encode(fval) if type(fval) == str else base64.b64encode(str(fval)) if isinstance(fval, datetime.datetime) else base64.b64encode(str(fval)) if type(fval) == long else fval for fval in row) for row in cur),), methodresponse = 1, allow_none = 1)
  if config.DB_COMMIT :
    db.commit()
  start_response("200 OK", [])
  return res
	def load_patients(self):
		self.list_of_patients.clear()
		self.list_of_patients_id.clear()
		self.w.delete('0', 'end')
		self.controller.patient_id.set("")

		cur.execute("SELECT patient_id, last_name, first_name, middle_name FROM patient")
		OPTIONS = cur.fetchall()
		for x in range(len(OPTIONS)):
			self.list_of_patients.append(OPTIONS[x][1] + ", " + OPTIONS[x][2] + " " + OPTIONS[x][3])
			self.list_of_patients_id.append(OPTIONS[x][0])

		if(len(self.list_of_patients) > 0):
			self.continue_bttn.config(state="normal")
		else:
			self.list_of_patients.append("None")
			self.continue_bttn.config(state="disabled")

	def changeValue(self):
		self.w["values"] = self.list_of_patients
				
if __name__ == "__main__":

	cn = cfg.dbconnect()
	cur = cn.cursor(buffered=True)

	app = MedSystem()
	app.title("Family Oriented Medical Record")
	app.geometry("1200x710")
	app.resizable(width=False, height=False)
	app.mainloop()
Exemple #9
0
from flask import Flask, redirect, render_template, request, session, abort
import json, requests
import mysql.connector
from config import dbconnect
import os

app = Flask(__name__)

db_config = dbconnect().db_config()


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


@app.route("/callback")
def abc():
    return render_template('call.html')


@app.route("/login")
def login():
    token = request.cookies.get('odauth')
    db = mysql.connector.connect(host=db_config['host'],
                                 database=db_config['database'],
                                 user=db_config['user'],
                                 password=db_config['password'])
    cursor = db.cursor()
    cursor.execute("SELECT driveid FROM user")
    data = cursor.fetchall()
import config
import PyzoServer
import ShelveApp
import SocketServer, xmlrpclib
import logging
import logging.handlers
import base64
import datetime
import time
import re
import sys

sys.stderr = open(config.STDERRFILE, 'a', 0)
dbtime = time.time()
db = config.dbconnect()

logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.handlers.RotatingFileHandler(config.LOGFILE_BASE, maxBytes=config.LOGFILE_MAXBYTES, backupCount=config.LOGFILE_BACKUPS))

def logtime() :
  return time.asctime()

def sql_handler(environ, start_response) :
  global db
  global dbtime
  (sql,), method = xmlrpclib.loads(environ["wsgi.input"].read())

  logger.debug(logtime() + ": method: %s" % method)
  logger.debug(logtime() + ": sql: ( %s )" % sql)