From e307a5546e3907fd8fb7945733c540a5ca732ca9 Mon Sep 17 00:00:00 2001 From: "wangwenyan@fangjia.com" Date: Fri, 15 Jun 2018 10:14:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PriceSystem/CalcCmdSender.py | 37 +++++++++--------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/PriceSystem/CalcCmdSender.py b/PriceSystem/CalcCmdSender.py index 1da19ec..4d9bee0 100644 --- a/PriceSystem/CalcCmdSender.py +++ b/PriceSystem/CalcCmdSender.py @@ -1,24 +1,13 @@ -import json -import redis -import fangjia -import config import datetime +import json import sys import time -import pytz - from datetime import date +import redis - -def get_weekend(tt): - - from dateutil.parser import parse - bb=parse(tt) - pacific = pytz.timezone('Asia/Shanghai') - return pacific.localize(bb) - -weekend = get_weekend('20180527') +import config +import fangjia class CJsonEncoder(json.JSONEncoder): @@ -32,17 +21,13 @@ class CJsonEncoder(json.JSONEncoder): QUEUE = "calc_cmd" -#redisPool = redis.ConnectionPool(host=config.get_redis_host(), port=6379, db=config.get_redis_db()) -redisPool = redis.ConnectionPool(host=config.get_redis_host(), port=6379, db=9) - - - +redisPool = redis.ConnectionPool(host=config.get_redis_host(), port=6379, db=config.get_redis_db()) client = redis.Redis(connection_pool=redisPool) logger = fangjia.get_logger("CalcCmdSender") def get_district(city): - #weekend = fangjia.get_weekend() + weekend = fangjia.get_weekend() seaweeds = [] keys = {"city": 1, "region": 1, "name": 1, "_id": 0} for dis in fangjia.get_collection("fangjia", "seaweed", config.get_seaweed_host()).find({"cat": "district", "status": 0, "city": city}, keys): @@ -59,9 +44,7 @@ def send_cmd(seaweed): def send_district_calc_cmd(): - #for city in fangjia.get_all_city(): - for city in ['上海']: - + for city in fangjia.get_all_city(): for seaweed in get_district(city): send_cmd(seaweed) @@ -88,10 +71,8 @@ def save_city_calc_command(city, region, weekend): def send_city_calc_cmd(): - #weekend = fangjia.get_weekend() - - for city in ['上海']: - #for city in fangjia.get_all_city(): + weekend = fangjia.get_weekend() + for city in fangjia.get_all_city(): for region in fangjia.get_region(city): save_city_calc_command(city, region, weekend) save_city_calc_command(city, None, weekend)