| 2315 |
chandransh |
1 |
#!/usr/bin/python
|
|
|
2 |
|
|
|
3 |
'''
|
|
|
4 |
Created on 23-Jun-2011
|
|
|
5 |
|
|
|
6 |
@author: Chandranshu
|
|
|
7 |
'''
|
|
|
8 |
import sys
|
|
|
9 |
import os
|
|
|
10 |
import csv
|
| 4016 |
chandransh |
11 |
import optparse
|
| 2315 |
chandransh |
12 |
|
|
|
13 |
if __name__ == '__main__' and __package__ is None:
|
|
|
14 |
sys.path.insert(0, os.getcwd())
|
|
|
15 |
|
|
|
16 |
from shop2020.model.v1.order.impl import DataAccessors, DataService
|
|
|
17 |
|
|
|
18 |
def main():
|
| 4016 |
chandransh |
19 |
parser = optparse.OptionParser()
|
|
|
20 |
parser.add_option("-H", "--host", dest="hostname",
|
|
|
21 |
default="localhost",
|
|
|
22 |
type="string", help="The HOST where the DB server is running",
|
|
|
23 |
metavar="HOST")
|
|
|
24 |
(options, args) = parser.parse_args()
|
|
|
25 |
if len(args) != 0:
|
|
|
26 |
parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
|
|
|
27 |
DataService.initialize(db_hostname=options.hostname, echoOn=False)
|
| 2315 |
chandransh |
28 |
filename = os.getenv("HOME") + os.sep + "ExpectedAndActualDeliveryReport.csv"
|
|
|
29 |
writer = csv.writer(open(filename, "wb"), delimiter=',', quoting=csv.QUOTE_NONE)
|
|
|
30 |
writer.writerow(["Order ID", "Customer Name", "Pin Code", "State", "AWB No", "Order Date", "Expected Date of Delivery", "Delivery Date"])
|
|
|
31 |
orders = DataAccessors.get_valid_orders(0)
|
|
|
32 |
orders.reverse()
|
|
|
33 |
for order in orders:
|
|
|
34 |
writer.writerow([order.id, order.customer_name, order.customer_pincode, order.customer_state, order.airwaybill_no, order.created_timestamp, order.expected_delivery_time, order.delivery_timestamp])
|
|
|
35 |
|
|
|
36 |
if __name__ == '__main__':
|
|
|
37 |
main()
|