Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
test_platform
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
Wallen姚文辉
test_platform
Commits
b76ead2b
Commit
b76ead2b
authored
Aug 27, 2024
by
Wallen姚文辉
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试用例文件系统
parent
8e1e230b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
146 additions
and
1 deletion
+146
-1
appUitest.py
controller/appUitest.py
+117
-0
mian.py
mian.py
+4
-1
test.py
test.py
+25
-0
No files found.
controller/appUitest.py
0 → 100644
View file @
b76ead2b
from
flask
import
Blueprint
,
request
,
jsonify
,
session
,
send_file
import
time
import
subprocess
import
os
from
manager.tools
import
get_config
apptool
=
Blueprint
(
"apptool"
,
__name__
,
url_prefix
=
'/apptool'
)
bath_path
=
get_config
()[
'other'
][
'casehome'
]
def
strftime
(
type
,
str
):
'''
type 1-包含年 0-不包含
'''
a
=
type
and
time
.
strptime
(
str
,
"
%
b-
%
d-
%
Y"
)
or
time
.
strptime
(
"Jun-17 18:58"
,
"
%
b-
%
d
%
H:
%
M"
)
return
time
.
strftime
(
"
%
m-
%
d
%
H:
%
M:
%
S"
,
a
)
k
=
lambda
x
:
':'
in
x
and
strftime
(
0
,
x
)
or
strftime
(
1
,
x
)
@
apptool
.
route
(
"/case/filelist"
,
methods
=
[
"GET"
])
def
filelist
():
path
=
request
.
args
.
get
(
"path"
)
a
=
subprocess
.
getoutput
(
'cd
%
s && ls -l'
%
os
.
path
.
join
(
bath_path
,
path
))
b
=
a
.
split
(
'
\n
'
)[
1
:]
for
i
in
range
(
len
(
b
)):
b
[
i
]
=
b
[
i
]
.
split
(
maxsplit
=
8
)
s
=
list
(
map
(
lambda
x
:{
'floder'
:
x
[
0
][
0
]
==
'd'
and
True
or
False
,
'size'
:
x
[
4
],
'update'
:
k
(
x
[
5
]
+
'-'
+
x
[
6
]
+
(
':'
in
x
[
7
]
and
' '
+
x
[
7
]
or
'-'
+
x
[
7
])),
'name'
:
x
[
8
]},
b
))
return
jsonify
({
"code"
:
200
,
"message"
:
"请求成功"
,
"data"
:
s
}),
200
@
apptool
.
route
(
"/case/create"
,
methods
=
[
"POST"
])
def
createFloder
():
path
=
request
.
json
.
get
(
"path"
)
name
=
request
.
json
.
get
(
"name"
)
type_
=
request
.
json
.
get
(
"type"
)
if
'../'
in
path
and
type_
==
'floder'
:
return
jsonify
({
"code"
:
403
,
"message"
:
"目录名违法"
}),
403
a
=
subprocess
.
getoutput
(
'cd
%
s && ls -l'
%
os
.
path
.
join
(
bath_path
,
path
))
b
=
a
.
split
(
'
\n
'
)[
1
:]
for
i
in
range
(
len
(
b
)):
b
[
i
]
=
b
[
i
]
.
split
()
s
=
list
(
map
(
lambda
x
:{
'floder'
:
x
[
0
][
0
]
==
'd'
and
True
or
False
,
'size'
:
x
[
4
],
'update'
:
k
(
x
[
5
]
+
'-'
+
x
[
6
]
+
(
':'
in
x
[
7
]
and
' '
+
x
[
7
]
or
'-'
+
x
[
7
])),
'name'
:
x
[
8
]},
b
))
for
each
in
s
:
if
each
.
get
(
"name"
)
==
name
and
each
.
get
(
"floder"
)
and
type_
==
'floder'
:
return
jsonify
({
"code"
:
503
,
"message"
:
"该目录已存在"
}),
503
elif
each
.
get
(
"name"
)
==
name
and
each
.
get
(
"file"
)
and
type_
==
'file'
:
return
jsonify
({
"code"
:
503
,
"message"
:
"该文件已存在"
}),
503
type_
==
'floder'
and
subprocess
.
getoutput
(
f
'cd {os.path.join(bath_path,path)} && mkdir "{name}"'
)
or
subprocess
.
getoutput
(
f
'cd {os.path.join(bath_path,path)} && touch "{name}"'
)
return
jsonify
({
"code"
:
200
,
"message"
:
"创建成功"
}),
200
@
apptool
.
route
(
"/case/rename"
,
methods
=
[
"POST"
])
def
rename
():
path
=
request
.
json
.
get
(
"path"
)
oldname
=
request
.
json
.
get
(
"oldname"
)
newname
=
request
.
json
.
get
(
"newname"
)
a
=
subprocess
.
getoutput
(
f
'cd {os.path.join(bath_path,path)} && mv "{oldname}" "{newname}"'
)
if
not
a
:
return
jsonify
({
"code"
:
200
,
"message"
:
"修改成功"
}),
200
else
:
return
jsonify
({
"code"
:
503
,
"message"
:
a
}),
503
@
apptool
.
route
(
"/case/move"
,
methods
=
[
"POST"
])
def
move
():
bath_path
=
'/home/yaowenhui/test_case'
path
=
request
.
json
.
get
(
"path"
)
name
=
request
.
json
.
get
(
"name"
)
targetPath
=
request
.
json
.
get
(
"targetPath"
)
if
'../'
in
path
or
'../'
in
targetPath
:
return
jsonify
({
"code"
:
403
,
"message"
:
"目录名违法"
}),
403
if
os
.
path
.
join
(
bath_path
,
path
)
.
endswith
(
'/'
):
p
=
os
.
path
.
join
(
bath_path
,
path
)
+
'"'
+
name
+
'"'
else
:
p
=
os
.
path
.
join
(
bath_path
,
path
)
+
'/"'
+
name
+
'"'
print
(
f
'mv {p} {os.path.join(bath_path,targetPath)}'
)
a
=
subprocess
.
getoutput
(
f
'mv {p} {os.path.join(bath_path,targetPath)}'
)
if
not
a
:
return
jsonify
({
"code"
:
200
,
"message"
:
"修改成功"
}),
200
else
:
if
(
"are the same file"
):
return
jsonify
({
"code"
:
503
,
"message"
:
"改路径已存在相同文件"
}),
503
return
jsonify
({
"code"
:
503
,
"message"
:
a
}),
503
@
apptool
.
route
(
"/case/delete"
,
methods
=
[
"POST"
])
def
delete
():
path
=
request
.
json
.
get
(
"path"
)
name
=
request
.
json
.
get
(
"name"
)
a
=
subprocess
.
getoutput
(
f
'cd {os.path.join(bath_path,path)} && rm -rf "{name}"'
)
if
not
a
:
return
jsonify
({
"code"
:
200
,
"message"
:
"删除成功"
}),
200
else
:
return
jsonify
({
"code"
:
503
,
"message"
:
a
}),
503
@
apptool
.
route
(
'/case/upload'
,
methods
=
[
"POST"
])
def
upload
():
path
=
request
.
form
.
get
(
"path"
)
if
'file'
not
in
request
.
files
:
return
jsonify
({
"code"
:
503
,
"message"
:
"请选择文件"
}),
503
file
=
request
.
files
[
'file'
]
if
file
:
# subprocess.getoutput(f'cd {os.path.join(bath_path,path)} && touch "{file.filename}"')
if
os
.
path
.
join
(
bath_path
,
path
)
.
endswith
(
'/'
):
file_path
=
os
.
path
.
join
(
bath_path
,
path
)
+
file
.
filename
else
:
file_path
=
os
.
path
.
join
(
bath_path
,
path
)
+
"/"
+
file
.
filename
file
.
save
(
file_path
)
return
jsonify
({
"code"
:
200
,
"message"
:
"上传成功"
,
"data"
:{
"filename"
:
file
.
filename
}}),
200
@
apptool
.
route
(
'/case/download'
,
methods
=
[
'GET'
])
def
download_file
():
path
=
request
.
args
.
get
(
"path"
)
name
=
request
.
args
.
get
(
"name"
)
if
os
.
path
.
join
(
bath_path
,
path
)
.
endswith
(
'/'
):
file_path
=
os
.
path
.
join
(
bath_path
,
path
)
+
name
else
:
file_path
=
os
.
path
.
join
(
bath_path
,
path
)
+
"/"
+
name
print
(
222
)
return
send_file
(
file_path
,
as_attachment
=
True
)
\ No newline at end of file
mian.py
View file @
b76ead2b
...
@@ -17,7 +17,7 @@ class Config(object):
...
@@ -17,7 +17,7 @@ class Config(object):
@
server
.
app
.
before_request
@
server
.
app
.
before_request
def
token
():
def
token
():
token
=
request
.
headers
.
get
(
"token"
)
token
=
request
.
headers
.
get
(
"token"
)
release_path
=
[
"/user/login"
,
"/user/logout"
,
'notoken'
]
release_path
=
[
"/user/login"
,
"/user/logout"
,
'notoken'
,
'download'
,
'upload'
]
next_
=
False
next_
=
False
for
i
in
release_path
:
for
i
in
release_path
:
if
i
in
request
.
path
:
if
i
in
request
.
path
:
...
@@ -76,6 +76,9 @@ if __name__ == '__main__':
...
@@ -76,6 +76,9 @@ if __name__ == '__main__':
from
controller.notoken
import
*
from
controller.notoken
import
*
server
.
app
.
register_blueprint
(
notoken
)
server
.
app
.
register_blueprint
(
notoken
)
from
controller.appUitest
import
*
server
.
app
.
register_blueprint
(
apptool
)
# server.app.run(host="0.0.0.0", port=8000, debug=True)
# server.app.run(host="0.0.0.0", port=8000, debug=True)
server
.
socketio
.
run
(
server
.
app
,
host
=
"0.0.0.0"
,
port
=
8000
,
debug
=
True
,
allow_unsafe_werkzeug
=
True
)
server
.
socketio
.
run
(
server
.
app
,
host
=
"0.0.0.0"
,
port
=
8000
,
debug
=
True
,
allow_unsafe_werkzeug
=
True
)
...
...
test.py
0 → 100644
View file @
b76ead2b
import
subprocess
import
time
import
os
def
test
(
path
):
bath_path
=
'~'
def
strftime
(
type
,
str
):
'''
type 1-包含年 0-不包含
'''
a
=
type
and
time
.
strptime
(
str
,
"
%
b-
%
d-
%
Y"
)
or
time
.
strptime
(
"Jun-17 18:58"
,
"
%
b-
%
d
%
H:
%
M"
)
return
time
.
strftime
(
"
%
m-
%
d
%
H:
%
M:
%
S"
,
a
)
k
=
lambda
x
:
':'
in
x
and
strftime
(
0
,
x
)
or
strftime
(
1
,
x
)
a
=
subprocess
.
getoutput
(
'cd
%
s && ls -l'
%
os
.
path
.
join
(
bath_path
,
path
))
b
=
a
.
split
(
'
\n
'
)[
1
:]
for
i
in
range
(
len
(
b
)):
b
[
i
]
=
b
[
i
]
.
split
()
s
=
list
(
map
(
lambda
x
:{
'floder'
:
x
[
0
][
0
]
==
'd'
and
True
or
False
,
'size'
:
x
[
4
],
'update'
:
k
(
x
[
5
]
+
'-'
+
x
[
6
]
+
(
':'
in
x
[
7
]
and
' '
+
x
[
7
]
or
'-'
+
x
[
7
])),
'name'
:
x
[
8
]},
b
))
return
s
print
(
test
(
'project-other/source'
))
# timeArray=time.strptime("Jun-17 18:58", "%b-%d %H:%M")
# otherStyleTime = time.strftime("%m-%d %H:%M:%S", timeArray)
# print(otherStyleTime)
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