Subversion Repositories SmartDukaan

Rev

Rev 14439 | Rev 14451 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14439 Rev 14440
Line 10... Line 10...
10
from email.mime.multipart import MIMEMultipart
10
from email.mime.multipart import MIMEMultipart
11
from email.mime.text import MIMEText
11
from email.mime.text import MIMEText
12
import MySQLdb
12
import MySQLdb
13
import datetime
13
import datetime
14
import smtplib
14
import smtplib
-
 
15
import traceback
15
import xlwt
16
import xlwt
16
 
17
 
17
 
18
 
18
 
19
 
19
DB_HOST = "localhost"
20
DB_HOST = "localhost"
20
DB_USER = "root"
21
DB_USER = "root"
21
DB_PASSWORD = "shop2020"
22
DB_PASSWORD = "shop2020"
22
DB_NAME = "dtr"
23
DB_NAME = "dtr"
23
xstr = lambda s: '' if s is None else str(s)
24
xstr = lambda s: '' if s is None else str(s)
24
connection = None
-
 
-
 
25
 
25
def getDbConnection():
26
def getDbConnection():
26
    connection = MySQLdb.connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
27
    return MySQLdb.connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
27
 
28
 
28
 
29
 
29
ORDERS_QUERY='''
30
ORDERS_QUERY='''
30
select * from order_view order by id desc limit %s offset %s
31
select * from order_view order by id desc limit %s offset %s
31
'''
32
'''
Line 64... Line 65...
64
        colhead="<tr><th>Id</th><th>User Id</th><th>Store Id</th><th>Order Url</th><th>Subtag</th><th>Statu</th><th>Created on</th></tr>"
65
        colhead="<tr><th>Id</th><th>User Id</th><th>Store Id</th><th>Order Url</th><th>Subtag</th><th>Statu</th><th>Created on</th></tr>"
65
        tbodyarr.append(colhead)
66
        tbodyarr.append(colhead)
66
        for row in result:
67
        for row in result:
67
            tbodyarr.append("<tr><td>" + xstr(row[0]) + "</td><td>" + xstr(row[1]) +"</td><td>" + xstr(row[2]) +"</td><td><a target='_blank' href='/rawhtml/" + xstr(row[0]) + "'>" + xstr(row[3])[:90] +"</a></td><td>" + xstr(row[4]) + "</td><td>" + row[5][:15]+ "</td><td>" + row[6].strftime("%Y-%m-%d %H:%M:%S") + "</td></tr>")
68
            tbodyarr.append("<tr><td>" + xstr(row[0]) + "</td><td>" + xstr(row[1]) +"</td><td>" + xstr(row[2]) +"</td><td><a target='_blank' href='/rawhtml/" + xstr(row[0]) + "'>" + xstr(row[3])[:90] +"</a></td><td>" + xstr(row[4]) + "</td><td>" + row[5][:15]+ "</td><td>" + row[6].strftime("%Y-%m-%d %H:%M:%S") + "</td></tr>")
68
        
69
        
69
        return template%(total_count, "".join(tbodyarr))    
70
        return template%(total_count, "".join(tbodyarr))
-
 
71
    except:
-
 
72
        traceback.print_exc()
70
    finally:
73
    finally:
71
        conn.close()
74
        conn.close()
72
def getOrderHtml(orderId):
75
def getOrderHtml(orderId):
73
    try:
76
    try:
74
        conn = getDbConnection()
77
        conn = getDbConnection()
Line 76... Line 79...
76
        # Execute the SQL command
79
        # Execute the SQL command
77
        # Fetch source id.
80
        # Fetch source id.
78
        cursor.execute(ORDER_HTML_QUERY%(orderId))
81
        cursor.execute(ORDER_HTML_QUERY%(orderId))
79
        result = cursor.fetchall()
82
        result = cursor.fetchall()
80
        return result[0][0]
83
        return result[0][0]
-
 
84
    except:
-
 
85
        traceback.print_exc()
81
    finally:
86
    finally:
82
        conn.close()
87
        conn.close()
83
 
88
 
84
def main():
89
def main():
85
    print getOrders()
90
    print getOrders()