예제 #1
0
파일: http_utils.py 프로젝트: godvmxi/demos
    def __getData(self,url):
        response  = urllib2.urlopen(url)

        # print response.info()
        #print response.geturl()
        if response.getcode() != 200:
            return None
        page = response.read()

        jsonDat = json.loads(page)
        body =  jsonDat["body"]
        httpSign =  jsonDat["sign"]
        oid =  None
        try :
            oid =  jsonDat["oid"]
        except :
            oid = None
        calSign  = HashUtils.calMd5hash(body)
        # print httpSign
        # print calSign
        result =  cmp(httpSign,calSign)


        if result == 0:
            return (body,oid)
        else :
            return None
예제 #2
0
파일: http_utils.py 프로젝트: godvmxi/demos
    def post(self,cmdHeader,cmdData):
        cmdAll = {
            "header":cmdHeader,
            "content" : cmdData
        }
        rawStr =  json.dumps(cmdAll)
        sign =  HashUtils.calMd5hash(rawStr)
        jsonData = {
            "sign": sign,
            "body" : rawStr
        }

        print jsonData
        result   = self.__postData(json.dumps(jsonData) )
        print "+++++++++++++>",result
        return