Rev 175 | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 25-May-2010@author: gaurav'''from datastore.DataAccessor import DataHelperimport sysphones = 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 = 0csv_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 phonetry:infibeam_price = phones.get_price_by_model(id, 71).final_priceinfibeam_ct = infibeam_ct+1except:infibeam_price = " "try:indiaplaza_price = phones.get_price_by_model(id, 72).final_priceindiaplaza_ct = indiaplaza_ct+1except:indiaplaza_price = " "try:mobilestore_price = phones.get_price_by_model(id, 68).final_pricemobilestore_ct = mobilestore_ct+1except:mobilestore_price = " "try:univercell_price = phones.get_price_by_model(id, 70).final_priceunivercell_ct = univercell_ct+1except:univercell_price = " "try:babuchak_price = phones.get_price_by_model(id, 69).final_pricebabuchak_ct = babuchak_ct+1except:babuchak_price = " "if infibeam_price == " " and indiaplaza_price == " " and mobilestore_price == " " and univercell_price == " " and babuchak_price == " ":continuecsv_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.guaranteeinfoexcept:guarntee_info = " "try:ship_info = ginfo.shipinfoexcept: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()