| Line 81... |
Line 81... |
| 81 |
|
81 |
|
| 82 |
def login(url):
|
82 |
def login(url):
|
| 83 |
br = getBrowserObject()
|
83 |
br = getBrowserObject()
|
| 84 |
br.open(url)
|
84 |
br.open(url)
|
| 85 |
response = br.open(url)
|
85 |
response = br.open(url)
|
| - |
|
86 |
ungzipResponse(response, br)
|
| 86 |
br.select_form(nr=0)
|
87 |
br.select_form(name="pgLogin:navbar")
|
| 87 |
br.form['username'] = "saholic-snapdeal@saholic.com"
|
88 |
br.form['pgLogin:navbar:txtUserName'] = "saholic-snapdeal@saholic.com"
|
| 88 |
br.form['password'] = "snapsaholic15"
|
89 |
br.form['pgLogin:navbar:txtPassword'] = "snapsaholic15"
|
| 89 |
print "Trying to login"
|
90 |
print "Trying to login"
|
| 90 |
response = br.submit()
|
91 |
response = br.submit()
|
| 91 |
return br
|
92 |
return br
|
| 92 |
|
93 |
|
| - |
|
94 |
def ungzipResponse(r,b):
|
| - |
|
95 |
headers = r.info()
|
| - |
|
96 |
if headers['Content-Encoding']=='gzip':
|
| - |
|
97 |
import gzip
|
| - |
|
98 |
print "********************"
|
| - |
|
99 |
print "Deflating gzip response"
|
| - |
|
100 |
print "********************"
|
| - |
|
101 |
gz = gzip.GzipFile(fileobj=r, mode='rb')
|
| - |
|
102 |
html = gz.read()
|
| - |
|
103 |
gz.close()
|
| - |
|
104 |
headers["Content-type"] = "text/html; charset=utf-8"
|
| - |
|
105 |
r.set_data( html )
|
| - |
|
106 |
b.set_response(r)
|
| - |
|
107 |
|
| - |
|
108 |
|
| 93 |
def populateStuff(br):
|
109 |
def populateStuff(br):
|
| 94 |
exceptionList = []
|
110 |
exceptionList = []
|
| 95 |
fetchedItems = []
|
111 |
fetchedItems = []
|
| 96 |
items = session.query(SnapdealItem,MarketplaceItems,Item).join((MarketplaceItems,SnapdealItem.item_id==MarketplaceItems.itemId)).join((Item,SnapdealItem.item_id==Item.id)).filter(MarketplaceItems.source==OrderSource.SNAPDEAL).all()
|
112 |
items = session.query(SnapdealItem,MarketplaceItems,Item).join((MarketplaceItems,SnapdealItem.item_id==MarketplaceItems.itemId)).join((Item,SnapdealItem.item_id==Item.id)).filter(MarketplaceItems.source==OrderSource.SNAPDEAL).all()
|
| 97 |
#items = session.query(SnapdealItem,MarketplaceItems,Item).join((MarketplaceItems,SnapdealItem.item_id==MarketplaceItems.itemId)).join((Item,SnapdealItem.item_id==Item.id)).filter(SnapdealItem.item_id==12613).filter(MarketplaceItems.source==OrderSource.SNAPDEAL).all()
|
113 |
#items = session.query(SnapdealItem,MarketplaceItems,Item).join((MarketplaceItems,SnapdealItem.item_id==MarketplaceItems.itemId)).join((Item,SnapdealItem.item_id==Item.id)).filter(SnapdealItem.item_id==12613).filter(MarketplaceItems.source==OrderSource.SNAPDEAL).all()
|
| Line 618... |
Line 634... |
| 618 |
except:
|
634 |
except:
|
| 619 |
print "Error: unable to send email."
|
635 |
print "Error: unable to send email."
|
| 620 |
|
636 |
|
| 621 |
def main():
|
637 |
def main():
|
| 622 |
print "Opening snapdeal seller login page"
|
638 |
print "Opening snapdeal seller login page"
|
| 623 |
br = login("http://selleraccounts.snapdeal.com/")
|
639 |
br = login("http://sellers.snapdeal.com/")
|
| 624 |
exceptionList, fetchedItems = populateStuff(br)
|
640 |
exceptionList, fetchedItems = populateStuff(br)
|
| 625 |
filteredData = filterData(fetchedItems)
|
641 |
filteredData = filterData(fetchedItems)
|
| 626 |
sendMail(filteredData,exceptionList)
|
642 |
sendMail(filteredData,exceptionList)
|
| 627 |
write_report(filteredData,exceptionList)
|
643 |
write_report(filteredData,exceptionList)
|
| 628 |
syncCourierCost(courierCostToSync)
|
644 |
syncCourierCost(courierCostToSync)
|