From 0cc85766a4778167542f3ab90f6739937099a37b Mon Sep 17 00:00:00 2001 From: wenxianping <931128603@qq.com> Date: Thu, 3 Jan 2019 11:23:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9win=E5=AF=B9=E6=97=B6?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/AutoSynchroTime.py | 32 +++++++--------------------- inter/GetPassCodeNewOrderAndLogin.py | 2 +- inter/Query.py | 2 +- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/config/AutoSynchroTime.py b/config/AutoSynchroTime.py index 41dceb3..bd8d846 100644 --- a/config/AutoSynchroTime.py +++ b/config/AutoSynchroTime.py @@ -19,30 +19,14 @@ def autoSynchroTime(): print(u"系统当前时间{}".format(str(datetime.datetime.now())[:22])) system = platform.system() if system == "Windows": # windows 同步时间未测试过,参考地址:https://www.jianshu.com/p/92ec15da6cc3 - print(u"windeos系统暂时不提供自动对时功能,请手动同步北京时间") - # for host in hosts: - # - # try: - # - # response = c.request(host) - # - # if response: - # break - # - # except Exception as e: - # print(u"时区获取异常:{0}".format(e)) - # current_time = response.tx_time - # - # _date, _time = str(datetime.datetime.fromtimestamp(current_time))[:22].split(' ') - # print(u"北京标准时间", _date, _time) - # - # a, b, c = _time.split(':') - # - # c = float(c) + 0.5 - # - # _time = "%s:%s:%s" % (a, b, c) - # - # os.system('date %s && time %s' % (_date, _time)) + for host in hosts: + os.system('w32tm /register') + os.system('net start w32time') + os.system('w32tm /config /manualpeerlist:"{}" /syncfromflags:manual /reliable:yes /update'.format(host)) + os.system('ping -n 3 127.0.0.1 >nul') + sin = os.system('w32tm /resync') + if sin is 0: + break else: # mac同步地址,如果ntpdate未安装,brew install ntpdate linux 安装 yum install -y ntpdate for host in hosts: sin = os.system('ntpdate {}'.format(host)) diff --git a/inter/GetPassCodeNewOrderAndLogin.py b/inter/GetPassCodeNewOrderAndLogin.py index f94be46..3689d01 100644 --- a/inter/GetPassCodeNewOrderAndLogin.py +++ b/inter/GetPassCodeNewOrderAndLogin.py @@ -22,7 +22,7 @@ def getPassCodeNewOrderAndLogin(session, imgType): result = session.httpClint.send(codeImgUrl) try: if isinstance(result, dict): - print(u"下载验证码失败, 请手动检查是否ip被封,或者重试,请求地址:{}".format(codeImgUrl)) + print(u"下载验证码失败, 请手动检查是否ip被封,或者重试,请求地址:{}".format(codeImgUrl.get("req_url"))) return False else: print(u"下载验证码成功") diff --git a/inter/Query.py b/inter/Query.py index 9660b34..81d5239 100644 --- a/inter/Query.py +++ b/inter/Query.py @@ -94,7 +94,7 @@ class query: continue value = station_ticket.get("data", "") if not value: - print (u'{0}-{1} 车次坐席查询为空, 查询url: https://kyfw.12306.cn{2}, 可以手动查询是否有票'.format(self.from_station_h, + print (u'{0}-{1} 车次坐席查询为空,ip网络异常,查询url: https://kyfw.12306.cn{2}, 可以手动查询是否有票'.format(self.from_station_h, self.to_station_h, select_url["req_url"])) else: