Subversion Repositories SmartDukaan

Rev

Rev 18843 | Rev 18901 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18843 Rev 18896
Line 33... Line 33...
33
from dtr.dao import AppOfferObj, UserAppBatchDrillDown, UserAppBatchDateDrillDown
33
from dtr.dao import AppOfferObj, UserAppBatchDrillDown, UserAppBatchDateDrillDown
34
import base64
34
import base64
35
from falcon.util.uri import decode
35
from falcon.util.uri import decode
36
import MySQLdb
36
import MySQLdb
37
from shop2020.clients.CatalogClient import CatalogClient  
37
from shop2020.clients.CatalogClient import CatalogClient  
-
 
38
from pyquery import PyQuery as pq
-
 
39
 
38
alphalist = list(string.uppercase)
40
alphalist = list(string.uppercase)
39
alphalist.remove('O')
41
alphalist.remove('O')
40
numList = ['1','2','3','4','5','6','7','8','9']
42
numList = ['1','2','3','4','5','6','7','8','9']
41
codesys = [alphalist, alphalist, numList, numList, numList]
43
codesys = [alphalist, alphalist, numList, numList, numList]
42
CONTACT_PRIORITY = ['sms', 'called', 'ringing']
44
CONTACT_PRIORITY = ['sms', 'called', 'ringing']
Line 1571... Line 1573...
1571
                'JSON was incorrect.')
1573
                'JSON was incorrect.')
1572
            
1574
            
1573
        result = Mongo.dummyRegister(result_json)
1575
        result = Mongo.dummyRegister(result_json)
1574
        resp.body = json.dumps(result, encoding='utf-8')
1576
        resp.body = json.dumps(result, encoding='utf-8')
1575
 
1577
 
-
 
1578
class TinSearch:
-
 
1579
    def on_get(self,req,resp):
-
 
1580
        tin = req.get_param("tin")
-
 
1581
        result = getTinInfo(tin)
-
 
1582
        resp.body = json.dumps(result, encoding='utf-8')
-
 
1583
        
-
 
1584
 
-
 
1585
def getTinInfo(tin):
-
 
1586
    tinInfo = {}
-
 
1587
    try:
-
 
1588
        params = ['tin','cst','counter_name','counter_address','state','pan','registered_on','cst_status','valid_since','created']
-
 
1589
        url  = "http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber=" + tin + "&searchBy=TIN"
-
 
1590
        req = urllib2.Request(url)
-
 
1591
        connection = urllib2.urlopen(req)
-
 
1592
        pageHtml = connection.read()
-
 
1593
        connection.close()        
-
 
1594
        doc = pq(pageHtml)
-
 
1595
        index=-1
-
 
1596
        for ele in pq(doc.find('table')[2])('tr td:nth-child(2)'):
-
 
1597
            index += 1
-
 
1598
            text = pq(ele).text().strip()
-
 
1599
            if not text:
-
 
1600
                text = pq(ele)('div').text().strip()
-
 
1601
            tinInfo[params[index]] = text
-
 
1602
        if index != 9:
-
 
1603
            raise
-
 
1604
        print "TinNumber: Successfully fetched details", tin
-
 
1605
    except:
-
 
1606
        tinInfo = {"isError":True,
-
 
1607
                    "errorMsg": "Could not find tin"
-
 
1608
        }
-
 
1609
        print "TinNumber: Problem fetching details", tin
-
 
1610
    return tinInfo
-
 
1611
        
-
 
1612
        
1576
class UpdateUser:
1613
class UpdateUser:
1577
    def on_post(self,req,resp):
1614
    def on_post(self,req,resp):
1578
        try:
1615
        try:
1579
            result_json = json.loads(req.stream.read(), encoding='utf-8')
1616
            result_json = json.loads(req.stream.read(), encoding='utf-8')
1580
        except ValueError:
1617
        except ValueError: