from Models import User from DBCon import * from ConfReader import get_conf_reader import sqlalchemy.pool as pool conf = get_conf_reader("dl.conf") threadpool = pool.QueuePool(get_db_con, max_overflow=10, pool_size=5) def user_login(username, password): db = threadpool.connect() if db is not None: cursor = db.cursor() sql = "SELECT * FROM user WHERE user_name=%s AND password=MD5(%s) AND blocked=0 AND approved=1;" cursor.execute(sql, (username, password)) data = cursor.fetchone() db.close() if data == None: return False else: return True def check_user_name(username): db = threadpool.connect() if db is not None: cursor = db.cursor() sql = "SELECT * FROM user WHERE user_name=%s;" cursor.execute(sql, (username)) data = cursor.fetchone() db.close()
import threading import queue import json, time from DownloadManager import * from Models import Status, Download from EMail import send_mail from DiskMan import * from ConfReader import get_conf_reader import websocket import sys conf = get_conf_reader("dl.conf") db_lock = threading.Lock() folder_size=0 startedDownloads = [] handlerLst = [] handler = None verbose = False sc = None if len(sys.argv) == 2 and sys.argv[1] == '-v': verbose = True class Handler(queue.Queue): def __init__(self, ws): queue.Queue.__init__(self) self.ws = ws self.num_workers = 5
import smtplib from ConfReader import get_conf_reader conf = get_conf_reader("email.conf") def send_mail(toaddrs, msg): server = smtplib.SMTP_SSL('smtp.gmail.com:465') server.login(conf['username'],conf['password']) server.sendmail(conf['username'], toaddrs, msg) server.quit()
import smtplib from ConfReader import get_conf_reader conf = get_conf_reader("email.conf") def send_mail(toaddrs, msg): server = smtplib.SMTP_SSL('smtp.gmail.com:465') server.login(conf['username'], conf['password']) server.sendmail(conf['username'], toaddrs, msg) server.quit()
#!/usr/bin/python # -*- coding: utf-8 -*- from Models import User from DBCon import * from ConfReader import get_conf_reader import sqlalchemy.pool as pool conf = get_conf_reader('dl.conf') threadpool = pool.QueuePool(get_db_con, max_overflow=10, pool_size=20) def user_login(username, password): db = threadpool.connect() if db is not None: cursor = db.cursor() sql = \ 'SELECT * FROM user WHERE user_name=%s AND password=MD5(%s) AND blocked=0;' cursor.execute(sql, (username, password)) data = cursor.fetchone() db.close() if data == None: return False else: return True def check_approved(username, password): db = threadpool.connect() if db is not None: cursor = db.cursor()