Пример #1
0
def setup_args():
    db.make_connect({
        "host": input("Host: "),
        "user": input("User: "******"passwd": input("Password: "******"db": input("Database: ")
    })
Пример #2
0
def get_last_quetion():
    conn, cursor = make_connect()
    cursor.execute("SELECT * FROM support")
    try:
        return cursor.fetchall()[0]
    except:
        return 0
Пример #3
0
def create_game(game_hash, sum_bet, creator_user_id, creator_value, type):
    #hash INTEGER, sum_bet FLOAT, creator_user_id INTEGER, player_user_id INTEGER, creator_value INTEGER, player_value INTEGER, type TEXT)
    conn, cursor = make_connect()
    cursor.execute(
        "INSERT INTO dice VALUES (?,?,?,?,?,?,?)",
        (game_hash, sum_bet, creator_user_id, 0, creator_value, 0, type))
    conn.commit()
Пример #4
0
def get_last_withdraw():
    try:
        conn, cursor = make_connect()
        cursor.execute("SELECT * FROM withdraw")
        return cursor.fetchall()[0]
    except:
        return 0
Пример #5
0
def update_user_sum_games(user_id, sum):
    conn, cursor = make_connect()
    sum_games = get_user_information(user_id)[3] + sum
    cursor.execute("UPDATE users SET sum_games = ? WHERE user_id = ?", (
        sum_games,
        user_id,
    ))
    conn.commit()
Пример #6
0
def create_answer(hash, quetion, answer):
    conn, cursor = make_connect()
    cursor.execute("INSERT INTO quetions VALUES (?,?,?)", (
        hash,
        quetion,
        answer,
    ))
    conn.commit()
Пример #7
0
def update_user_count_games(user_id):
    conn, cursor = make_connect()
    count_games = get_user_information(user_id)[2] + 1
    cursor.execute("UPDATE users SET count_games = ? WHERE user_id = ?", (
        count_games,
        user_id,
    ))
    conn.commit()
Пример #8
0
def make_connect(thread_index):
	global lcd, DoorbellIO

	cherrypy.thread_data.conn = db.make_connect()
	lcd = i2c_lcd_smbus.i2c_lcd(0x3f, 1, 2, 1, 0, 4, 5, 6, 7, 3)
	cherrypy.thread_data.lcd = lcd

	GPIO.setmode(GPIO.BCM)
	GPIO.setup(DoorbellIO, GPIO.IN, pull_up_down=GPIO.PUD_UP)

	GPIO.add_event_detect(DoorbellIO, GPIO.FALLING, callback=TurnOnDisplay, bouncetime=1000)

	UpdateLCD()
	TurnOnDisplay(DoorbellIO)
Пример #9
0
def create_support_quetion(user_id, quetion):
    conn, cursor = make_connect()
    cursor.execute("INSERT INTO support VALUES (?,?)", (user_id, quetion))
    conn.commit()
Пример #10
0
def check_unik_quetion(user_id):
    conn, cursor = make_connect()
    cursor.execute("SELECT COUNT(*) FROM support WHERE user_id = ?",
                   (user_id, ))
    return cursor.fetchone()[0] == 0
Пример #11
0
def get_all_users_inform():
    conn, cursor = make_connect()
    cursor.execute("SELECT * FROM users")
    return cursor.fetchall()
Пример #12
0
def delete_non_true_user(user_id):
    conn, cursor = make_connect()
    cursor.execute("DELETE FROM nontrueusers WHERE user_id = ?", (user_id, ))
    conn.commit()
Пример #13
0
def create_qiwi_popoln(user_id, sum, phone, random_code):
    conn, cursor = make_connect()
    cursor.execute("INSERT INTO qiwi_popoln VALUES(?,?,?,?)",
                   (user_id, sum, phone, random_code))
    conn.commit()
Пример #14
0
def get_answer_by_hash(hash):
    conn, cursor = make_connect()
    cursor.execute("SELECT * FROM quetions WHERE hash = ?", (hash, ))
    return cursor.fetchone()
Пример #15
0
def delete_last_popoln(user_id):
    conn, cursor = make_connect()
    cursor.execute("DELETE FROM qiwi_popoln WHERE user_id = ?", (user_id, ))
    conn.commit()
Пример #16
0
def get_all_answers():
    conn, cursor = make_connect()
    cursor.execute("SELECT * FROM quetions")
    return cursor.fetchall()
Пример #17
0
def add_user_to_ban(user_id):
    conn, cursor = make_connect()
    cursor.execute("INSERT INTO ban VALUES (?,?)", (user_id, 0))
    conn.commit()
Пример #18
0
def delete_user_from_ban(user_id):
    conn, cursor = make_connect()
    cursor.execute("DELETE FROM ban WHERE user_id = ?", (user_id, ))
    conn.commit()
Пример #19
0
def delete_dice_game_by_hash(game_hash):
    conn, cursor = make_connect()
    cursor.execute("DELETE FROM dice WHERE hash = ?", (game_hash, ))
    conn.commit()
Пример #20
0
def create_new_history(user_id, game_hash, sum_win):
    conn, cursor = make_connect()
    cursor.execute("INSERT INTO history_dice VALUES (?,?,?)",
                   (user_id, game_hash, sum_win))
    conn.commit()
Пример #21
0
def get_user_information(user_id):
    conn, cursor = make_connect()
    cursor.execute("SELECT * FROM users WHERE user_id = ?", (user_id, ))
    return cursor.fetchone()
Пример #22
0
def get_dice_by_hash(game_hash):
    conn, cursor = make_connect()
    cursor.execute("SELECT * FROM dice WHERE hash = ?", (game_hash, ))
    return cursor.fetchone()
Пример #23
0
	},
	'/favicon.ico':
	{
		'tools.staticfile.on': True,
		'tools.staticfile.filename': os.path.join(current_dir, "favicon.ico")
	},
	'/profile-images':
	{
		'tools.staticdir.on': True,
		'tools.staticdir.root': current_dir,
		'tools.staticdir.dir': "profile-images"
	}
}
cherrypy.tree.mount(NerfAssassin(), "/", config=config)

dbconn = db.make_connect()
ServerInfo = db.GetConfig(dbconn, ["server_ip","server_port","server_ssl","server_private","server_certificate"])
dbconn.close()

cherrypy.config.update({
		'request.error_response': handle_errors,
		'error_page.default': error_page,
		'server.socket_host': ServerInfo["server_ip"].Value,
		'server.socket_port': int(ServerInfo["server_port"].Value)})

if int(ServerInfo["server_ssl"].Value) == 1:
	cherrypy.config.update({
			'server.ssl_module': 'pyopenssl',
			'server.ssl_certificate': ServerInfo["server_certificate"].Value,
			'server.ssl_private_key': ServerInfo["server_private"].Value})
	
Пример #24
0
def delete_quetion(user_id):
    conn, cursor = make_connect()
    cursor.execute("DELETE FROM support WHERE user_id = ?", (user_id, ))
    conn.commit()
Пример #25
0
def delete_withdraw(user_id):
    conn, cursor = make_connect()
    cursor.execute("DELETE FROM withdraw WHERE user_id = ?", (user_id, ))
    conn.commit()
Пример #26
0
def make_connect(thread_index):
	cherrypy.thread_data.conn = db.make_connect()
Пример #27
0
def add_non_true_user(user_id):
    conn, cursor = make_connect()
    cursor.execute("INSERT INTO nontrueusers VALUES (?,?)", (user_id, 0))
    conn.commit()
Пример #28
0
def delete_answer(hash):
    conn, cursor = make_connect()
    cursor.execute("DELETE FROM quetions WHERE hash = ?", (hash, ))
    conn.commit()
Пример #29
0
def check_non_true_user(user_id):
    conn, cursor = make_connect()
    cursor.execute("SELECT COUNT(*) FROM nontrueusers WHERE user_id = ?",
                   (user_id, ))
    return cursor.fetchone()[0] == 0
Пример #30
0
def get_last_popoln(user_id):
    conn, cursor = make_connect()
    cursor.execute("SELECT * FROM qiwi_popoln WHERE user_id = ?", (user_id, ))
    return cursor.fetchone()
Пример #31
0
def get_all_history(user_id):
    conn, cursor = make_connect()
    cursor.execute("SELECT * FROM history_dice WHERE user_id = ?", (user_id, ))
    return cursor.fetchall()
Пример #32
0
def check_user_unicless(user_id):
    conn, cursor = make_connect()
    cursor.execute("SELECT COUNT(*) FROM users WHERE user_id = ?", (user_id, ))
    return cursor.fetchone()[0] == 0
Пример #33
0
def update_user_balanse(user_id, new_balanse):
    conn, cursor = make_connect()
    cursor.execute("UPDATE users SET bal = ? WHERE user_id = ?",
                   (new_balanse, user_id))
    conn.commit()