Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
175 ashish 1
'''
2
Created on 25-May-2010
3
 
4
@author: gaurav
5
'''
6
from datastore.DataAccessor import DataHelper
7
import sys
8
 
9
 
10
phones = DataHelper()
11
 
12
phone_list = phones.get_all_models()
13
 
14
 
15
if not phones:
16
    print "Error while getting phones"
17
    sys.exit(-1)
18
 
19
file_to_write = "/tmp/allprices.csv"
20
 
21
data_file = open(file_to_write,"w")
22
 
23
for phone in phone_list:
24
    id = phone.id
25
    #get all prices for this phone
26
    try:
27
        infibeam_price = phones.get_price_by_model(id, 1).final_price
28
    except:
29
        infibeam_price = " "
30
 
31
    try:
32
        indiaplaza_price = phones.get_price_by_model(id, 2).final_price
33
    except:
34
        indiaplaza_price = " "
35
 
36
    try:
37
        mobilestore_price = phones.get_price_by_model(id, 3).final_price
38
    except:
39
        mobilestore_price = " "
40
    try:
41
        univercell_price = phones.get_price_by_model(id, 4).final_price
42
    except:
43
        univercell_price = " "
44
 
45
    try:
46
        ginfo = phones.get_gs_bymid(id)
47
        try:
48
            guarntee_info = ginfo.guaranteeinfo
49
        except:
50
            guarntee_info = " "
51
        try:
52
            ship_info = ginfo.shipinfo
53
        except:
54
            ship_info = " "        
55
    except:
56
        guarntee_info = " "
57
        ship_info = " "     
58
 
59
 
60
    csv_data =  "%s, %s, %s, %s, %s, %s, %s, %s \n" %(phone.brand, phone.model, str(infibeam_price), str(indiaplaza_price), guarntee_info, ship_info, str(mobilestore_price), str(univercell_price))
61
    data_file.write(csv_data)
62
 
63
data_file.close()
64