| Line 914... |
Line 914... |
| 914 |
previouslyAutoFav.append(aItem.itemId)
|
914 |
previouslyAutoFav.append(aItem.itemId)
|
| 915 |
aItem.autoFavourite = toMark
|
915 |
aItem.autoFavourite = toMark
|
| 916 |
session.commit()
|
916 |
session.commit()
|
| 917 |
return previouslyAutoFav, nowAutoFav
|
917 |
return previouslyAutoFav, nowAutoFav
|
| 918 |
|
918 |
|
| 919 |
def writeReport(timestamp,autoDecreaseItems,autoIncreaseItems,previousAutoFav,nowAutoFav):
|
919 |
def writeReport(timestamp,autoDecreaseItems,autoIncreaseItems,previousAutoFav,nowAutoFav,runType):
|
| 920 |
wbk = xlwt.Workbook()
|
920 |
wbk = xlwt.Workbook()
|
| 921 |
sheet = wbk.add_sheet('Can\'t Compete')
|
921 |
sheet = wbk.add_sheet('Can\'t Compete')
|
| 922 |
xstr = lambda s: s or ""
|
922 |
xstr = lambda s: s or ""
|
| 923 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
923 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| 924 |
|
924 |
|
| Line 958... |
Line 958... |
| 958 |
sheet.write(0, 29, "Proposed Sp", heading_xf)
|
958 |
sheet.write(0, 29, "Proposed Sp", heading_xf)
|
| 959 |
sheet.write(0, 30, "Proposed Tp", heading_xf)
|
959 |
sheet.write(0, 30, "Proposed Tp", heading_xf)
|
| 960 |
sheet.write(0, 31, "Target Nlc", heading_xf)
|
960 |
sheet.write(0, 31, "Target Nlc", heading_xf)
|
| 961 |
sheet.write(0, 32, "Avg Sale", heading_xf)
|
961 |
sheet.write(0, 32, "Avg Sale", heading_xf)
|
| 962 |
sheet.write(0, 33, "Sales History", heading_xf)
|
962 |
sheet.write(0, 33, "Sales History", heading_xf)
|
| - |
|
963 |
sheet.write(0, 34, "Decision", heading_xf)
|
| - |
|
964 |
sheet.write(0, 35, "Reason", heading_xf)
|
| - |
|
965 |
sheet.write(0, 36, "Updated Price", heading_xf)
|
| 963 |
|
966 |
|
| 964 |
sheet_iterator = 1
|
967 |
sheet_iterator = 1
|
| 965 |
cantCompeteItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.CANT_COMPETE).all()
|
968 |
cantCompeteItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.CANT_COMPETE).all()
|
| 966 |
for cantCompeteItem in cantCompeteItems:
|
969 |
for cantCompeteItem in cantCompeteItems:
|
| 967 |
amScraping = cantCompeteItem[0]
|
970 |
amScraping = cantCompeteItem[0]
|
| Line 1010... |
Line 1013... |
| 1010 |
sheet.write(sheet_iterator, 29, amScraping.proposedSp)
|
1013 |
sheet.write(sheet_iterator, 29, amScraping.proposedSp)
|
| 1011 |
sheet.write(sheet_iterator, 30, amScraping.proposedTp)
|
1014 |
sheet.write(sheet_iterator, 30, amScraping.proposedTp)
|
| 1012 |
sheet.write(sheet_iterator, 31, amScraping.targetNlc)
|
1015 |
sheet.write(sheet_iterator, 31, amScraping.targetNlc)
|
| 1013 |
sheet.write(sheet_iterator, 32, amScraping.avgSale)
|
1016 |
sheet.write(sheet_iterator, 32, amScraping.avgSale)
|
| 1014 |
sheet.write(sheet_iterator, 33, getOosString(saleMap.get(sku)))
|
1017 |
sheet.write(sheet_iterator, 33, getOosString(saleMap.get(sku)))
|
| - |
|
1018 |
if amScraping.decision is None:
|
| - |
|
1019 |
sheet.write(sheet_iterator, 34, 'Auto Pricing Inactive')
|
| - |
|
1020 |
sheet_iterator+=1
|
| - |
|
1021 |
continue
|
| - |
|
1022 |
sheet.write(sheet_iterator, 34, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
| - |
|
1023 |
sheet.write(sheet_iterator, 35, amScraping.reason)
|
| - |
|
1024 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
| - |
|
1025 |
sheet.write(sheet_iterator, 36, math.ceil(amScraping.proposedSellingPrice))
|
| - |
|
1026 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
| - |
|
1027 |
sheet.write(sheet_iterator, 36, math.ceil(amScraping.ourSellingPrice+max(10,.01*amScraping.ourSellingPrice)))
|
| 1015 |
sheet_iterator+=1
|
1028 |
sheet_iterator+=1
|
| 1016 |
|
1029 |
|
| 1017 |
sheet = wbk.add_sheet('Competitive')
|
1030 |
sheet = wbk.add_sheet('Competitive')
|
| 1018 |
xstr = lambda s: s or ""
|
1031 |
xstr = lambda s: s or ""
|
| 1019 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
1032 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| Line 1053... |
Line 1066... |
| 1053 |
sheet.write(0, 28, "Risky", heading_xf)
|
1066 |
sheet.write(0, 28, "Risky", heading_xf)
|
| 1054 |
sheet.write(0, 29, "Proposed Sp", heading_xf)
|
1067 |
sheet.write(0, 29, "Proposed Sp", heading_xf)
|
| 1055 |
sheet.write(0, 30, "Proposed Tp", heading_xf)
|
1068 |
sheet.write(0, 30, "Proposed Tp", heading_xf)
|
| 1056 |
sheet.write(0, 31, "Avg Sale", heading_xf)
|
1069 |
sheet.write(0, 31, "Avg Sale", heading_xf)
|
| 1057 |
sheet.write(0, 32, "Sales History", heading_xf)
|
1070 |
sheet.write(0, 32, "Sales History", heading_xf)
|
| - |
|
1071 |
sheet.write(0, 33, "Decision", heading_xf)
|
| - |
|
1072 |
sheet.write(0, 34, "Reason", heading_xf)
|
| - |
|
1073 |
sheet.write(0, 35, "Updated Price", heading_xf)
|
| 1058 |
|
1074 |
|
| 1059 |
sheet_iterator = 1
|
1075 |
sheet_iterator = 1
|
| 1060 |
competitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.COMPETITIVE).all()
|
1076 |
competitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.COMPETITIVE).all()
|
| 1061 |
for competitiveItem in competitiveItems:
|
1077 |
for competitiveItem in competitiveItems:
|
| 1062 |
amScraping = competitiveItem[0]
|
1078 |
amScraping = competitiveItem[0]
|
| Line 1104... |
Line 1120... |
| 1104 |
sheet.write(sheet_iterator, 28, item.risky)
|
1120 |
sheet.write(sheet_iterator, 28, item.risky)
|
| 1105 |
sheet.write(sheet_iterator, 29, amScraping.proposedSp)
|
1121 |
sheet.write(sheet_iterator, 29, amScraping.proposedSp)
|
| 1106 |
sheet.write(sheet_iterator, 30, amScraping.proposedTp)
|
1122 |
sheet.write(sheet_iterator, 30, amScraping.proposedTp)
|
| 1107 |
sheet.write(sheet_iterator, 31, amScraping.avgSale)
|
1123 |
sheet.write(sheet_iterator, 31, amScraping.avgSale)
|
| 1108 |
sheet.write(sheet_iterator, 32, getOosString(saleMap.get(sku)))
|
1124 |
sheet.write(sheet_iterator, 32, getOosString(saleMap.get(sku)))
|
| - |
|
1125 |
if amScraping.decision is None:
|
| - |
|
1126 |
sheet.write(sheet_iterator, 33, 'Auto Pricing Inactive')
|
| - |
|
1127 |
sheet_iterator+=1
|
| - |
|
1128 |
continue
|
| - |
|
1129 |
sheet.write(sheet_iterator, 33, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
| - |
|
1130 |
sheet.write(sheet_iterator, 34, amScraping.reason)
|
| - |
|
1131 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
| - |
|
1132 |
sheet.write(sheet_iterator, 35, math.ceil(amScraping.proposedSellingPrice))
|
| - |
|
1133 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
| - |
|
1134 |
sheet.write(sheet_iterator, 35, math.ceil(amScraping.ourSellingPrice+max(10,.01*amScraping.ourSellingPrice)))
|
| 1109 |
sheet_iterator+=1
|
1135 |
sheet_iterator+=1
|
| 1110 |
|
1136 |
|
| 1111 |
sheet = wbk.add_sheet('Almost Competitive')
|
1137 |
sheet = wbk.add_sheet('Almost Competitive')
|
| 1112 |
xstr = lambda s: s or ""
|
1138 |
xstr = lambda s: s or ""
|
| 1113 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
1139 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| Line 1147... |
Line 1173... |
| 1147 |
sheet.write(0, 28, "Risky", heading_xf)
|
1173 |
sheet.write(0, 28, "Risky", heading_xf)
|
| 1148 |
sheet.write(0, 29, "Proposed Sp", heading_xf)
|
1174 |
sheet.write(0, 29, "Proposed Sp", heading_xf)
|
| 1149 |
sheet.write(0, 30, "Proposed Tp", heading_xf)
|
1175 |
sheet.write(0, 30, "Proposed Tp", heading_xf)
|
| 1150 |
sheet.write(0, 31, "Avg Sale", heading_xf)
|
1176 |
sheet.write(0, 31, "Avg Sale", heading_xf)
|
| 1151 |
sheet.write(0, 32, "Sales History", heading_xf)
|
1177 |
sheet.write(0, 32, "Sales History", heading_xf)
|
| - |
|
1178 |
sheet.write(0, 33, "Decision", heading_xf)
|
| - |
|
1179 |
sheet.write(0, 34, "Reason", heading_xf)
|
| - |
|
1180 |
sheet.write(0, 35, "Updated Price", heading_xf)
|
| 1152 |
|
1181 |
|
| 1153 |
sheet_iterator = 1
|
1182 |
sheet_iterator = 1
|
| 1154 |
almostCompetitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.ALMOST_COMPETE).all()
|
1183 |
almostCompetitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.ALMOST_COMPETE).all()
|
| 1155 |
for almostCompetitiveItem in almostCompetitiveItems:
|
1184 |
for almostCompetitiveItem in almostCompetitiveItems:
|
| 1156 |
amScraping = almostCompetitiveItem[0]
|
1185 |
amScraping = almostCompetitiveItem[0]
|
| Line 1207... |
Line 1236... |
| 1207 |
sheet.write(sheet_iterator, 28, item.risky)
|
1236 |
sheet.write(sheet_iterator, 28, item.risky)
|
| 1208 |
sheet.write(sheet_iterator, 29, amScraping.proposedSp)
|
1237 |
sheet.write(sheet_iterator, 29, amScraping.proposedSp)
|
| 1209 |
sheet.write(sheet_iterator, 30, amScraping.proposedTp)
|
1238 |
sheet.write(sheet_iterator, 30, amScraping.proposedTp)
|
| 1210 |
sheet.write(sheet_iterator, 31, amScraping.avgSale)
|
1239 |
sheet.write(sheet_iterator, 31, amScraping.avgSale)
|
| 1211 |
sheet.write(sheet_iterator, 32, getOosString(saleMap.get(sku)))
|
1240 |
sheet.write(sheet_iterator, 32, getOosString(saleMap.get(sku)))
|
| - |
|
1241 |
if amScraping.decision is None:
|
| - |
|
1242 |
sheet.write(sheet_iterator, 33, 'Auto Pricing Inactive')
|
| - |
|
1243 |
sheet_iterator+=1
|
| - |
|
1244 |
continue
|
| - |
|
1245 |
sheet.write(sheet_iterator, 33, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
| - |
|
1246 |
sheet.write(sheet_iterator, 34, amScraping.reason)
|
| - |
|
1247 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
| - |
|
1248 |
sheet.write(sheet_iterator, 35, math.ceil(amScraping.proposedSellingPrice))
|
| - |
|
1249 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
| - |
|
1250 |
sheet.write(sheet_iterator, 35, math.ceil(amScraping.ourSellingPrice+max(10,.01*amScraping.ourSellingPrice)))
|
| 1212 |
sheet_iterator+=1
|
1251 |
sheet_iterator+=1
|
| 1213 |
|
1252 |
|
| 1214 |
sheet = wbk.add_sheet('Among Cheapest')
|
1253 |
sheet = wbk.add_sheet('Among Cheapest')
|
| 1215 |
xstr = lambda s: s or ""
|
1254 |
xstr = lambda s: s or ""
|
| 1216 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
1255 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| Line 1250... |
Line 1289... |
| 1250 |
sheet.write(0, 28, "Risky", heading_xf)
|
1289 |
sheet.write(0, 28, "Risky", heading_xf)
|
| 1251 |
sheet.write(0, 29, "Proposed Sp", heading_xf)
|
1290 |
sheet.write(0, 29, "Proposed Sp", heading_xf)
|
| 1252 |
sheet.write(0, 30, "Proposed Tp", heading_xf)
|
1291 |
sheet.write(0, 30, "Proposed Tp", heading_xf)
|
| 1253 |
sheet.write(0, 31, "Avg Sale", heading_xf)
|
1292 |
sheet.write(0, 31, "Avg Sale", heading_xf)
|
| 1254 |
sheet.write(0, 32, "Sales History", heading_xf)
|
1293 |
sheet.write(0, 32, "Sales History", heading_xf)
|
| - |
|
1294 |
sheet.write(0, 33, "Decision", heading_xf)
|
| - |
|
1295 |
sheet.write(0, 34, "Reason", heading_xf)
|
| - |
|
1296 |
sheet.write(0, 35, "Updated Price", heading_xf)
|
| 1255 |
|
1297 |
|
| 1256 |
sheet_iterator = 1
|
1298 |
sheet_iterator = 1
|
| 1257 |
amongCheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.AMONG_CHEAPEST_CAN_COMPETE).all()
|
1299 |
amongCheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.AMONG_CHEAPEST_CAN_COMPETE).all()
|
| 1258 |
for amongCheapestItem in amongCheapestItems:
|
1300 |
for amongCheapestItem in amongCheapestItems:
|
| 1259 |
amScraping = amongCheapestItem[0]
|
1301 |
amScraping = amongCheapestItem[0]
|
| Line 1301... |
Line 1343... |
| 1301 |
sheet.write(sheet_iterator, 28, item.risky)
|
1343 |
sheet.write(sheet_iterator, 28, item.risky)
|
| 1302 |
sheet.write(sheet_iterator, 29, amScraping.proposedSp)
|
1344 |
sheet.write(sheet_iterator, 29, amScraping.proposedSp)
|
| 1303 |
sheet.write(sheet_iterator, 30, amScraping.proposedTp)
|
1345 |
sheet.write(sheet_iterator, 30, amScraping.proposedTp)
|
| 1304 |
sheet.write(sheet_iterator, 31, amScraping.avgSale)
|
1346 |
sheet.write(sheet_iterator, 31, amScraping.avgSale)
|
| 1305 |
sheet.write(sheet_iterator, 32, getOosString(saleMap.get(sku)))
|
1347 |
sheet.write(sheet_iterator, 32, getOosString(saleMap.get(sku)))
|
| - |
|
1348 |
if amScraping.decision is None:
|
| - |
|
1349 |
sheet.write(sheet_iterator, 33, 'Auto Pricing Inactive')
|
| - |
|
1350 |
sheet_iterator+=1
|
| - |
|
1351 |
continue
|
| - |
|
1352 |
sheet.write(sheet_iterator, 33, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
| - |
|
1353 |
sheet.write(sheet_iterator, 34, amScraping.reason)
|
| - |
|
1354 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
| - |
|
1355 |
sheet.write(sheet_iterator, 35, math.ceil(amScraping.proposedSellingPrice))
|
| - |
|
1356 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
| - |
|
1357 |
sheet.write(sheet_iterator, 35, math.ceil(amScraping.ourSellingPrice+max(10,.01*amScraping.ourSellingPrice)))
|
| 1306 |
sheet_iterator+=1
|
1358 |
sheet_iterator+=1
|
| 1307 |
|
1359 |
|
| 1308 |
sheet = wbk.add_sheet('Cheapest')
|
1360 |
sheet = wbk.add_sheet('Cheapest')
|
| 1309 |
xstr = lambda s: s or ""
|
1361 |
xstr = lambda s: s or ""
|
| 1310 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
1362 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| Line 1345... |
Line 1397... |
| 1345 |
sheet.write(0, 29, "Proposed Sp", heading_xf)
|
1397 |
sheet.write(0, 29, "Proposed Sp", heading_xf)
|
| 1346 |
sheet.write(0, 30, "Proposed Tp", heading_xf)
|
1398 |
sheet.write(0, 30, "Proposed Tp", heading_xf)
|
| 1347 |
sheet.write(0, 31, "Margin Increased Potential", heading_xf)
|
1399 |
sheet.write(0, 31, "Margin Increased Potential", heading_xf)
|
| 1348 |
sheet.write(0, 32, "Avg Sale", heading_xf)
|
1400 |
sheet.write(0, 32, "Avg Sale", heading_xf)
|
| 1349 |
sheet.write(0, 33, "Sales History", heading_xf)
|
1401 |
sheet.write(0, 33, "Sales History", heading_xf)
|
| - |
|
1402 |
sheet.write(0, 34, "Decision", heading_xf)
|
| - |
|
1403 |
sheet.write(0, 35, "Reason", heading_xf)
|
| - |
|
1404 |
sheet.write(0, 36, "Updated Price", heading_xf)
|
| 1350 |
|
1405 |
|
| 1351 |
sheet_iterator = 1
|
1406 |
sheet_iterator = 1
|
| 1352 |
cheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.BUY_BOX).all()
|
1407 |
cheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.BUY_BOX).all()
|
| 1353 |
for cheapestItem in cheapestItems:
|
1408 |
for cheapestItem in cheapestItems:
|
| 1354 |
amScraping = cheapestItem[0]
|
1409 |
amScraping = cheapestItem[0]
|
| Line 1397... |
Line 1452... |
| 1397 |
sheet.write(sheet_iterator, 29, amScraping.proposedSp)
|
1452 |
sheet.write(sheet_iterator, 29, amScraping.proposedSp)
|
| 1398 |
sheet.write(sheet_iterator, 30, amScraping.proposedTp)
|
1453 |
sheet.write(sheet_iterator, 30, amScraping.proposedTp)
|
| 1399 |
sheet.write(sheet_iterator, 31, amScraping.targetNlc)
|
1454 |
sheet.write(sheet_iterator, 31, amScraping.targetNlc)
|
| 1400 |
sheet.write(sheet_iterator, 32, amScraping.avgSale)
|
1455 |
sheet.write(sheet_iterator, 32, amScraping.avgSale)
|
| 1401 |
sheet.write(sheet_iterator, 33, getOosString(saleMap.get(sku)))
|
1456 |
sheet.write(sheet_iterator, 33, getOosString(saleMap.get(sku)))
|
| - |
|
1457 |
if amScraping.decision is None:
|
| - |
|
1458 |
sheet.write(sheet_iterator, 34, 'Auto Pricing Inactive')
|
| - |
|
1459 |
sheet_iterator+=1
|
| - |
|
1460 |
continue
|
| - |
|
1461 |
sheet.write(sheet_iterator, 34, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
| - |
|
1462 |
sheet.write(sheet_iterator, 35, amScraping.reason)
|
| - |
|
1463 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
| - |
|
1464 |
sheet.write(sheet_iterator, 36, math.ceil(amScraping.proposedSellingPrice))
|
| - |
|
1465 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
| - |
|
1466 |
sheet.write(sheet_iterator, 36, math.ceil(amScraping.ourSellingPrice+max(10,.01*amScraping.ourSellingPrice)))
|
| 1402 |
sheet_iterator+=1
|
1467 |
sheet_iterator+=1
|
| 1403 |
|
1468 |
|
| 1404 |
sheet = wbk.add_sheet('Negative Margin')
|
1469 |
sheet = wbk.add_sheet('Negative Margin')
|
| 1405 |
xstr = lambda s: s or ""
|
1470 |
xstr = lambda s: s or ""
|
| 1406 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
1471 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| Line 1523... |
Line 1588... |
| 1523 |
sheet.write(sheet_iterator, 4, item.brand)
|
1588 |
sheet.write(sheet_iterator, 4, item.brand)
|
| 1524 |
sheet.write(sheet_iterator, 5, xstr(item.brand)+" "+xstr(item.model_name)+" "+xstr(item.model_number)+" "+xstr(item.color))
|
1589 |
sheet.write(sheet_iterator, 5, xstr(item.brand)+" "+xstr(item.model_name)+" "+xstr(item.model_number)+" "+xstr(item.color))
|
| 1525 |
sheet.write(sheet_iterator, 6, amScraping.reason)
|
1590 |
sheet.write(sheet_iterator, 6, amScraping.reason)
|
| 1526 |
sheet_iterator+=1
|
1591 |
sheet_iterator+=1
|
| 1527 |
|
1592 |
|
| - |
|
1593 |
|
| - |
|
1594 |
if (runType=='FULL'):
|
| - |
|
1595 |
sheet = wbk.add_sheet('Auto Favorites')
|
| - |
|
1596 |
|
| - |
|
1597 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| - |
|
1598 |
|
| - |
|
1599 |
excel_integer_format = '0'
|
| - |
|
1600 |
integer_style = xlwt.XFStyle()
|
| - |
|
1601 |
integer_style.num_format_str = excel_integer_format
|
| - |
|
1602 |
xstr = lambda s: s or ""
|
| - |
|
1603 |
|
| - |
|
1604 |
sheet.write(0, 0, "Item ID", heading_xf)
|
| - |
|
1605 |
sheet.write(0, 1, "Brand", heading_xf)
|
| - |
|
1606 |
sheet.write(0, 2, "Product Name", heading_xf)
|
| - |
|
1607 |
sheet.write(0, 3, "Auto Favourite", heading_xf)
|
| - |
|
1608 |
sheet.write(0, 4, "Reason", heading_xf)
|
| - |
|
1609 |
|
| - |
|
1610 |
sheet_iterator=1
|
| - |
|
1611 |
for autoFav in nowAutoFav:
|
| - |
|
1612 |
itemId = autoFav[0]
|
| - |
|
1613 |
reason = autoFav[1]
|
| - |
|
1614 |
it = Item.query.filter_by(id=itemId).one()
|
| - |
|
1615 |
sheet.write(sheet_iterator, 0, itemId)
|
| - |
|
1616 |
sheet.write(sheet_iterator, 1, it.brand)
|
| - |
|
1617 |
sheet.write(sheet_iterator, 2, xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color))
|
| - |
|
1618 |
sheet.write(sheet_iterator, 3, "True")
|
| - |
|
1619 |
sheet.write(sheet_iterator, 4, reason)
|
| - |
|
1620 |
sheet_iterator+=1
|
| - |
|
1621 |
for prevFav in previousAutoFav:
|
| - |
|
1622 |
it = Item.query.filter_by(id=prevFav).one()
|
| - |
|
1623 |
sheet.write(sheet_iterator, 0, prevFav)
|
| - |
|
1624 |
sheet.write(sheet_iterator, 1, it.brand)
|
| - |
|
1625 |
sheet.write(sheet_iterator, 2, xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color))
|
| - |
|
1626 |
sheet.write(sheet_iterator, 3, "False")
|
| - |
|
1627 |
sheet_iterator+=1
|
| - |
|
1628 |
|
| 1528 |
filename = "/tmp/amazon-scraping.xls"
|
1629 |
filename = "/tmp/amazon-scraping.xls"
|
| 1529 |
wbk.save(filename)
|
1630 |
wbk.save(filename)
|
| 1530 |
|
1631 |
|
| 1531 |
def main():
|
1632 |
def main():
|
| 1532 |
parser = optparse.OptionParser()
|
1633 |
parser = optparse.OptionParser()
|
| Line 1570... |
Line 1671... |
| 1570 |
commitCantCompete(cantCompete, timestamp,options.runType)
|
1671 |
commitCantCompete(cantCompete, timestamp,options.runType)
|
| 1571 |
exceptionList[:], negativeMargin[:], cheapest[:], amongCheapestAndCanCompete[:], canCompete[:], almostCompete[:], cantCompete[:] =[],[],[],[],[],[],[]
|
1672 |
exceptionList[:], negativeMargin[:], cheapest[:], amongCheapestAndCanCompete[:], canCompete[:], almostCompete[:], cantCompete[:] =[],[],[],[],[],[],[]
|
| 1572 |
autoDecreaseItems = fetchItemsForAutoDecrease(timestamp)
|
1673 |
autoDecreaseItems = fetchItemsForAutoDecrease(timestamp)
|
| 1573 |
autoIncreaseItems = fetchItemsForAutoIncrease(timestamp)
|
1674 |
autoIncreaseItems = fetchItemsForAutoIncrease(timestamp)
|
| 1574 |
previousAutoFav, nowAutoFav = markAutoFavourites(timestamp)
|
1675 |
previousAutoFav, nowAutoFav = markAutoFavourites(timestamp)
|
| 1575 |
writeReport(timestamp,autoDecreaseItems,autoIncreaseItems,previousAutoFav,nowAutoFav)
|
1676 |
writeReport(timestamp,autoDecreaseItems,autoIncreaseItems,previousAutoFav,nowAutoFav,options.runType)
|
| 1576 |
if __name__=='__main__':
|
1677 |
if __name__=='__main__':
|
| 1577 |
main()
|
1678 |
main()
|
| 1578 |
|
1679 |
|