Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
py12306
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
python
py12306
Commits
b333b09f
Commit
b333b09f
authored
Jan 14, 2019
by
Jalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复 bug #16,增加任务更新后重新检测乘客
parent
c8988cd2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
9 deletions
+16
-9
func.py
py12306/helpers/func.py
+4
-0
query.py
py12306/query/query.py
+1
-0
log.py
py12306/web/handler/log.py
+11
-9
No files found.
py12306/helpers/func.py
View file @
b333b09f
...
...
@@ -105,6 +105,10 @@ def get_file_total_line_num(file, encoding='utf-8'):
return
len
(
f
.
readlines
())
def
pick_file_lines
(
file
,
lines
):
return
[
x
for
i
,
x
in
enumerate
(
file
)
if
i
in
lines
]
def
str_to_time
(
str
):
return
datetime
.
datetime
.
strptime
(
str
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S.
%
f'
)
...
...
py12306/query/query.py
View file @
b333b09f
...
...
@@ -41,6 +41,7 @@ class Query:
if
auto
:
QueryLog
.
add_quick_log
(
QueryLog
.
MESSAGE_JOBS_DID_CHANGED
)
.
flush
()
self
.
refresh_jobs
()
jobs_do
(
self
.
jobs
,
'check_passengers'
)
@
classmethod
def
run
(
cls
):
...
...
py12306/web/handler/log.py
View file @
b333b09f
...
...
@@ -5,7 +5,7 @@ from flask.json import jsonify
from
flask_jwt_extended
import
(
jwt_required
)
from
py12306.config
import
Config
from
py12306.helpers.func
import
get_file_total_line_num
from
py12306.helpers.func
import
get_file_total_line_num
,
pick_file_lines
from
py12306.log.common_log
import
CommonLog
from
py12306.query.query
import
Query
from
py12306.user.user
import
User
...
...
@@ -29,17 +29,19 @@ def log_output():
if
last_line
==
-
1
:
total_line
=
get_file_total_line_num
(
file
)
last_line
=
total_line
-
max_old
if
total_line
>
max_old
else
0
ranges
=
range
(
max_old
+
limit
)
ranges
=
range
(
last_line
,
last_line
+
max_old
+
limit
)
# limit = max_old + limit
else
:
ranges
=
range
(
limit
)
ranges
=
range
(
l
ast_line
,
last_line
+
l
imit
)
if
Config
()
.
OUT_PUT_LOG_TO_FILE_ENABLED
:
# with open(Config().OUT_PUT_LOG_TO_FILE_PATH, 'r', encoding='utf-8') as f:
# res = f.readlines()[last_line:limit]
linecache
.
updatecache
(
file
)
for
i
in
ranges
:
tmp
=
linecache
.
getline
(
file
,
last_line
+
i
)
if
tmp
!=
''
:
res
.
append
(
tmp
)
with
open
(
Config
()
.
OUT_PUT_LOG_TO_FILE_PATH
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
res
=
pick_file_lines
(
f
,
ranges
)
# linecache.updatecache(file) # 使用 linecache windows 平台会出来编码问题 暂时弃用
# for i in ranges:
# tmp = linecache.getline(file, last_line + i)
# if tmp != '': res.append(tmp)
last_line
+=
len
(
res
)
else
:
res
=
CommonLog
.
MESSAGE_OUTPUT_TO_FILE_IS_UN_ENABLE
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment