def main(): #主函数入口 Config = HandleConfig() today = (datetime.datetime.now() - datetime.timedelta(days=1)).strftime("%Y-%m-%d") redispool = redis.ConnectionPool(host=Config.RedisIp, port=6379, db=0) redata = redis.Redis(connection_pool=redispool) mongoconn = MongoClient(Config.MongodbIp, 27017) mysql_conn = MySQLdb.connect(host=Config.MysqldbIp, user=Config.MysqlUser, port=Config.MysqldbPort, passwd=Config.MysqlPassword, db=Config.MysqlDbname, charset="utf8") logger = getLog("Step6", logfile=Config.LogFile, loglevel=Config.LogLevel) logger.info("Step6 Handle Start") set_alluser = redata.smembers("user_info") list_user = list(set_alluser) for i in list_user: uidObj = UidInfo(mysql_conn, mongoconn, i) CheckSpace(Config, uidObj, Mail_list, redata, today, logger) logger.info("Step6 Handle End")
def main(): Config = HandleConfig() redispool = redis.ConnectionPool(host=Config.RedisIp, port=6379, db=0) redata = redis.Redis(connection_pool=redispool) mongoconn = MongoClient(Config.MongodbIp, 27017) #mysql_conn = MySQLdb.connect(host=Config.MysqldbIp,user=Config.MysqlUser,port=Config.MysqldbPort,passwd=Config.MysqlPassword,db=Config.MysqlDbname,charset="utf8") logger = getLog("Step7", logfile=Config.LogFile, loglevel=Config.LogLevel) logger.info("Step7 Handle Start") datadate = Config.date queue = Queue.Queue(0) list_user = list(redata.smembers("user_info")) for i in range(Config.workers): worker_obj = WriteDefaultPlaylist(datadate, queue, mongoconn, redata, Config, logger) worker_obj.setDaemon(True) worker_obj.start() for item in list_user: print item queue.put(item) queue.join() logger.info("Step7 Handle End")
def __init__(self, mysqlconn, mongodbconn, vid): self.vid = vid self.mysqlconn = mysqlconn self.mongodbconn = mongodbconn self.cursor = self.mysqlconn.cursor() Config = HandleConfig() self.mongodbName = Config.MongodbName
# --/ # 基础数据是否存在于redis # --/ def isExists(logger,redpipe,datadate): redpipe.exists("T_VIDS_%s"%datadate) for bvalue in redpipe.execute(): if bvalue == False: return False return True try: Config = HandleConfig() logger = getLog("Step3",logfile=Config.LogFile,loglevel=Config.LogLevel) logger.info("Step3 Handle Start") datadate = Config.date redispool = redis.ConnectionPool(host=Config.RedisIp,port=6379,db=0) redata = redis.Redis(connection_pool=redispool) redpipe = redata.pipeline() if not isExists(logger,redpipe,datadate): logger.error("Does not satisfy the data processing requirements") sys.exit(Config.EX_CODE_3)