Subversion Repositories SmartDukaan

Rev

Rev 175 | Blame | Compare with Previous | Last modification | View Log | RSS feed

'''
Created on 25-May-2010

@author: gaurav
'''
from datastore.DataAccessor import DataHelper
import sys


phones = DataHelper()

phone_list = phones.get_all_models()


if not phones:
    print "Error while getting phones"
    sys.exit(-1)


file_to_write = "/tmp/allprices.csv"
data_file = open(file_to_write,"w")

infibeam_ct = indiaplaza_ct = mobilestore_ct = univercell_ct = babuchak_ct = 0
csv_data =  "%s, %s, %s, %s, %s, %s, %s \n" %('brand', 'model', 'infibeam_price', 'indiaplaza_price', 'mobilestore_price', 'univercell_price', 'babuchak_price' )
data_file.write(csv_data)
for phone in phone_list:
    id = phone.id
    #get all prices for this phone
    try:
        infibeam_price = phones.get_price_by_model(id, 71).final_price
        infibeam_ct = infibeam_ct+1 
    except:
        infibeam_price = " "
        
    try:
        indiaplaza_price = phones.get_price_by_model(id, 72).final_price
        indiaplaza_ct = indiaplaza_ct+1 
    except:
        indiaplaza_price = " "
        
    try:
        mobilestore_price = phones.get_price_by_model(id, 68).final_price
        mobilestore_ct = mobilestore_ct+1
    except:
        mobilestore_price = " "
    
    try:
        univercell_price = phones.get_price_by_model(id, 70).final_price
        univercell_ct = univercell_ct+1
    except:
        univercell_price = " "
    
    try:
        babuchak_price = phones.get_price_by_model(id, 69).final_price
        babuchak_ct = babuchak_ct+1
    except:
        babuchak_price = " "
    
    if infibeam_price == " " and indiaplaza_price == " " and mobilestore_price == " " and univercell_price == " " and babuchak_price == " ":
        continue    
    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) )
    data_file.write(csv_data)
        
'''
    try:
        ginfo = phones.get_gs_bymid(id)
        try:
            guarntee_info = ginfo.guaranteeinfo
        except:
            guarntee_info = " "
        try:
            ship_info = ginfo.shipinfo
        except:
            ship_info = " "        
    except:
        guarntee_info = " "
        ship_info = " "     
        
    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))
    data_file.write(csv_data)
    '''
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) )
data_file.write(csv_data)
data_file.close()