Subversion Repositories SmartDukaan

Rev

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

from shop2020.thriftpy.model.v1.catalog.ttypes import Item, status, Warehouse
import datetime
from shop2020.clients.CatalogClient import CatalogClient
from shop2020.utils.Utils import to_java_date
import xlrd

inventory_client = CatalogClient()

#inventory_client.__start__()

client = inventory_client.get_client()


#For accessories
"""
wb = xlrd.open_workbook('/home/rajveer/Desktop/test1.xls')
sheet = wb.sheet_by_index(0)

count = 1
for rownum in range(sheet.nrows):
    
    if count < 16:
        count = count + 1
        continue
    print sheet.row_values(count)
    item = Item()
    item.catalogItemId = sheet.row_values(count)[0]
    item.category = sheet.row_values(count)[1]
    item.brand = sheet.row_values(count)[2]
    item.modelNumber = sheet.row_values(count)[3]
    item.modelName = sheet.row_values(count)[4]
    item.mrp = sheet.row_values(count)[5]
    item.sellingPrice = sheet.row_values(count)[6]
    item.vendorItemId = str(long(sheet.row_values(count)[8]))
    
    item.itemStatus = status.ACTIVE
    client.addItem(item)
    count = count + 1

"""

#For phones
wb = xlrd.open_workbook('/home/rajveer/Desktop/phone-models.xls')
sheet = wb.sheet_by_index(0)

count = 0
for rownum in range(sheet.nrows):
    #print sheet.row_values(rownum)

    item = Item()

    item.catalogItemId = long(sheet.row_values(count)[0])
    #item.category = sheet.row_values(count)[1]
    #item.brand = sheet.row_values(count)[2]
    #item.modelNumber = sheet.row_values(count)[3]
    #item.modelName = sheet.row_values(count)[4]
    #item.mrp = long(sheet.row_values(count)[5])
    #item.sellingPrice = long(sheet.row_values(count)[6])
    
    item.mrp = 981*(count+1)
    item.sellingPrice = 819*(count+1)
    item.vendorItemId = "CBHCC"+str(count)
    item.itemStatus = status.ACTIVE
    item.status_description = "This item is active"
    client.addItem(item)