def re_subscription(self, sim): logging.info("[LBMP] Terminal: %s not reply sms, Re_subscription it.", sim) # args = dict(id="ZSCLGZ", # pwd="ZSCLGZ20120920", # serviceid="ZSCLGZ", # appName="ACB", # area="0760") args = dict(id="zsds20120224", pwd="zsds20120224", serviceid="zsds", appName="acb", area="0760") args['phoneNum'] = sim args['action'] = "D" sc = SubscriptionComposer(args) response = self.send(ConfHelper.LBMP_CONF.zs_host, ConfHelper.LBMP_CONF.zs_subscription_url, sc.get_request()) sp = SubscriptionParser(response) if sp.success == '000': logging.info("[LBMP] Cancel Subscription mobile: %s success!", sim) logging.info("[LBMP] Re_Subscription mobile: %s start...", sim) args['action'] = "A" sc = SubscriptionComposer(args) response = self.send(ConfHelper.LBMP_CONF.zs_host, ConfHelper.LBMP_CONF.zs_subscription_url, sc.get_request()) sp = SubscriptionParser(response) if sp.success == '000': logging.info("[LBMP] Re_Subscription mobile: %s success!", sim) else: logging.info("[LBMP] Re_Subscription mobile: %s faild!", sim) else: logging.info("[LBMP] Cancel Subscription mobile: %s faild!", sim)
def _on_finish(): try: sc = SubscriptionComposer(args) logging.debug("Subscription request:\n%s", sc.get_request()) response = self.send(ConfHelper.LBMP_CONF.zs_host, ConfHelper.LBMP_CONF.zs_subscription_url, sc.get_request()) logging.debug("Subscription response:\n%s", response.decode('utf-8')) sp = SubscriptionParser(response) ret.success = sp.success ret.info = sp.info except Exception as e: logging.exception("Subscription error: %s", e.args) self.write(ret) IOLoop.instance().add_callback(self.finish)