pull/2/head
wenxianping 2018-01-11 13:20:39 +08:00
parent fdba481ee5
commit e5b16fe778
3 changed files with 456 additions and 178 deletions

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="79a86edc-721f-4aad-920d-b595d0348b7f" name="Default" comment="fix"> <list default="true" id="79a86edc-721f-4aad-920d-b595d0348b7f" name="Default" comment="转码">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/agency/agency_tools.py" afterPath="$PROJECT_DIR$/agency/agency_tools.py" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/config/ticket_config.yaml" afterPath="$PROJECT_DIR$/config/ticket_config.yaml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/init/select_ticket_info.py" afterPath="$PROJECT_DIR$/init/select_ticket_info.py" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/init/select_ticket_info.py" afterPath="$PROJECT_DIR$/init/select_ticket_info.py" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@ -25,7 +25,7 @@
<SUITE FILE_PATH="coverage/12306$ticketConf.coverage" NAME="ticketConf Coverage Results" MODIFIED="1515140061195" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/yixing/config" /> <SUITE FILE_PATH="coverage/12306$ticketConf.coverage" NAME="ticketConf Coverage Results" MODIFIED="1515140061195" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/yixing/config" />
<SUITE FILE_PATH="coverage/12306$login.coverage" NAME="login Coverage Results" MODIFIED="1501571219088" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/yixing/init" /> <SUITE FILE_PATH="coverage/12306$login.coverage" NAME="login Coverage Results" MODIFIED="1501571219088" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/yixing/init" />
<SUITE FILE_PATH="coverage/12306$tiket.coverage" NAME="tiket Coverage Results" MODIFIED="1495973122962" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/yixing" /> <SUITE FILE_PATH="coverage/12306$tiket.coverage" NAME="tiket Coverage Results" MODIFIED="1495973122962" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/yixing" />
<SUITE FILE_PATH="coverage/12306$run__1_.coverage" NAME="run (1) Coverage Results" MODIFIED="1515404440456" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" /> <SUITE FILE_PATH="coverage/12306$run__1_.coverage" NAME="run (1) Coverage Results" MODIFIED="1515637863079" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/12306$haha.coverage" NAME="haha Coverage Results" MODIFIED="1515250987704" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/yixing" /> <SUITE FILE_PATH="coverage/12306$haha.coverage" NAME="haha Coverage Results" MODIFIED="1515250987704" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/yixing" />
<SUITE FILE_PATH="coverage/12306$12306.coverage" NAME="12306 Coverage Results" MODIFIED="1495722251078" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" /> <SUITE FILE_PATH="coverage/12306$12306.coverage" NAME="12306 Coverage Results" MODIFIED="1495722251078" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component> </component>
@ -64,8 +64,8 @@
<file leaf-file-name="run.py" pinned="false" current-in-tab="false"> <file leaf-file-name="run.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/run.py"> <entry file="file://$PROJECT_DIR$/run.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="112"> <state relative-caret-position="84">
<caret line="8" column="5" lean-forward="false" selection-start-line="8" selection-start-column="5" selection-end-line="8" selection-end-column="5" /> <caret line="6" column="33" lean-forward="false" selection-start-line="6" selection-start-column="33" selection-end-line="6" selection-end-column="33" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -86,9 +86,11 @@
<file leaf-file-name="select_ticket_info.py" pinned="false" current-in-tab="true"> <file leaf-file-name="select_ticket_info.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/init/select_ticket_info.py"> <entry file="file://$PROJECT_DIR$/init/select_ticket_info.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="97"> <state relative-caret-position="446">
<caret line="219" column="86" lean-forward="false" selection-start-line="219" selection-start-column="84" selection-end-line="219" selection-end-column="86" /> <caret line="673" column="0" lean-forward="true" selection-start-line="673" selection-start-column="0" selection-end-line="673" selection-end-column="0" />
<folding /> <folding>
<element signature="e#23#34#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
@ -96,8 +98,18 @@
<file leaf-file-name="ticket_config.yaml" pinned="false" current-in-tab="false"> <file leaf-file-name="ticket_config.yaml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/config/ticket_config.yaml"> <entry file="file://$PROJECT_DIR$/config/ticket_config.yaml">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="459"> <state relative-caret-position="574">
<caret line="47" column="21" lean-forward="true" selection-start-line="47" selection-start-column="21" selection-end-line="47" selection-end-column="21" /> <caret line="41" column="10" lean-forward="false" selection-start-line="41" selection-start-column="10" selection-end-line="41" selection-end-column="10" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="requirements.txt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/requirements.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="70">
<caret line="5" column="6" lean-forward="false" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="6" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -124,11 +136,6 @@
</component> </component>
<component name="FindInProjectRecents"> <component name="FindInProjectRecents">
<findStrings> <findStrings>
<find>dateEdit_2</find>
<find>today</find>
<find>车次作息查询为空</find>
<find>出票成功</find>
<find>set_type</find>
<find>SNH</find> <find>SNH</find>
<find>DTO</find> <find>DTO</find>
<find>\u4e0a\u6d77</find> <find>\u4e0a\u6d77</find>
@ -152,10 +159,22 @@
<find>正在执行第1次查询</find> <find>正在执行第1次查询</find>
<find>正在执行</find> <find>正在执行</find>
<find>select_refresh_interval</find> <find>select_refresh_interval</find>
<find>出票失败</find>
<find>检查到有未支付的订单,程序自动停止</find>
<find>正在等待中</find>
<find>正在尝试</find>
<find>confirmSingleForQueue</find>
<find>checkOrderInfo'</find>
<find>leftTicketLog</find>
</findStrings> </findStrings>
</component> </component>
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="master" />
</map>
</option>
</component> </component>
<component name="IdeDocumentHistory"> <component name="IdeDocumentHistory">
<option name="CHANGED_PATHS"> <option name="CHANGED_PATHS">
@ -182,7 +201,6 @@
<option value="$PROJECT_DIR$/yixing/myUrllib/myurllib2.py" /> <option value="$PROJECT_DIR$/yixing/myUrllib/myurllib2.py" />
<option value="$PROJECT_DIR$/yixing/myException/ticketIsExitsException.py" /> <option value="$PROJECT_DIR$/yixing/myException/ticketIsExitsException.py" />
<option value="$PROJECT_DIR$/yixing/requirements.txt" /> <option value="$PROJECT_DIR$/yixing/requirements.txt" />
<option value="$PROJECT_DIR$/README.md" />
<option value="$PROJECT_DIR$/yixing/run.py" /> <option value="$PROJECT_DIR$/yixing/run.py" />
<option value="$PROJECT_DIR$/yixing/config/ticket_config.yaml" /> <option value="$PROJECT_DIR$/yixing/config/ticket_config.yaml" />
<option value="$PROJECT_DIR$/yixing/init/select_ticket_info.py" /> <option value="$PROJECT_DIR$/yixing/init/select_ticket_info.py" />
@ -192,6 +210,7 @@
<option value="$PROJECT_DIR$/myException/ticketNumOutException.py" /> <option value="$PROJECT_DIR$/myException/ticketNumOutException.py" />
<option value="$PROJECT_DIR$/damatuCode/damatuWeb.py" /> <option value="$PROJECT_DIR$/damatuCode/damatuWeb.py" />
<option value="$PROJECT_DIR$/.gitignore" /> <option value="$PROJECT_DIR$/.gitignore" />
<option value="$PROJECT_DIR$/README.md" />
<option value="$PROJECT_DIR$/config/ticket_config.yaml" /> <option value="$PROJECT_DIR$/config/ticket_config.yaml" />
<option value="$PROJECT_DIR$/init/select_ticket_info.py" /> <option value="$PROJECT_DIR$/init/select_ticket_info.py" />
</list> </list>
@ -251,6 +270,11 @@
<item name="12306" type="462c0819:PsiDirectoryNode" /> <item name="12306" type="462c0819:PsiDirectoryNode" />
<item name="init" type="462c0819:PsiDirectoryNode" /> <item name="init" type="462c0819:PsiDirectoryNode" />
</path> </path>
<path>
<item name="12306" type="b2602c69:ProjectViewProjectNode" />
<item name="12306" type="462c0819:PsiDirectoryNode" />
<item name="myUrllib" type="462c0819:PsiDirectoryNode" />
</path>
</expand> </expand>
<select /> <select />
</subPane> </subPane>
@ -267,15 +291,15 @@
<property name="SearchEverywhereHistoryKey" value="&#9;FILE&#9;file://D:/my_work/12306/yixing/12306.py" /> <property name="SearchEverywhereHistoryKey" value="&#9;FILE&#9;file://D:/my_work/12306/yixing/12306.py" />
</component> </component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/yixing/config" />
</key>
<key name="CopyFile.RECENT_KEYS"> <key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/uml" />
<recent name="$PROJECT_DIR$/myException" /> <recent name="$PROJECT_DIR$/myException" />
<recent name="$PROJECT_DIR$" /> <recent name="$PROJECT_DIR$" />
<recent name="$PROJECT_DIR$/yixing/myUrllib" /> <recent name="$PROJECT_DIR$/yixing/myUrllib" />
<recent name="D:\my_work\12306" /> <recent name="D:\my_work\12306" />
<recent name="D:\my_work\12306\12306login" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/yixing/config" />
</key> </key>
</component> </component>
<component name="RunDashboard"> <component name="RunDashboard">
@ -753,23 +777,110 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1515562610299</updated> <updated>1515562610299</updated>
</task> </task>
<option name="localTasksCounter" value="17" /> <task id="LOCAL-00017" summary="转码">
<created>1515562865714</created>
<option name="number" value="00017" />
<option name="presentableId" value="LOCAL-00017" />
<option name="project" value="LOCAL" />
<updated>1515562865714</updated>
</task>
<task id="LOCAL-00018" summary="优化查询速度">
<created>1515569033305</created>
<option name="number" value="00018" />
<option name="presentableId" value="LOCAL-00018" />
<option name="project" value="LOCAL" />
<updated>1515569033305</updated>
</task>
<task id="LOCAL-00019" summary="fix">
<created>1515576348917</created>
<option name="number" value="00019" />
<option name="presentableId" value="LOCAL-00019" />
<option name="project" value="LOCAL" />
<updated>1515576348917</updated>
</task>
<task id="LOCAL-00020" summary="转码">
<created>1515576545344</created>
<option name="number" value="00020" />
<option name="presentableId" value="LOCAL-00020" />
<option name="project" value="LOCAL" />
<updated>1515576545344</updated>
</task>
<task id="LOCAL-00021" summary="gix">
<created>1515576601373</created>
<option name="number" value="00021" />
<option name="presentableId" value="LOCAL-00021" />
<option name="project" value="LOCAL" />
<updated>1515576601373</updated>
</task>
<task id="LOCAL-00022" summary="优化登录订票流程">
<created>1515584182647</created>
<option name="number" value="00022" />
<option name="presentableId" value="LOCAL-00022" />
<option name="project" value="LOCAL" />
<updated>1515584182647</updated>
</task>
<task id="LOCAL-00023" summary="优化查询逻辑">
<created>1515591131460</created>
<option name="number" value="00023" />
<option name="presentableId" value="LOCAL-00023" />
<option name="project" value="LOCAL" />
<updated>1515591131460</updated>
</task>
<task id="LOCAL-00024" summary="test">
<created>1515592719036</created>
<option name="number" value="00024" />
<option name="presentableId" value="LOCAL-00024" />
<option name="project" value="LOCAL" />
<updated>1515592719036</updated>
</task>
<task id="LOCAL-00025" summary="优化排队效率">
<created>1515595011159</created>
<option name="number" value="00025" />
<option name="presentableId" value="LOCAL-00025" />
<option name="project" value="LOCAL" />
<updated>1515595011159</updated>
</task>
<task id="LOCAL-00026" summary="排队订单sleep逻辑修改&#10;判断联系人不在列表给出提示">
<created>1515640001295</created>
<option name="number" value="00026" />
<option name="presentableId" value="LOCAL-00026" />
<option name="project" value="LOCAL" />
<updated>1515640001295</updated>
</task>
<task id="LOCAL-00027" summary="fix">
<created>1515640516193</created>
<option name="number" value="00027" />
<option name="presentableId" value="LOCAL-00027" />
<option name="project" value="LOCAL" />
<updated>1515640516193</updated>
</task>
<option name="localTasksCounter" value="28" />
<servers /> <servers />
</component> </component>
<component name="TodoView">
<todo-panel id="selected-file">
<is-autoscroll-to-source value="true" />
</todo-panel>
<todo-panel id="all">
<are-packages-shown value="true" />
<is-autoscroll-to-source value="true" />
</todo-panel>
</component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="0" y="0" width="1440" height="900" extended-state="0" /> <frame x="0" y="0" width="1440" height="900" extended-state="0" />
<editor active="true" /> <editor active="true" />
<layout> <layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.1702432" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32889965" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.5465538" sideWeight="0.50429183" order="7" side_tool="true" content_ui="tabs" /> <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.5465538" sideWeight="0.50429183" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.54413545" sideWeight="0.49570817" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.54413545" sideWeight="0.49570817" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32889965" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32889965" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.48004836" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32889965" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.24964234" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32889965" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32889965" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.7315599" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.1702432" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32889965" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.24964234" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3808948" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297568" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" /> <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297568" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Data View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297568" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Data View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3297568" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" /> <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
@ -778,7 +889,6 @@
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Coverage" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="true" content_ui="tabs" /> <window_info id="Coverage" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="true" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" /> <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32889965" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout> </layout>
<layout-to-restore> <layout-to-restore>
@ -819,6 +929,17 @@
<option name="RECENTLY_FILTERED_BRANCH_GROUPS"> <option name="RECENTLY_FILTERED_BRANCH_GROUPS">
<collection /> <collection />
</option> </option>
<option name="FILTERS">
<map>
<entry key="branch">
<value>
<list>
<option value="master" />
</list>
</value>
</entry>
</map>
</option>
<option name="COLUMN_ORDER"> <option name="COLUMN_ORDER">
<list> <list>
<option value="0" /> <option value="0" />
@ -849,22 +970,24 @@
<MESSAGE value="优化订购车票流程" /> <MESSAGE value="优化订购车票流程" />
<MESSAGE value="1、12306接口无响应的时候给出合理提示&#10;2、优化订票排队时间" /> <MESSAGE value="1、12306接口无响应的时候给出合理提示&#10;2、优化订票排队时间" />
<MESSAGE value="更改冗余目录结构" /> <MESSAGE value="更改冗余目录结构" />
<MESSAGE value="优化查询速度" />
<MESSAGE value="转码" />
<MESSAGE value="gix" />
<MESSAGE value="优化登录订票流程" />
<MESSAGE value="优化查询逻辑" />
<MESSAGE value="test" />
<MESSAGE value="优化排队效率" />
<MESSAGE value="排队订单sleep逻辑修改&#10;判断联系人不在列表给出提示" />
<MESSAGE value="fix" /> <MESSAGE value="fix" />
<option name="LAST_COMMIT_MESSAGE" value="fix" /> <option name="LAST_COMMIT_MESSAGE" value="fix" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
<option name="time" value="18" /> <option name="time" value="39" />
</breakpoint-manager> </breakpoint-manager>
<watches-manager /> <watches-manager />
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/yixing/test" />
<entry file="file://$USER_HOME$/.PyCharm2016.3/system/python_stubs/-762174762/PyQt5/QtCore/pyqtBoundSignal.py" />
<entry file="file://$USER_HOME$/.PyCharm2016.3/system/python_stubs/-762174762/PyQt5/QtWidgets/QColorDialog.py" />
<entry file="file://$USER_HOME$/.PyCharm2016.3/system/python_stubs/-762174762/PyQt5/Qt.py" />
<entry file="file://$USER_HOME$/.PyCharm2016.3/system/python_stubs/-762174762/PyQt5/QtWidgets/QGridLayout.py" />
<entry file="file://$PROJECT_DIR$/yixing/ChildrenForm.py" />
<entry file="file://$USER_HOME$/.PyCharm2016.3/system/python_stubs/-762174762/PyQt5/QtWidgets/QDateTimeEdit.py" /> <entry file="file://$USER_HOME$/.PyCharm2016.3/system/python_stubs/-762174762/PyQt5/QtWidgets/QDateTimeEdit.py" />
<entry file="file://$USER_HOME$/.PyCharm2016.3/system/python_stubs/-762174762/PyQt5/QtWidgets/QWidget.py" /> <entry file="file://$USER_HOME$/.PyCharm2016.3/system/python_stubs/-762174762/PyQt5/QtWidgets/QWidget.py" />
<entry file="file://$USER_HOME$/.PyCharm2016.3/system/python_stubs/-762174762/PySide/QtGui/QTextTable.py" /> <entry file="file://$USER_HOME$/.PyCharm2016.3/system/python_stubs/-762174762/PySide/QtGui/QTextTable.py" />
@ -958,22 +1081,45 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/README.md"> <entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="126"> <state relative-caret-position="28">
<caret line="9" column="38" lean-forward="false" selection-start-line="9" selection-start-column="38" selection-end-line="9" selection-end-column="38" /> <caret line="2" column="6" lean-forward="false" selection-start-line="2" selection-start-column="6" selection-end-line="2" selection-end-column="6" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/run.py"> <entry file="file://$PROJECT_DIR$/uml/uml.png">
<provider selected="true" editor-type-id="images">
<state />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="112"> <state relative-caret-position="266">
<caret line="8" column="5" lean-forward="false" selection-start-line="8" selection-start-column="5" selection-end-line="8" selection-end-column="5" /> <caret line="22" column="77" lean-forward="false" selection-start-line="22" selection-start-column="77" selection-end-line="22" selection-end-column="77" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/myException/ticketIsExitsException.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/init/login.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="29" column="24" lean-forward="false" selection-start-line="29" selection-start-column="24" selection-end-line="29" selection-end-column="24" />
<folding>
<element signature="e#41#54#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config/ticketConf.py"> <entry file="file://$PROJECT_DIR$/config/ticketConf.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="168"> <state relative-caret-position="168">
@ -984,26 +1130,26 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/.gitignore"> <entry file="file://$PROJECT_DIR$/station_name.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="28">
<caret line="2" column="6" lean-forward="false" selection-start-line="2" selection-start-column="6" selection-end-line="2" selection-end-column="6" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/myException/ticketNumOutException.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="0">
<caret line="0" column="27" lean-forward="false" selection-start-line="0" selection-start-column="27" selection-end-line="0" selection-end-column="27" /> <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/config/ticket_config.yaml"> <entry file="file://$PROJECT_DIR$/requirements.txt">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="459"> <state relative-caret-position="70">
<caret line="47" column="21" lean-forward="true" selection-start-line="47" selection-start-column="21" selection-end-line="47" selection-end-column="21" /> <caret line="5" column="6" lean-forward="false" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="6" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/run.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="84">
<caret line="6" column="33" lean-forward="false" selection-start-line="6" selection-start-column="33" selection-end-line="6" selection-end-column="33" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -1018,21 +1164,45 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/init/login.py"> <entry file="file://$PROJECT_DIR$/myUrllib/httpUtils.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153"> <state relative-caret-position="0">
<caret line="29" column="24" lean-forward="false" selection-start-line="29" selection-start-column="24" selection-end-line="29" selection-end-column="24" /> <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding> <folding />
<element signature="e#41#54#0" expanded="true" /> </state>
</folding> </provider>
</entry>
<entry file="file://$PROJECT_DIR$/myException/ticketNumOutException.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="27" lean-forward="false" selection-start-line="0" selection-start-column="27" selection-end-line="0" selection-end-column="27" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/myUrllib/myurllib2.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="59">
<caret line="39" column="4" lean-forward="false" selection-start-line="39" selection-start-column="4" selection-end-line="39" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config/ticket_config.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="574">
<caret line="41" column="10" lean-forward="false" selection-start-line="41" selection-start-column="10" selection-end-line="41" selection-end-column="10" />
<folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/init/select_ticket_info.py"> <entry file="file://$PROJECT_DIR$/init/select_ticket_info.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="97"> <state relative-caret-position="446">
<caret line="219" column="86" lean-forward="false" selection-start-line="219" selection-start-column="84" selection-end-line="219" selection-end-column="86" /> <caret line="673" column="0" lean-forward="true" selection-start-line="673" selection-start-column="0" selection-end-line="673" selection-end-column="0" />
<folding /> <folding>
<element signature="e#23#34#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>

View File

@ -23,39 +23,38 @@
#damatu打码兔账号用于自动登录 #damatu打码兔账号用于自动登录
#is_aotu_code是否自动打码如果选择Ture,则调用打码兔打码,默认不使用打码兔 #is_aotu_code是否自动打码如果选择Ture,则调用打码兔打码,默认不使用打码兔
set: set:
station_date: "2018-02-06" station_date: "2018-02-09"
station_trains: station_trains:
- "G1353" - "G4741"
- "G2365"
- "G1371"
- "G1377"
- "G1329" - "G1329"
- "G1355" # - "G1361"
- "G1303" # - "G1373"
- "G1357" # - "G1363"
- "G1305"
- "G1359"
- "G1361"
- "G1373"
- "G1363"
from_station: "上海" from_station: "上海"
to_station: "长沙" to_station: "邵阳"
set_type: set_type:
- "二等座" - "二等座"
- "一等座"
is_more_ticket: True is_more_ticket: True
ticke_peoples: ticke_peoples:
- "文贤平" - "文贤平"
- "梁敏" # - "梁敏"
12306count: 12306count:
- uesr: "@qq.com" # - uesr: "13828728396"
# - pwd: "649823049lilymin"
- uesr: "931128603@qq.com"
- pwd: "QWERTY" - pwd: "QWERTY"
select_refresh_interval: 0.01 select_refresh_interval: 0.1
expect_refresh_interval: 1 expect_refresh_interval: 0.1
ticket_black_list_time: 3 ticket_black_list_time: 3
is_aotu_code: False is_aotu_code: True
#enable_proxy: False #enable_proxy: False
damatu: damatu:
uesr: "" uesr: "wenxianping"
pwd: "wen1995" pwd: "wen1995"

View File

@ -3,9 +3,11 @@ import json
import datetime import datetime
import random import random
import re import re
import threading
import urllib import urllib
import sys import sys
import time import time
from Queue import Queue
from collections import OrderedDict from collections import OrderedDict
from config.ticketConf import _get_yaml from config.ticketConf import _get_yaml
@ -49,7 +51,7 @@ class select:
expect_refresh_interval = ticket_info_config["expect_refresh_interval"] expect_refresh_interval = ticket_info_config["expect_refresh_interval"]
ticket_black_list_time = ticket_info_config["ticket_black_list_time"] ticket_black_list_time = ticket_info_config["ticket_black_list_time"]
print "*"*20 print "*"*20
print "当前配置:出发站:{0}\n到达站:{1}\n乘车日期:{2}\n坐席:{3}\n是否有票自动提交:{4}\n乘车人:{5}\n刷新间隔:{6}\n候选购买车次:{7}\n未开始刷票间隔时间:{8}\n僵尸票关小黑屋时长:{9}\n".format\ print "当前配置:出发站:{0}\n到达站:{1}\n乘车日期:{2}\n坐席:{3}\n是否有票自动提交:{4}\n乘车人:{5}\n刷新间隔:{6}\n候选购买车次:{7}\n未开始刷票间隔时间:{8}\n僵尸票关小黑屋时长:{9}".format\
( (
from_station, from_station,
to_station, to_station,
@ -232,19 +234,19 @@ class select:
break break
else: else:
print ('正在尝试提交订票...') print ('正在尝试提交订票...')
if self.check_user(): return train_no # 提交车次
self.submit_station() # if self.check_user():
self.getPassengerTicketStr(self._station_seat[j].encode("utf8")) # self.submit_station()
self.getRepeatSubmitToken() # self.getPassengerTicketStr(self._station_seat[j].encode("utf8"))
self.user_info = self.getPassengerDTOs() # self.getRepeatSubmitToken()
if self.checkOrderInfo(train_no, self._station_seat[j].encode("utf8")): # self.user_info = self.getPassengerDTOs()
break # if self.checkOrderInfo(train_no, self._station_seat[j].encode("utf8")):
# break
else: else:
pass pass
print "当前车次{0} 查询无符合条件坐席,正在重新查询".format(ticket_info[3])
else: else:
time.sleep(self.expect_refresh_interval)
pass pass
time.sleep(self.expect_refresh_interval)
else: else:
raise ticketConfigException("车次配置信息有误,请检查") raise ticketConfigException("车次配置信息有误,请检查")
@ -293,7 +295,7 @@ class select:
else: else:
print ('出票失败') print ('出票失败')
elif 'messages' in submitResult and submitResult['messages']: elif 'messages' in submitResult and submitResult['messages']:
raise ticketIsExitsException("检查到有未支付的订单,程序自动停止") raise ticketIsExitsException(submitResult['messages'][0])
def getPassengerTicketStr(self, set_type): def getPassengerTicketStr(self, set_type):
""" """
@ -327,6 +329,8 @@ class select:
""" """
passengerTicketStrList = [] passengerTicketStrList = []
oldPassengerStr = [] oldPassengerStr = []
if not self.user_info:
raise PassengerUserException("联系人不在列表中,请查证后添加")
if len(self.user_info) is 1: if len(self.user_info) is 1:
passengerTicketStrList.append( passengerTicketStrList.append(
'0,' + self.user_info[0]['passenger_id_type_code'] + "," + self.user_info[0][ '0,' + self.user_info[0]['passenger_id_type_code'] + "," + self.user_info[0][
@ -375,8 +379,12 @@ class select:
open(img_path, 'wb').write(result) open(img_path, 'wb').write(result)
data['pass_code'] = DamatuApi(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"], img_path).main() data['pass_code'] = DamatuApi(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"], img_path).main()
checkOrderInfo = json.loads(myurllib2.Post(checkOrderInfoUrl, data, )) checkOrderInfo = json.loads(myurllib2.Post(checkOrderInfoUrl, data, ))
if self.getQueueCount(train_no, set_type): if checkOrderInfo['data']['submitStatus'] is True:
return True print ('车票提交通过,正在尝试排队')
if self.getQueueCount(train_no, set_type):
return True
else:
raise ticketNumOutException("提交订单失败")
else: else:
print("验证码识别错误,第{0}次重试".format(i)) print("验证码识别错误,第{0}次重试".format(i))
if checkOrderInfo['data']['submitStatus'] is True: if checkOrderInfo['data']['submitStatus'] is True:
@ -386,6 +394,24 @@ class select:
else: else:
if "errMsg" in checkOrderInfo['data'] and checkOrderInfo['data']["errMsg"]: if "errMsg" in checkOrderInfo['data'] and checkOrderInfo['data']["errMsg"]:
print checkOrderInfo['data']["errMsg"] print checkOrderInfo['data']["errMsg"]
if checkOrderInfo['data']["errMsg"].find("验证码") != -1:
print("需要验证码,正在使用自动识别验证码功能")
for i in range(3):
codeimg = 'https://kyfw.12306.cn/otn/passcodeNew/getPassCodeNew?module=login&rand=sjrand&%s' % random.random()
result = myurllib2.get(codeimg)
img_path = './tkcode'
open(img_path, 'wb').write(result)
data['pass_code'] = DamatuApi(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"],
img_path).main()
checkOrderInfo = json.loads(myurllib2.Post(checkOrderInfoUrl, data, ))
if checkOrderInfo['data']['submitStatus'] is True:
print ('车票提交通过,正在尝试排队')
if self.getQueueCount(train_no, set_type):
return True
else:
raise ticketNumOutException("提交订单失败")
else:
print("验证码识别错误,第{0}次重试".format(i))
else: else:
print checkOrderInfo print checkOrderInfo
elif 'messages' in checkOrderInfo and checkOrderInfo['messages']: elif 'messages' in checkOrderInfo and checkOrderInfo['messages']:
@ -415,41 +441,38 @@ class select:
'train_location': self.get_ticketInfoForPassengerForm()['train_location'], 'train_location': self.get_ticketInfoForPassengerForm()['train_location'],
'REPEAT_SUBMIT_TOKEN': self.get_token(), 'REPEAT_SUBMIT_TOKEN': self.get_token(),
} }
for i in range(3): getQueueCountResult = json.loads(myurllib2.Post(getQueueCountUrl, data))
print("{0}次排队".format(i+1)) if "status" in getQueueCountResult and getQueueCountResult["status"] is True:
getQueueCountResult = json.loads(myurllib2.Post(getQueueCountUrl, data)) if "countT" in getQueueCountResult["data"]:
if "status" in getQueueCountResult and getQueueCountResult["status"] is True: ticket = getQueueCountResult["data"]["ticket"]
if "countT" in getQueueCountResult["data"]: ticket_split = sum(map(self.conversion_int, ticket.split(","))) if ticket.find(",") != -1 else ticket
ticket = getQueueCountResult["data"]["ticket"] # ticket_sum = sum([int(ticket_split[0]),int(ticket_split[1])])
ticket_split = sum(map(self.conversion_int, ticket.split(","))) if ticket.find(",") != -1 else ticket # if set_type == "无座": # 修改无座和硬座的座位号提交是个字符串的问题
# ticket_sum = sum([int(ticket_split[0]),int(ticket_split[1])]) # ticket = ticket_split[1]
# if set_type == "无座": # 修改无座和硬座的座位号提交是个字符串的问题 # elif set_type == "硬座":
# ticket = ticket_split[1] # ticket = ticket_split[0]
# elif set_type == "硬座": countT = getQueueCountResult["data"]["countT"]
# ticket = ticket_split[0] if int(countT) is 0:
countT = getQueueCountResult["data"]["countT"] if int(ticket_split) < len(self.user_info):
if int(countT) is 0: print("当前余票数小于乘车人数,放弃订票")
if int(ticket_split) < len(self.user_info):
print("当前余票数小于乘车人数,放弃订票")
else:
print("排队成功, 当前余票还剩余: {0}".format(ticket_split))
if self.checkQueueOrder():
return True
else: else:
print("当前排队人数:" + str(countT) + "当前余票还剩余:{} 张,继续排队中".format(ticket_split)) print("排队成功, 当前余票还剩余: {0}".format(ticket_split))
if self.checkQueueOrder():
return True
else: else:
print("排队发现未知错误{0},将此列车 {1}加入小黑屋".format(getQueueCountResult, train_no)) print("当前排队人数:" + str(countT) + "当前余票还剩余:{0} 张,继续排队中".format(ticket_split))
self.ticket_black_list[train_no] = datetime.datetime.now()
break
elif "messages" in getQueueCountResult and getQueueCountResult["messages"]:
print("排队异常,错误信息:{0}, 将此列车 {1}加入小黑屋".format(getQueueCountResult["messages"][0], train_no))
self.ticket_black_list[train_no] = datetime.datetime.now()
break
else: else:
print("排队发现未知错误{0},将此列车 {1}加入小黑屋".format(getQueueCountResult, train_no))
self.ticket_black_list[train_no] = datetime.datetime.now()
elif "messages" in getQueueCountResult and getQueueCountResult["messages"]:
print("排队异常,错误信息:{0}, 将此列车 {1}加入小黑屋".format(getQueueCountResult["messages"][0], train_no))
self.ticket_black_list[train_no] = datetime.datetime.now()
else:
if "validateMessages" in getQueueCountResult and getQueueCountResult["validateMessages"]:
print(str(getQueueCountResult["validateMessages"])) print(str(getQueueCountResult["validateMessages"]))
self.ticket_black_list[train_no] = datetime.datetime.now() self.ticket_black_list[train_no] = datetime.datetime.now()
break else:
time.sleep(1) print("未知错误 {0}".format("".join(getQueueCountResult)))
def checkQueueOrder(self): def checkQueueOrder(self):
""" """
@ -471,97 +494,106 @@ class select:
"REPEAT_SUBMIT_TOKEN": self.get_token(), "REPEAT_SUBMIT_TOKEN": self.get_token(),
} }
try: try:
checkQueueOrderResult = json.loads(myurllib2.Post(checkQueueOrderUrl, data)) for i in range(3):
checkQueueOrderResult = json.loads(myurllib2.Post(checkQueueOrderUrl, data))
if checkQueueOrderResult:
break
except ValueError:
checkQueueOrderResult = {}
if checkQueueOrderResult:
if "status" in checkQueueOrderResult and checkQueueOrderResult["status"]: if "status" in checkQueueOrderResult and checkQueueOrderResult["status"]:
c_data = checkQueueOrderResult["data"] if "data" in checkQueueOrderResult else {} c_data = checkQueueOrderResult["data"] if "data" in checkQueueOrderResult else {}
if 'submitStatus' in c_data and c_data['submitStatus']: if 'submitStatus' in c_data and c_data['submitStatus']:
print("提交订单成功!") print("提交订单成功!")
if self.queryOrderWaitTime(): self.queryOrderWaitTime()
return True
else: else:
if 'errMsg' in c_data and c_data['errMsg']: if 'errMsg' in c_data and c_data['errMsg']:
print("提交订单成功!" + c_data['errMsg']) print("提交订单失败" + c_data['errMsg'])
else: else:
print(c_data) print(c_data)
print('订票失败!很抱歉,请重试提交预订功能!') print('订票失败!很抱歉,请重试提交预订功能!')
elif "messages" in checkQueueOrderResult and checkQueueOrderResult["messages"]: elif "messages" in checkQueueOrderResult and checkQueueOrderResult["messages"]:
print("提交订单失败,错误信息: " + checkQueueOrderResult["messages"]) print("提交订单失败,错误信息: " + checkQueueOrderResult["messages"])
else: else:
print("订单提交中,请耐心等待:" + str(checkQueueOrderResult["validateMessages"])) print("提交订单中,请耐心等待:" + str(checkQueueOrderResult["validateMessages"]))
except ValueError: else:
pass print("接口 {} 无响应".format(checkQueueOrderUrl))
def queryOrderWaitTime(self): def queryOrderWaitTime(self):
""" """
排队获取订单等待信息,每隔3秒请求一次最高请求次数为20次 排队获取订单等待信息,每隔3秒请求一次最高请求次数为20次
:return: :return:
""" """
queryOrderWaitTimeUrl = "https://kyfw.12306.cn/otn/confirmPassenger/queryOrderWaitTime" # queryOrderWaitTimeUrl = "https://kyfw.12306.cn/otn/confirmPassenger/queryOrderWaitTime"
data = { # data = {
"random": "149545481029" + str(random.randint(1, 9)), # "random": "{0}{1}".format(int(time.time()), random.randint(1, 9)),
"tourFlag": "dc", # "tourFlag": "dc",
"REPEAT_SUBMIT_TOKEN": self.get_token(), # "REPEAT_SUBMIT_TOKEN": self.get_token(),
} # }
num = 1 num = 1
while True: while True:
_random = int(round(time.time() * 1000))
num += 1 num += 1
if num > 30: if num > 30:
print("超出排队时间,自动放弃,正在重新刷票") print("超出排队时间,自动放弃,正在重新刷票")
break break
try: try:
queryOrderWaitTimeResult = json.loads(myurllib2.Post(queryOrderWaitTimeUrl, data)) queryOrderWaitTimeUrl = "https://kyfw.12306.cn/otn/confirmPassenger/queryOrderWaitTime?random={0}&tourFlag=dc&_json_att=&REPEAT_SUBMIT_TOKEN={1}".format(_random, self.get_token())
queryOrderWaitTimeResult = json.loads(myurllib2.get(queryOrderWaitTimeUrl))
except ValueError: except ValueError:
pass queryOrderWaitTimeResult = {}
if "status" in queryOrderWaitTimeResult and queryOrderWaitTimeResult["status"]: if queryOrderWaitTimeResult:
if "orderId" in queryOrderWaitTimeResult["data"] and queryOrderWaitTimeResult["data"]["orderId"] != "null": if "status" in queryOrderWaitTimeResult and queryOrderWaitTimeResult["status"]:
self.initNoComplete() if "orderId" in queryOrderWaitTimeResult["data"] and queryOrderWaitTimeResult["data"]["orderId"] is not None:
orderId = self.queryMyOrderNoComplete() raise ticketIsExitsException("恭喜您订票成功,订单号为:{0}, 请立即打开浏览器登录12306访问未完成订单在30分钟内完成支付".format(queryOrderWaitTimeResult["data"]["orderId"]))
if orderId: elif "msg" in queryOrderWaitTimeResult["data"] and queryOrderWaitTimeResult["data"]["msg"]:
raise ticketIsExitsException(("恭喜您订票成功,订单号为:{0}, 请立即打开浏览器登录12306访问未完成订单在30分钟内完成支付".format(orderId))) print queryOrderWaitTimeResult["data"]["msg"]
else:
print("等待出票中...")
continue
elif "msg" in queryOrderWaitTimeResult["data"] and queryOrderWaitTimeResult["data"]["msg"]:
orderId = self.queryMyOrderNoComplete()
if orderId:
raise ticketIsExitsException(
("恭喜您订票成功,订单号为:{0}, 请立即打开浏览器登录12306访问未完成订单在30分钟内完成支付".format(orderId)))
else:
break break
elif "messages" in queryOrderWaitTimeResult and queryOrderWaitTimeResult["messages"]: elif "waitTime"in queryOrderWaitTimeResult["data"] and queryOrderWaitTimeResult["data"]["waitTime"]:
print("订单提交失败: " + queryOrderWaitTimeResult["messages"]) print("排队等待时间预计还剩 {0} ms".format(0-queryOrderWaitTimeResult["data"]["waitTime"]))
orderId = self.queryMyOrderNoComplete() else:
if orderId: print ("正在等待中")
raise ticketIsExitsException( elif "messages" in queryOrderWaitTimeResult and queryOrderWaitTimeResult["messages"]:
("恭喜您订票成功,订单号为:{0}, 请立即打开浏览器登录12306访问未完成订单在30分钟内完成支付".format(orderId))) print("排队等待失败: " + queryOrderWaitTimeResult["messages"])
else: else:
break print("{}排队中,请耐心等待".format(num))
else: else:
print("订单提交中,请耐心等待") print("排队中")
time.sleep(1) time.sleep(2)
raise ticketNumOutException("订单提交时排队超时,重新刷票") order_id = self.queryMyOrderNoComplete() # 尝试查看订单列表,如果有订单,则判断成功,不过一般可能性不大
if order_id:
raise ticketIsExitsException("恭喜您订票成功,订单号为:{0}, 请立即打开浏览器登录12306访问未完成订单在30分钟内完成支付".format(order_id))
else:
print(ticketNumOutException("订单提交失败!,正在重新刷票"))
def queryMyOrderNoComplete(self): def queryMyOrderNoComplete(self):
""" """
获取订单列表信息 获取订单列表信息
:return: :return:
""" """
self.initNoComplete()
queryMyOrderNoCompleteUrl = "https://kyfw.12306.cn/otn/queryOrder/queryMyOrderNoComplete" queryMyOrderNoCompleteUrl = "https://kyfw.12306.cn/otn/queryOrder/queryMyOrderNoComplete"
data = {"_json_att": None} data = {"_json_att": None}
queryMyOrderNoCompleteResult = json.loads(myurllib2.Post(queryMyOrderNoCompleteUrl, data)) try:
if "data" in queryMyOrderNoCompleteResult and queryMyOrderNoCompleteResult["data"] and "orderDBList" in queryMyOrderNoCompleteResult["data"] and queryMyOrderNoCompleteResult["data"]["orderDBList"]: queryMyOrderNoCompleteResult = json.loads(myurllib2.Post(queryMyOrderNoCompleteUrl, data))
orderId = queryMyOrderNoCompleteResult["data"]["orderDBList"][0]["sequence_no"] except ValueError:
return orderId queryMyOrderNoCompleteResult = {}
elif "data" in queryMyOrderNoCompleteResult and "orderCacheDTO" in queryMyOrderNoCompleteResult["data"] and queryMyOrderNoCompleteResult["data"]["orderCacheDTO"]: if queryMyOrderNoCompleteResult:
if "message" in queryMyOrderNoCompleteResult["data"]["orderCacheDTO"] and queryMyOrderNoCompleteResult["data"]["orderCacheDTO"]["message"]: if "data" in queryMyOrderNoCompleteResult and queryMyOrderNoCompleteResult["data"] and "orderDBList" in queryMyOrderNoCompleteResult["data"] and queryMyOrderNoCompleteResult["data"]["orderDBList"]:
print(queryMyOrderNoCompleteResult["data"]["orderCacheDTO"]["message"]["message"]) orderId = queryMyOrderNoCompleteResult["data"]["orderDBList"][0]["sequence_no"]
raise ticketNumOutException(queryMyOrderNoCompleteResult["data"]["orderCacheDTO"]["message"]["message"]) return orderId
else: elif "data" in queryMyOrderNoCompleteResult and "orderCacheDTO" in queryMyOrderNoCompleteResult["data"] and queryMyOrderNoCompleteResult["data"]["orderCacheDTO"]:
if "message" in queryMyOrderNoCompleteResult and queryMyOrderNoCompleteResult["message"]: if "message" in queryMyOrderNoCompleteResult["data"]["orderCacheDTO"] and queryMyOrderNoCompleteResult["data"]["orderCacheDTO"]["message"]:
print queryMyOrderNoCompleteResult["message"] print(queryMyOrderNoCompleteResult["data"]["orderCacheDTO"]["message"]["message"])
return False raise ticketNumOutException(queryMyOrderNoCompleteResult["data"]["orderCacheDTO"]["message"]["message"])
else: else:
return False if "message" in queryMyOrderNoCompleteResult and queryMyOrderNoCompleteResult["message"]:
print queryMyOrderNoCompleteResult["message"]
return False
else:
return False
else:
print("接口 {} 无响应".format(queryMyOrderNoCompleteUrl))
def initNoComplete(self): def initNoComplete(self):
""" """
@ -597,7 +629,7 @@ class select:
break break
start_time = datetime.datetime.now() start_time = datetime.datetime.now()
self.submitOrderRequest(from_station, to_station) self.submitOrderRequest(from_station, to_station)
print "正在第{0}次查询 乘车日期: {1} 查询无票 代理设置无 总耗时{2}ms".format(num, self.station_date, (datetime.datetime.now()-start_time).microseconds/1000) print "正在第{0}次查询 乘车日期: {1} 车次{2} 查询无票 代理设置 无 总耗时{3}ms".format(num, self.station_date, ",".join(self.station_trains), (datetime.datetime.now()-start_time).microseconds/1000)
except PassengerUserException as e: except PassengerUserException as e:
print e.message print e.message
break break
@ -617,6 +649,83 @@ class select:
print(e.message) print(e.message)
class selectProducer(threading.Thread):
"""刷票队列"""
def __init__(self, t_name, queue, selectObj, from_station, to_station, expect_refresh_interval, select_refresh_interval):
threading.Thread.__init__(self, name=t_name)
self.data = queue
self.selectObj = selectObj
self.from_station, self.to_station = from_station, to_station
self.expect_refresh_interval, self.select_refresh_interval = expect_refresh_interval, select_refresh_interval
print "{0} 正在运行".format(t_name)
def run(self):
from_station, to_station = self.selectObj.station_table(self.from_station, self.to_station)
if self.selectObj.leftTicketLog(from_station, to_station):
num = 1
while 1:
try:
num += 1
time.sleep(self.select_refresh_interval)
if time.strftime('%H:%M:%S', time.localtime(time.time())) > "23:00:00":
print "12306休息时间本程序自动停止,明天早上七点运行
break
else:
self.selectObj
tain_no = self.selectObj.submitOrderRequest()
class submitOrderConsumer(threading.Thread):
"""订单队列"""
def __init__(self, t_name, queue, selectObj):
threading.Thread.__init__(self, name=t_name)
self.data = queue
print "{0} 正在运行".format(t_name)
def run(self):
pass
def get_ticket_info():
"""
获取配置信息
:return:
"""
ticket_info_config = _get_yaml()
from_station = ticket_info_config["set"]["from_station"].encode("utf8")
to_station = ticket_info_config["set"]["to_station"].encode("utf8")
station_date = ticket_info_config["set"]["station_date"].encode("utf8")
set_type = ticket_info_config["set"]["set_type"]
is_more_ticket = ticket_info_config["set"]["is_more_ticket"]
ticke_peoples = ticket_info_config["set"]["ticke_peoples"]
select_refresh_interval = ticket_info_config["select_refresh_interval"]
station_trains = ticket_info_config["set"]["station_trains"]
expect_refresh_interval = ticket_info_config["expect_refresh_interval"]
ticket_black_list_time = ticket_info_config["ticket_black_list_time"]
print "*"*20
print "当前配置:出发站:{0}\n到达站:{1}\n乘车日期:{2}\n坐席:{3}\n是否有票自动提交:{4}\n乘车人:{5}\n刷新间隔:{6}\n候选购买车次:{7}\n未开始刷票间隔时间:{8}\n僵尸票关小黑屋时长:{9}".format\
(
from_station,
to_station,
station_date,
",".join(set_type),
is_more_ticket,
",".join(ticke_peoples),
select_refresh_interval,
",".join(station_trains),
expect_refresh_interval,
ticket_black_list_time,
)
print "*"*20
return from_station, to_station, station_date, set_type, is_more_ticket, ticke_peoples, select_refresh_interval, station_trains, expect_refresh_interval, ticket_black_list_time
def main():
queue = Queue(20)
from_station, to_station, station_date, set_type, is_more_ticket, ticke_peoples, select_refresh_interval, station_trains, expect_refresh_interval, ticket_black_list_time = get_ticket_info()
if __name__ == '__main__': if __name__ == '__main__':
a = select('上海', '北京') a = select('上海', '北京')
a.main() a.main()