From 80323caaf659fada98876a30ea5365e1b3a5967f Mon Sep 17 00:00:00 2001 From: Tomek Dubrownik Date: Tue, 1 May 2012 23:03:45 +0200 Subject: [PATCH] strip in server + sync with proliant --- mainframe/logic.py | 4 ++-- mainframe/server.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mainframe/logic.py b/mainframe/logic.py index 347df04..460c2bc 100644 --- a/mainframe/logic.py +++ b/mainframe/logic.py @@ -71,8 +71,8 @@ def add_topup(db, user_id, value): def add_purchase(db, user_id, product_id, code=None): if code: - product_id = __sql_execute(db, "SELECT product_id FROM %spurchases WHERE code=%%s" % - config.db_prefix, (code,))[0]['product_id'] + product_id = __sql_execute(db, "SELECT id FROM %sproducts WHERE code=%%s" % + config.db_prefix, (code,))[0]['id'] __sql_execute(db, "INSERT INTO %spurchases (product_id, user_id, datetime) VALUES (%%s, %%s, NOW());" % config.db_prefix, (product_id, user_id)) def print_info(db): diff --git a/mainframe/server.py b/mainframe/server.py index 9a2dc37..9539f5e 100644 --- a/mainframe/server.py +++ b/mainframe/server.py @@ -10,7 +10,7 @@ class TerminalHandler(SocketServer.StreamRequestHandler): try: line = self.rfile.readline() db = logic.sql_connect() - code, dn = line.split(' ') + code, dn = map(lambda s: s.strip(), line.split(' ')) print code, dn logic.add_purchase(db, dn, None, code) db.close()