Subversion Repositories SmartDukaan

Rev

Rev 175 | Details | Compare with Previous | 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
 
224 ashish 19
 
175 ashish 20
file_to_write = "/tmp/allprices.csv"
21
data_file = open(file_to_write,"w")
22
 
224 ashish 23
infibeam_ct = indiaplaza_ct = mobilestore_ct = univercell_ct = babuchak_ct = 0
24
csv_data =  "%s, %s, %s, %s, %s, %s, %s \n" %('brand', 'model', 'infibeam_price', 'indiaplaza_price', 'mobilestore_price', 'univercell_price', 'babuchak_price' )
25
data_file.write(csv_data)
175 ashish 26
for phone in phone_list:
27
    id = phone.id
28
    #get all prices for this phone
29
    try:
224 ashish 30
        infibeam_price = phones.get_price_by_model(id, 71).final_price
31
        infibeam_ct = infibeam_ct+1 
175 ashish 32
    except:
33
        infibeam_price = " "
34
 
35
    try:
224 ashish 36
        indiaplaza_price = phones.get_price_by_model(id, 72).final_price
37
        indiaplaza_ct = indiaplaza_ct+1 
175 ashish 38
    except:
39
        indiaplaza_price = " "
40
 
41
    try:
224 ashish 42
        mobilestore_price = phones.get_price_by_model(id, 68).final_price
43
        mobilestore_ct = mobilestore_ct+1
175 ashish 44
    except:
45
        mobilestore_price = " "
224 ashish 46
 
175 ashish 47
    try:
224 ashish 48
        univercell_price = phones.get_price_by_model(id, 70).final_price
49
        univercell_ct = univercell_ct+1
175 ashish 50
    except:
51
        univercell_price = " "
52
 
53
    try:
224 ashish 54
        babuchak_price = phones.get_price_by_model(id, 69).final_price
55
        babuchak_ct = babuchak_ct+1
56
    except:
57
        babuchak_price = " "
58
 
59
    if infibeam_price == " " and indiaplaza_price == " " and mobilestore_price == " " and univercell_price == " " and babuchak_price == " ":
60
        continue    
61
    csv_data =  "%s, %s, %s, %s, %s, %s, %s \n" %(phone.brand, phone.model, str(infibeam_price), str(indiaplaza_price), str(mobilestore_price), str(univercell_price), str(babuchak_price) )
62
    data_file.write(csv_data)
63
 
64
'''
65
    try:
175 ashish 66
        ginfo = phones.get_gs_bymid(id)
67
        try:
68
            guarntee_info = ginfo.guaranteeinfo
69
        except:
70
            guarntee_info = " "
71
        try:
72
            ship_info = ginfo.shipinfo
73
        except:
74
            ship_info = " "        
75
    except:
76
        guarntee_info = " "
77
        ship_info = " "     
224 ashish 78
 
175 ashish 79
    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))
80
    data_file.write(csv_data)
224 ashish 81
    '''
82
csv_data =  "%s, %s, %s, %s, %s, %s, %s \n" %('total count ', ' ', str(infibeam_ct), str(indiaplaza_ct), str(mobilestore_ct), str(univercell_ct), str(babuchak_ct) )
83
data_file.write(csv_data)
175 ashish 84
data_file.close()
85