def get_logger(logger): if logger is None: loggerDate = getDate.getToday() log_dir = createPath.mkdir(config.log_dir) got_logger = printLog.printLog(loggerDate, '', log_dir) return got_logger else: return logger
#coding:utf8 import os import sys BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(BASE_DIR) sys.dont_write_bytecode = True from Utils import getDate, printLog, createPath from conf import config import sendmessage import time loggerTime = getDate.getTime() today = getDate.getToday() log_dir = createPath.mkdir(config.log_dir) phone_dir = createPath.mkdir(config.data_dir + '/duanxin') logger = printLog.getLogger(loggerTime, 'duanxin', log_dir) messageFile = config.conf_dir + '/message.conf' resultFile = '%s/sent_%s.txt' % (phone_dir, loggerTime) failedFile = '%s/unsend_%s.txt' % (phone_dir, loggerTime) def getData(): ''' 读取号码文件 :param batch_phone_file: :return: ''' files = os.popen('ls %s/*%s.dat' % (phone_dir, today)) filelist = files.readlines()
def toRequest(self, phone): info = self.getInfo(phone) req = requests.session() if info != None: id = info["loginId"] alias = info["misassperId"] phoneNumber = info["phone"] agentType = info["agentType"] tenantId = info["shopId"] modifiedTime = getDate.getToday() print(str(phone) + "-------------------request start") header = { 'content-type': 'application/json', 'cookie': 'test=lalala' } url = "http://221.176.60.135:80/i/livechat-web-console/rest/agentSynchronousController/insertOrUpdateAgent" #这是公网ip访问 #url ="http://bd.shop.10086.cn/i/livechat-web-console/rest/agentSynchronousController/insertOrUpdateAgent?id=cecef80c12f54284b1a59be67df3c024&phoneNumber=13932176881&tenantId=1000047&agentType=1" if tenantId == None or tenantId == '-------': params = { "id": id, "alias": alias, "phoneNumber": phoneNumber, "tenantId": 1, "agentType": agentType, "modifiedBy": "15032609451", "modifiedTime": modifiedTime } else: params = { "id": id, "alias": alias, "phoneNumber": phoneNumber, "agentType": agentType, "tenantId": tenantId, "modifiedBy": "15032609451", "modifiedTime": modifiedTime } try: response = req.request(method='POST', params=params, url=url, headers=header, timeout=10, proxies=None) print(response.content) print "asd" except Exception as e: print("请求失败") #print type(json.loads(response.content)) #//dict # if json.loads(response)["retCode"] =="000000": # print("同步成功,结束") # return response # else: # print "同步未成功,请核查原因" else: print "请求参数信息为空,同步请求失败" return
#coding:utf8 import os import sys BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(BASE_DIR) sys.dont_write_bytecode = True from Utils import getDate, printLog, dbOper, createPath from conf import config import sendcard import sendEmail today = getDate.getToday() dataBase = config.ecora # 当前时间20180126-183918 loggerDate = getDate.getToday() # yesterday='20180125' class runMe(object): def __init__(self, pcard_name=None, logger=None): self.pcardName = pcard_name self.resData = createPath.mkdir(config.data_dir + '/' + pcard_name) self.logger = printLog.getLogger(loggerDate, pcard_name, createPath.mkdir(config.log_dir)) self.phoneFileName = pcard_name + today def getOptSeq(self): #返回券列表 # return ["1020171215941493862723223552_1320171215941493862966886400_991"]