Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
evm-store
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
wanli
evm-store
Commits
9ed09a30
Commit
9ed09a30
authored
Jul 13, 2021
by
wanli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
f374ceaa
Changes
33
Show whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
3077 additions
and
0 deletions
+3077
-0
tools/build_out/controllers/annex.py
tools/build_out/controllers/annex.py
+86
-0
tools/build_out/controllers/api.py
tools/build_out/controllers/api.py
+101
-0
tools/build_out/controllers/device.py
tools/build_out/controllers/device.py
+86
-0
tools/build_out/controllers/file.py
tools/build_out/controllers/file.py
+278
-0
tools/build_out/controllers/monitor.py
tools/build_out/controllers/monitor.py
+178
-0
tools/build_out/controllers/monitorEvm.py
tools/build_out/controllers/monitorEvm.py
+86
-0
tools/build_out/controllers/monitorImage.py
tools/build_out/controllers/monitorImage.py
+78
-0
tools/build_out/controllers/monitorLvgl.py
tools/build_out/controllers/monitorLvgl.py
+78
-0
tools/build_out/controllers/monitorSystem.py
tools/build_out/controllers/monitorSystem.py
+78
-0
tools/build_out/controllers/monitorWatch.py
tools/build_out/controllers/monitorWatch.py
+78
-0
tools/build_out/controllers/upload.py
tools/build_out/controllers/upload.py
+155
-0
tools/build_out/evue_photo.png
tools/build_out/evue_photo.png
+0
-0
tools/build_out/models/annex.py
tools/build_out/models/annex.py
+81
-0
tools/build_out/models/device.py
tools/build_out/models/device.py
+97
-0
tools/build_out/models/monitorEvm.py
tools/build_out/models/monitorEvm.py
+65
-0
tools/build_out/models/monitorImage.py
tools/build_out/models/monitorImage.py
+65
-0
tools/build_out/models/monitorLvgl.py
tools/build_out/models/monitorLvgl.py
+71
-0
tools/build_out/models/monitorSystem.py
tools/build_out/models/monitorSystem.py
+62
-0
tools/build_out/models/monitorWatch.py
tools/build_out/models/monitorWatch.py
+50
-0
tools/build_out/result.json
tools/build_out/result.json
+1
-0
tools/build_out/views/annex.py
tools/build_out/views/annex.py
+77
-0
tools/build_out/views/device.py
tools/build_out/views/device.py
+106
-0
tools/build_out/views/monitorEvm.py
tools/build_out/views/monitorEvm.py
+64
-0
tools/build_out/views/monitorImage.py
tools/build_out/views/monitorImage.py
+64
-0
tools/build_out/views/monitorLvgl.py
tools/build_out/views/monitorLvgl.py
+64
-0
tools/build_out/views/monitorSystem.py
tools/build_out/views/monitorSystem.py
+64
-0
tools/build_out/views/monitorWatch.py
tools/build_out/views/monitorWatch.py
+64
-0
tools/build_out/webcreator/utils/ccode.py
tools/build_out/webcreator/utils/ccode.py
+76
-0
tools/build_out/webcreator/utils/epk.py
tools/build_out/webcreator/utils/epk.py
+267
-0
tools/build_out/webcreator/utils/epk_2.0.py
tools/build_out/webcreator/utils/epk_2.0.py
+234
-0
tools/build_out/webcreator/utils/lib/eheatshrink.dll
tools/build_out/webcreator/utils/lib/eheatshrink.dll
+0
-0
tools/build_out/webcreator/utils/lib/libeheatshrink.so
tools/build_out/webcreator/utils/lib/libeheatshrink.so
+0
-0
tools/build_out/webcreator/utils/tools_epk_1.0.py
tools/build_out/webcreator/utils/tools_epk_1.0.py
+223
-0
No files found.
tools/build_out/controllers/annex.py
0 → 100644
View file @
9ed09a30
'''
Author: your name
Date: 2021-07-11 01:47:14
LastEditTime: 2021-07-12 11:31:33
LastEditors: your name
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\
controllers
\a
nnex.py
'''
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
datetime
import
datetime
from
application.app
import
db
from
models.annex
import
AnnexModel
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
class
AnnexResource
(
object
):
def
__init__
(
self
):
super
()
.
__init__
()
def
get
(
self
,
uuid
,
params
):
# handle business
filters
=
[
AnnexModel
.
is_delete
==
False
,
AnnexModel
.
uuid
==
uuid
]
result
=
AnnexModel
.
query
.
filter
(
*
filters
)
.
first
()
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
getList
(
self
,
params
):
# handle business
logger
.
warn
(
params
)
filters
=
[
AnnexModel
.
is_delete
==
False
]
result
=
AnnexModel
.
query
.
filter
(
*
filters
)
.
order_by
(
AnnexModel
.
create_at
)
.
paginate
(
params
.
get
(
'page'
,
1
),
params
.
get
(
'pageSize'
,
10
),
error_out
=
False
)
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
result
=
AnnexModel
.
query
.
filter
(
AnnexModel
.
app
==
params
.
get
(
'app'
))
.
first
()
if
result
and
result
.
is_delete
:
result
.
is_delete
=
False
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
elif
result
and
result
.
is_delete
==
False
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
result
=
AnnexModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
put
(
self
,
uuid
,
params
,
jwt
=
{}):
# handle business
result
=
AnnexModel
.
query
.
filter
(
AnnexModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
if
params
:
for
key
,
value
in
params
.
items
():
if
value
!=
None
:
setattr
(
result
,
key
,
value
)
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
else
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
AnnexModel
.
query
.
filter
(
AnnexModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
result
.
is_delete
=
True
db
.
session
.
delete
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
annexManager
=
AnnexResource
()
\ No newline at end of file
tools/build_out/controllers/api.py
0 → 100644
View file @
9ed09a30
'''
Author: your name
Date: 2021-07-12 11:14:48
LastEditTime: 2021-07-12 11:29:36
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\
controllers
\a
ppi.py
'''
import
os
import
re
import
json
import
shutil
from
urllib
import
parse
from
datetime
import
datetime
from
application.app
import
db
,
config
from
models.annex
import
AnnexModel
from
models.app
import
AppModel
from
models.user
import
UserModel
from
models.package
import
PackageModel
from
webcreator.log
import
logger
from
webcreator
import
utils
from
webcreator.utils.epk
import
EpkApp
from
webcreator.response
import
ResponseCode
class
BuildAppResource
(
object
):
def
__init__
(
self
):
super
()
.
__init__
()
def
post
(
self
,
params
,
jwt
=
{}):
logger
.
info
(
params
)
user
=
UserModel
.
query
.
filter
(
UserModel
.
id
==
jwt
[
'id'
])
if
not
user
:
return
False
,
ResponseCode
.
USER_NOT_EXISTS
if
params
.
get
(
"access_key"
):
params
.
pop
(
"access_key"
)
params
.
update
({
'create_by'
:
user
,
'create_at'
:
datetime
.
now
(),
'update_by'
:
user
,
'update_at'
:
datetime
.
now
(),
})
app
=
AppModel
(
**
params
)
db
.
session
.
add
(
app
)
db
.
session
.
commit
()
dir_format
=
"{}-{}-{}"
.
format
(
app
.
app_name
,
app
.
app_version
,
datetime
.
now
()
.
strftime
(
"
%
Y
%
m
%
d
%
H
%
M
%
S"
))
upload_dir
=
os
.
sep
.
join
([
config
.
UPLOAD_ROOT_DIR
,
"evueapps"
])
target_dir
=
os
.
sep
.
join
([
upload_dir
,
user
.
account
,
dir_format
])
dest_dir
=
os
.
sep
.
join
([
target_dir
,
"src"
])
if
not
os
.
path
.
exists
(
dest_dir
):
os
.
makedirs
(
dest_dir
)
for
target_file
in
params
.
get
(
'files'
):
filename
=
os
.
path
.
basename
(
target_file
)
name
,
suffix
=
os
.
path
.
splitext
(
filename
)
name
=
re
.
sub
(
r"_\d{14}$"
,
""
,
name
)
dst_file
=
os
.
path
.
normpath
(
os
.
sep
.
join
([
dest_dir
,
name
+
suffix
]))
shutil
.
copy
(
os
.
path
.
normpath
(
target_file
),
dst_file
)
res
=
AnnexModel
(
app
=
app
,
title
=
filename
,
path
=
dst_file
.
replace
(
config
.
UPLOAD_ROOT_DIR
,
""
),
size
=
os
.
path
.
getsize
(
dst_file
),
create_by
=
user
,
create_at
=
datetime
.
now
(),
update_by
=
user
,
update_at
=
datetime
.
now
())
db
.
session
.
add
(
res
)
db
.
session
.
flush
()
db
.
session
.
commit
()
# 打包成EPK文件
app_info
=
{}
params
=
{
'appName'
:
app
.
app_name
,
'appDir'
:
dest_dir
,
'appVersion'
:
app
.
app_version
,
'output'
:
target_dir
}
if
user
.
role
==
"administrator"
or
user
.
role
==
"community"
:
params
[
'algorithm'
]
=
"h"
epk
=
EpkApp
(
**
params
)
app_info
=
epk
.
pack
()
app_info
[
'md5'
]
=
str
(
app_info
[
'md5'
])
# 更新数据库对应文件路径
# 将文件拷贝过去后,需要重新更新数据库文件记录
epk_path
=
os
.
sep
.
join
([
target_dir
.
replace
(
config
.
UPLOAD_ROOT_DIR
,
""
),
"{}.epk"
.
format
(
app
.
app_name
)])
.
replace
(
'
\\
'
,
'/'
)
result
=
PackageModel
.
query
.
filter
(
PackageModel
.
app
==
app
.
id
)
.
one_or_none
()
if
result
:
result
.
app_path
=
epk_path
result
.
app_info
=
app_info
result
.
update_by
=
user
result
.
update_at
=
datetime
.
now
()
db
.
session
.
commit
()
else
:
result
=
PackageModel
(
app
=
app
.
id
,
file_path
=
epk_path
,
package_info
=
app_info
,
app_version
=
params
.
get
(
"app_version"
),
source
=
2
,
create_by
=
user
,
create_at
=
datetime
.
now
(),
update_by
=
user
,
update_at
=
datetime
.
now
())
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
with
open
(
os
.
sep
.
join
([
target_dir
,
"epk.json"
]),
"w"
)
as
f
:
json
.
dump
(
app
.
to_dict
(),
f
)
return
{
'app_name'
:
app
.
app_name
,
'app_file'
:
"{}.epk"
.
format
(
app
.
app_name
),
'app_url'
:
parse
.
urljoin
(
config
[
'UPLOAD_SERVER'
],
epk_path
)
},
ResponseCode
.
HTTP_SUCCESS
buildAppResource
=
BuildAppResource
()
tools/build_out/controllers/device.py
0 → 100644
View file @
9ed09a30
'''
Author: your name
Date: 2021-07-11 01:47:14
LastEditTime: 2021-07-12 18:18:21
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\
controllers
\
device.py
'''
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
datetime
import
datetime
from
application.app
import
db
from
models.device
import
DeviceModel
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
class
DeviceResource
(
object
):
def
__init__
(
self
):
super
()
.
__init__
()
def
get
(
self
,
uuid
,
params
):
# handle business
filters
=
[
DeviceModel
.
is_delete
==
False
,
DeviceModel
.
uuid
==
uuid
]
result
=
DeviceModel
.
query
.
filter
(
*
filters
)
.
first
()
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
getList
(
self
,
params
):
# handle business
logger
.
warn
(
params
)
filters
=
[
DeviceModel
.
is_delete
==
False
]
result
=
DeviceModel
.
query
.
filter
(
*
filters
)
.
order_by
(
DeviceModel
.
create_at
)
.
paginate
(
params
.
get
(
'page'
,
1
),
params
.
get
(
'pageSize'
,
10
),
error_out
=
False
)
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
result
=
DeviceModel
.
query
.
filter
(
DeviceModel
.
imei
==
params
.
get
(
'imei'
))
.
first
()
if
result
and
result
.
is_delete
:
result
.
is_delete
=
False
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
elif
result
and
result
.
is_delete
==
False
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
result
=
DeviceModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
put
(
self
,
uuid
,
params
,
jwt
=
{}):
# handle business
result
=
DeviceModel
.
query
.
filter
(
DeviceModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
if
params
:
for
key
,
value
in
params
.
items
():
if
value
!=
None
:
setattr
(
result
,
key
,
value
)
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
else
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
DeviceModel
.
query
.
filter
(
DeviceModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
result
.
is_delete
=
True
db
.
session
.
delete
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
deviceManager
=
DeviceResource
()
\ No newline at end of file
tools/build_out/controllers/file.py
0 → 100644
View file @
9ed09a30
import
pprint
import
base64
from
pathlib
import
Path
import
json
import
mimetypes
from
webcreator.log
import
logger
from
application.config
import
config
from
webcreator.response
import
ResponseCode
disk_root
=
config
.
UPLOAD_ROOT_DIR
logger
.
info
(
disk_root
)
class
FileManager
(
object
):
def
__init__
(
self
)
->
None
:
pass
'''
@description: 根据前端传递的路径参数,获取该路径的目录以及文件信息,文件类别,可以看做是一个盘符
@param {*} self
@return {*}
'''
def
initialize
(
self
):
'''
disks: {
files: {driver: "local"},
images: {driver: "local"}
}
lang: "en"
leftDisk: null
rightDisk: null
windowsConfig: 2
'''
result
=
{
"disks"
:
{},
"lang"
:
"zh"
,
"leftDisk"
:
None
,
"rightDisk"
:
None
,
"windowsConfig"
:
1
}
# 这里需要过滤,有些目录只能管理员才能查看
p
=
Path
(
disk_root
)
for
child
in
p
.
iterdir
():
if
child
.
is_dir
():
result
[
"disks"
]
.
update
({
child
.
name
:
{
"driver"
:
"local"
}
})
return
result
,
ResponseCode
.
HTTP_SUCCESS
'''
@description: 获取当前类别的目录信息
@param {*} self
@return {*}
'''
def
content
(
self
,
disk
,
target_path
=
'/'
):
'''
目录信息结构体:
{
basename: "docs"
dirname: ""
path: "docs"
timestamp: 1556821372
type: "dir"
},
{
basename: "cars"
dirname: "wallpapers"
path: "wallpapers/cars"
timestamp: 1544277291
type: "dir"
}
文件信息结构体:
{
basename: "alfa.sql"
dirname: "code"
extension: "sql"
filename: "alfa"
path: "code/alfa.sql"
size: 3208
timestamp: 1544277274
type: "file"
}
'''
target_path
=
Path
(
target_path
)
result
=
{
"directories"
:
[],
"files"
:
[]
}
disk_path
=
Path
(
disk_root
)
.
joinpath
(
disk
)
if
not
disk_path
.
exists
():
return
result
target_path
=
disk_path
.
joinpath
(
target_path
)
if
not
target_path
.
exists
():
return
result
for
child
in
target_path
.
iterdir
():
if
child
.
is_dir
():
result
[
"directories"
]
.
append
({
"basename"
:
child
.
name
,
"dirname"
:
child
.
parent
.
relative_to
(
disk_path
)
.
as_posix
(),
"path"
:
child
.
resolve
()
.
relative_to
(
disk_path
)
.
as_posix
(),
"timestamp"
:
int
(
child
.
stat
()
.
st_mtime
),
"type"
:
"dir"
})
else
:
result
[
"files"
]
.
append
({
"basename"
:
child
.
name
,
"dirname"
:
child
.
parent
,
"extension"
:
child
.
suffix
[
1
:],
"filename"
:
child
.
stem
,
"path"
:
child
.
resolve
()
.
relative_to
(
disk_path
)
.
as_posix
(),
"size"
:
child
.
stat
()
.
st_size
,
"timestamp"
:
int
(
child
.
stat
()
.
st_mtime
),
"type"
:
"file"
})
with
open
(
"result.json"
,
"w"
)
as
f
:
json
.
dump
(
result
,
f
)
f
.
seek
(
0
)
f
.
truncate
()
f
.
write
(
json
.
dumps
(
result
,
ensure_ascii
=
True
))
pprint
.
pprint
(
result
)
return
result
,
ResponseCode
.
HTTP_SUCCESS
'''
@description: 获取目录结构树
@param {*} self
@return {*}
'''
def
tree
(
self
,
disk
,
target_path
=
"/"
):
'''
{
basename: "trees"
dirname: "wallpapers/nature"
path: "wallpapers/nature/trees"
props: {
hasSubdirectories: false
}
timestamp: 1544277291
type: "dir"
}
'''
target_path
=
Path
(
target_path
)
result
=
[]
rp
=
Path
(
disk_root
)
disk_path
=
rp
/
disk
if
not
disk_path
.
exists
():
return
result
temp_path
=
disk_path
.
joinpath
(
target_path
)
if
not
temp_path
.
exists
():
return
result
p
=
Path
(
disk_path
)
for
child
in
p
.
iterdir
():
if
child
.
is_dir
():
result
.
append
({
"basename"
:
child
.
name
,
"dirname"
:
child
.
parent
.
relative_to
(
rp
)
.
as_posix
(),
"path"
:
child
.
relative_to
(
rp
)
.
as_posix
(),
"props"
:
{
"hasSubdirectories"
:
True
if
child
.
iterdir
()
else
False
},
"timestamp"
:
int
(
child
.
stat
()
.
st_mtime
),
"type"
:
"dir"
})
pprint
.
pprint
(
result
)
return
result
,
ResponseCode
.
HTTP_SUCCESS
def
disk
(
self
,
disk
):
# select-disks
print
(
disk
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
upload
(
self
,
disk
):
# select-disks
print
(
disk
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
create_dir
(
self
,
disk
,
target_file
):
# create directory
print
(
disk
,
target_file
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
create_file
(
self
,
disk
,
target_file
,
content
):
# create file
print
(
disk
,
target_file
,
content
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
delete
(
self
,
disk
):
# delete file
print
(
disk
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
copy
(
self
,
disk
):
# copy file
print
(
disk
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
cut
(
self
,
disk
):
# cut file
print
(
disk
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
paste
(
self
,
disk
):
# paste file
print
(
disk
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
download
(
self
,
disk
,
target_file
):
# 获取文件内容
if
not
target_file
:
target_file
=
Path
(
'result.json'
)
else
:
target_file
=
Path
(
disk_root
)
.
joinpath
(
disk
)
.
joinpath
(
target_file
)
if
not
target_file
.
exists
():
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
# with open(target_file.resolve().as_posix(), "r", encoding="utf-8") as f:
# data = f.read()
# logger.info(data)
mime
=
mimetypes
.
guess_type
(
target_file
.
resolve
()
.
as_posix
())[
0
]
content
=
target_file
.
read_text
(
encoding
=
"utf-8"
)
return
(
content
,
mime
),
ResponseCode
.
HTTP_SUCCESS
def
preview
(
self
,
disk
,
target_file
):
# 预览图片
if
not
target_file
:
target_file
=
Path
(
'evue_photo.png'
)
else
:
target_file
=
Path
(
disk_root
)
.
joinpath
(
disk
)
.
joinpath
(
target_file
)
if
not
target_file
.
exists
():
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
mime
=
mimetypes
.
guess_type
(
target_file
.
resolve
()
.
as_posix
())[
0
]
# mime = MimeTypes.guess_type(target_file.resolve().as_posix())
img_stream
=
target_file
.
read_bytes
()
# with open(target_file, 'rb') as img_f:
# img_stream = img_f.read()
# img_stream = base64.b64encode(img_stream).decode()
return
(
img_stream
,
mime
),
ResponseCode
.
HTTP_SUCCESS
fileManager
=
FileManager
()
if
__name__
==
"__main__"
:
'''
python -m memory_profiler example.py
'''
# from memory_profiler import profile
# @profile
# def test():
# pass
result
=
fileManager
.
initialize
()
print
(
"----->"
,
result
)
result
=
fileManager
.
content
(
"uploads"
,
"evueapps/evm"
)
print
(
">>>>>>"
,
result
)
result
=
fileManager
.
tree
(
"uploads"
,
"evueapps/evm"
)
print
(
"=====>"
,
result
)
result
=
fileManager
.
preview
(
"uploads"
,
"evueapps/evm"
)
print
(
"$$$$$>"
,
result
)
tools/build_out/controllers/monitor.py
0 → 100644
View file @
9ed09a30
'''
Author: your name
Date: 2021-06-29 19:24:32
LastEditTime: 2021-07-12 12:09:34
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\b
ackend
\
controller
\
monitor.py
'''
from
application.app
import
db
from
models.monitorEvm
import
MonitorEvmModel
from
models.monitorImage
import
MonitorImageModel
from
models.monitorLvgl
import
MonitorLvglModel
from
models.monitorSystem
import
MonitorSystemModel
from
models.monitorWatch
import
MonitorWatchModel
class
SystemResource
(
object
):
def
get
(
self
):
return
MonitorSystemModel
.
query
.
all
()
def
post
(
self
,
params
):
result
=
MonitorSystemModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
class
LvglResource
(
object
):
def
get
(
self
):
return
MonitorLvglModel
.
query
.
all
()
def
post
(
self
,
params
):
result
=
MonitorLvglModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
class
EvmResource
(
object
):
def
get
(
self
):
return
MonitorEvmModel
.
query
.
all
()
def
post
(
self
,
params
):
result
=
MonitorEvmModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
class
ImageResource
(
object
):
def
get
(
self
):
return
MonitorImageModel
.
query
.
all
()
def
post
(
self
,
params
):
result
=
MonitorImageModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
def
post_array
(
self
,
array
,
watch
):
t
=
[]
for
a
in
array
:
a
.
update
({
"watch"
:
watch
})
t
.
append
(
**
a
)
db
.
session
.
execute
(
MonitorImageModel
.
__table__
.
insert
(),
t
)
db
.
session
.
commit
()
return
True
systemResource
=
SystemResource
()
lvglResource
=
LvglResource
()
evmResource
=
EvmResource
()
imageResource
=
ImageResource
()
def
insert_data
(
msg
):
# 先判断手表imei是否存在,不存在则先注册手表IMEI
watch_id
=
-
1
if
msg
.
get
(
"imei"
):
result
=
MonitorWatchModel
.
query
.
filter_by
(
imei
=
msg
.
get
(
"imei"
))
.
one_or_none
()
if
result
:
watch_id
=
result
.
id
else
:
result
=
MonitorWatchModel
.
query
.
filter
(
MonitorWatchModel
.
imei
==
msg
.
get
(
"imei"
))
.
one_or_none
()
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
watch_id
=
result
.
id
if
msg
.
get
(
"system"
)
or
msg
.
get
(
"request"
):
msg
.
get
(
"system"
,
{})
.
update
({
"watch"
:
watch_id
})
msg
.
get
(
"system"
)
.
update
(
msg
.
get
(
"request"
,
{}))
systemResource
.
post
(
msg
.
get
(
"system"
))
if
msg
.
get
(
"lvgl"
):
msg
.
get
(
"lvgl"
)
.
update
({
"watch"
:
watch_id
})
lvglResource
.
post
(
msg
.
get
(
"lvgl"
))
if
msg
.
get
(
"evm"
):
msg
.
get
(
"evm"
)
.
update
({
"watch"
:
watch_id
})
evmResource
.
post
(
msg
.
get
(
"evm"
))
if
msg
.
get
(
"image"
):
imageResource
.
post_array
(
msg
.
get
(
"image"
),
watch_id
)
def
get_watch_list
():
result
=
MonitorWatchModel
.
query
.
all
()
tmp
=
[]
for
item
in
result
:
tmp
.
append
({
'id'
:
item
.
id
,
'imei'
:
item
.
imei
})
return
tmp
def
evm_data
(
watch
,
start
,
end
):
filters
=
[
MonitorEvmModel
.
watch
==
watch
]
if
start
:
filters
.
append
(
MonitorEvmModel
.
timestamp
>=
start
)
if
end
:
filters
.
append
(
MonitorEvmModel
.
timestamp
<=
end
)
result
=
MonitorEvmModel
.
query
.
filter
(
*
filters
)
.
order_by
(
MonitorEvmModel
.
timestamp
)
.
all
()
temp
=
[]
for
item
in
result
:
t
=
item
.
to_dict
()
if
t
.
get
(
"timestamp"
):
t
.
update
({
'timestamp'
:
t
.
get
(
"timestamp"
)
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
})
temp
.
append
(
t
)
return
temp
def
lvgl_data
(
watch
,
start
,
end
):
filters
=
[
MonitorLvglModel
.
watch
==
watch
]
if
start
:
filters
.
append
(
MonitorLvglModel
.
timestamp
>=
start
)
if
end
:
filters
.
append
(
MonitorLvglModel
.
timestamp
<=
end
)
result
=
MonitorLvglModel
.
query
.
filter
(
*
filters
)
.
order_by
(
MonitorLvglModel
.
timestamp
)
.
all
()
temp
=
[]
for
item
in
result
:
t
=
item
.
to_dict
()
if
t
.
get
(
"timestamp"
):
t
.
update
({
'timestamp'
:
t
.
get
(
"timestamp"
)
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
})
temp
.
append
(
t
)
return
temp
def
image_data
(
watch
,
start
,
end
):
filters
=
[
MonitorImageModel
.
watch
==
watch
]
if
start
:
filters
.
append
(
MonitorImageModel
.
timestamp
>=
start
)
if
end
:
filters
.
append
(
MonitorImageModel
.
timestamp
<=
end
)
result
=
MonitorImageModel
.
query
.
filter
(
*
filters
)
.
order_by
(
MonitorImageModel
.
timestamp
)
.
all
()
temp
=
[]
for
item
in
result
:
t
=
item
.
to_dict
()
if
t
.
get
(
"timestamp"
):
t
.
update
({
'timestamp'
:
t
.
get
(
"timestamp"
)
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
})
temp
.
append
(
t
)
return
temp
def
get_monitor_list
(
watch
,
category
,
start
,
end
):
# 判断watch是否存在
w
=
MonitorWatchModel
.
query
.
filter
(
MonitorWatchModel
.
id
==
watch
)
.
first
()
if
not
w
:
return
[]
if
category
==
"system"
:
return
[]
elif
category
==
"image"
:
return
image_data
(
watch
,
start
,
end
)
elif
category
==
"lvgl"
:
return
lvgl_data
(
watch
,
start
,
end
)
elif
category
==
"evm"
:
return
evm_data
(
watch
,
start
,
end
)
else
:
return
{
'evm'
:
evm_data
(
watch
,
start
,
end
),
'lvgl'
:
lvgl_data
(
watch
,
start
,
end
),
'image'
:
image_data
(
watch
,
start
,
end
)
}
tools/build_out/controllers/monitorEvm.py
0 → 100644
View file @
9ed09a30
'''
Author: your name
Date: 2021-07-11 01:47:14
LastEditTime: 2021-07-12 18:19:09
LastEditors: your name
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\
controllers
\
monitorEvm.py
'''
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
datetime
import
datetime
from
application.app
import
db
from
models.monitorEvm
import
MonitorEvmModel
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
class
MonitorEvmResource
(
object
):
def
__init__
(
self
):
super
()
.
__init__
()
def
get
(
self
,
uuid
,
params
):
# handle business
filters
=
[
MonitorEvmModel
.
is_delete
==
False
,
MonitorEvmModel
.
uuid
==
uuid
]
result
=
MonitorEvmModel
.
query
.
filter
(
*
filters
)
.
first
()
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
getList
(
self
,
params
):
# handle business
logger
.
warn
(
params
)
filters
=
[
MonitorEvmModel
.
is_delete
==
False
]
result
=
MonitorEvmModel
.
query
.
filter
(
*
filters
)
.
order_by
(
MonitorEvmModel
.
create_at
)
.
paginate
(
params
.
get
(
'page'
,
1
),
params
.
get
(
'pageSize'
,
10
),
error_out
=
False
)
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
result
=
MonitorEvmModel
.
query
.
filter
(
MonitorEvmModel
.
watch
==
params
.
get
(
'watch'
))
.
first
()
if
result
and
result
.
is_delete
:
result
.
is_delete
=
False
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
elif
result
and
result
.
is_delete
==
False
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
result
=
MonitorEvmModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
put
(
self
,
uuid
,
params
,
jwt
=
{}):
# handle business
result
=
MonitorEvmModel
.
query
.
filter
(
MonitorEvmModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
if
params
:
for
key
,
value
in
params
.
items
():
if
value
!=
None
:
setattr
(
result
,
key
,
value
)
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
else
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
MonitorEvmModel
.
query
.
filter
(
MonitorEvmModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
result
.
is_delete
=
True
db
.
session
.
delete
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
monitorEvmManager
=
MonitorEvmResource
()
\ No newline at end of file
tools/build_out/controllers/monitorImage.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
datetime
import
datetime
from
application.app
import
db
from
models.monitorImage
import
MonitorImageModel
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
MonitorImageResource
(
object
):
def
__init__
(
self
):
super
()
.
__init__
()
def
get
(
self
,
uuid
,
params
):
# handle business
filters
=
[
MonitorImageModel
.
is_delete
==
False
,
MonitorImageModel
.
uuid
==
uuid
]
result
=
MonitorImageModel
.
query
.
filter
(
*
filters
)
.
first
()
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
getList
(
self
,
params
):
# handle business
logger
.
warn
(
params
)
filters
=
[
MonitorImageModel
.
is_delete
==
False
]
result
=
MonitorImageModel
.
query
.
filter
(
*
filters
)
.
order_by
(
MonitorImageModel
.
create_at
)
.
paginate
(
params
.
get
(
'page'
,
1
),
params
.
get
(
'pageSize'
,
10
),
error_out
=
False
)
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
result
=
MonitorImageModel
.
query
.
filter
(
MonitorImageModel
.
watch
==
params
.
get
(
'watch'
))
.
first
()
if
result
and
result
.
is_delete
:
result
.
is_delete
=
False
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
elif
result
and
result
.
is_delete
==
False
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
result
=
MonitorImageModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
put
(
self
,
uuid
,
params
,
jwt
=
{}):
# handle business
result
=
MonitorImageModel
.
query
.
filter
(
MonitorImageModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
if
params
:
for
key
,
value
in
params
.
items
():
if
value
!=
None
:
setattr
(
result
,
key
,
value
)
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
else
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
MonitorImageModel
.
query
.
filter
(
MonitorImageModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
result
.
is_delete
=
True
db
.
session
.
delete
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
monitorImageManager
=
MonitorImageResource
()
\ No newline at end of file
tools/build_out/controllers/monitorLvgl.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
datetime
import
datetime
from
application.app
import
db
from
models.monitorLvgl
import
MonitorLvglModel
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
MonitorLvglResource
(
object
):
def
__init__
(
self
):
super
()
.
__init__
()
def
get
(
self
,
uuid
,
params
):
# handle business
filters
=
[
MonitorLvglModel
.
is_delete
==
False
,
MonitorLvglModel
.
uuid
==
uuid
]
result
=
MonitorLvglModel
.
query
.
filter
(
*
filters
)
.
first
()
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
getList
(
self
,
params
):
# handle business
logger
.
warn
(
params
)
filters
=
[
MonitorLvglModel
.
is_delete
==
False
]
result
=
MonitorLvglModel
.
query
.
filter
(
*
filters
)
.
order_by
(
MonitorLvglModel
.
create_at
)
.
paginate
(
params
.
get
(
'page'
,
1
),
params
.
get
(
'pageSize'
,
10
),
error_out
=
False
)
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
result
=
MonitorLvglModel
.
query
.
filter
(
MonitorLvglModel
.
watch
==
params
.
get
(
'watch'
))
.
first
()
if
result
and
result
.
is_delete
:
result
.
is_delete
=
False
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
elif
result
and
result
.
is_delete
==
False
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
result
=
MonitorLvglModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
put
(
self
,
uuid
,
params
,
jwt
=
{}):
# handle business
result
=
MonitorLvglModel
.
query
.
filter
(
MonitorLvglModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
if
params
:
for
key
,
value
in
params
.
items
():
if
value
!=
None
:
setattr
(
result
,
key
,
value
)
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
else
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
MonitorLvglModel
.
query
.
filter
(
MonitorLvglModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
result
.
is_delete
=
True
db
.
session
.
delete
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
monitorLvglManager
=
MonitorLvglResource
()
\ No newline at end of file
tools/build_out/controllers/monitorSystem.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
datetime
import
datetime
from
application.app
import
db
from
models.monitorSystem
import
MonitorSystemModel
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
MonitorSystemResource
(
object
):
def
__init__
(
self
):
super
()
.
__init__
()
def
get
(
self
,
uuid
,
params
):
# handle business
filters
=
[
MonitorSystemModel
.
is_delete
==
False
,
MonitorSystemModel
.
uuid
==
uuid
]
result
=
MonitorSystemModel
.
query
.
filter
(
*
filters
)
.
first
()
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
getList
(
self
,
params
):
# handle business
logger
.
warn
(
params
)
filters
=
[
MonitorSystemModel
.
is_delete
==
False
]
result
=
MonitorSystemModel
.
query
.
filter
(
*
filters
)
.
order_by
(
MonitorSystemModel
.
create_at
)
.
paginate
(
params
.
get
(
'page'
,
1
),
params
.
get
(
'pageSize'
,
10
),
error_out
=
False
)
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
result
=
MonitorSystemModel
.
query
.
filter
(
MonitorSystemModel
.
watch
==
params
.
get
(
'watch'
))
.
first
()
if
result
and
result
.
is_delete
:
result
.
is_delete
=
False
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
elif
result
and
result
.
is_delete
==
False
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
result
=
MonitorSystemModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
put
(
self
,
uuid
,
params
,
jwt
=
{}):
# handle business
result
=
MonitorSystemModel
.
query
.
filter
(
MonitorSystemModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
if
params
:
for
key
,
value
in
params
.
items
():
if
value
!=
None
:
setattr
(
result
,
key
,
value
)
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
else
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
MonitorSystemModel
.
query
.
filter
(
MonitorSystemModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
result
.
is_delete
=
True
db
.
session
.
delete
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
monitorSystemManager
=
MonitorSystemResource
()
\ No newline at end of file
tools/build_out/controllers/monitorWatch.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
datetime
import
datetime
from
application.app
import
db
from
models.monitorWatch
import
MonitorWatchModel
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
MonitorWatchResource
(
object
):
def
__init__
(
self
):
super
()
.
__init__
()
def
get
(
self
,
uuid
,
params
):
# handle business
filters
=
[
MonitorWatchModel
.
is_delete
==
False
,
MonitorWatchModel
.
uuid
==
uuid
]
result
=
MonitorWatchModel
.
query
.
filter
(
*
filters
)
.
first
()
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
getList
(
self
,
params
):
# handle business
logger
.
warn
(
params
)
filters
=
[
MonitorWatchModel
.
is_delete
==
False
]
result
=
MonitorWatchModel
.
query
.
filter
(
*
filters
)
.
order_by
(
MonitorWatchModel
.
create_at
)
.
paginate
(
params
.
get
(
'page'
,
1
),
params
.
get
(
'pageSize'
,
10
),
error_out
=
False
)
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
result
=
MonitorWatchModel
.
query
.
filter
(
MonitorWatchModel
.
imei
==
params
.
get
(
'imei'
))
.
first
()
if
result
and
result
.
is_delete
:
result
.
is_delete
=
False
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
elif
result
and
result
.
is_delete
==
False
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
result
=
MonitorWatchModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
put
(
self
,
uuid
,
params
,
jwt
=
{}):
# handle business
result
=
MonitorWatchModel
.
query
.
filter
(
MonitorWatchModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
if
params
:
for
key
,
value
in
params
.
items
():
if
value
!=
None
:
setattr
(
result
,
key
,
value
)
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
else
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
MonitorWatchModel
.
query
.
filter
(
MonitorWatchModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
result
.
is_delete
=
True
db
.
session
.
delete
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
monitorWatchManager
=
MonitorWatchResource
()
\ No newline at end of file
tools/build_out/controllers/upload.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
import
os
import
json
import
traceback
import
tempfile
import
base64
from
hashlib
import
md5
from
application.config
import
config
from
webcreator.log
import
logger
# 判断目录是否存在,不存在则创建
# if not os.path.exists(os.path.join(config.UPLOAD_ROOT_DIR, config.get("UPLOAD_DIR"))):
# os.makedirs(os.path.join(config.UPLOAD_ROOT_DIR, config.get("UPLOAD_DIR")))
def
checkAccess
(
path
):
realpath
=
os
.
path
.
realpath
(
path
)
if
not
realpath
.
startswith
(
config
.
UPLOAD_ROOT_DIR
):
return
False
return
True
def
checkPath
(
path
):
if
not
path
:
return
False
,
{
"code"
:
-
1
,
"data"
:
None
,
"message"
:
"[
%
s] arg missed!"
%
path
}
fpath
=
os
.
path
.
abspath
(
os
.
sep
.
join
(
[
os
.
path
.
abspath
(
config
.
UPLOAD_ROOT_DIR
),
path
]))
if
not
checkAccess
(
fpath
):
return
False
,
{
"code"
:
-
1
,
"data"
:
None
,
"message"
:
"You have no access to [
%
s]!"
%
fpath
}
if
not
os
.
path
.
exists
(
fpath
):
return
False
,
{
"code"
:
-
1
,
"data"
:
None
,
"message"
:
"[
%
s] is not existed!"
%
fpath
}
return
True
,
os
.
path
.
abspath
(
fpath
)
def
saveToFile
(
saveFile
,
content
):
try
:
tfn
=
tempfile
.
mktemp
()
tf
=
open
(
tfn
,
'w+b'
)
tf
.
write
(
content
)
tf
.
close
()
os
.
rename
(
tfn
,
saveFile
)
return
True
except
Exception
as
e
:
traceback
.
print_exc
()
logger
.
error
(
str
(
e
))
return
False
def
getFileInfo
(
infofile
):
info
=
dict
()
info
.
update
({
"isfile"
:
os
.
path
.
isfile
(
infofile
),
"isdir"
:
os
.
path
.
isdir
(
infofile
),
"size"
:
os
.
path
.
getsize
(
infofile
),
"atime"
:
os
.
path
.
getatime
(
infofile
),
"mtime"
:
os
.
path
.
getmtime
(
infofile
),
"ctime"
:
os
.
path
.
getctime
(
infofile
),
"name"
:
os
.
path
.
basename
(
infofile
)
})
return
info
class
UploadResource
(
object
):
def
__init__
(
self
):
super
(
UploadResource
,
self
)
.
__init__
()
def
download
(
self
,
data
):
obj
=
json
.
loads
(
data
)
isAccessed
,
path
=
checkPath
(
obj
[
"path"
])
if
not
isAccessed
:
return
{
"code"
:
-
1
,
"data"
:
None
,
"message"
:
"invaild access"
}
if
not
os
.
path
.
isfile
(
path
):
return
{
"code"
:
-
1
,
"data"
:
None
,
"message"
:
"Path [
%
s] is not a valid file!"
%
path
}
try
:
with
open
(
path
,
"rb"
)
as
f
:
content
=
base64
.
b64encode
(
f
.
read
())
md5code
=
md5
(
content
)
.
hexdigest
()
return
{
"data"
:
{
"content"
:
content
,
"md5"
:
md5code
,
"filename"
:
os
.
path
.
basename
(
path
)
},
"code"
:
0
,
"message"
:
"download file [
%
s] successfully!"
%
obj
[
'path'
]
}
except
Exception
as
e
:
traceback
.
print_exc
()
logger
.
error
(
str
(
e
))
return
{
"data"
:
None
,
"code"
:
-
1
,
"message"
:
"upload file [
%
s] failed!
\n
%
s"
%
(
obj
[
'path'
],
repr
(
e
))
}
def
delete
(
self
,
data
):
try
:
isAccessed
,
path
=
checkPath
(
data
[
"path"
])
if
not
isAccessed
:
return
{
"code"
:
-
1
,
"data"
:
None
,
"message"
:
"invaild access"
}
if
os
.
path
.
isfile
(
path
):
os
.
remove
(
path
)
return
{
"code"
:
0
,
"data"
:
None
,
"message"
:
"delete file [
%
s] successfully!"
%
path
}
elif
os
.
path
.
isdir
(
path
):
os
.
rmdir
(
path
)
return
{
"code"
:
0
,
"data"
:
None
,
"message"
:
"delete dir [
%
s] successfully!"
%
path
}
else
:
return
{
"code"
:
0
,
"data"
:
None
,
"message"
:
"Path [
%
s] is not a valid file or path!"
%
path
}
except
Exception
as
e
:
traceback
.
print_exc
()
logger
.
error
(
str
(
e
))
return
{
"code"
:
-
1
,
"data"
:
None
,
"message"
:
repr
(
e
)}
def
dirlist
(
self
,
data
):
obj
=
json
.
loads
(
data
)
isAccessed
,
path
=
checkPath
(
obj
[
"path"
])
if
not
isAccessed
:
return
{
"code"
:
-
1
,
"data"
:
None
,
"message"
:
"invaild access"
}
result
=
[]
for
p
in
os
.
listdir
(
path
):
result
.
append
(
getFileInfo
(
os
.
path
.
join
(
config
.
UPLOAD_ROOT_DIR
,
p
)))
return
{
"code"
:
0
,
"result"
:
result
,
"message"
:
"Get [
%
s] successfully!"
%
path
}
def
filemd5
(
self
,
data
):
obj
=
json
.
loads
(
data
)
isAccessed
,
path
=
checkPath
(
obj
[
"path"
])
if
not
isAccessed
:
return
{
"code"
:
-
1
,
"data"
:
None
,
"message"
:
"invaild access"
}
if
not
os
.
path
.
isfile
(
path
):
return
{
"code"
:
-
1
,
"data"
:
None
,
"message"
:
"Path [
%
s] is not a valid file!"
%
path
}
with
open
(
path
,
"rb"
)
as
f
:
filemd5
=
md5
(
f
.
read
())
.
hexdigest
()
return
{
"code"
:
0
,
"result"
:
filemd5
,
"message"
:
"Get md5 of [
%
s] successfully!"
%
path
}
def
fileinfo
(
self
,
data
):
obj
=
json
.
loads
(
data
)
isAccessed
,
path
=
checkPath
(
obj
[
"path"
])
if
not
isAccessed
:
return
{
"code"
:
-
1
,
"data"
:
None
,
"message"
:
"invaild access"
}
if
not
os
.
path
.
isfile
(
path
):
return
{
"code"
:
-
1
,
"data"
:
None
,
"message"
:
"Path [
%
s] is not a valid file!"
%
path
}
return
{
"code"
:
0
,
"result"
:
getFileInfo
(
path
),
"message"
:
"Get md5 of [
%
s] successfully!"
%
path
}
uploadResource
=
UploadResource
()
tools/build_out/evue_photo.png
0 → 100644
View file @
9ed09a30
4.19 KB
tools/build_out/models/annex.py
0 → 100644
View file @
9ed09a30
'''
Author: your name
Date: 2021-07-11 01:47:14
LastEditTime: 2021-07-12 01:56:38
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\
models
\a
nnex.py
'''
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
application.app
import
db
,
ma
from
.base
import
PrimaryModel
from
marshmallow
import
Schema
,
fields
,
INCLUDE
,
EXCLUDE
class
AnnexModel
(
PrimaryModel
):
__tablename__
=
'evm_annex'
app
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
title
=
db
.
Column
(
db
.
String
(
100
),
index
=
True
,
nullable
=
False
,
default
=
''
)
path
=
db
.
Column
(
db
.
String
(
256
),
index
=
True
,
nullable
=
False
,
default
=
''
)
size
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
,
default
=
0
)
# __table_args__ = (
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# )
def
__init__
(
self
,
app
,
title
=
''
,
path
=
''
,
size
=
0
,
create_by
=
None
,
create_at
=
None
,
update_by
=
None
,
update_at
=
None
):
self
.
app
=
app
self
.
title
=
title
self
.
path
=
path
self
.
size
=
size
self
.
create_by
=
create_by
self
.
create_at
=
create_at
self
.
update_by
=
update_by
self
.
update_at
=
update_at
def
__repr__
(
self
):
return
'<AnnexModel
%
r>'
%
(
self
.
app
)
def
to_dict
(
self
):
return
{
'app'
:
self
.
app
,
'title'
:
self
.
title
,
'path'
:
self
.
path
,
'size'
:
self
.
size
,
}
class
DeleteAnnexSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
AnnexModel
deleteAnnexSchema
=
DeleteAnnexSchema
()
class
GetListAnnexSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
AnnexModel
page
=
fields
.
Integer
(
required
=
False
)
pageSize
=
fields
.
Integer
(
required
=
False
)
title
=
ma
.
auto_field
()
app
=
ma
.
auto_field
()
getListAnnexSchema
=
GetListAnnexSchema
()
getListAnnexsSchema
=
GetListAnnexSchema
(
many
=
True
)
class
GetAnnexSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
AnnexModel
app
=
ma
.
auto_field
()
getAnnexSchema
=
GetAnnexSchema
()
tools/build_out/models/device.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
application.app
import
db
,
ma
from
.base
import
PrimaryModel
from
marshmallow
import
Schema
,
fields
,
INCLUDE
,
EXCLUDE
class
DeviceModel
(
PrimaryModel
):
__tablename__
=
'evm_device'
imei
=
db
.
Column
(
db
.
String
(
20
),
index
=
True
,
nullable
=
False
)
name
=
db
.
Column
(
db
.
String
(
20
),
index
=
True
,
nullable
=
False
,
default
=
''
)
type
=
db
.
Column
(
db
.
String
(
20
),
nullable
=
False
,
default
=
''
)
desc
=
db
.
Column
(
db
.
String
(
20
),
index
=
True
,
nullable
=
False
,
default
=
''
)
# __table_args__ = (
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# )
def
__init__
(
self
,
imei
,
name
=
''
,
type
=
''
,
desc
=
''
):
self
.
imei
=
imei
self
.
name
=
name
self
.
type
=
type
self
.
desc
=
desc
def
__repr__
(
self
):
return
'<DeviceModel
%
r>'
%
(
self
.
imei
)
def
to_dict
(
self
):
return
{
'imei'
:
self
.
imei
,
'name'
:
self
.
name
,
'type'
:
self
.
type
,
'desc'
:
self
.
desc
,
}
class
PostDeviceSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
DeviceModel
imei
=
ma
.
auto_field
()
name
=
ma
.
auto_field
()
type
=
ma
.
auto_field
()
desc
=
ma
.
auto_field
()
postDeviceSchema
=
PostDeviceSchema
()
class
DeleteDeviceSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
DeviceModel
deleteDeviceSchema
=
DeleteDeviceSchema
()
class
GetListDeviceSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
DeviceModel
page
=
fields
.
Integer
(
required
=
False
)
pageSize
=
fields
.
Integer
(
required
=
False
)
imei
=
ma
.
auto_field
()
name
=
ma
.
auto_field
()
getListDeviceSchema
=
GetListDeviceSchema
()
getListDevicesSchema
=
GetListDeviceSchema
(
many
=
True
)
class
GetDeviceSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
DeviceModel
imei
=
ma
.
auto_field
()
name
=
ma
.
auto_field
()
type
=
ma
.
auto_field
()
getDeviceSchema
=
GetDeviceSchema
()
class
PutDeviceSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
DeviceModel
imei
=
fields
.
String
(
required
=
False
,
length
=
None
)
name
=
fields
.
String
(
required
=
False
,
length
=
None
)
type
=
fields
.
String
(
required
=
False
,
length
=
None
)
desc
=
fields
.
String
(
required
=
False
,
length
=
None
)
putDeviceSchema
=
PutDeviceSchema
()
tools/build_out/models/monitorEvm.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
application.app
import
db
,
ma
from
.base
import
PrimaryModel
from
marshmallow
import
Schema
,
fields
,
INCLUDE
,
EXCLUDE
class
MonitorEvmModel
(
PrimaryModel
):
__tablename__
=
'evm_monitor_evm'
watch
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
heap_map_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
,
default
=
0
)
heap_total_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
,
default
=
0
)
heap_used_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
,
default
=
0
)
stack_total_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
,
default
=
0
)
stack_used_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
,
default
=
0
)
# __table_args__ = (
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# )
def
__init__
(
self
,
watch
,
heap_map_size
=
0
,
heap_total_size
=
0
,
heap_used_size
=
0
,
stack_total_size
=
0
,
stack_used_size
=
0
):
self
.
watch
=
watch
self
.
heap_map_size
=
heap_map_size
self
.
heap_total_size
=
heap_total_size
self
.
heap_used_size
=
heap_used_size
self
.
stack_total_size
=
stack_total_size
self
.
stack_used_size
=
stack_used_size
def
__repr__
(
self
):
return
'<MonitorEvmModel
%
r>'
%
(
self
.
watch
)
def
to_dict
(
self
):
return
{
'watch'
:
self
.
watch
,
'heap_map_size'
:
self
.
heap_map_size
,
'heap_total_size'
:
self
.
heap_total_size
,
'heap_used_size'
:
self
.
heap_used_size
,
'stack_total_size'
:
self
.
stack_total_size
,
'stack_used_size'
:
self
.
stack_used_size
,
}
class
GetListMonitorEvmSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
MonitorEvmModel
page
=
fields
.
Integer
(
required
=
False
)
pageSize
=
fields
.
Integer
(
required
=
False
)
watch
=
ma
.
auto_field
()
getListMonitorEvmSchema
=
GetListMonitorEvmSchema
()
getListMonitorEvmsSchema
=
GetListMonitorEvmSchema
(
many
=
True
)
class
GetMonitorEvmSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
MonitorEvmModel
watch
=
ma
.
auto_field
()
getMonitorEvmSchema
=
GetMonitorEvmSchema
()
tools/build_out/models/monitorImage.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
application.app
import
db
,
ma
from
.base
import
PrimaryModel
from
marshmallow
import
Schema
,
fields
,
INCLUDE
,
EXCLUDE
class
MonitorImageModel
(
PrimaryModel
):
__tablename__
=
'evm_monitor_image'
watch
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
length
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
,
default
=
0
)
png_uncompressed_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
,
default
=
0
)
png_total_count
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
,
default
=
0
)
png_file_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
,
default
=
0
)
uri
=
db
.
Column
(
db
.
String
(
20
),
index
=
True
,
nullable
=
False
,
default
=
''
)
# __table_args__ = (
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# )
def
__init__
(
self
,
watch
,
length
=
0
,
png_uncompressed_size
=
0
,
png_total_count
=
0
,
png_file_size
=
0
,
uri
=
''
):
self
.
watch
=
watch
self
.
length
=
length
self
.
png_uncompressed_size
=
png_uncompressed_size
self
.
png_total_count
=
png_total_count
self
.
png_file_size
=
png_file_size
self
.
uri
=
uri
def
__repr__
(
self
):
return
'<MonitorImageModel
%
r>'
%
(
self
.
watch
)
def
to_dict
(
self
):
return
{
'watch'
:
self
.
watch
,
'length'
:
self
.
length
,
'png_uncompressed_size'
:
self
.
png_uncompressed_size
,
'png_total_count'
:
self
.
png_total_count
,
'png_file_size'
:
self
.
png_file_size
,
'uri'
:
self
.
uri
,
}
class
GetListMonitorImageSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
MonitorImageModel
page
=
fields
.
Integer
(
required
=
False
)
pageSize
=
fields
.
Integer
(
required
=
False
)
watch
=
ma
.
auto_field
()
getListMonitorImageSchema
=
GetListMonitorImageSchema
()
getListMonitorImagesSchema
=
GetListMonitorImageSchema
(
many
=
True
)
class
GetMonitorImageSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
MonitorImageModel
watch
=
ma
.
auto_field
()
getMonitorImageSchema
=
GetMonitorImageSchema
()
tools/build_out/models/monitorLvgl.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
application.app
import
db
,
ma
from
.base
import
PrimaryModel
from
marshmallow
import
Schema
,
fields
,
INCLUDE
,
EXCLUDE
class
MonitorLvglModel
(
PrimaryModel
):
__tablename__
=
'evm_monitor_lvgl'
watch
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
total_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
,
default
=
0
)
free_cnt
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
,
default
=
0
)
free_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
,
default
=
0
)
free_biggest_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
,
default
=
0
)
used_cnt
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
,
default
=
0
)
used_pct
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
,
default
=
0
)
frag_pct
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
,
default
=
0
)
# __table_args__ = (
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# )
def
__init__
(
self
,
watch
,
total_size
=
0
,
free_cnt
=
0
,
free_size
=
0
,
free_biggest_size
=
0
,
used_cnt
=
0
,
used_pct
=
0
,
frag_pct
=
0
):
self
.
watch
=
watch
self
.
total_size
=
total_size
self
.
free_cnt
=
free_cnt
self
.
free_size
=
free_size
self
.
free_biggest_size
=
free_biggest_size
self
.
used_cnt
=
used_cnt
self
.
used_pct
=
used_pct
self
.
frag_pct
=
frag_pct
def
__repr__
(
self
):
return
'<MonitorLvglModel
%
r>'
%
(
self
.
watch
)
def
to_dict
(
self
):
return
{
'watch'
:
self
.
watch
,
'total_size'
:
self
.
total_size
,
'free_cnt'
:
self
.
free_cnt
,
'free_size'
:
self
.
free_size
,
'free_biggest_size'
:
self
.
free_biggest_size
,
'used_cnt'
:
self
.
used_cnt
,
'used_pct'
:
self
.
used_pct
,
'frag_pct'
:
self
.
frag_pct
,
}
class
GetListMonitorLvglSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
MonitorLvglModel
page
=
fields
.
Integer
(
required
=
False
)
pageSize
=
fields
.
Integer
(
required
=
False
)
watch
=
ma
.
auto_field
()
getListMonitorLvglSchema
=
GetListMonitorLvglSchema
()
getListMonitorLvglsSchema
=
GetListMonitorLvglSchema
(
many
=
True
)
class
GetMonitorLvglSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
MonitorLvglModel
watch
=
ma
.
auto_field
()
getMonitorLvglSchema
=
GetMonitorLvglSchema
()
tools/build_out/models/monitorSystem.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
application.app
import
db
,
ma
from
.base
import
PrimaryModel
from
marshmallow
import
Schema
,
fields
,
INCLUDE
,
EXCLUDE
class
MonitorSystemModel
(
PrimaryModel
):
__tablename__
=
'evm_monitor_system'
watch
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
free_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
,
default
=
0
)
host
=
db
.
Column
(
db
.
String
(
20
),
index
=
True
,
nullable
=
False
,
default
=
''
)
path
=
db
.
Column
(
db
.
String
(
20
),
index
=
True
,
nullable
=
False
,
default
=
''
)
protocol
=
db
.
Column
(
db
.
String
(
20
),
index
=
True
,
nullable
=
False
,
default
=
''
)
# __table_args__ = (
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# )
def
__init__
(
self
,
watch
,
free_size
=
0
,
host
=
''
,
path
=
''
,
protocol
=
''
):
self
.
watch
=
watch
self
.
free_size
=
free_size
self
.
host
=
host
self
.
path
=
path
self
.
protocol
=
protocol
def
__repr__
(
self
):
return
'<MonitorSystemModel
%
r>'
%
(
self
.
watch
)
def
to_dict
(
self
):
return
{
'watch'
:
self
.
watch
,
'free_size'
:
self
.
free_size
,
'host'
:
self
.
host
,
'path'
:
self
.
path
,
'protocol'
:
self
.
protocol
,
}
class
GetListMonitorSystemSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
MonitorSystemModel
page
=
fields
.
Integer
(
required
=
False
)
pageSize
=
fields
.
Integer
(
required
=
False
)
watch
=
ma
.
auto_field
()
getListMonitorSystemSchema
=
GetListMonitorSystemSchema
()
getListMonitorSystemsSchema
=
GetListMonitorSystemSchema
(
many
=
True
)
class
GetMonitorSystemSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
MonitorSystemModel
watch
=
ma
.
auto_field
()
getMonitorSystemSchema
=
GetMonitorSystemSchema
()
tools/build_out/models/monitorWatch.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
application.app
import
db
,
ma
from
.base
import
PrimaryModel
from
marshmallow
import
Schema
,
fields
,
INCLUDE
,
EXCLUDE
class
MonitorWatchModel
(
PrimaryModel
):
__tablename__
=
'evm_monitor_watch'
imei
=
db
.
Column
(
db
.
String
(
20
),
index
=
True
,
nullable
=
False
,
default
=
''
)
# __table_args__ = (
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# )
def
__init__
(
self
,
imei
=
''
):
self
.
imei
=
imei
def
__repr__
(
self
):
return
'<MonitorWatchModel
%
r>'
%
(
self
.
imei
)
def
to_dict
(
self
):
return
{
'imei'
:
self
.
imei
,
}
class
GetListMonitorWatchSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
MonitorWatchModel
page
=
fields
.
Integer
(
required
=
False
)
pageSize
=
fields
.
Integer
(
required
=
False
)
imei
=
ma
.
auto_field
()
getListMonitorWatchSchema
=
GetListMonitorWatchSchema
()
getListMonitorWatchsSchema
=
GetListMonitorWatchSchema
(
many
=
True
)
class
GetMonitorWatchSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
MonitorWatchModel
imei
=
ma
.
auto_field
()
getMonitorWatchSchema
=
GetMonitorWatchSchema
()
tools/build_out/result.json
0 → 100644
View file @
9ed09a30
{
"directories"
:
[{
"basename"
:
"evue_launcher-1.0-20210420145404"
,
"dirname"
:
"evueapps/evm"
,
"path"
:
"evueapps/evm/evue_launcher-1.0-20210420145404"
,
"timestamp"
:
1618901645
,
"type"
:
"dir"
}],
"files"
:
[]}
\ No newline at end of file
tools/build_out/views/annex.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
flask
import
current_app
,
jsonify
,
request
from
flask_restful
import
Resource
from
flask_restful.reqparse
import
RequestParser
from
flask_jwt_extended
import
(
jwt_required
,
get_jwt_identity
)
from
application.signal_manager
import
signalManager
from
models.annex
import
deleteAnnexSchema
,
getListAnnexSchema
,
getListAnnexsSchema
,
getAnnexSchema
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
AnnexResourceList
(
Resource
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser = RequestParser()
def
get
(
self
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser.add_argument("page", type=int, location="args", default=1)
# self.parser.add_argument("pageSize", type=int, location="args", default=15)
# args = self.parser.parse_args()
try
:
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getListAnnexSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetListAnnex
.
emit
(
data
)
json_dumps
=
getListAnnexSchema
.
dump
(
result
)
if
result
:
json_dumps
=
getListAnnexsSchema
.
dump
(
result
.
items
)
logger
.
warn
(
json_dumps
)
return
response_result
(
message
,
data
=
json_dumps
,
count
=
result
.
total
)
return
response_result
(
message
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
class
AnnexResource
(
Resource
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser = RequestParser()
@
jwt_required
(
locations
=
[
"headers"
])
def
get
(
self
,
uuid
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser.add_argument("page", type=int, location="args", default=1)
# self.parser.add_argument("pageSize", type=int, location="args", default=15)
# args = self.parser.parse_args()
try
:
json_payload
=
request
.
json
print
(
"========>"
,
uuid
,
json_payload
)
data
=
getAnnexSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetAnnex
.
emit
(
uuid
,
data
)
if
result
:
json_dumps
=
getAnnexSchema
.
dump
(
result
)
return
response_result
(
message
,
data
=
json_dumps
)
return
response_result
(
message
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
@
jwt_required
(
locations
=
[
"headers"
])
def
delete
(
self
,
uuid
):
try
:
json_payload
=
request
.
json
print
(
"========>"
,
uuid
,
json_payload
)
# data = deleteAnnexSchema.load(json_payload)
result
,
message
=
signalManager
.
actionDeleteAnnex
.
emit
(
uuid
)
return
response_result
(
message
,
data
=
result
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
tools/build_out/views/device.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
flask
import
current_app
,
jsonify
,
request
from
flask_restful
import
Resource
from
flask_restful.reqparse
import
RequestParser
from
flask_jwt_extended
import
(
jwt_required
,
get_jwt_identity
)
from
application.signal_manager
import
signalManager
from
models.device
import
postDeviceSchema
,
deleteDeviceSchema
,
getListDeviceSchema
,
getListDevicesSchema
,
getDeviceSchema
,
putDeviceSchema
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
DeviceResourceList
(
Resource
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser = RequestParser()
def
get
(
self
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser.add_argument("page", type=int, location="args", default=1)
# self.parser.add_argument("pageSize", type=int, location="args", default=15)
# args = self.parser.parse_args()
try
:
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getListDeviceSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetListDevice
.
emit
(
data
)
json_dumps
=
getListDeviceSchema
.
dump
(
result
)
if
result
:
json_dumps
=
getListDevicesSchema
.
dump
(
result
.
items
)
logger
.
warn
(
json_dumps
)
return
response_result
(
message
,
data
=
json_dumps
,
count
=
result
.
total
)
return
response_result
(
message
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
@
jwt_required
(
locations
=
[
"headers"
])
def
post
(
self
):
try
:
json_payload
=
request
.
json
data
=
postDeviceSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionPostDevice
.
emit
(
data
)
logger
.
info
(
result
)
logger
.
warn
(
message
)
return
response_result
(
message
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
class
DeviceResource
(
Resource
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser = RequestParser()
@
jwt_required
(
locations
=
[
"headers"
])
def
get
(
self
,
uuid
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser.add_argument("page", type=int, location="args", default=1)
# self.parser.add_argument("pageSize", type=int, location="args", default=15)
# args = self.parser.parse_args()
try
:
json_payload
=
request
.
json
print
(
"========>"
,
uuid
,
json_payload
)
data
=
getDeviceSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetDevice
.
emit
(
uuid
,
data
)
if
result
:
json_dumps
=
getDeviceSchema
.
dump
(
result
)
return
response_result
(
message
,
data
=
json_dumps
)
return
response_result
(
message
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
@
jwt_required
(
locations
=
[
"headers"
])
def
put
(
self
,
uuid
):
try
:
json_payload
=
request
.
json
print
(
"========>"
,
uuid
,
json_payload
)
data
=
putDeviceSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionPutDevice
.
emit
(
uuid
,
data
)
logger
.
info
(
result
)
logger
.
info
(
message
)
return
response_result
(
message
,
data
=
result
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
@
jwt_required
(
locations
=
[
"headers"
])
def
delete
(
self
,
uuid
):
try
:
json_payload
=
request
.
json
print
(
"========>"
,
uuid
,
json_payload
)
# data = deleteDeviceSchema.load(json_payload)
result
,
message
=
signalManager
.
actionDeleteDevice
.
emit
(
uuid
)
return
response_result
(
message
,
data
=
result
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
tools/build_out/views/monitorEvm.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
flask
import
current_app
,
jsonify
,
request
from
flask_restful
import
Resource
from
flask_restful.reqparse
import
RequestParser
from
flask_jwt_extended
import
(
jwt_required
,
get_jwt_identity
)
from
application.signal_manager
import
signalManager
from
models.monitorEvm
import
getListMonitorEvmSchema
,
getListMonitorEvmsSchema
,
getMonitorEvmSchema
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
MonitorEvmResourceList
(
Resource
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser = RequestParser()
def
get
(
self
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser.add_argument("page", type=int, location="args", default=1)
# self.parser.add_argument("pageSize", type=int, location="args", default=15)
# args = self.parser.parse_args()
try
:
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getListMonitorEvmSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetListMonitorEvm
.
emit
(
data
)
json_dumps
=
getListMonitorEvmSchema
.
dump
(
result
)
if
result
:
json_dumps
=
getListMonitorEvmsSchema
.
dump
(
result
.
items
)
logger
.
warn
(
json_dumps
)
return
response_result
(
message
,
data
=
json_dumps
,
count
=
result
.
total
)
return
response_result
(
message
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
class
MonitorEvmResource
(
Resource
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser = RequestParser()
@
jwt_required
(
locations
=
[
"headers"
])
def
get
(
self
,
uuid
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser.add_argument("page", type=int, location="args", default=1)
# self.parser.add_argument("pageSize", type=int, location="args", default=15)
# args = self.parser.parse_args()
try
:
json_payload
=
request
.
json
print
(
"========>"
,
uuid
,
json_payload
)
data
=
getMonitorEvmSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetMonitorEvm
.
emit
(
uuid
,
data
)
if
result
:
json_dumps
=
getMonitorEvmSchema
.
dump
(
result
)
return
response_result
(
message
,
data
=
json_dumps
)
return
response_result
(
message
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
tools/build_out/views/monitorImage.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
flask
import
current_app
,
jsonify
,
request
from
flask_restful
import
Resource
from
flask_restful.reqparse
import
RequestParser
from
flask_jwt_extended
import
(
jwt_required
,
get_jwt_identity
)
from
application.signal_manager
import
signalManager
from
models.monitorImage
import
getListMonitorImageSchema
,
getListMonitorImagesSchema
,
getMonitorImageSchema
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
MonitorImageResourceList
(
Resource
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser = RequestParser()
def
get
(
self
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser.add_argument("page", type=int, location="args", default=1)
# self.parser.add_argument("pageSize", type=int, location="args", default=15)
# args = self.parser.parse_args()
try
:
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getListMonitorImageSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetListMonitorImage
.
emit
(
data
)
json_dumps
=
getListMonitorImageSchema
.
dump
(
result
)
if
result
:
json_dumps
=
getListMonitorImagesSchema
.
dump
(
result
.
items
)
logger
.
warn
(
json_dumps
)
return
response_result
(
message
,
data
=
json_dumps
,
count
=
result
.
total
)
return
response_result
(
message
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
class
MonitorImageResource
(
Resource
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser = RequestParser()
@
jwt_required
(
locations
=
[
"headers"
])
def
get
(
self
,
uuid
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser.add_argument("page", type=int, location="args", default=1)
# self.parser.add_argument("pageSize", type=int, location="args", default=15)
# args = self.parser.parse_args()
try
:
json_payload
=
request
.
json
print
(
"========>"
,
uuid
,
json_payload
)
data
=
getMonitorImageSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetMonitorImage
.
emit
(
uuid
,
data
)
if
result
:
json_dumps
=
getMonitorImageSchema
.
dump
(
result
)
return
response_result
(
message
,
data
=
json_dumps
)
return
response_result
(
message
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
tools/build_out/views/monitorLvgl.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
flask
import
current_app
,
jsonify
,
request
from
flask_restful
import
Resource
from
flask_restful.reqparse
import
RequestParser
from
flask_jwt_extended
import
(
jwt_required
,
get_jwt_identity
)
from
application.signal_manager
import
signalManager
from
models.monitorLvgl
import
getListMonitorLvglSchema
,
getListMonitorLvglsSchema
,
getMonitorLvglSchema
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
MonitorLvglResourceList
(
Resource
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser = RequestParser()
def
get
(
self
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser.add_argument("page", type=int, location="args", default=1)
# self.parser.add_argument("pageSize", type=int, location="args", default=15)
# args = self.parser.parse_args()
try
:
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getListMonitorLvglSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetListMonitorLvgl
.
emit
(
data
)
json_dumps
=
getListMonitorLvglSchema
.
dump
(
result
)
if
result
:
json_dumps
=
getListMonitorLvglsSchema
.
dump
(
result
.
items
)
logger
.
warn
(
json_dumps
)
return
response_result
(
message
,
data
=
json_dumps
,
count
=
result
.
total
)
return
response_result
(
message
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
class
MonitorLvglResource
(
Resource
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser = RequestParser()
@
jwt_required
(
locations
=
[
"headers"
])
def
get
(
self
,
uuid
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser.add_argument("page", type=int, location="args", default=1)
# self.parser.add_argument("pageSize", type=int, location="args", default=15)
# args = self.parser.parse_args()
try
:
json_payload
=
request
.
json
print
(
"========>"
,
uuid
,
json_payload
)
data
=
getMonitorLvglSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetMonitorLvgl
.
emit
(
uuid
,
data
)
if
result
:
json_dumps
=
getMonitorLvglSchema
.
dump
(
result
)
return
response_result
(
message
,
data
=
json_dumps
)
return
response_result
(
message
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
tools/build_out/views/monitorSystem.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
flask
import
current_app
,
jsonify
,
request
from
flask_restful
import
Resource
from
flask_restful.reqparse
import
RequestParser
from
flask_jwt_extended
import
(
jwt_required
,
get_jwt_identity
)
from
application.signal_manager
import
signalManager
from
models.monitorSystem
import
getListMonitorSystemSchema
,
getListMonitorSystemsSchema
,
getMonitorSystemSchema
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
MonitorSystemResourceList
(
Resource
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser = RequestParser()
def
get
(
self
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser.add_argument("page", type=int, location="args", default=1)
# self.parser.add_argument("pageSize", type=int, location="args", default=15)
# args = self.parser.parse_args()
try
:
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getListMonitorSystemSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetListMonitorSystem
.
emit
(
data
)
json_dumps
=
getListMonitorSystemSchema
.
dump
(
result
)
if
result
:
json_dumps
=
getListMonitorSystemsSchema
.
dump
(
result
.
items
)
logger
.
warn
(
json_dumps
)
return
response_result
(
message
,
data
=
json_dumps
,
count
=
result
.
total
)
return
response_result
(
message
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
class
MonitorSystemResource
(
Resource
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser = RequestParser()
@
jwt_required
(
locations
=
[
"headers"
])
def
get
(
self
,
uuid
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser.add_argument("page", type=int, location="args", default=1)
# self.parser.add_argument("pageSize", type=int, location="args", default=15)
# args = self.parser.parse_args()
try
:
json_payload
=
request
.
json
print
(
"========>"
,
uuid
,
json_payload
)
data
=
getMonitorSystemSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetMonitorSystem
.
emit
(
uuid
,
data
)
if
result
:
json_dumps
=
getMonitorSystemSchema
.
dump
(
result
)
return
response_result
(
message
,
data
=
json_dumps
)
return
response_result
(
message
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
tools/build_out/views/monitorWatch.py
0 → 100644
View file @
9ed09a30
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
flask
import
current_app
,
jsonify
,
request
from
flask_restful
import
Resource
from
flask_restful.reqparse
import
RequestParser
from
flask_jwt_extended
import
(
jwt_required
,
get_jwt_identity
)
from
application.signal_manager
import
signalManager
from
models.monitorWatch
import
getListMonitorWatchSchema
,
getListMonitorWatchsSchema
,
getMonitorWatchSchema
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
MonitorWatchResourceList
(
Resource
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser = RequestParser()
def
get
(
self
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser.add_argument("page", type=int, location="args", default=1)
# self.parser.add_argument("pageSize", type=int, location="args", default=15)
# args = self.parser.parse_args()
try
:
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getListMonitorWatchSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetListMonitorWatch
.
emit
(
data
)
json_dumps
=
getListMonitorWatchSchema
.
dump
(
result
)
if
result
:
json_dumps
=
getListMonitorWatchsSchema
.
dump
(
result
.
items
)
logger
.
warn
(
json_dumps
)
return
response_result
(
message
,
data
=
json_dumps
,
count
=
result
.
total
)
return
response_result
(
message
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
class
MonitorWatchResource
(
Resource
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser = RequestParser()
@
jwt_required
(
locations
=
[
"headers"
])
def
get
(
self
,
uuid
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser.add_argument("page", type=int, location="args", default=1)
# self.parser.add_argument("pageSize", type=int, location="args", default=15)
# args = self.parser.parse_args()
try
:
json_payload
=
request
.
json
print
(
"========>"
,
uuid
,
json_payload
)
data
=
getMonitorWatchSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetMonitorWatch
.
emit
(
uuid
,
data
)
if
result
:
json_dumps
=
getMonitorWatchSchema
.
dump
(
result
)
return
response_result
(
message
,
data
=
json_dumps
)
return
response_result
(
message
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
tools/build_out/webcreator/utils/ccode.py
0 → 100644
View file @
9ed09a30
'''
Author: your name
Date: 2021-04-29 12:12:01
LastEditTime: 2021-07-12 00:56:10
LastEditors: your name
Description: In User Settings Edit
FilePath:
\
evm-store
\b
ackend
\
utils
\
ccode.py
'''
# -*- coding: utf-8 -*-
import
sys
header
=
\
u'''
/****************************************************************************
**
** Copyright (C) 2021 @scriptiot
**
** EVM是一款通用化设计的虚拟机引擎,拥有语法解析前端接口、编译器、虚拟机和虚拟机扩展接口框架。
** 支持js、python、qml、lua等多种脚本语言,纯C开发,零依赖,支持主流 ROM > 50KB, RAM > 2KB的MCU;
** 自带垃圾回收(GC)先进的内存管理,采用最复杂的压缩算法,无内存碎片(大部分解释器都存在内存碎片)
** Version : 3.0
** Email : scriptiot@aliyun.com
** Website : https://github.com/scriptiot
** Licence: MIT Licence
****************************************************************************/
'''
def
cstr_encode
(
text
,
splitLines
=
True
,
escapePercent
=
False
):
output
=
"
\"
"
count
=
len
(
text
)
for
i
in
range
(
count
):
if
text
[
i
]
==
'
\f
'
:
output
+=
"
\\
f"
elif
text
[
i
]
==
'
\n
'
:
if
splitLines
:
output
+=
"
\\
n
\"\n\"
"
else
:
output
+=
"
\\
n"
;
elif
text
[
i
]
==
'
\r
'
:
output
+=
"
\\
r"
elif
text
[
i
]
==
'
\t
'
:
output
+=
"
\\
t"
elif
text
[
i
]
==
'
\"
'
:
output
+=
"
\\\"
"
elif
text
[
i
]
==
'
\\
'
:
output
+=
"
\\\\
"
elif
text
[
i
]
==
'
%
'
:
if
escapePercent
:
output
+=
"
%%
"
else
:
output
+=
"
%
"
else
:
output
+=
text
[
i
]
output
+=
"
\"
"
return
output
def
convert
(
fpath
):
with
open
(
fpath
,
"r"
)
as
f
:
content
=
f
.
read
()
ret
=
cstr_encode
(
content
)
ccode
=
"
%
s
\n
const char * appjs_content=
\\\n
%
s;"
%
(
header
,
ret
)
with
open
(
"appjs.c"
,
"w"
,
encoding
=
"utf-8"
)
as
f
:
f
.
write
(
ccode
)
return
ccode
def
convert_string
(
string
):
return
"
%
s
\n
const char * appjs_content=
\\\n
%
s;"
%
(
header
,
cstr_encode
(
string
))
if
__name__
==
'__main__'
:
ret
=
convert
(
sys
.
argv
[
1
])
print
(
ret
)
tools/build_out/webcreator/utils/epk.py
0 → 100644
View file @
9ed09a30
#-*- coding: UTF-8 -*-
#!/usr/bin/python
import
os
import
sys
import
fs
import
struct
import
json
from
collections
import
OrderedDict
import
zlib
import
pprint
import
hashlib
from
ctypes
import
*
import
platform
lib_path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
if
platform
.
system
()
==
'Windows'
:
pDll
=
CDLL
(
os
.
sep
.
join
([
lib_path
,
"lib"
,
"eheatshrink.dll"
]))
elif
platform
.
system
()
==
'Linux'
:
pDll
=
CDLL
(
os
.
sep
.
join
([
lib_path
,
"lib"
,
"libeheatshrink.so"
]))
pDll
.
ecompress_size
.
restype
=
c_uint32
pDll
.
ecompress_size
.
argtypes
=
[
c_void_p
,
c_uint32
]
pDll
.
ecompress
.
restype
=
POINTER
(
c_uint8
)
pDll
.
ecompress
.
argtypes
=
[
c_void_p
,
c_uint32
]
def
heatshrink_compress
(
buf
:
bytes
,
level
:
int
):
count
=
len
(
buf
)
size
=
pDll
.
ecompress_size
(
buf
,
count
)
pDll
.
ecompress
.
restype
=
POINTER
(
c_uint8
)
pDll
.
ecompress
.
argtypes
=
[
c_void_p
,
c_uint32
]
ret
=
pDll
.
ecompress
(
buf
,
count
)
arr
=
bytearray
(
size
)
i
=
0
while
i
<
size
:
arr
[
i
]
=
ret
[
i
]
i
=
i
+
1
return
arr
def
str_to_hex
(
s
):
return
' '
.
join
([
hex
(
ord
(
c
))
.
replace
(
'0x'
,
''
)
for
c
in
s
])
def
hex_to_str
(
s
):
return
''
.
join
([
chr
(
i
)
for
i
in
[
int
(
b
,
16
)
for
b
in
s
.
split
(
' '
)]])
def
str_to_bin
(
s
):
return
' '
.
join
([
bin
(
ord
(
c
))
.
replace
(
'0b'
,
''
)
for
c
in
s
])
def
bin_to_str
(
s
):
return
''
.
join
([
chr
(
i
)
for
i
in
[
int
(
b
,
2
)
for
b
in
s
.
split
(
' '
)]])
def
eprint
(
*
args
,
**
kwargs
):
# print(*args, **kwargs)
pass
class
EpkApp
(
object
):
def
__init__
(
self
,
appName
,
appDir
,
algorithm
=
'zlib'
,
appVersion
=
"1.0"
,
output
=
"epks"
):
super
(
EpkApp
,
self
)
.
__init__
()
self
.
_appName
=
appName
self
.
_appDir
=
os
.
path
.
abspath
(
appDir
)
self
.
algorithm
=
algorithm
eprint
(
sys
.
argv
)
eprint
(
appName
)
eprint
(
appDir
)
eprint
(
self
.
_appDir
)
self
.
_appVersion
=
appVersion
self
.
_appCRCCode
=
None
self
.
_files
=
[]
self
.
_infoPath
=
os
.
sep
.
join
([
self
.
_appDir
,
"
%
s.json"
%
self
.
_appName
])
self
.
_epksDir
=
output
if
not
os
.
path
.
exists
(
self
.
_epksDir
):
fs
.
open_fs
(
os
.
getcwd
())
.
makedirs
(
output
)
self
.
_epkName
=
os
.
sep
.
join
([
self
.
_epksDir
,
"
%
s.epk"
%
self
.
_appName
])
def
compress
(
self
):
if
self
.
algorithm
==
'h'
:
return
heatshrink_compress
return
zlib
.
compress
def
epkInfo
(
self
):
epkInfo
=
OrderedDict
({
"appName"
:
self
.
_appName
,
"appVersion"
:
self
.
_appVersion
,
"files"
:
self
.
fileinfos
(
self
.
_appDir
),
})
infocontent
=
json
.
dumps
(
epkInfo
)
with
open
(
self
.
_infoPath
,
"w"
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
infocontent
)
return
epkInfo
def
fileinfos
(
self
,
path
):
path
=
os
.
path
.
abspath
(
path
)
home_fs
=
fs
.
open_fs
(
path
)
files
=
[]
for
jspath
in
home_fs
.
glob
(
'*'
,
namespaces
=
[
'details'
]):
fpath
=
"C:/
%
s"
%
jspath
.
info
.
name
fname
=
jspath
.
info
.
name
fsize
=
jspath
.
info
.
size
fbasename
,
fext
=
os
.
path
.
splitext
(
jspath
.
info
.
name
)
if
fext
in
[
""
,
".exe"
,
".dll"
,
".nv"
,
".conf"
]:
continue
finfo
=
{
"path"
:
fpath
,
"name"
:
fname
,
"size"
:
fsize
,
"basename"
:
fbasename
,
"ext"
:
fext
}
if
self
.
_infoPath
==
os
.
sep
.
join
([
path
,
fname
]):
eprint
(
finfo
)
files
.
insert
(
0
,
finfo
)
else
:
files
.
append
(
finfo
)
if
fext
==
".evue"
:
self
.
fileMD5
(
finfo
)
return
files
def
header
(
self
,
epk_start
=
0xAA
,
md5_offset
=
0
,
file_count
=
0
):
if
self
.
algorithm
==
'zlib'
:
bytes_header
=
struct
.
pack
(
"<BBLH"
,
epk_start
,
1
,
md5_offset
,
file_count
)
else
:
bytes_header
=
struct
.
pack
(
"<BBLH"
,
epk_start
,
2
,
md5_offset
,
file_count
)
return
bytes_header
def
fileMD5
(
self
,
info
):
md5path
=
os
.
sep
.
join
([
self
.
_appDir
,
"
%
s.md5"
%
info
[
"basename"
]])
fpath
=
os
.
sep
.
join
([
self
.
_appDir
,
info
[
"name"
]])
with
open
(
fpath
,
"rb"
)
as
f
:
filecontent
=
f
.
read
()
newmd5
=
self
.
md5
(
filecontent
)
with
open
(
md5path
,
"wb"
)
as
f
:
f
.
write
(
newmd5
)
return
newmd5
def
sign
(
self
,
content
):
ret
=
b
""
for
i
in
range
(
int
(
len
(
content
)
/
2
)):
ret
+=
struct
.
pack
(
"<B"
,
int
(
"0x
%
s"
%
(
content
[
i
*
2
:
i
*
2
+
2
]),
16
))
ret
=
ret
+
b
'EVM is NB ++!'
return
ret
def
md5
(
self
,
filecontent
):
newmd5
=
''
content
=
filecontent
for
i
in
range
(
3
):
md5
=
hashlib
.
md5
()
#获取一个md5加密算法对象
md5
.
update
(
content
)
#指定需要加密的字符串
newmd5
=
md5
.
hexdigest
()
#获取加密后的16进制字符串
eprint
(
"md5 == "
,
newmd5
)
content
=
self
.
sign
(
newmd5
)
ret
=
b
""
for
i
in
range
(
int
(
len
(
newmd5
)
/
2
)):
ret
+=
struct
.
pack
(
"<B"
,
int
(
"0x
%
s"
%
(
newmd5
[
i
*
2
:
i
*
2
+
2
]),
16
))
return
ret
def
packFile
(
self
,
info
,
level
=
9
):
fname
=
info
[
"name"
]
fpath
=
os
.
sep
.
join
([
self
.
_appDir
,
fname
])
fext
=
info
[
"ext"
]
fileBytes
=
b
""
if
fext
==
"md5"
:
fileBytes
+=
struct
.
pack
(
"<B"
,
1
)
else
:
fileBytes
+=
struct
.
pack
(
"<B"
,
2
)
_name
=
fname
+
"
\0
"
fileBytes
+=
struct
.
pack
(
"<B"
,
len
(
_name
))
fileBytes
+=
struct
.
pack
(
"<
%
ds"
%
len
(
_name
),
fname
.
encode
(
"utf-8"
))
with
open
(
fpath
,
"rb"
)
as
fc
:
fileContentBytes
=
fc
.
read
()
eprint
(
info
[
"name"
])
eprint
(
len
(
fileContentBytes
))
fileBytes
+=
struct
.
pack
(
"<L"
,
len
(
fileContentBytes
))
if
fext
==
"md5"
:
fileCompressBytes
=
fileContentBytes
else
:
fileCompressBytes
=
self
.
compress
()(
fileContentBytes
,
level
)
eprint
(
"==="
,
fileCompressBytes
[
0
])
eprint
(
fileCompressBytes
)
fileBytes
+=
struct
.
pack
(
"<L"
,
len
(
fileCompressBytes
))
eprint
(
fileBytes
)
fileBytes
+=
fileCompressBytes
return
fileBytes
def
pack
(
self
,
level
=
9
):
for
i
in
range
(
10
):
infos
=
self
.
epkInfo
()
# infos = self.epkInfo()
# infos = self.epkInfo()
epkFileBytes
=
b
""
ret
=
None
epkFileContentBytes
=
b
""
file_count
=
len
(
infos
[
"files"
])
with
open
(
self
.
_epkName
,
"wb"
)
as
f
:
for
info
in
infos
[
"files"
]:
epkFileContentBytes
+=
self
.
packFile
(
info
)
epkFileContentLength
=
len
(
epkFileContentBytes
)
epkFileBytes
+=
self
.
header
(
md5_offset
=
8
+
epkFileContentLength
,
file_count
=
file_count
)
epkFileBytes
+=
epkFileContentBytes
epkmd5Bytes
=
self
.
md5
(
epkFileBytes
)
epkFileBytes
+=
struct
.
pack
(
"<H"
,
len
(
epkmd5Bytes
))
epkFileBytes
+=
epkmd5Bytes
crcBytes
=
zlib
.
crc32
(
epkFileBytes
)
epkFileBytes
+=
struct
.
pack
(
"<L"
,
crcBytes
)
f
.
write
(
epkFileBytes
)
ret
=
{
"epkfile"
:
self
.
_epkName
,
"epk_filecontent_size"
:
epkFileContentLength
,
"md5_offset"
:
10
+
epkFileContentLength
,
"file_count"
:
file_count
,
"md5_length"
:
len
(
epkmd5Bytes
),
"md5"
:
epkmd5Bytes
,
"raw_crc"
:
hex
(
crcBytes
),
"compress_level"
:
level
,
"buff_length"
:
len
(
epkFileBytes
)
}
pprint
.
pprint
(
ret
)
return
ret
def
main
(
path
,
appName
,
algorithm
):
epk
=
EpkApp
(
appName
,
path
,
algorithm
)
epk
.
pack
()
if
__name__
==
'__main__'
:
main
(
sys
.
argv
[
1
],
sys
.
argv
[
2
],
sys
.
argv
[
3
])
tools/build_out/webcreator/utils/epk_2.0.py
0 → 100644
View file @
9ed09a30
#-*- coding: UTF-8 -*-
#!/usr/bin/python
import
os
import
sys
import
fs
import
struct
import
json
from
collections
import
OrderedDict
import
zlib
import
pprint
import
hashlib
from
ctypes
import
*
import
platform
current_abspath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
if
platform
.
system
()
==
'Windows'
:
pDll
=
CDLL
(
os
.
sep
.
join
([
current_abspath
,
"lib"
,
"eheatshrink.dll"
]))
elif
platform
.
system
()
==
'Linux'
:
pDll
=
CDLL
(
os
.
sep
.
join
([
current_abspath
,
"lib"
,
"libeheatshrink.so"
]))
pDll
.
ecompress_size
.
restype
=
c_uint32
pDll
.
ecompress_size
.
argtypes
=
[
c_void_p
,
c_uint32
]
pDll
.
ecompress
.
restype
=
POINTER
(
c_uint8
)
pDll
.
ecompress
.
argtypes
=
[
c_void_p
,
c_uint32
]
def
heatshrink_compress
(
buf
:
bytes
,
level
:
int
):
count
=
len
(
buf
)
size
=
pDll
.
ecompress_size
(
buf
,
count
)
pDll
.
ecompress
.
restype
=
POINTER
(
c_uint8
)
pDll
.
ecompress
.
argtypes
=
[
c_void_p
,
c_uint32
]
ret
=
pDll
.
ecompress
(
buf
,
count
)
arr
=
bytearray
(
size
)
i
=
0
while
i
<
size
:
arr
[
i
]
=
ret
[
i
]
i
=
i
+
1
return
arr
def
str_to_hex
(
s
):
return
' '
.
join
([
hex
(
ord
(
c
))
.
replace
(
'0x'
,
''
)
for
c
in
s
])
def
hex_to_str
(
s
):
return
''
.
join
([
chr
(
i
)
for
i
in
[
int
(
b
,
16
)
for
b
in
s
.
split
(
' '
)]])
def
str_to_bin
(
s
):
return
' '
.
join
([
bin
(
ord
(
c
))
.
replace
(
'0b'
,
''
)
for
c
in
s
])
def
bin_to_str
(
s
):
return
''
.
join
([
chr
(
i
)
for
i
in
[
int
(
b
,
2
)
for
b
in
s
.
split
(
' '
)]])
class
EpkApp
(
object
):
def
__init__
(
self
,
appName
,
appDir
,
algorithm
=
'zlib'
,
appVersion
=
"1.0"
,
output
=
"epks"
):
super
(
EpkApp
,
self
)
.
__init__
()
self
.
_appName
=
appName
self
.
_appDir
=
os
.
path
.
abspath
(
appDir
)
self
.
algorithm
=
algorithm
self
.
_appVersion
=
appVersion
self
.
_appCRCCode
=
None
self
.
_files
=
[]
self
.
_infoPath
=
os
.
sep
.
join
([
self
.
_appDir
,
"
%
s.json"
%
self
.
_appName
])
self
.
_epksDir
=
output
if
not
os
.
path
.
exists
(
self
.
_epksDir
):
fs
.
open_fs
(
os
.
getcwd
())
.
makedirs
(
output
)
self
.
_epkName
=
os
.
sep
.
join
([
self
.
_epksDir
,
"
%
s.epk"
%
self
.
_appName
])
def
compress
(
self
):
if
self
.
algorithm
==
'h'
:
return
heatshrink_compress
return
zlib
.
compress
def
epkInfo
(
self
):
epkInfo
=
OrderedDict
({
"appName"
:
self
.
_appName
,
"appVersion"
:
self
.
_appVersion
,
"files"
:
self
.
fileinfos
(
self
.
_appDir
),
})
infocontent
=
json
.
dumps
(
epkInfo
)
with
open
(
self
.
_infoPath
,
"w"
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
infocontent
)
return
epkInfo
def
fileinfos
(
self
,
path
):
path
=
os
.
path
.
abspath
(
path
)
home_fs
=
fs
.
open_fs
(
path
)
files
=
[]
for
jspath
in
home_fs
.
glob
(
'*'
,
namespaces
=
[
'details'
]):
fpath
=
"C:/
%
s"
%
jspath
.
info
.
name
fname
=
jspath
.
info
.
name
fsize
=
jspath
.
info
.
size
fbasename
,
fext
=
os
.
path
.
splitext
(
jspath
.
info
.
name
)
if
fext
in
[
""
,
".exe"
,
".dll"
,
".nv"
,
".conf"
]:
continue
finfo
=
{
"path"
:
fpath
,
"name"
:
fname
,
"size"
:
fsize
,
"basename"
:
fbasename
,
"ext"
:
fext
}
if
self
.
_infoPath
==
os
.
sep
.
join
([
path
,
fname
]):
files
.
insert
(
0
,
finfo
)
else
:
files
.
append
(
finfo
)
if
fext
==
".evue"
:
self
.
fileMD5
(
finfo
)
return
files
def
header
(
self
,
epk_start
=
0xAAAA
,
md5_offset
=
0
,
file_count
=
0
):
bytes_header
=
struct
.
pack
(
"<HLH"
,
epk_start
,
md5_offset
,
file_count
)
return
bytes_header
def
fileMD5
(
self
,
info
):
md5path
=
os
.
sep
.
join
([
self
.
_appDir
,
"
%
s.md5"
%
info
[
"basename"
]])
fpath
=
os
.
sep
.
join
([
self
.
_appDir
,
info
[
"name"
]])
with
open
(
fpath
,
"rb"
)
as
f
:
filecontent
=
f
.
read
()
newmd5
=
self
.
md5
(
filecontent
)
with
open
(
md5path
,
"wb"
)
as
f
:
f
.
write
(
newmd5
)
return
newmd5
def
sign
(
self
,
content
):
ret
=
b
""
for
i
in
range
(
int
(
len
(
content
)
/
2
)):
ret
+=
struct
.
pack
(
"<B"
,
int
(
"0x
%
s"
%
(
content
[
i
*
2
:
i
*
2
+
2
]),
16
))
ret
=
ret
+
b
'EVM is NB ++!'
return
ret
def
md5
(
self
,
filecontent
):
newmd5
=
''
content
=
filecontent
for
i
in
range
(
3
):
md5
=
hashlib
.
md5
()
#获取一个md5加密算法对象
md5
.
update
(
content
)
#指定需要加密的字符串
newmd5
=
md5
.
hexdigest
()
#获取加密后的16进制字符串
content
=
self
.
sign
(
newmd5
)
ret
=
b
""
for
i
in
range
(
int
(
len
(
newmd5
)
/
2
)):
ret
+=
struct
.
pack
(
"<B"
,
int
(
"0x
%
s"
%
(
newmd5
[
i
*
2
:
i
*
2
+
2
]),
16
))
return
ret
def
packFile
(
self
,
info
,
level
=
9
):
fname
=
info
[
"name"
]
fpath
=
os
.
sep
.
join
([
self
.
_appDir
,
fname
])
fext
=
info
[
"ext"
]
fileBytes
=
b
""
if
fext
==
"md5"
:
fileBytes
+=
struct
.
pack
(
"<B"
,
1
)
else
:
fileBytes
+=
struct
.
pack
(
"<B"
,
2
)
_name
=
fname
+
"
\0
"
fileBytes
+=
struct
.
pack
(
"<B"
,
len
(
_name
))
fileBytes
+=
struct
.
pack
(
"<
%
ds"
%
len
(
_name
),
fname
.
encode
(
"utf-8"
))
with
open
(
fpath
,
"rb"
)
as
fc
:
fileContentBytes
=
fc
.
read
()
fileBytes
+=
struct
.
pack
(
"<L"
,
len
(
fileContentBytes
))
if
fext
==
"md5"
:
fileCompressBytes
=
fileContentBytes
else
:
fileCompressBytes
=
self
.
compress
()(
fileContentBytes
,
level
)
fileBytes
+=
struct
.
pack
(
"<L"
,
len
(
fileCompressBytes
))
fileBytes
+=
fileCompressBytes
return
fileBytes
def
pack
(
self
,
level
=
9
):
for
i
in
range
(
10
):
infos
=
self
.
epkInfo
()
# infos = self.epkInfo()
# infos = self.epkInfo()
epkFileBytes
=
b
""
epkFileContentBytes
=
b
""
file_count
=
len
(
infos
[
"files"
])
with
open
(
self
.
_epkName
,
"wb"
)
as
f
:
for
info
in
infos
[
"files"
]:
epkFileContentBytes
+=
self
.
packFile
(
info
)
epkFileContentLength
=
len
(
epkFileContentBytes
)
epkFileBytes
+=
self
.
header
(
md5_offset
=
8
+
epkFileContentLength
,
file_count
=
file_count
)
epkFileBytes
+=
epkFileContentBytes
epkmd5Bytes
=
self
.
md5
(
epkFileBytes
)
epkFileBytes
+=
struct
.
pack
(
"<H"
,
len
(
epkmd5Bytes
))
epkFileBytes
+=
epkmd5Bytes
crcBytes
=
zlib
.
crc32
(
epkFileBytes
)
epkFileBytes
+=
struct
.
pack
(
"<L"
,
crcBytes
)
f
.
write
(
epkFileBytes
)
ret
=
{
"epkfile"
:
self
.
_epkName
,
"epk_filecontent_size"
:
epkFileContentLength
,
"md5_offset"
:
10
+
epkFileContentLength
,
"file_count"
:
file_count
,
"md5_length"
:
len
(
epkmd5Bytes
),
"md5"
:
epkmd5Bytes
,
"raw_crc"
:
hex
(
crcBytes
),
"compress_level"
:
level
,
"buff_length"
:
len
(
epkFileBytes
)
}
pprint
.
pprint
(
ret
)
return
ret
def
main
(
path
,
appName
,
algorithm
):
epk
=
EpkApp
(
appName
,
path
,
algorithm
)
epk
.
pack
()
if
__name__
==
'__main__'
:
main
(
sys
.
argv
[
1
],
sys
.
argv
[
2
],
sys
.
argv
[
3
])
tools/build_out/webcreator/utils/lib/eheatshrink.dll
0 → 100644
View file @
9ed09a30
File added
tools/build_out/webcreator/utils/lib/libeheatshrink.so
0 → 100644
View file @
9ed09a30
File added
tools/build_out/webcreator/utils/tools_epk_1.0.py
0 → 100644
View file @
9ed09a30
#-*- coding: UTF-8 -*-
#!/usr/bin/python
import
os
import
sys
import
fs
import
struct
import
json
from
collections
import
OrderedDict
import
zlib
import
pprint
import
hashlib
def
str_to_hex
(
s
):
return
' '
.
join
([
hex
(
ord
(
c
))
.
replace
(
'0x'
,
''
)
for
c
in
s
])
def
hex_to_str
(
s
):
return
''
.
join
([
chr
(
i
)
for
i
in
[
int
(
b
,
16
)
for
b
in
s
.
split
(
' '
)]])
def
str_to_bin
(
s
):
return
' '
.
join
([
bin
(
ord
(
c
))
.
replace
(
'0b'
,
''
)
for
c
in
s
])
def
bin_to_str
(
s
):
return
''
.
join
([
chr
(
i
)
for
i
in
[
int
(
b
,
2
)
for
b
in
s
.
split
(
' '
)]])
class
EpkApp
(
object
):
def
__init__
(
self
,
appName
,
appDir
,
appVersion
=
"1.0"
,
output
=
"epks"
):
super
(
EpkApp
,
self
)
.
__init__
()
self
.
_appName
=
appName
self
.
_appDir
=
os
.
path
.
abspath
(
appDir
)
self
.
_appVersion
=
appVersion
self
.
_appCRCCode
=
None
self
.
_files
=
[]
self
.
_infoPath
=
os
.
sep
.
join
([
self
.
_appDir
,
"
%
s.json"
%
self
.
_appName
])
self
.
_epksDir
=
output
if
not
os
.
path
.
exists
(
self
.
_epksDir
):
fs
.
open_fs
(
os
.
getcwd
())
.
makedirs
(
output
)
self
.
_epkName
=
os
.
sep
.
join
([
self
.
_epksDir
,
"
%
s.epk"
%
self
.
_appName
])
def
epkInfo
(
self
):
epkInfo
=
OrderedDict
({
"appName"
:
self
.
_appName
,
"appVersion"
:
self
.
_appVersion
,
"files"
:
self
.
fileinfos
(
self
.
_appDir
),
})
infocontent
=
json
.
dumps
(
epkInfo
)
with
open
(
self
.
_infoPath
,
"w"
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
infocontent
)
return
epkInfo
def
fileinfos
(
self
,
path
):
path
=
os
.
path
.
abspath
(
path
)
home_fs
=
fs
.
open_fs
(
path
)
files
=
[]
for
jspath
in
home_fs
.
glob
(
'*'
,
namespaces
=
[
'details'
]):
fpath
=
"C:/
%
s"
%
jspath
.
info
.
name
fname
=
jspath
.
info
.
name
fsize
=
jspath
.
info
.
size
fbasename
=
jspath
.
info
.
name
.
split
(
"."
)[
0
]
fext
=
jspath
.
info
.
name
.
split
(
"."
)[
1
]
if
fext
in
[
"exe"
,
"dll"
,
"nv"
,
"conf"
]:
continue
finfo
=
{
"path"
:
fpath
,
"name"
:
fname
,
"size"
:
fsize
,
"basename"
:
fbasename
,
"ext"
:
fext
}
if
self
.
_infoPath
==
os
.
sep
.
join
([
path
,
fname
]):
files
.
insert
(
0
,
finfo
)
else
:
files
.
append
(
finfo
)
if
fext
==
"evue"
:
self
.
fileMD5
(
finfo
)
return
files
def
header
(
self
,
epk_start
=
0xAAAA
,
md5_offset
=
0
,
file_count
=
0
):
bytes_header
=
struct
.
pack
(
"<HLH"
,
epk_start
,
md5_offset
,
file_count
)
return
bytes_header
def
fileMD5
(
self
,
info
):
md5path
=
os
.
sep
.
join
([
self
.
_appDir
,
"
%
s.md5"
%
info
[
"basename"
]])
fpath
=
os
.
sep
.
join
([
self
.
_appDir
,
info
[
"name"
]])
with
open
(
fpath
,
"rb"
)
as
f
:
filecontent
=
f
.
read
()
print
(
fpath
)
newmd5
=
self
.
md5
(
filecontent
)
print
(
md5path
)
with
open
(
md5path
,
"wb"
)
as
f
:
f
.
write
(
newmd5
)
return
newmd5
def
sign
(
self
,
content
):
ret
=
b
""
for
i
in
range
(
int
(
len
(
content
)
/
2
)):
ret
+=
struct
.
pack
(
"<B"
,
int
(
"0x
%
s"
%
(
content
[
i
*
2
:
i
*
2
+
2
]),
16
))
ret
=
ret
+
b
'EVM is NB ++!'
return
ret
def
md5
(
self
,
filecontent
):
newmd5
=
''
content
=
filecontent
for
i
in
range
(
3
):
md5
=
hashlib
.
md5
()
#获取一个md5加密算法对象
md5
.
update
(
content
)
#指定需要加密的字符串
newmd5
=
md5
.
hexdigest
()
#获取加密后的16进制字符串
print
(
newmd5
)
content
=
self
.
sign
(
newmd5
)
ret
=
b
""
for
i
in
range
(
int
(
len
(
newmd5
)
/
2
)):
ret
+=
struct
.
pack
(
"<B"
,
int
(
"0x
%
s"
%
(
newmd5
[
i
*
2
:
i
*
2
+
2
]),
16
))
return
ret
def
packFile
(
self
,
info
,
level
=
9
):
fname
=
info
[
"name"
]
fpath
=
os
.
sep
.
join
([
self
.
_appDir
,
fname
])
fext
=
info
[
"ext"
]
fileBytes
=
b
""
if
fext
==
"md5"
:
fileBytes
+=
struct
.
pack
(
"<B"
,
1
)
else
:
fileBytes
+=
struct
.
pack
(
"<B"
,
2
)
_name
=
fname
+
"
\0
"
fileBytes
+=
struct
.
pack
(
"<B"
,
len
(
_name
))
fileBytes
+=
struct
.
pack
(
"<
%
ds"
%
len
(
_name
),
fname
.
encode
(
"utf-8"
))
with
open
(
fpath
,
"rb"
)
as
fc
:
fileContentBytes
=
fc
.
read
()
print
(
info
[
"name"
])
print
(
len
(
fileContentBytes
))
fileBytes
+=
struct
.
pack
(
"<L"
,
len
(
fileContentBytes
))
if
fext
==
"md5"
:
fileCompressBytes
=
fileContentBytes
else
:
fileCompressBytes
=
zlib
.
compress
(
fileContentBytes
,
level
)
print
(
len
(
fileCompressBytes
))
fileBytes
+=
struct
.
pack
(
"<L"
,
len
(
fileCompressBytes
))
fileBytes
+=
fileCompressBytes
return
fileBytes
def
pack
(
self
,
level
=
9
):
for
i
in
range
(
10
):
infos
=
self
.
epkInfo
()
# infos = self.epkInfo()
# infos = self.epkInfo()
result
=
{}
epkFileBytes
=
b
""
epkFileContentBytes
=
b
""
file_count
=
len
(
infos
[
"files"
])
with
open
(
self
.
_epkName
,
"wb"
)
as
f
:
for
info
in
infos
[
"files"
]:
epkFileContentBytes
+=
self
.
packFile
(
info
)
epkFileContentLength
=
len
(
epkFileContentBytes
)
epkFileBytes
+=
self
.
header
(
md5_offset
=
8
+
epkFileContentLength
,
file_count
=
file_count
)
epkFileBytes
+=
epkFileContentBytes
epkmd5Bytes
=
self
.
md5
(
epkFileBytes
)
epkFileBytes
+=
struct
.
pack
(
"<H"
,
len
(
epkmd5Bytes
))
epkFileBytes
+=
epkmd5Bytes
crcBytes
=
zlib
.
crc32
(
epkFileBytes
)
epkFileBytes
+=
struct
.
pack
(
"<L"
,
crcBytes
)
f
.
write
(
epkFileBytes
)
ret
=
{
"epkfile"
:
self
.
_epkName
,
"epk_filecontent_size"
:
epkFileContentLength
,
"md5_offset"
:
10
+
epkFileContentLength
,
"file_count"
:
file_count
,
"md5_length"
:
len
(
epkmd5Bytes
),
"md5"
:
epkmd5Bytes
,
"raw_crc"
:
hex
(
crcBytes
),
"compress_level"
:
level
,
"buff_length"
:
len
(
epkFileBytes
)
}
result
=
ret
return
result
def
main
(
path
,
appName
):
epk
=
EpkApp
(
appName
,
path
)
epk
.
pack
()
if
__name__
==
'__main__'
:
main
(
sys
.
argv
[
1
],
sys
.
argv
[
2
])
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