| Line 31... |
Line 31... |
| 31 |
import email
|
31 |
import email
|
| 32 |
from email.mime.multipart import MIMEMultipart
|
32 |
from email.mime.multipart import MIMEMultipart
|
| 33 |
import email.encoders
|
33 |
import email.encoders
|
| 34 |
import cookielib
|
34 |
import cookielib
|
| 35 |
from multiprocessing import Pool
|
35 |
from multiprocessing import Pool
|
| 36 |
from multiprocessing.dummy import Pool as ThreadPool
|
36 |
from multiprocessing.dummy import Pool as ThreadPool
|
| 37 |
import urllib2
|
- |
|
| 38 |
from BeautifulSoup import BeautifulSoup
|
- |
|
| 39 |
import re
|
- |
|
| 40 |
from sys import exit
|
- |
|
| 41 |
|
37 |
|
| 42 |
config_client = ConfigClient()
|
38 |
config_client = ConfigClient()
|
| 43 |
host = config_client.get_property('staging_hostname')
|
39 |
host = config_client.get_property('staging_hostname')
|
| 44 |
syncPrice=config_client.get_property('sync_price_on_marketplace')
|
40 |
syncPrice=config_client.get_property('sync_price_on_marketplace')
|
| 45 |
|
41 |
|
| Line 685... |
Line 681... |
| 685 |
itemInfo.append(flipkartItemInfo)
|
681 |
itemInfo.append(flipkartItemInfo)
|
| 686 |
session.close()
|
682 |
session.close()
|
| 687 |
return itemInfo
|
683 |
return itemInfo
|
| 688 |
|
684 |
|
| 689 |
def fetchDetails(flipkartSerialNumber):
|
685 |
def fetchDetails(flipkartSerialNumber):
|
| - |
|
686 |
url = "http://www.flipkart.com/ps/%s"%(flipkartSerialNumber)
|
| - |
|
687 |
#url = "http://www.flipkart.com/ps/MOBDTXVZXVY3GFG8"
|
| - |
|
688 |
#scraper.read(url)
|
| - |
|
689 |
scraper = FlipkartScraper.FlipkartScraper()
|
| - |
|
690 |
vendorsData = scraper.read(url)
|
| - |
|
691 |
fin = datetime.now()
|
| - |
|
692 |
print "Finish with data for serial Number %s %s" %(flipkartSerialNumber,str(fin))
|
| - |
|
693 |
sortedVendorsData = sorted(vendorsData, key=itemgetter('sellingPrice'))
|
| - |
|
694 |
vendorsData[:]=[]
|
| - |
|
695 |
rank ,ourSp, iterator, secondLowestSellerSp, prefSellerSp, lowestSellerSp, lowestSellerScore, prefSellerScore, secondLowestSellerScore, ourScore, shippingTimeLowerLimitLowestSeller,shippingTimeUpperLimitLowestSeller, \
|
| - |
|
696 |
shippingTimeLowerLimitPrefSeller, shippingTimeUpperLimitPrefSeller, shippingTimeLowerLimitOur, shippingTimeUpperLimitOur, shippingTimeLowerLimitSecondLowestSeller, shippingTimeUpperLimitSecondLowestSeller, totalAvailableSeller= (0,)*19
|
| - |
|
697 |
lowestSellerName, lowestSellerCode, secondLowestSellerName, secondLowestSellerCode, prefSellerName, prefSellerCode, lowestSellerBuyTrend, \
|
| - |
|
698 |
ourBuyTrend, prefSellerBuyTrend, secondLowestSellerBuyTrend, ourCode = ('',)*11
|
| - |
|
699 |
for data in sortedVendorsData:
|
| - |
|
700 |
if iterator == 0:
|
| - |
|
701 |
lowestSellerName = data['sellerName']
|
| - |
|
702 |
lowestSellerScore = data['sellerScore']
|
| - |
|
703 |
lowestSellerCode = data['sellerCode']
|
| - |
|
704 |
lowestSellerSp = data['sellingPrice']
|
| - |
|
705 |
lowestSellerBuyTrend = data['buyTrend']
|
| - |
|
706 |
try:
|
| - |
|
707 |
shippingTimeLowerLimitLowestSeller, shippingTimeUpperLimitLowestSeller = data['shippingTime'].split('-')
|
| - |
|
708 |
except ValueError:
|
| - |
|
709 |
shippingTimeLowerLimitLowestSeller = int(data['shippingTime'])
|
| - |
|
710 |
|
| - |
|
711 |
if iterator ==1:
|
| - |
|
712 |
secondLowestSellerName = data['sellerName']
|
| - |
|
713 |
secondLowestSellerScore = data['sellerScore']
|
| - |
|
714 |
secondLowestSellerCode = data['sellerCode']
|
| - |
|
715 |
secondLowestSellerSp = data['sellingPrice']
|
| - |
|
716 |
secondLowestSellerBuyTrend = data['buyTrend']
|
| - |
|
717 |
try:
|
| - |
|
718 |
shippingTimeLowerLimitSecondLowestSeller, shippingTimeUpperLimitSecondLowestSeller = data['shippingTime'].split('-')
|
| - |
|
719 |
except ValueError:
|
| - |
|
720 |
shippingTimeLowerLimitSecondLowestSeller = int(data['shippingTime'])
|
| - |
|
721 |
|
| - |
|
722 |
if data['sellerName'] == 'Saholic':
|
| - |
|
723 |
ourScore = data['sellerScore']
|
| - |
|
724 |
ourCode = data['sellerCode']
|
| - |
|
725 |
ourSp = data['sellingPrice']
|
| - |
|
726 |
ourBuyTrend = data['buyTrend']
|
| - |
|
727 |
try:
|
| - |
|
728 |
shippingTimeLowerLimitOur, shippingTimeUpperLimitOur = data['shippingTime'].split('-')
|
| - |
|
729 |
except ValueError:
|
| - |
|
730 |
shippingTimeLowerLimitOur = int(data['shippingTime'])
|
| - |
|
731 |
rank = iterator + 1
|
| - |
|
732 |
|
| - |
|
733 |
if data['buyTrend'] in ('PrefCheap','PrefNCheap',''):
|
| - |
|
734 |
prefSellerName = data['sellerName']
|
| - |
|
735 |
prefSellerScore = data['sellerScore']
|
| - |
|
736 |
prefSellerCode = data['sellerCode']
|
| - |
|
737 |
prefSellerSp = data['sellingPrice']
|
| - |
|
738 |
prefSellerBuyTrend = data['buyTrend']
|
| - |
|
739 |
try:
|
| - |
|
740 |
shippingTimeLowerLimitPrefSeller, shippingTimeUpperLimitPrefSeller = data['shippingTime'].split('-')
|
| - |
|
741 |
except ValueError:
|
| - |
|
742 |
shippingTimeLowerLimitPrefSeller = int(data['shippingTime'])
|
| - |
|
743 |
|
| - |
|
744 |
iterator+=1
|
| - |
|
745 |
|
| - |
|
746 |
flipkartDetails = __FlipkartDetails(rank ,ourSp , secondLowestSellerSp, prefSellerSp, lowestSellerSp, lowestSellerScore, prefSellerScore, secondLowestSellerScore, ourScore, int(shippingTimeLowerLimitLowestSeller),int(shippingTimeUpperLimitLowestSeller), \
|
| 690 |
pass
|
747 |
int(shippingTimeLowerLimitPrefSeller), int(shippingTimeUpperLimitPrefSeller), int(shippingTimeLowerLimitOur), int(shippingTimeUpperLimitOur), int(shippingTimeLowerLimitSecondLowestSeller), int(shippingTimeUpperLimitSecondLowestSeller), len(sortedVendorsData), lowestSellerName, lowestSellerCode, secondLowestSellerName, secondLowestSellerCode, prefSellerName, prefSellerCode, lowestSellerBuyTrend, \
|
| - |
|
748 |
ourBuyTrend, prefSellerBuyTrend, secondLowestSellerBuyTrend, ourCode)
|
| - |
|
749 |
|
| - |
|
750 |
if flipkartDetails.ourBuyTrend == 'PrefCheap'and flipkartDetails.rank!=1 and flipkartDetails.ourSp==flipkartDetails.secondLowestSellerSp:
|
| - |
|
751 |
print "Under PrefCheap category.Switching data for ",flipkartSerialNumber
|
| - |
|
752 |
flipkartDetails.lowestSellerSp, flipkartDetails.secondLowestSellerSp = flipkartDetails.secondLowestSellerSp,flipkartDetails.lowestSellerSp
|
| - |
|
753 |
flipkartDetails.lowestSellerScore, flipkartDetails.secondLowestSellerScore = flipkartDetails.secondLowestSellerScore,flipkartDetails.lowestSellerScore
|
| - |
|
754 |
flipkartDetails.shippingTimeLowerLimitLowestSeller, flipkartDetails.shippingTimeLowerLimitSecondLowestSeller = flipkartDetails.shippingTimeLowerLimitSecondLowestSeller,flipkartDetails.shippingTimeLowerLimitLowestSeller
|
| - |
|
755 |
flipkartDetails.shippingTimeUpperLimitLowestSeller, flipkartDetails.shippingTimeUpperLimitSecondLowestSeller = flipkartDetails.shippingTimeUpperLimitSecondLowestSeller,flipkartDetails.shippingTimeUpperLimitLowestSeller
|
| - |
|
756 |
flipkartDetails.lowestSellerName, flipkartDetails.secondLowestSellerName = flipkartDetails.secondLowestSellerName,flipkartDetails.lowestSellerName
|
| - |
|
757 |
flipkartDetails.lowestSellerCode, flipkartDetails.secondLowestSellerCode = flipkartDetails.secondLowestSellerCode,flipkartDetails.lowestSellerCode
|
| - |
|
758 |
flipkartDetails.lowestSellerBuyTrend, flipkartDetails.secondLowestSellerBuyTrend = flipkartDetails.secondLowestSellerBuyTrend,flipkartDetails.lowestSellerBuyTrend
|
| - |
|
759 |
flipkartDetails.rank=1
|
| - |
|
760 |
|
| - |
|
761 |
if flipkartDetails.ourBuyTrend == 'NPrefCheap'and flipkartDetails.rank!=1 and flipkartDetails.ourSp==flipkartDetails.lowestSellerSp:
|
| - |
|
762 |
print "Under NPrefCheap category.Switching data for ",flipkartSerialNumber
|
| - |
|
763 |
flipkartDetails.lowestSellerSp = flipkartDetails.ourSp
|
| - |
|
764 |
flipkartDetails.lowestSellerScore = flipkartDetails.ourScore
|
| - |
|
765 |
flipkartDetails.shippingTimeLowerLimitLowestSeller = flipkartDetails.shippingTimeLowerLimitOur
|
| - |
|
766 |
flipkartDetails.shippingTimeUpperLimitLowestSeller = flipkartDetails.shippingTimeUpperLimitOur
|
| - |
|
767 |
flipkartDetails.lowestSellerName = 'Saholic'
|
| - |
|
768 |
flipkartDetails.lowestSellerCode = flipkartDetails.ourCode
|
| - |
|
769 |
flipkartDetails.lowestSellerBuyTrend = flipkartDetails.ourBuyTrend
|
| - |
|
770 |
|
| - |
|
771 |
return flipkartDetails
|
| 691 |
|
772 |
|
| 692 |
def calculateAverageSale(oosStatus):
|
773 |
def calculateAverageSale(oosStatus):
|
| 693 |
count,sale = 0,0
|
774 |
count,sale = 0,0
|
| 694 |
for obj in oosStatus:
|
775 |
for obj in oosStatus:
|
| 695 |
if not obj.is_oos:
|
776 |
if not obj.is_oos:
|
| Line 2020... |
Line 2101... |
| 2020 |
|
2101 |
|
| 2021 |
def populateScrapingResults(val):
|
2102 |
def populateScrapingResults(val):
|
| 2022 |
try:
|
2103 |
try:
|
| 2023 |
now = datetime.now()
|
2104 |
now = datetime.now()
|
| 2024 |
print "Fetching data for serial Number %s %s" %(val.fkSerialNumber,str(now))
|
2105 |
print "Fetching data for serial Number %s %s" %(val.fkSerialNumber,str(now))
|
| 2025 |
print "Inside fetch details"
|
- |
|
| 2026 |
flipkartSerialNumber = val.fkSerialNumber
|
- |
|
| 2027 |
url = "http://www.flipkart.com/ps/%s"%(flipkartSerialNumber)
|
- |
|
| 2028 |
#url = "http://www.flipkart.com/ps/MOBDTXVZXVY3GFG8"
|
- |
|
| 2029 |
#scraper.read(url)
|
- |
|
| 2030 |
# scraper = FlipkartScraper.FlipkartScraper()
|
- |
|
| 2031 |
# vendorsData = scraper.read(url)
|
- |
|
| 2032 |
request = urllib2.Request(url)
|
- |
|
| 2033 |
request.add_header('User-Agent', 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.218 Safari/535.1')
|
- |
|
| 2034 |
opener = urllib2.build_opener()
|
- |
|
| 2035 |
response_data = ""
|
- |
|
| 2036 |
try:
|
- |
|
| 2037 |
response_data = opener.open(request).read()
|
- |
|
| 2038 |
print datetime.now()
|
- |
|
| 2039 |
print "Fetched response from flipkart for %s" %(url)
|
- |
|
| 2040 |
|
- |
|
| 2041 |
except urllib2.HTTPError as e:
|
- |
|
| 2042 |
print 'ERROR: ', e
|
- |
|
| 2043 |
print 'Retrying'
|
- |
|
| 2044 |
|
- |
|
| 2045 |
response_data=response_data
|
- |
|
| 2046 |
page=response_data.decode("utf-8")
|
- |
|
| 2047 |
print datetime.now()
|
- |
|
| 2048 |
soup = BeautifulSoup(page,convertEntities=BeautifulSoup.HTML_ENTITIES)
|
- |
|
| 2049 |
page = None
|
- |
|
| 2050 |
response_data = None
|
- |
|
| 2051 |
print datetime.now()
|
- |
|
| 2052 |
print "Soup created from flipkart data for %s" %(url)
|
- |
|
| 2053 |
info = []
|
- |
|
| 2054 |
oddSeller = soup.findAll("div" , {"class" : "line seller-item odd "})
|
- |
|
| 2055 |
for data in oddSeller:
|
- |
|
| 2056 |
temp={}
|
- |
|
| 2057 |
try:
|
- |
|
| 2058 |
businessDays = data.find('span', attrs={'class' : re.compile('fk-deliverable.*')})
|
- |
|
| 2059 |
shippingTime = businessDays.find('span', attrs={'class' : re.compile('fk-bold')}).string.replace('to','').replace('business days.','').strip().replace(' ','-')
|
- |
|
| 2060 |
temp['shippingTime']=shippingTime
|
- |
|
| 2061 |
except:
|
- |
|
| 2062 |
pass
|
- |
|
| 2063 |
price = data.find('span', attrs={'class' : re.compile('pxs-final-price.*')}).string.strip('Rs.').strip()
|
- |
|
| 2064 |
temp['sellingPrice']=float(price)
|
- |
|
| 2065 |
for sellerInfo in data.findAll("div",{"class":re.compile(".*seller-info*")}):
|
- |
|
| 2066 |
sellerName = sellerInfo.find('a').string
|
- |
|
| 2067 |
temp['sellerName'] = sellerName
|
- |
|
| 2068 |
for metrics in data.find("div",{"class":"fk-text-right"}):
|
- |
|
| 2069 |
try:
|
- |
|
| 2070 |
metric = metrics.findAll('input', {'type': 'submit'})
|
- |
|
| 2071 |
except AttributeError:
|
- |
|
| 2072 |
continue
|
- |
|
| 2073 |
try:
|
- |
|
| 2074 |
inputTags = metric[0]['data-lst-buytrend']
|
- |
|
| 2075 |
except TypeError:
|
- |
|
| 2076 |
continue
|
- |
|
| 2077 |
dataMetrics = metric[0]['data-listing-metrics']
|
- |
|
| 2078 |
try:
|
- |
|
| 2079 |
buyTrend = inputTags[0:str(inputTags).index('NWSR')].replace('_','')
|
- |
|
| 2080 |
except ValueError:
|
- |
|
| 2081 |
buyTrend = inputTags[0:str(inputTags).index('WSR')].replace('_','')
|
- |
|
| 2082 |
temp['buyTrend']=buyTrend
|
- |
|
| 2083 |
dataMetric = dataMetrics.split(';')
|
- |
|
| 2084 |
sellerCode = dataMetric[0]
|
- |
|
| 2085 |
temp['sellerCode']=sellerCode
|
- |
|
| 2086 |
temp['sellingPriceMetric'] = float(dataMetric[1])
|
- |
|
| 2087 |
if not temp.has_key('shippingTime'):
|
- |
|
| 2088 |
print "Populating shipping time from metrics"
|
- |
|
| 2089 |
temp['shippingTime'] = dataMetric[3]
|
- |
|
| 2090 |
temp['sellerScore'] = int(dataMetric[4])
|
- |
|
| 2091 |
info.append(temp)
|
- |
|
| 2092 |
evenSeller = soup.findAll("div" , {"class" : "line seller-item even "})
|
- |
|
| 2093 |
for data in evenSeller:
|
- |
|
| 2094 |
temp={}
|
- |
|
| 2095 |
price = data.find('span', attrs={'class' : re.compile('pxs-final-price.*')}).string.strip('Rs.')
|
- |
|
| 2096 |
try:
|
- |
|
| 2097 |
businessDays = data.find('span', attrs={'class' : re.compile('fk-deliverable.*')})
|
- |
|
| 2098 |
shippingTime = businessDays.find('span', attrs={'class' : re.compile('fk-bold')}).string.replace('to','').replace('business days.','').strip().replace(' ','-')
|
- |
|
| 2099 |
temp['shippingTime']=shippingTime
|
- |
|
| 2100 |
except:
|
- |
|
| 2101 |
pass
|
- |
|
| 2102 |
temp['sellingPrice']=float(price)
|
- |
|
| 2103 |
for sellerInfo in data.findAll("div",{"class":re.compile(".*seller-info*")}):
|
- |
|
| 2104 |
sellerName = sellerInfo.find('a').string
|
- |
|
| 2105 |
temp['sellerName'] = sellerName
|
- |
|
| 2106 |
for metrics in data.find("div",{"class":"fk-text-right"}):
|
- |
|
| 2107 |
try:
|
- |
|
| 2108 |
metric = metrics.findAll('input', {'type': 'submit'})
|
- |
|
| 2109 |
except AttributeError:
|
- |
|
| 2110 |
continue
|
- |
|
| 2111 |
try:
|
- |
|
| 2112 |
inputTags = metric[0]['data-lst-buytrend']
|
- |
|
| 2113 |
except TypeError:
|
- |
|
| 2114 |
continue
|
- |
|
| 2115 |
dataMetrics = metric[0]['data-listing-metrics']
|
- |
|
| 2116 |
try:
|
- |
|
| 2117 |
buyTrend = inputTags[0:str(inputTags).index('NWSR')].replace('_','')
|
- |
|
| 2118 |
except ValueError:
|
- |
|
| 2119 |
buyTrend = inputTags[0:str(inputTags).index('WSR')].replace('_','')
|
- |
|
| 2120 |
temp['buyTrend']=buyTrend
|
- |
|
| 2121 |
dataMetric = dataMetrics.split(';')
|
- |
|
| 2122 |
temp['sellerCode'] = dataMetric[0]
|
- |
|
| 2123 |
temp['sellingPriceMetric'] = float(dataMetric[1])
|
- |
|
| 2124 |
if not temp.has_key('shippingTime'):
|
- |
|
| 2125 |
print "Populating shipping time from metrics"
|
- |
|
| 2126 |
temp['shippingTime'] = dataMetric[3]
|
- |
|
| 2127 |
temp['sellerScore'] = int(dataMetric[4])
|
- |
|
| 2128 |
info.append(temp)
|
- |
|
| 2129 |
vendorsData = info
|
- |
|
| 2130 |
info = []
|
- |
|
| 2131 |
print "Returning Json response from flipkart for %s" %(url)
|
- |
|
| 2132 |
fin = datetime.now()
|
- |
|
| 2133 |
print "Finish with data for serial Number %s %s" %(flipkartSerialNumber,str(fin))
|
- |
|
| 2134 |
sortedVendorsData = sorted(vendorsData, key=itemgetter('sellingPrice'))
|
- |
|
| 2135 |
vendorsData[:]=[]
|
- |
|
| 2136 |
rank ,ourSp, iterator, secondLowestSellerSp, prefSellerSp, lowestSellerSp, lowestSellerScore, prefSellerScore, secondLowestSellerScore, ourScore, shippingTimeLowerLimitLowestSeller,shippingTimeUpperLimitLowestSeller, \
|
- |
|
| 2137 |
shippingTimeLowerLimitPrefSeller, shippingTimeUpperLimitPrefSeller, shippingTimeLowerLimitOur, shippingTimeUpperLimitOur, shippingTimeLowerLimitSecondLowestSeller, shippingTimeUpperLimitSecondLowestSeller, totalAvailableSeller= (0,)*19
|
- |
|
| 2138 |
lowestSellerName, lowestSellerCode, secondLowestSellerName, secondLowestSellerCode, prefSellerName, prefSellerCode, lowestSellerBuyTrend, \
|
- |
|
| 2139 |
ourBuyTrend, prefSellerBuyTrend, secondLowestSellerBuyTrend, ourCode = ('',)*11
|
- |
|
| 2140 |
for data in sortedVendorsData:
|
- |
|
| 2141 |
if iterator == 0:
|
- |
|
| 2142 |
lowestSellerName = data['sellerName']
|
- |
|
| 2143 |
lowestSellerScore = data['sellerScore']
|
- |
|
| 2144 |
lowestSellerCode = data['sellerCode']
|
- |
|
| 2145 |
lowestSellerSp = data['sellingPrice']
|
- |
|
| 2146 |
lowestSellerBuyTrend = data['buyTrend']
|
- |
|
| 2147 |
try:
|
- |
|
| 2148 |
shippingTimeLowerLimitLowestSeller, shippingTimeUpperLimitLowestSeller = data['shippingTime'].split('-')
|
- |
|
| 2149 |
except ValueError:
|
- |
|
| 2150 |
shippingTimeLowerLimitLowestSeller = int(data['shippingTime'])
|
- |
|
| 2151 |
|
- |
|
| 2152 |
if iterator ==1:
|
- |
|
| 2153 |
secondLowestSellerName = data['sellerName']
|
- |
|
| 2154 |
secondLowestSellerScore = data['sellerScore']
|
- |
|
| 2155 |
secondLowestSellerCode = data['sellerCode']
|
- |
|
| 2156 |
secondLowestSellerSp = data['sellingPrice']
|
- |
|
| 2157 |
secondLowestSellerBuyTrend = data['buyTrend']
|
- |
|
| 2158 |
try:
|
- |
|
| 2159 |
shippingTimeLowerLimitSecondLowestSeller, shippingTimeUpperLimitSecondLowestSeller = data['shippingTime'].split('-')
|
- |
|
| 2160 |
except ValueError:
|
- |
|
| 2161 |
shippingTimeLowerLimitSecondLowestSeller = int(data['shippingTime'])
|
- |
|
| 2162 |
|
- |
|
| 2163 |
if data['sellerName'] == 'Saholic':
|
- |
|
| 2164 |
ourScore = data['sellerScore']
|
- |
|
| 2165 |
ourCode = data['sellerCode']
|
- |
|
| 2166 |
ourSp = data['sellingPrice']
|
- |
|
| 2167 |
ourBuyTrend = data['buyTrend']
|
- |
|
| 2168 |
try:
|
- |
|
| 2169 |
shippingTimeLowerLimitOur, shippingTimeUpperLimitOur = data['shippingTime'].split('-')
|
- |
|
| 2170 |
except ValueError:
|
- |
|
| 2171 |
shippingTimeLowerLimitOur = int(data['shippingTime'])
|
- |
|
| 2172 |
rank = iterator + 1
|
- |
|
| 2173 |
|
- |
|
| 2174 |
if data['buyTrend'] in ('PrefCheap','PrefNCheap',''):
|
- |
|
| 2175 |
prefSellerName = data['sellerName']
|
- |
|
| 2176 |
prefSellerScore = data['sellerScore']
|
- |
|
| 2177 |
prefSellerCode = data['sellerCode']
|
- |
|
| 2178 |
prefSellerSp = data['sellingPrice']
|
- |
|
| 2179 |
prefSellerBuyTrend = data['buyTrend']
|
- |
|
| 2180 |
try:
|
- |
|
| 2181 |
shippingTimeLowerLimitPrefSeller, shippingTimeUpperLimitPrefSeller = data['shippingTime'].split('-')
|
- |
|
| 2182 |
except ValueError:
|
- |
|
| 2183 |
shippingTimeLowerLimitPrefSeller = int(data['shippingTime'])
|
- |
|
| 2184 |
|
- |
|
| 2185 |
iterator+=1
|
- |
|
| 2186 |
|
- |
|
| 2187 |
flipkartDetails = __FlipkartDetails(rank ,ourSp , secondLowestSellerSp, prefSellerSp, lowestSellerSp, lowestSellerScore, prefSellerScore, secondLowestSellerScore, ourScore, int(shippingTimeLowerLimitLowestSeller),int(shippingTimeUpperLimitLowestSeller), \
|
- |
|
| 2188 |
int(shippingTimeLowerLimitPrefSeller), int(shippingTimeUpperLimitPrefSeller), int(shippingTimeLowerLimitOur), int(shippingTimeUpperLimitOur), int(shippingTimeLowerLimitSecondLowestSeller), int(shippingTimeUpperLimitSecondLowestSeller), len(sortedVendorsData), lowestSellerName, lowestSellerCode, secondLowestSellerName, secondLowestSellerCode, prefSellerName, prefSellerCode, lowestSellerBuyTrend, \
|
2106 |
flipkartDetails = fetchDetails(val.fkSerialNumber)
|
| 2189 |
ourBuyTrend, prefSellerBuyTrend, secondLowestSellerBuyTrend, ourCode)
|
- |
|
| 2190 |
|
- |
|
| 2191 |
if flipkartDetails.ourBuyTrend == 'PrefCheap'and flipkartDetails.rank!=1 and flipkartDetails.ourSp==flipkartDetails.secondLowestSellerSp:
|
- |
|
| 2192 |
print "Under PrefCheap category.Switching data for ",flipkartSerialNumber
|
- |
|
| 2193 |
flipkartDetails.lowestSellerSp, flipkartDetails.secondLowestSellerSp = flipkartDetails.secondLowestSellerSp,flipkartDetails.lowestSellerSp
|
- |
|
| 2194 |
flipkartDetails.lowestSellerScore, flipkartDetails.secondLowestSellerScore = flipkartDetails.secondLowestSellerScore,flipkartDetails.lowestSellerScore
|
- |
|
| 2195 |
flipkartDetails.shippingTimeLowerLimitLowestSeller, flipkartDetails.shippingTimeLowerLimitSecondLowestSeller = flipkartDetails.shippingTimeLowerLimitSecondLowestSeller,flipkartDetails.shippingTimeLowerLimitLowestSeller
|
- |
|
| 2196 |
flipkartDetails.shippingTimeUpperLimitLowestSeller, flipkartDetails.shippingTimeUpperLimitSecondLowestSeller = flipkartDetails.shippingTimeUpperLimitSecondLowestSeller,flipkartDetails.shippingTimeUpperLimitLowestSeller
|
- |
|
| 2197 |
flipkartDetails.lowestSellerName, flipkartDetails.secondLowestSellerName = flipkartDetails.secondLowestSellerName,flipkartDetails.lowestSellerName
|
- |
|
| 2198 |
flipkartDetails.lowestSellerCode, flipkartDetails.secondLowestSellerCode = flipkartDetails.secondLowestSellerCode,flipkartDetails.lowestSellerCode
|
- |
|
| 2199 |
flipkartDetails.lowestSellerBuyTrend, flipkartDetails.secondLowestSellerBuyTrend = flipkartDetails.secondLowestSellerBuyTrend,flipkartDetails.lowestSellerBuyTrend
|
- |
|
| 2200 |
flipkartDetails.rank=1
|
- |
|
| 2201 |
|
- |
|
| 2202 |
if flipkartDetails.ourBuyTrend == 'NPrefCheap'and flipkartDetails.rank!=1 and flipkartDetails.ourSp==flipkartDetails.lowestSellerSp:
|
- |
|
| 2203 |
print "Under NPrefCheap category.Switching data for ",flipkartSerialNumber
|
- |
|
| 2204 |
flipkartDetails.lowestSellerSp = flipkartDetails.ourSp
|
- |
|
| 2205 |
flipkartDetails.lowestSellerScore = flipkartDetails.ourScore
|
- |
|
| 2206 |
flipkartDetails.shippingTimeLowerLimitLowestSeller = flipkartDetails.shippingTimeLowerLimitOur
|
- |
|
| 2207 |
flipkartDetails.shippingTimeUpperLimitLowestSeller = flipkartDetails.shippingTimeUpperLimitOur
|
- |
|
| 2208 |
flipkartDetails.lowestSellerName = 'Saholic'
|
- |
|
| 2209 |
flipkartDetails.lowestSellerCode = flipkartDetails.ourCode
|
- |
|
| 2210 |
flipkartDetails.lowestSellerBuyTrend = flipkartDetails.ourBuyTrend
|
- |
|
| 2211 |
|
- |
|
| 2212 |
#flipkartDetails = fetchDetails(val.fkSerialNumber)
|
- |
|
| 2213 |
val.flipkartDetails = flipkartDetails
|
2107 |
val.flipkartDetails = flipkartDetails
|
| 2214 |
except Exception as e:
|
2108 |
except Exception as e:
|
| 2215 |
print "Unable to fetch details of %s" %(val.fkSerialNumber)
|
2109 |
print "Unable to fetch details of %s" %(val.fkSerialNumber)
|
| 2216 |
print e
|
2110 |
print e
|
| 2217 |
val.flipkartDetails = None
|
2111 |
val.flipkartDetails = None
|
| 2218 |
return
|
2112 |
return
|
| Line 2227... |
Line 2121... |
| 2227 |
# finally:
|
2121 |
# finally:
|
| 2228 |
# r={}
|
2122 |
# r={}
|
| 2229 |
#
|
2123 |
#
|
| 2230 |
val.ourFlipkartInventory = 0
|
2124 |
val.ourFlipkartInventory = 0
|
| 2231 |
|
2125 |
|
| 2232 |
def threadsToSpawn(runType,itemInfo,itemPopulated):
|
2126 |
def threadsToSpawn(runType,itemInfo,scraper,itemPopulated):
|
| 2233 |
if runType == RunType.FAVOURITE:
|
2127 |
if runType == RunType.FAVOURITE:
|
| 2234 |
count = 0
|
2128 |
count = 0
|
| 2235 |
pool = ThreadPool(3)
|
2129 |
pool = ThreadPool(3)
|
| 2236 |
startOffset = 0
|
2130 |
startOffset = 0
|
| 2237 |
endOffset = startOffset
|
2131 |
endOffset = startOffset
|
| Line 2755... |
Line 2649... |
| 2755 |
timestamp = datetime.now()
|
2649 |
timestamp = datetime.now()
|
| 2756 |
previousProcessingTimestamp = session.query(func.max(MarketPlaceHistory.timestamp)).filter(MarketPlaceHistory.source==OrderSource.FLIPKART).one()
|
2650 |
previousProcessingTimestamp = session.query(func.max(MarketPlaceHistory.timestamp)).filter(MarketPlaceHistory.source==OrderSource.FLIPKART).one()
|
| 2757 |
itemInfo= populateStuff(options.runType,timestamp)
|
2651 |
itemInfo= populateStuff(options.runType,timestamp)
|
| 2758 |
itemsPopulated = 0
|
2652 |
itemsPopulated = 0
|
| 2759 |
while (len(itemInfo)>0):
|
2653 |
while (len(itemInfo)>0):
|
| 2760 |
itemsPopulated = threadsToSpawn(options.runType,itemInfo,itemsPopulated)
|
2654 |
itemsPopulated = threadsToSpawn(options.runType,itemInfo,scraper,itemsPopulated)
|
| 2761 |
cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionItems, negativeMargin, cheapButNotPref, prefButNotCheap = decideCategory(itemInfo[0:itemsPopulated])
|
2655 |
cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionItems, negativeMargin, cheapButNotPref, prefButNotCheap = decideCategory(itemInfo[0:itemsPopulated])
|
| 2762 |
itemInfo[0:itemsPopulated] = []
|
2656 |
itemInfo[0:itemsPopulated] = []
|
| 2763 |
commitExceptionList(exceptionItems,timestamp)
|
2657 |
commitExceptionList(exceptionItems,timestamp)
|
| 2764 |
commitCantCompete(cantCompete,timestamp)
|
2658 |
commitCantCompete(cantCompete,timestamp)
|
| 2765 |
commitBuyBox(buyBoxItems,timestamp)
|
2659 |
commitBuyBox(buyBoxItems,timestamp)
|