| Line 44... |
Line 44... |
| 44 |
|
44 |
|
| 45 |
threads = []
|
45 |
threads = []
|
| 46 |
inventoryMap = {}
|
46 |
inventoryMap = {}
|
| 47 |
itemSaleMap = {}
|
47 |
itemSaleMap = {}
|
| 48 |
cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionItems, negativeMargin, cheapButNotPref, prefButNotCheap = [],[],[],[],[],[],[],[]
|
48 |
cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionItems, negativeMargin, cheapButNotPref, prefButNotCheap = [],[],[],[],[],[],[],[]
|
| - |
|
49 |
scraper = FlipkartScraper.FlipkartScraper()
|
| - |
|
50 |
|
| 49 |
|
51 |
|
| 50 |
class __FlipkartDetails:
|
52 |
class __FlipkartDetails:
|
| 51 |
|
53 |
|
| 52 |
def __init__(self,rank ,ourSp , secondLowestSellerSp, prefSellerSp, lowestSellerSp, lowestSellerScore, prefSellerScore, secondLowestSellerScore, ourScore, shippingTimeLowerLimitLowestSeller,shippingTimeUpperLimitLowestSeller, \
|
54 |
def __init__(self,rank ,ourSp , secondLowestSellerSp, prefSellerSp, lowestSellerSp, lowestSellerScore, prefSellerScore, secondLowestSellerScore, ourScore, shippingTimeLowerLimitLowestSeller,shippingTimeUpperLimitLowestSeller, \
|
| 53 |
shippingTimeLowerLimitPrefSeller, shippingTimeUpperLimitPrefSeller, shippingTimeLowerLimitOur, shippingTimeUpperLimitOur, shippingTimeLowerLimitSecondLowestSeller, shippingTimeUpperLimitSecondLowestSeller, totalAvailableSeller, lowestSellerName, lowestSellerCode, secondLowestSellerName, secondLowestSellerCode, prefSellerName, prefSellerCode, lowestSellerBuyTrend, \
|
55 |
shippingTimeLowerLimitPrefSeller, shippingTimeUpperLimitPrefSeller, shippingTimeLowerLimitOur, shippingTimeUpperLimitOur, shippingTimeLowerLimitSecondLowestSeller, shippingTimeUpperLimitSecondLowestSeller, totalAvailableSeller, lowestSellerName, lowestSellerCode, secondLowestSellerName, secondLowestSellerCode, prefSellerName, prefSellerCode, lowestSellerBuyTrend, \
|
| Line 771... |
Line 773... |
| 771 |
elif (float(lowestSellingPrice - ourNlc))/lowestSellingPrice >=0 and (float(lowestSellingPrice - ourNlc))/lowestSellingPrice <=.02:
|
773 |
elif (float(lowestSellingPrice - ourNlc))/lowestSellingPrice >=0 and (float(lowestSellingPrice - ourNlc))/lowestSellingPrice <=.02:
|
| 772 |
return 'MEDIUM'
|
774 |
return 'MEDIUM'
|
| 773 |
else:
|
775 |
else:
|
| 774 |
return 'LOW'
|
776 |
return 'LOW'
|
| 775 |
|
777 |
|
| 776 |
def decideCategory(itemInfo,scraper):
|
778 |
def decideCategory(itemInfo):
|
| 777 |
print "length****",len(itemInfo)
|
779 |
print "length****",len(itemInfo)
|
| 778 |
global itemSaleMap
|
780 |
global itemSaleMap
|
| 779 |
global cantCompete
|
781 |
global cantCompete
|
| 780 |
global buyBoxItems
|
782 |
global buyBoxItems
|
| 781 |
global competitive
|
783 |
global competitive
|
| Line 1904... |
Line 1906... |
| 1904 |
endOffset = startOffset
|
1906 |
endOffset = startOffset
|
| 1905 |
while(len(threads)< 3 and endOffset<len(itemInfo)):
|
1907 |
while(len(threads)< 3 and endOffset<len(itemInfo)):
|
| 1906 |
endOffset = startOffset + 20
|
1908 |
endOffset = startOffset + 20
|
| 1907 |
if (endOffset >= len(itemInfo)):
|
1909 |
if (endOffset >= len(itemInfo)):
|
| 1908 |
endOffset = len(itemInfo)
|
1910 |
endOffset = len(itemInfo)
|
| 1909 |
t = threading.Thread(target=partial(decideCategory, itemInfo[startOffset:endOffset], scraper))
|
1911 |
t = threading.Thread(target=partial(decideCategory, itemInfo[startOffset:endOffset]))
|
| 1910 |
#t = threading.Thread(target=partial(test, startOffset, endOffset))
|
1912 |
#t = threading.Thread(target=partial(test, startOffset, endOffset))
|
| 1911 |
threads.append(t)
|
1913 |
threads.append(t)
|
| 1912 |
startOffset = startOffset + 20
|
1914 |
startOffset = startOffset + 20
|
| 1913 |
[t.start() for t in threads]
|
1915 |
[t.start() for t in threads]
|
| 1914 |
[t.join() for t in threads]
|
1916 |
[t.join() for t in threads]
|
| Line 1921... |
Line 1923... |
| 1921 |
endOffset = startOffset
|
1923 |
endOffset = startOffset
|
| 1922 |
while(count<10 and endOffset<len(itemInfo)):
|
1924 |
while(count<10 and endOffset<len(itemInfo)):
|
| 1923 |
endOffset = startOffset + 50
|
1925 |
endOffset = startOffset + 50
|
| 1924 |
if (endOffset >= len(itemInfo)):
|
1926 |
if (endOffset >= len(itemInfo)):
|
| 1925 |
endOffset = len(itemInfo)
|
1927 |
endOffset = len(itemInfo)
|
| 1926 |
pool.map(decideCategory,itemInfo[startOffset:endOffset],scraper)
|
1928 |
pool.map(decideCategory,itemInfo[startOffset:endOffset])
|
| 1927 |
#t = Process(target=decideCategory,args=(itemInfo[startOffset:endOffset], scraper))
|
1929 |
#t = Process(target=decideCategory,args=(itemInfo[startOffset:endOffset], scraper))
|
| 1928 |
#t = threading.Thread(target=partial(decideCategory, itemInfo[startOffset:endOffset], scraper))
|
1930 |
#t = threading.Thread(target=partial(decideCategory, itemInfo[startOffset:endOffset], scraper))
|
| 1929 |
#t = threading.Thread(target=partial(test, startOffset, endOffset))
|
1931 |
#t = threading.Thread(target=partial(test, startOffset, endOffset))
|
| 1930 |
#threads.append(t)
|
1932 |
#threads.append(t)
|
| 1931 |
startOffset = startOffset + 50
|
1933 |
startOffset = startOffset + 50
|
| Line 1944... |
Line 1946... |
| 1944 |
(options, args) = parser.parse_args()
|
1946 |
(options, args) = parser.parse_args()
|
| 1945 |
if options.runType not in ('FULL','FAVOURITE'):
|
1947 |
if options.runType not in ('FULL','FAVOURITE'):
|
| 1946 |
print "Run type argument illegal."
|
1948 |
print "Run type argument illegal."
|
| 1947 |
sys.exit(1)
|
1949 |
sys.exit(1)
|
| 1948 |
timestamp = datetime.now()
|
1950 |
timestamp = datetime.now()
|
| 1949 |
scraper = FlipkartScraper.FlipkartScraper()
|
- |
|
| 1950 |
itemInfo= populateStuff(options.runType,timestamp)
|
1951 |
itemInfo= populateStuff(options.runType,timestamp)
|
| 1951 |
itemsPopulated = 0
|
1952 |
itemsPopulated = 0
|
| 1952 |
while (itemsPopulated<len(itemInfo)):
|
1953 |
while (itemsPopulated<len(itemInfo)):
|
| 1953 |
itemsPopulated = threadsToSpawn(options.runType,itemInfo,scraper,itemsPopulated)
|
1954 |
itemsPopulated = threadsToSpawn(options.runType,itemInfo,scraper,itemsPopulated)
|
| 1954 |
previousProcessingTimestamp = session.query(func.max(MarketPlaceHistory.timestamp)).filter(MarketPlaceHistory.source==OrderSource.FLIPKART).one()
|
1955 |
previousProcessingTimestamp = session.query(func.max(MarketPlaceHistory.timestamp)).filter(MarketPlaceHistory.source==OrderSource.FLIPKART).one()
|