Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
platform
/
tx1_box_serv
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b17c0900
authored
Dec 24, 2018
by
熊付
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
【任务空指针异常处理】
1 parent
57a2af4d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
16 deletions
code/tx1_box_serv/apps/api/task.py
code/tx1_box_serv/apps/api/task.pyc
code/tx1_box_serv/apps/api/task.py
View file @
b17c090
...
...
@@ -61,14 +61,19 @@ def edit_task_inf(task_index):
'''
===========================更改task_name start===============
'''
if
task_data
.
has_key
(
'task_name'
):
task_name
=
task_data
[
'task_name'
]
if
task_data
.
has_key
(
'
sub
task_name'
):
task_name
=
task_data
[
'
sub
task_name'
]
if
task_name
is
not
None
:
task_name_doc
=
editXml
.
parseXmlStr
(
tasks
[
0
]
)
if
task_name_doc
:
root
=
task_name_doc
.
documentElement
Name
=
root
.
getElementsByTagName
(
"Name"
)[
0
]
.
childNodes
[
0
]
Name
.
data
=
task_name
Name
=
root
.
getElementsByTagName
(
"Name"
)[
0
]
if
Name
is
None
or
len
(
Name
.
childNodes
)
==
0
:
newtext
=
task_name_doc
.
createTextNode
(
task_name
)
Name
.
appendChild
(
newtext
)
else
:
Name
=
Name
.
childNodes
[
0
]
Name
.
data
=
task_name
xml
=
task_name_doc
.
toxml
()
xml
=
xml
.
replace
(
'<?xml version="1.0" ?>'
,
'<?xml version="1.0" encoding="GBK"?>'
)
editXml
.
writeXml
(
tasks
[
0
],
task_name_doc
.
toxml
()
)
...
...
@@ -82,9 +87,17 @@ def edit_task_inf(task_index):
if
play_url
is
not
None
:
scenes
=
editXml
.
parseXmlStr
(
os
.
path
.
join
(
tasks
[
1
],
'scene.xml'
)
)
root
=
scenes
.
documentElement
scen_play_url
=
root
.
getElementsByTagName
(
"scene1"
)[
0
]
.
getElementsByTagName
(
"play_urls"
)[
0
]
.
getElementsByTagName
(
"rtsp"
)[
0
]
.
childNodes
[
0
]
print
scen_play_url
.
data
scen_play_url
.
data
=
play_url
#scen_play_url = root.getElementsByTagName ( "scene1" )[0].getElementsByTagName ( "play_urls" )[0].getElementsByTagName ( "rtsp" )[0].childNodes[0]
scen_play_url
=
\
root
.
getElementsByTagName
(
"scene1"
)[
0
]
.
getElementsByTagName
(
"play_urls"
)[
0
]
.
getElementsByTagName
(
"rtsp"
)[
0
]
print
scen_play_url
if
scen_play_url
is
None
or
len
(
scen_play_url
.
childNodes
)
==
0
:
newtext
=
scenes
.
createTextNode
(
play_url
)
scen_play_url
.
appendChild
(
newtext
)
else
:
scen_play_url
=
scen_play_url
.
childNodes
[
0
]
scen_play_url
.
data
=
play_url
xml
=
scenes
.
toxml
()
xml
=
xml
.
replace
(
'"'
,
'"'
)
xml
=
xml
.
replace
(
'<?xml version="1.0" ?>'
,
'<?xml version="1.0" encoding="GBK"?>'
)
...
...
@@ -124,7 +137,7 @@ def edit_task_inf(task_index):
'''
启动任务开始
'''
os
.
system
(
'pkill VAServer'
)
os
.
system
(
'pkill
-9
VAServer'
)
result_data
=
{
"ecode"
:
"200"
,
"enote"
:
"OK"
}
res
=
flask
.
make_response
(
...
...
@@ -190,18 +203,22 @@ def read_task_name(xmlPath):
task_name_doc
=
editXml
.
parseXmlStr
(
xmlPath
)
if
task_name_doc
:
root
=
task_name_doc
.
documentElement
name
=
root
.
getElementsByTagName
(
"Name"
)[
0
]
.
childNodes
[
0
]
print
'name =
%
s'
%
name
.
data
return
name
.
data
name
=
root
.
getElementsByTagName
(
"Name"
)[
0
]
if
name
is
not
None
and
len
(
name
.
childNodes
)
>
0
:
name
=
name
.
childNodes
[
0
]
print
'name =
%
s'
%
name
.
data
return
name
.
data
return
''
def
read_task_id
(
xmlPath
):
task_id_doc
=
editXml
.
parseXmlStr
(
xmlPath
)
if
task_id_doc
:
root
=
task_id_doc
.
documentElement
task_id
=
root
.
getElementsByTagName
(
"task_unid"
)[
0
]
.
childNodes
[
0
]
print
'task_id =
%
s'
%
task_id
.
data
return
task_id
.
data
task_id
=
root
.
getElementsByTagName
(
"task_unid"
)[
0
]
if
task_id
is
not
None
and
len
(
task_id
.
childNodes
)
>
0
:
task_id
=
task_id
.
childNodes
[
0
]
print
'task_id =
%
s'
%
task_id
.
data
return
task_id
.
data
return
''
def
read_rtsp
(
xmlPath
):
...
...
@@ -210,8 +227,10 @@ def read_rtsp(xmlPath):
root
=
scenes
.
documentElement
scen_play_url
=
\
root
.
getElementsByTagName
(
"scene1"
)[
0
]
.
getElementsByTagName
(
"play_urls"
)[
0
]
.
getElementsByTagName
(
"rtsp"
)[
0
]
.
childNodes
[
0
]
return
scen_play_url
.
data
"rtsp"
)[
0
]
if
scen_play_url
is
not
None
and
len
(
scen_play_url
.
childNodes
)
>
0
:
scen_play_url
=
scen_play_url
.
childNodes
[
0
]
return
scen_play_url
.
data
return
''
def
make_mtasks
(
cal_path
,
roi_path
,
basconpath
,
conpath
,
rtsp
):
...
...
code/tx1_box_serv/apps/api/task.pyc
View file @
b17c090
No preview for this file type
Write
Preview
Markdown
is supported
Attach a file
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 post a comment