-
Notifications
You must be signed in to change notification settings - Fork 152
/
easytrain.py
48 lines (41 loc) · 1.57 KB
/
easytrain.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import time
from Configure import *
from define.Const import SEAT_TYPE
from train.login.Login import Login
from train.query.Query import Query
from train.submit.Submit import Submit
from utils import TrainUtils
from utils import Utils
from utils.Log import Log
def main():
login = Login()
Log.v('正在登录...')
result, msg = login.login(USER_NAME, USER_PWD)
if not Utils.check(result, msg):
Log.e(msg)
return
Log.v('%s,登录成功' % msg)
seatTypesCode = SEAT_TYPE_CODE if SEAT_TYPE_CODE else [SEAT_TYPE[key] for key in SEAT_TYPE.keys()]
passengerTypeCode = PASSENGER_TYPE_CODE if PASSENGER_TYPE_CODE else '1'
while True:
# 死循环一直查票,直到下单成功
try:
print('-' * 40)
ticketDetails = Query.loopQuery(TRAIN_DATE, FROM_STATION, TO_STATION,
TrainUtils.passengerType2Desc(passengerTypeCode),
TRAINS_NO,
seatTypesCode)
Log.v('已为您查询到可用余票:%s' % ticketDetails)
ticketDetails.passengersId = PASSENGERS_ID
ticketDetails.ticketTypeCodes = passengerTypeCode
ticketDetails.tourFlag = TOUR_FLAG if TOUR_FLAG else 'dc'
submit = Submit(ticketDetails)
if submit.submit():
submit.showSubmitInfoPretty()
break
time.sleep(1)
except Exception as e:
Log.w(e)
print(login.loginOut())
if __name__ == '__main__':
main()