Example #1
0
 def __init__(self, host, port, api_key, api_secret, per_token_hours_limit, per_ip_hours_limit, buffer_size, ip_address):
     r = _default_redis(host, port)
     self.req_count = _v1_req_count(r, api_key=api_key, api_secret=api_secret)
     self.req_ip_count = _ip_req_count(r)
     self.localIp = ip_address
     self.tk_alive = _v1_tk_alive(r, api_key=api_key, api_secret=api_secret)
     self.per_token_hours_limit = per_token_hours_limit
     self.per_ip_hours_limit = per_ip_hours_limit
     self.buffer_size = buffer_size
     self.api_key = api_key
     self.api_secret = api_secret
# -*- coding: utf-8 -*-

from tk_maintain import _default_redis, _v1_req_count, _v1_tk_alive, calibration_v1, \
                        API_KEY, API_SECRET, PER_TOKEN_HOURS_LIMIT


r = _default_redis()
req_count = _v1_req_count(r)
tk_alive = _v1_tk_alive(r)
calibration_v1(API_KEY, API_SECRET, req_count, tk_alive, PER_TOKEN_HOURS_LIMIT)

# windows cron jobs
# schtasks /create /sc minute /mo 5 /tn PythonTokenCalibrationTask /TR "C:\python27\python.exe E:\scrapy_weibo_v1\install\utils4scrapy-master\utils4scrapy\auto_calibration.py"
# schtasks /delete /tn PythonTokenCalibrationTask

# linux cron jobs
# cd /etc/crontab;
# vim /etc/crontab;
# */2 * * * * root cd /home/mirage/linhao/scrapy_weibo/install/utils4scrapy-master/utils4scrapy;python auto_calibration.py