#!/usr/bin/python
#coding=utf-8
import urllib2
import urllib
import sys
import json
import Logger
reload(sys)
sys.setdefaultencoding('utf8')
logger = Logger.getLogger("IsInInstallQueue.py")
class RestCall(object):
def __init__(self, url, data,param):
self.url = url
self.data = data
self.param=param
def get(self):
req = urllib2.Request(self.url)
try:
resp = urllib2.urlopen(req)
except urllib2.HTTPError, error:
print "Cannot remove service instance!", error
logger.info(self.param)
sys.exit(1)
response = resp.read()
return response
def post(self):
data = urllib.urlencode(self.data)
req = urllib2.Request(self.url, data)
try:
resp = urllib2.urlopen(req)
except urllib2.HTTPError, error:
logger.info(self.param)
logger.info(error)
sys.exit(1)
response = resp.read()
return response
def main(data,url,param):
# print data
rc = RestCall(
url = url,
data = data,
param=param
)
result=rc.post()
result_obj= json.loads(result)
return result_obj
if __name__ == "__main__":
data={}
# print "111"
result= main(data,url,'ReportConfig')
print result
# result_obj = json.load(result)
# a=json.dumps(result)
# test=json.loads(a)
# print str(test['data']['result'])
# result_obj = json.load(result)
# print result_obj
# result_obj=json.load(result_json)
# print result_obj['data']['result']