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
3922979c
Commit
3922979c
authored
Jul 14, 2021
by
wanli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
d109566c
Changes
72
Hide whitespace changes
Inline
Side-by-side
Showing
72 changed files
with
2241 additions
and
1765 deletions
+2241
-1765
tools/build_out/.gitignore
tools/build_out/.gitignore
+1
-0
tools/build_out/application/signal_manager.20210709130326.py
tools/build_out/application/signal_manager.20210709130326.py
+0
-38
tools/build_out/application/signal_manager.py
tools/build_out/application/signal_manager.py
+9
-0
tools/build_out/controllers/__init__.py
tools/build_out/controllers/__init__.py
+34
-4
tools/build_out/controllers/annex.py
tools/build_out/controllers/annex.py
+12
-25
tools/build_out/controllers/api.py
tools/build_out/controllers/api.py
+0
-101
tools/build_out/controllers/app.20210709005815.py
tools/build_out/controllers/app.20210709005815.py
+0
-73
tools/build_out/controllers/app.py
tools/build_out/controllers/app.py
+231
-28
tools/build_out/controllers/area.20210709005815.py
tools/build_out/controllers/area.20210709005815.py
+0
-73
tools/build_out/controllers/area.py
tools/build_out/controllers/area.py
+22
-12
tools/build_out/controllers/device.py
tools/build_out/controllers/device.py
+13
-26
tools/build_out/controllers/login.20210709005815.py
tools/build_out/controllers/login.20210709005815.py
+0
-73
tools/build_out/controllers/login.py
tools/build_out/controllers/login.py
+56
-21
tools/build_out/controllers/monitor.py
tools/build_out/controllers/monitor.py
+0
-178
tools/build_out/controllers/monitorEvm.py
tools/build_out/controllers/monitorEvm.py
+12
-25
tools/build_out/controllers/monitorImage.py
tools/build_out/controllers/monitorImage.py
+12
-17
tools/build_out/controllers/monitorLvgl.py
tools/build_out/controllers/monitorLvgl.py
+12
-17
tools/build_out/controllers/monitorSystem.py
tools/build_out/controllers/monitorSystem.py
+12
-17
tools/build_out/controllers/monitorWatch.py
tools/build_out/controllers/monitorWatch.py
+12
-17
tools/build_out/controllers/package.20210709005815.py
tools/build_out/controllers/package.20210709005815.py
+0
-73
tools/build_out/controllers/package.20210714181414.py
tools/build_out/controllers/package.20210714181414.py
+174
-0
tools/build_out/controllers/upload.py
tools/build_out/controllers/upload.py
+0
-155
tools/build_out/controllers/user.20210709005815.py
tools/build_out/controllers/user.20210709005815.py
+0
-73
tools/build_out/controllers/user.py
tools/build_out/controllers/user.py
+24
-14
tools/build_out/logs/running.log
tools/build_out/logs/running.log
+0
-57
tools/build_out/models/annex.py
tools/build_out/models/annex.py
+7
-8
tools/build_out/models/app.py
tools/build_out/models/app.py
+4
-4
tools/build_out/models/area.py
tools/build_out/models/area.py
+1
-1
tools/build_out/models/device.py
tools/build_out/models/device.py
+3
-4
tools/build_out/models/login.py
tools/build_out/models/login.py
+27
-15
tools/build_out/models/monitorEvm.py
tools/build_out/models/monitorEvm.py
+9
-10
tools/build_out/models/monitorImage.py
tools/build_out/models/monitorImage.py
+8
-9
tools/build_out/models/monitorLvgl.py
tools/build_out/models/monitorLvgl.py
+11
-12
tools/build_out/models/monitorSystem.py
tools/build_out/models/monitorSystem.py
+5
-6
tools/build_out/models/monitorWatch.py
tools/build_out/models/monitorWatch.py
+4
-5
tools/build_out/models/package.20210714181414.py
tools/build_out/models/package.20210714181414.py
+106
-0
tools/build_out/models/package.py
tools/build_out/models/package.py
+13
-1
tools/build_out/models/user.py
tools/build_out/models/user.py
+44
-67
tools/build_out/result.json
tools/build_out/result.json
+0
-1
tools/build_out/views/__init__.20210709130326.py
tools/build_out/views/__init__.20210709130326.py
+0
-1
tools/build_out/views/__init__.20210714181414.py
tools/build_out/views/__init__.20210714181414.py
+66
-0
tools/build_out/views/__init__.py
tools/build_out/views/__init__.py
+28
-0
tools/build_out/views/annex.py
tools/build_out/views/annex.py
+17
-18
tools/build_out/views/app.20210714181414.py
tools/build_out/views/app.20210714181414.py
+106
-0
tools/build_out/views/area.py
tools/build_out/views/area.py
+14
-14
tools/build_out/views/device.py
tools/build_out/views/device.py
+30
-28
tools/build_out/views/login.py
tools/build_out/views/login.py
+31
-20
tools/build_out/views/monitorEvm.py
tools/build_out/views/monitorEvm.py
+12
-15
tools/build_out/views/monitorImage.py
tools/build_out/views/monitorImage.py
+12
-15
tools/build_out/views/monitorLvgl.py
tools/build_out/views/monitorLvgl.py
+12
-15
tools/build_out/views/monitorSystem.py
tools/build_out/views/monitorSystem.py
+12
-15
tools/build_out/views/monitorWatch.py
tools/build_out/views/monitorWatch.py
+12
-15
tools/build_out/views/package.20210714181414.py
tools/build_out/views/package.20210714181414.py
+64
-0
tools/build_out/views/user.py
tools/build_out/views/user.py
+26
-32
tools/build_out/webcreator/event.py
tools/build_out/webcreator/event.py
+1
-5
tools/build_out/webcreator/log.py
tools/build_out/webcreator/log.py
+2
-7
tools/build_out/webcreator/utils/ccode.py
tools/build_out/webcreator/utils/ccode.py
+1
-9
tools/build_out/webcreator/webscoket.py
tools/build_out/webcreator/webscoket.py
+9
-20
tools/logs/running.log
tools/logs/running.log
+1
-0
tools/modules/file-manager.py
tools/modules/file-manager.py
+0
-215
tools/modules/file.py
tools/modules/file.py
+82
-19
tools/resources/application/app.py
tools/resources/application/app.py
+6
-6
tools/resources/application/config.py
tools/resources/application/config.py
+16
-5
tools/resources/webcreator/event.py
tools/resources/webcreator/event.py
+0
-4
tools/resources/webcreator/log.py
tools/resources/webcreator/log.py
+2
-7
tools/resources/webcreator/utils/ccode.py
tools/resources/webcreator/utils/ccode.py
+68
-0
tools/resources/webcreator/utils/epk.py
tools/resources/webcreator/utils/epk.py
+267
-0
tools/resources/webcreator/utils/epk_2.0.py
tools/resources/webcreator/utils/epk_2.0.py
+234
-0
tools/resources/webcreator/utils/lib/eheatshrink.dll
tools/resources/webcreator/utils/lib/eheatshrink.dll
+0
-0
tools/resources/webcreator/utils/lib/libeheatshrink.so
tools/resources/webcreator/utils/lib/libeheatshrink.so
+0
-0
tools/resources/webcreator/utils/tools_epk_1.0.py
tools/resources/webcreator/utils/tools_epk_1.0.py
+223
-0
tools/resources/webcreator/webscoket.py
tools/resources/webcreator/webscoket.py
+9
-20
No files found.
tools/build_out/.gitignore
0 → 100644
View file @
3922979c
logs/
\ No newline at end of file
tools/build_out/application/signal_manager.20210709130326.py
deleted
100644 → 0
View file @
d109566c
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
webcreator.event
import
PySignal
class
SignalManager
(
object
):
actionPostArea
=
PySignal
()
actionDeleteArea
=
PySignal
()
actionGetListArea
=
PySignal
()
actionGetArea
=
PySignal
()
actionPutArea
=
PySignal
()
actionPostApp
=
PySignal
()
actionDeleteApp
=
PySignal
()
actionGetListApp
=
PySignal
()
actionGetApp
=
PySignal
()
actionPutApp
=
PySignal
()
actionGetListPackage
=
PySignal
()
actionGetPackage
=
PySignal
()
actionPostUser
=
PySignal
()
actionDeleteUser
=
PySignal
()
actionGetListUser
=
PySignal
()
actionGetUser
=
PySignal
()
actionPutUser
=
PySignal
()
actionPostLogin
=
PySignal
()
actionGetListLogin
=
PySignal
()
actionGetLogin
=
PySignal
()
# file manager api
actionGetFileInit
=
PySignal
()
actionGetFileContent
=
PySignal
()
actionGetFileTree
=
PySignal
()
actionGetFileDisk
=
PySignal
()
actionGetFileDown
=
PySignal
()
actionGetFilePreview
=
PySignal
()
def
__init__
(
self
):
super
()
.
__init__
()
signalManager
=
SignalManager
()
\ No newline at end of file
tools/build_out/application/signal_manager.py
View file @
3922979c
'''
Author: your name
Date: 2021-06-30 18:03:41
LastEditTime: 2021-07-14 18:14:38
LastEditors: your name
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\a
pplication
\
signal_manager.py
'''
#!/usr/bin/env python
# -*- coding: utf_8 -*-
...
...
@@ -50,6 +58,7 @@ class SignalManager(object):
actionGetFileDown
=
PySignal
()
actionGetFilePreview
=
PySignal
()
def
__init__
(
self
):
super
()
.
__init__
()
...
...
tools/build_out/controllers/__init__.py
View file @
3922979c
'''
Author: your name
Date: 2021-06-30 17:43:46
LastEditTime: 2021-07-
09 13:10:51
LastEditors:
Please set LastEditors
LastEditTime: 2021-07-
14 18:22:50
LastEditors:
your name
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\
controllers
\
__init__.py
'''
...
...
@@ -15,7 +15,14 @@ from .app import appManager
from
.package
import
packageManager
from
.user
import
userManager
from
.login
import
loginManager
from
.file_manager
import
fileManager
from
.device
import
deviceManager
from
.annex
import
annexManager
from
.monitorWatch
import
monitorWatchManager
from
.monitorSystem
import
monitorSystemManager
from
.monitorLvgl
import
monitorLvglManager
from
.monitorImage
import
monitorImageManager
from
.monitorEvm
import
monitorEvmManager
from
.file
import
fileManager
def
initConnect
():
signalManager
.
actionPostArea
.
connect
(
areaManager
.
post
)
...
...
@@ -38,5 +45,28 @@ def initConnect():
signalManager
.
actionPostLogin
.
connect
(
loginManager
.
post
)
signalManager
.
actionGetListLogin
.
connect
(
loginManager
.
getList
)
signalManager
.
actionGetLogin
.
connect
(
loginManager
.
get
)
signalManager
.
actionPostDevice
.
connect
(
deviceManager
.
post
)
signalManager
.
actionDeleteDevice
.
connect
(
deviceManager
.
delete
)
signalManager
.
actionGetListDevice
.
connect
(
deviceManager
.
getList
)
signalManager
.
actionGetDevice
.
connect
(
deviceManager
.
get
)
signalManager
.
actionPutDevice
.
connect
(
deviceManager
.
put
)
signalManager
.
actionDeleteAnnex
.
connect
(
annexManager
.
delete
)
signalManager
.
actionGetListAnnex
.
connect
(
annexManager
.
getList
)
signalManager
.
actionGetAnnex
.
connect
(
annexManager
.
get
)
signalManager
.
actionGetListMonitorWatch
.
connect
(
monitorWatchManager
.
getList
)
signalManager
.
actionGetMonitorWatch
.
connect
(
monitorWatchManager
.
get
)
signalManager
.
actionGetListMonitorSystem
.
connect
(
monitorSystemManager
.
getList
)
signalManager
.
actionGetMonitorSystem
.
connect
(
monitorSystemManager
.
get
)
signalManager
.
actionGetListMonitorLvgl
.
connect
(
monitorLvglManager
.
getList
)
signalManager
.
actionGetMonitorLvgl
.
connect
(
monitorLvglManager
.
get
)
signalManager
.
actionGetListMonitorImage
.
connect
(
monitorImageManager
.
getList
)
signalManager
.
actionGetMonitorImage
.
connect
(
monitorImageManager
.
get
)
signalManager
.
actionGetListMonitorEvm
.
connect
(
monitorEvmManager
.
getList
)
signalManager
.
actionGetMonitorEvm
.
connect
(
monitorEvmManager
.
get
)
# file manager api
signalManager
.
actionGetFileContent
.
connect
(
fileManager
.
content
)
# signalManager.actionGEt
\ No newline at end of file
signalManager
.
actionGetFileDisk
.
connect
(
fileManager
.
disk
)
signalManager
.
actionGetFileDown
.
connect
(
fileManager
.
download
)
signalManager
.
actionGetFileInit
.
connect
(
fileManager
.
initialize
)
signalManager
.
actionGetFilePreview
.
connect
(
fileManager
.
preview
)
signalManager
.
actionGetFileTree
.
connect
(
fileManager
.
tree
)
tools/build_out/controllers/annex.py
View file @
3922979c
'''
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
# from webcreator.response import ResponseCode, response_result
class
AnnexResource
(
object
):
def
__init__
(
self
):
...
...
@@ -24,8 +13,8 @@ class AnnexResource(object):
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
return
(
True
,
result
)
return
(
False
,
result
)
def
getList
(
self
,
params
):
# handle business
...
...
@@ -33,9 +22,7 @@ class AnnexResource(object):
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
return
(
True
,
result
.
items
,
result
.
total
)
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
...
...
@@ -45,20 +32,20 @@ class AnnexResource(object):
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
elif
result
and
result
.
is_delete
==
False
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
return
(
False
,
"record code exists"
)
result
=
AnnexModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
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
return
(
False
,
"record not exists"
)
if
params
:
for
key
,
value
in
params
.
items
():
...
...
@@ -66,21 +53,21 @@ class AnnexResource(object):
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
else
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
return
(
False
,
"params is null"
)
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
AnnexModel
.
query
.
filter
(
AnnexModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
return
(
False
,
"record not exists"
)
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
return
(
True
,
None
)
annexManager
=
AnnexResource
()
\ No newline at end of file
tools/build_out/controllers/api.py
deleted
100644 → 0
View file @
d109566c
'''
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/app.20210709005815.py
deleted
100644 → 0
View file @
d109566c
from
datetime
import
datetime
from
application.app
import
db
from
models.app
import
AppModel
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
AppResource
(
object
):
def
__init__
(
self
):
super
()
.
__init__
()
def
get
(
self
,
uuid
,
params
):
# handle business
filters
=
[
AppModel
.
is_delete
==
False
,
AppModel
.
uuid
==
uuid
]
result
=
AppModel
.
query
.
filter
(
*
filters
)
.
first
()
if
result
:
return
(
True
,
result
)
return
(
False
,
result
)
def
getList
(
self
,
params
):
# handle business
logger
.
warn
(
params
)
filters
=
[
AppModel
.
is_delete
==
False
]
result
=
AppModel
.
query
.
filter
(
*
filters
)
.
order_by
(
AppModel
.
create_at
)
.
paginate
(
params
.
get
(
'page'
,
1
),
params
.
get
(
'pageSize'
,
10
),
error_out
=
False
)
return
(
True
,
result
.
items
,
result
.
total
)
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
result
=
AppModel
.
query
.
filter
(
AppModel
.
app_name
==
params
.
get
(
'app_name'
))
.
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
,
None
)
elif
result
and
result
.
is_delete
==
False
:
return
(
False
,
"record code exists"
)
result
=
AppModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
(
True
,
None
)
def
put
(
self
,
uuid
,
params
,
jwt
=
{}):
# handle business
result
=
AppModel
.
query
.
filter
(
AppModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
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
,
None
)
else
:
return
(
False
,
"params is null"
)
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
AppModel
.
query
.
filter
(
AppModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
result
.
is_delete
=
True
db
.
session
.
delete
(
result
)
db
.
session
.
commit
()
return
(
True
,
None
)
appManager
=
AppResource
()
\ No newline at end of file
tools/build_out/controllers/app.py
View file @
3922979c
#!/usr/bin/env python
# -*- coding: utf_8 -*-
import
os
import
re
import
json
import
shutil
from
datetime
import
datetime
from
sqlalchemy
import
func
,
distinct
from
application.app
import
db
from
models.package
import
PackageModel
from
models.annex
import
AnnexModel
from
models.user
import
UserModel
from
models.app
import
AppModel
from
application.config
import
config
from
webcreator.utils.epk
import
EpkApp
from
webcreator.log
import
logger
# from webcreator.response import ResponseCode, response_result
from
webcreator.response
import
ResponseCode
class
AppResource
(
object
):
def
__init__
(
self
):
...
...
@@ -11,10 +24,74 @@ class AppResource(object):
def
get
(
self
,
uuid
,
params
):
# handle business
filters
=
[
AppModel
.
is_delete
==
False
,
AppModel
.
uuid
==
uuid
]
result
=
AppModel
.
query
.
filter
(
*
filters
)
.
first
()
if
result
:
return
(
True
,
result
)
return
(
False
,
result
)
app
=
AppModel
.
query
.
filter
(
*
filters
)
.
one_or_none
()
if
not
app
:
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
user
=
UserModel
.
query
.
filter
(
UserModel
.
id
==
params
.
get
(
'user'
))
.
one_or_none
()
if
not
user
:
return
False
,
ResponseCode
.
USER_NOT_EXISTS
# 根据app查询应用,获取应用有哪些文件
# 按格式创建文件夹,将这些文件移动到这个文件夹
# 将这些零散文件进行打包
# 更新数据库对应文件的路径
source_files
=
AnnexModel
.
query
.
filter
(
AnnexModel
.
app
==
app
)
.
all
()
if
not
source_files
:
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
dtNowString
=
datetime
.
now
()
.
strftime
(
"
%
Y
%
m
%
d
%
H
%
M
%
S"
)
dirname
=
"{}-{}-{}-{}"
.
format
(
app
.
app_name
,
app
.
app_version
,
app
.
category
,
dtNowString
)
upload_dir
=
os
.
sep
.
join
([
config
.
UPLOAD_ROOT_DIR
,
config
.
EPK_DIR
])
target_dir
=
os
.
sep
.
join
([
upload_dir
,
dirname
])
dest_dir
=
os
.
sep
.
join
([
target_dir
,
"src"
])
if
not
os
.
path
.
exists
(
dest_dir
):
os
.
makedirs
(
dest_dir
)
app_files
=
[]
for
sf
in
source_files
:
target_file
=
sf
.
path
if
not
os
.
path
.
exists
(
sf
.
path
):
target_file
=
os
.
sep
.
join
([
config
.
UPLOAD_ROOT_DIR
,
sf
.
path
])
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
)
app_files
.
append
([
sf
.
id
,
dst_file
])
with
open
(
os
.
sep
.
join
([
target_dir
,
"epk.json"
]),
"w"
)
as
f
:
json
.
dump
(
app
.
to_dict
(
exclude
=
[
"uuid"
,
"create_at"
,
"update_at"
,
"delete_at"
]),
f
)
# 打包成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
(
'
\\
'
,
'/'
)
package
=
PackageModel
.
query
.
filter
(
PackageModel
.
app
==
app
)
.
one_or_none
()
if
package
:
package
.
app_path
=
epk_path
package
.
app_info
=
app_info
package
.
update_by
=
user
.
id
package
.
update_at
=
datetime
.
now
()
db
.
session
.
commit
()
# 新增一条AppLogs
package
=
PackageModel
(
app
=
app
.
app_name
,
app_version
=
app
.
app_version
,
file_path
=
epk_path
,
package_info
=
app_info
,
create_by
=
user
,
create_at
=
datetime
.
now
())
db
.
session
.
add
(
package
)
db
.
session
.
commit
()
return
{
'app_name'
:
app
.
app_name
,
'app_path'
:
epk_path
},
ResponseCode
.
HTTP_NOT_FOUND
def
getList
(
self
,
params
):
# handle business
...
...
@@ -22,52 +99,178 @@ class AppResource(object):
filters
=
[
AppModel
.
is_delete
==
False
]
result
=
AppModel
.
query
.
filter
(
*
filters
)
.
order_by
(
AppModel
.
create_at
)
.
paginate
(
params
.
get
(
'page'
,
1
),
params
.
get
(
'pageSize'
,
10
),
error_out
=
False
)
return
(
True
,
result
.
items
,
result
.
total
)
if
not
result
:
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
user
=
UserModel
.
query
.
filter
(
UserModel
.
id
==
params
.
get
(
'user'
))
.
one_or_none
()
if
not
user
:
return
False
,
ResponseCode
.
USER_NOT_EXISTS
temp
=
{}
if
user
.
role
==
"administrator"
:
temp
.
update
({
"is_delete"
:
False
})
else
:
temp
.
update
({
"create_by"
:
user
,
"is_delete"
:
False
})
if
"scope_type"
in
params
and
params
.
get
(
"scope_type"
)
==
"list"
:
result
=
AppModel
.
query
.
filter_by
(
**
temp
)
.
order_by
(
AppModel
.
create_at
.
desc
())
temp
=
[]
for
item
in
result
:
temp
.
append
(
item
.
to_dict
(
only
=
[
"uuid"
,
"app_name"
]))
return
(
temp
,
len
(
temp
)),
ResponseCode
.
HTTP_SUCCESS
elif
"scope_type"
in
params
and
params
.
get
(
"scope_type"
)
==
"distinct"
:
result
=
db
.
session
.
query
(
AppModel
,
func
.
count
(
distinct
(
AppModel
.
name
)))
.
all
()
temp
=
[]
for
item
in
result
:
temp
.
append
(
item
)
return
(
temp
,
len
(
temp
)),
ResponseCode
.
HTTP_SUCCESS
result
=
AppModel
.
query
.
filter_by
(
**
temp
)
.
order_by
(
AppModel
.
sort
)
.
order_by
(
AppModel
.
create_at
.
desc
())
.
paginate
(
params
.
get
(
"pagenum"
,
1
),
params
.
get
(
"pagesize"
,
10
),
error_out
=
False
)
if
result
.
total
and
len
(
result
.
items
):
temp
=
[]
for
item
in
result
.
items
:
t
=
dict
()
t
.
update
(
item
.
to_json
())
t
.
update
({
"create_by"
:
item
.
create_by
.
to_dict
(
only
=
[
"uuid"
,
"username"
]),
"update_by"
:
item
.
update_by
.
to_dict
(
only
=
[
"uuid"
,
"username"
]),
"create_at"
:
item
.
create_at
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
if
item
.
create_at
else
None
,
"update_at"
:
item
.
update_at
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
if
item
.
update_at
else
None
,
})
temp
.
append
(
t
)
result
=
temp
return
result
,
ResponseCode
.
HTTP_SUCCESS
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
result
=
AppModel
.
query
.
filter
(
AppModel
.
app_name
==
params
.
get
(
'app_name'
))
.
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
,
None
)
elif
result
and
result
.
is_delete
==
False
:
return
(
False
,
"record code exists"
)
# 应用打包
# 插入一条打包记录
user
=
UserModel
.
query
.
filter
(
UserModel
.
id
==
params
.
get
(
'user'
))
.
one_or_none
()
if
not
user
:
return
False
,
ResponseCode
.
USER_NOT_EXISTS
# 判断下app是否存在
# result = Apps.select(app_name=data.get("app_name"), is_delete=False).count()
# if result < 1:
# return False, "app_name has been exists."
result
=
AppModel
(
**
params
)
db
.
session
.
add
(
result
)
params
.
update
({
'app_icon'
:
params
[
"app_icon"
]
.
replace
(
config
.
UPLOAD_ROOT_DIR
,
""
),
'create_by'
:
user
.
id
,
'create_at'
:
datetime
.
now
(),
'update_by'
:
user
.
id
,
'update_at'
:
datetime
.
now
(),
})
app_files
=
[]
epk_path
=
""
if
params
.
get
(
"fileList"
):
app_files
=
params
.
get
(
"fileList"
)
params
.
pop
(
"fileList"
)
epk_path
=
params
.
get
(
"epk_path"
)
params
.
pop
(
"epk_path"
)
app
=
AppModel
(
**
params
)
db
.
session
.
add
(
app
)
db
.
session
.
commit
()
return
(
True
,
None
)
# 在EPK目录下生成JSON文件
with
open
(
os
.
sep
.
join
([
os
.
path
.
dirname
(
epk_path
),
"epk.json"
]),
"w"
)
as
f
:
json
.
dump
(
app
.
to_dict
(),
f
)
for
a
in
app_files
:
res
=
AnnexModel
(
app
=
app
,
title
=
os
.
path
.
basename
(
a
),
path
=
a
,
size
=
os
.
path
.
getsize
(
a
),
create_by
=
user
,
create_at
=
datetime
.
now
(),
update_by
=
user
,
update_at
=
datetime
.
now
())
db
.
session
.
add
(
res
)
db
.
session
.
flush
()
db
.
session
.
commit
()
app_info
=
{}
params
=
{
'appName'
:
app
.
app_name
,
'appDir'
:
epk_path
,
'appVersion'
:
app
.
app_version
,
'output'
:
os
.
path
.
dirname
(
epk_path
)
}
if
user
.
role
==
"administrator"
or
user
.
role
==
"community"
:
params
[
'algorithm'
]
=
"h"
epk
=
EpkApp
(
**
params
)
app_info
=
epk
.
pack
()
epk_filename
=
os
.
sep
.
join
([
os
.
path
.
dirname
(
epk_path
)
.
replace
(
config
.
UPLOAD_ROOT_DIR
,
""
),
"{}.epk"
.
format
(
app
.
app_name
)])
.
replace
(
'
\\
'
,
'/'
)
if
app_info
:
app_info
[
'md5'
]
=
str
(
app_info
[
'md5'
])
package
=
PackageModel
(
app
=
app
,
file_path
=
epk_filename
,
app_version
=
params
.
get
(
"app_version"
),
package_info
=
app_info
,
source
=
1
,
create_by
=
user
,
create_at
=
datetime
.
now
(),
update_by
=
user
,
update_at
=
datetime
.
now
())
db
.
session
.
add
(
package
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
# result = AppModel.query.filter(AppModel.app_name == params.get('app_name')).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 = AppModel(**params)
# db.session.add(result)
# db.session.commit()
# return True, ResponseCode.HTTP_SUCCESS
def
put
(
self
,
uuid
,
params
,
jwt
=
{}):
user
=
UserModel
.
query
.
filter
(
UserModel
.
id
==
params
.
get
(
'user'
))
.
one_or_none
()
if
not
user
:
return
False
,
ResponseCode
.
USER_NOT_EXISTS
# handle business
result
=
AppModel
.
query
.
filter
(
AppModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
app
=
AppModel
.
query
.
filter
(
AppModel
.
uuid
==
uuid
)
.
first
()
if
not
app
:
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
if
params
:
# 更新文件
if
params
.
get
(
"app_files"
):
for
a
in
params
.
get
(
"app_files"
):
res
=
AnnexModel
(
app
=
app
,
title
=
a
.
get
(
"filename"
),
path
=
a
.
get
(
"filepath"
),
size
=
a
.
get
(
"filesize"
),
create_by
=
user
,
create_at
=
datetime
.
now
(),
update_by
=
user
,
update_at
=
datetime
.
now
())
db
.
session
.
add
(
res
)
db
.
session
.
flush
()
db
.
session
.
commit
()
params
.
pop
(
"app_files"
)
# 更新icon
if
params
.
get
(
"app_icon"
):
condition
=
{
'update_by'
:
user
,
'update_at'
:
datetime
.
now
()
}
if
params
.
get
(
"app_icon"
)
.
get
(
"filename"
):
condition
.
update
({
"title"
:
params
.
get
(
"app_icon"
)
.
get
(
"filename"
)})
if
params
.
get
(
"app_icon"
)
.
get
(
"filepath"
):
condition
.
update
({
"path"
:
params
.
get
(
"app_icon"
)
.
get
(
"filepath"
)})
if
params
.
get
(
"app_icon"
)
.
get
(
"filesize"
):
condition
.
update
({
"size"
:
params
.
get
(
"app_icon"
)
.
get
(
"filesize"
)})
params
.
pop
(
"app_icon"
)
for
key
,
value
in
params
.
items
():
if
value
!=
None
:
setattr
(
result
,
key
,
value
)
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
if
value
!=
None
:
setattr
(
app
,
key
,
value
)
app
.
update_by
=
jwt
.
get
(
"id"
,
""
)
app
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
(
True
,
None
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
else
:
return
(
False
,
"params is null"
)
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
AppModel
.
query
.
filter
(
AppModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
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
,
None
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
appManager
=
AppResource
()
\ No newline at end of file
tools/build_out/controllers/area.20210709005815.py
deleted
100644 → 0
View file @
d109566c
from
datetime
import
datetime
from
application.app
import
db
from
models.area
import
AreaModel
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
AreaResource
(
object
):
def
__init__
(
self
):
super
()
.
__init__
()
def
get
(
self
,
uuid
,
params
):
# handle business
filters
=
[
AreaModel
.
is_delete
==
False
,
AreaModel
.
uuid
==
uuid
]
result
=
AreaModel
.
query
.
filter
(
*
filters
)
.
first
()
if
result
:
return
(
True
,
result
)
return
(
False
,
result
)
def
getList
(
self
,
params
):
# handle business
logger
.
warn
(
params
)
filters
=
[
AreaModel
.
is_delete
==
False
]
result
=
AreaModel
.
query
.
filter
(
*
filters
)
.
order_by
(
AreaModel
.
create_at
)
.
paginate
(
params
.
get
(
'page'
,
1
),
params
.
get
(
'pageSize'
,
10
),
error_out
=
False
)
return
(
True
,
result
.
items
,
result
.
total
)
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
result
=
AreaModel
.
query
.
filter
(
AreaModel
.
areaCode
==
params
.
get
(
'areaCode'
))
.
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
,
None
)
elif
result
and
result
.
is_delete
==
False
:
return
(
False
,
"record code exists"
)
result
=
AreaModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
(
True
,
None
)
def
put
(
self
,
uuid
,
params
,
jwt
=
{}):
# handle business
result
=
AreaModel
.
query
.
filter
(
AreaModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
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
,
None
)
else
:
return
(
False
,
"params is null"
)
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
AreaModel
.
query
.
filter
(
AreaModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
result
.
is_delete
=
True
db
.
session
.
delete
(
result
)
db
.
session
.
commit
()
return
(
True
,
None
)
areaManager
=
AreaResource
()
\ No newline at end of file
tools/build_out/controllers/area.py
View file @
3922979c
'''
Author: your name
Date: 2021-06-30 18:03:41
LastEditTime: 2021-07-12 11:31:06
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\
controllers
\a
rea.py
'''
from
datetime
import
datetime
from
application.app
import
db
from
models.area
import
AreaModel
from
webcreator.log
import
logger
# from webcreator.response import ResponseCode, response_result
from
webcreator.response
import
ResponseCode
class
AreaResource
(
object
):
def
__init__
(
self
):
...
...
@@ -13,8 +21,8 @@ class AreaResource(object):
filters
=
[
AreaModel
.
is_delete
==
False
,
AreaModel
.
uuid
==
uuid
]
result
=
AreaModel
.
query
.
filter
(
*
filters
)
.
first
()
if
result
:
return
(
True
,
result
)
return
(
False
,
result
)
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
result
,
ResponseCode
.
HTTP_NOT_FOUND
def
getList
(
self
,
params
):
# handle business
...
...
@@ -22,7 +30,9 @@ class AreaResource(object):
filters
=
[
AreaModel
.
is_delete
==
False
]
result
=
AreaModel
.
query
.
filter
(
*
filters
)
.
order_by
(
AreaModel
.
create_at
)
.
paginate
(
params
.
get
(
'page'
,
1
),
params
.
get
(
'pageSize'
,
10
),
error_out
=
False
)
return
(
True
,
result
.
items
,
result
.
total
)
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
...
...
@@ -32,9 +42,9 @@ class AreaResource(object):
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
(
True
,
None
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
elif
result
and
result
.
is_delete
==
False
:
return
(
False
,
"record code exists"
)
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
result
=
AreaModel
(
**
params
)
db
.
session
.
add
(
result
)
...
...
@@ -45,7 +55,7 @@ class AreaResource(object):
# handle business
result
=
AreaModel
.
query
.
filter
(
AreaModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
if
params
:
for
key
,
value
in
params
.
items
():
...
...
@@ -53,21 +63,21 @@ class AreaResource(object):
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
(
True
,
None
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
else
:
return
(
False
,
"params is null"
)
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
AreaModel
.
query
.
filter
(
AreaModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
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
,
None
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
areaManager
=
AreaResource
()
\ No newline at end of file
areaManager
=
AreaResource
()
tools/build_out/controllers/device.py
View file @
3922979c
'''
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
# from webcreator.response import ResponseCode, response_result
class
DeviceResource
(
object
):
def
__init__
(
self
):
...
...
@@ -24,8 +13,8 @@ class DeviceResource(object):
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
return
(
True
,
result
)
return
(
False
,
result
)
def
getList
(
self
,
params
):
# handle business
...
...
@@ -33,32 +22,30 @@ class DeviceResource(object):
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
return
(
True
,
result
.
items
,
result
.
total
)
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
result
=
DeviceModel
.
query
.
filter
(
DeviceModel
.
imei
==
params
.
get
(
'imei'
))
.
first
()
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
return
(
True
,
None
)
elif
result
and
result
.
is_delete
==
False
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
return
(
False
,
"record code exists"
)
result
=
DeviceModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
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
return
(
False
,
"record not exists"
)
if
params
:
for
key
,
value
in
params
.
items
():
...
...
@@ -66,21 +53,21 @@ class DeviceResource(object):
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
else
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
return
(
False
,
"params is null"
)
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
DeviceModel
.
query
.
filter
(
DeviceModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
return
(
False
,
"record not exists"
)
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
return
(
True
,
None
)
deviceManager
=
DeviceResource
()
\ No newline at end of file
tools/build_out/controllers/login.20210709005815.py
deleted
100644 → 0
View file @
d109566c
from
datetime
import
datetime
from
application.app
import
db
from
models.login
import
LoginModel
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
LoginResource
(
object
):
def
__init__
(
self
):
super
()
.
__init__
()
def
get
(
self
,
uuid
,
params
):
# handle business
filters
=
[
LoginModel
.
is_delete
==
False
,
LoginModel
.
uuid
==
uuid
]
result
=
LoginModel
.
query
.
filter
(
*
filters
)
.
first
()
if
result
:
return
(
True
,
result
)
return
(
False
,
result
)
def
getList
(
self
,
params
):
# handle business
logger
.
warn
(
params
)
filters
=
[
LoginModel
.
is_delete
==
False
]
result
=
LoginModel
.
query
.
filter
(
*
filters
)
.
order_by
(
LoginModel
.
create_at
)
.
paginate
(
params
.
get
(
'page'
,
1
),
params
.
get
(
'pageSize'
,
10
),
error_out
=
False
)
return
(
True
,
result
.
items
,
result
.
total
)
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
result
=
LoginModel
.
query
.
filter
(
LoginModel
.
user
==
params
.
get
(
'user'
))
.
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
,
None
)
elif
result
and
result
.
is_delete
==
False
:
return
(
False
,
"record code exists"
)
result
=
LoginModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
(
True
,
None
)
def
put
(
self
,
uuid
,
params
,
jwt
=
{}):
# handle business
result
=
LoginModel
.
query
.
filter
(
LoginModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
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
,
None
)
else
:
return
(
False
,
"params is null"
)
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
LoginModel
.
query
.
filter
(
LoginModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
result
.
is_delete
=
True
db
.
session
.
delete
(
result
)
db
.
session
.
commit
()
return
(
True
,
None
)
loginManager
=
LoginResource
()
\ No newline at end of file
tools/build_out/controllers/login.py
View file @
3922979c
#!/usr/bin/env python
# -*- coding: utf_8 -*-
import
json
from
datetime
import
datetime
from
flask_jwt_extended
import
(
create_access_token
,)
from
application.app
import
db
from
models.login
import
LoginModel
from
models.user
import
UserModel
from
webcreator.log
import
logger
# from webcreator.response import ResponseCode, response_result
from
webcreator
import
utils
from
webcreator.response
import
ResponseCode
@
utils
.
ThreadMaker
def
update_login_information
(
ip
,
log_id
):
try
:
jsonData
=
utils
.
get_location_by_ip
(
ip
)
logger
.
info
(
jsonData
)
if
(
0
!=
jsonData
[
'status'
]):
return
None
record
=
LoginModel
.
query
.
filter
(
LoginModel
.
id
==
log_id
)
.
first
()
record
.
geo_location
=
json
.
dumps
(
jsonData
,
ensure_ascii
=
False
)
db
.
session
.
commit
()
except
Exception
as
e
:
logger
.
error
(
e
)
class
LoginResource
(
object
):
def
__init__
(
self
):
...
...
@@ -13,8 +35,8 @@ class LoginResource(object):
filters
=
[
LoginModel
.
is_delete
==
False
,
LoginModel
.
uuid
==
uuid
]
result
=
LoginModel
.
query
.
filter
(
*
filters
)
.
first
()
if
result
:
return
(
True
,
result
)
return
(
False
,
result
)
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
getList
(
self
,
params
):
# handle business
...
...
@@ -22,30 +44,43 @@ class LoginResource(object):
filters
=
[
LoginModel
.
is_delete
==
False
]
result
=
LoginModel
.
query
.
filter
(
*
filters
)
.
order_by
(
LoginModel
.
create_at
)
.
paginate
(
params
.
get
(
'page'
,
1
),
params
.
get
(
'pageSize'
,
10
),
error_out
=
False
)
return
(
True
,
result
.
items
,
result
.
total
)
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
result
=
LoginModel
.
query
.
filter
(
LoginModel
.
user
==
params
.
get
(
'user'
))
.
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
,
None
)
elif
result
and
result
.
is_delete
==
False
:
return
(
False
,
"record code exists"
)
user
=
UserModel
.
query
.
filter
(
UserModel
.
account
==
params
.
get
(
"account"
))
.
first
()
if
not
user
:
return
False
,
ResponseCode
.
USER_NOT_EXISTS
result
=
LoginModel
(
**
params
)
logger
.
info
(
params
)
if
user
.
password
!=
utils
.
md5_encryption
(
params
.
get
(
"password"
)):
return
False
,
ResponseCode
.
USER_PASSWORD_ERROR
# 插入一条登录记录
obj
=
{
'user'
:
user
.
id
,
'user_agent'
:
params
.
get
(
"user_agent"
),
'ip'
:
params
.
get
(
"ip"
),
'geo_location'
:
''
,
'operator'
:
''
,
'login_at'
:
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
}
result
=
LoginModel
(
**
obj
)
result
.
operator
=
""
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
(
True
,
None
)
# 获取当前登录IP地理位置信息
update_login_information
(
params
.
get
(
"ip"
),
result
.
id
)
# 生成一个token,返回给前端
result
=
{
'uuid'
:
user
.
uuid
,
'name'
:
user
.
username
,
'token'
:
create_access_token
(
identity
=
{
'uuid'
:
user
.
uuid
,
'name'
:
user
.
username
}),
}
return
result
,
ResponseCode
.
HTTP_SUCCESS
def
put
(
self
,
uuid
,
params
,
jwt
=
{}):
# handle business
result
=
LoginModel
.
query
.
filter
(
LoginModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
if
params
:
for
key
,
value
in
params
.
items
():
...
...
@@ -53,21 +88,21 @@ class LoginResource(object):
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
(
True
,
None
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
else
:
return
(
False
,
"params is null"
)
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
LoginModel
.
query
.
filter
(
LoginModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
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
,
None
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
loginManager
=
LoginResource
()
\ No newline at end of file
loginManager
=
LoginResource
()
tools/build_out/controllers/monitor.py
deleted
100644 → 0
View file @
d109566c
'''
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
View file @
3922979c
'''
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
# from webcreator.response import ResponseCode, response_result
class
MonitorEvmResource
(
object
):
def
__init__
(
self
):
...
...
@@ -24,8 +13,8 @@ class MonitorEvmResource(object):
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
return
(
True
,
result
)
return
(
False
,
result
)
def
getList
(
self
,
params
):
# handle business
...
...
@@ -33,9 +22,7 @@ class MonitorEvmResource(object):
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
return
(
True
,
result
.
items
,
result
.
total
)
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
...
...
@@ -45,20 +32,20 @@ class MonitorEvmResource(object):
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
elif
result
and
result
.
is_delete
==
False
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
return
(
False
,
"record code exists"
)
result
=
MonitorEvmModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
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
return
(
False
,
"record not exists"
)
if
params
:
for
key
,
value
in
params
.
items
():
...
...
@@ -66,21 +53,21 @@ class MonitorEvmResource(object):
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
else
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
return
(
False
,
"params is null"
)
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
MonitorEvmModel
.
query
.
filter
(
MonitorEvmModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
return
(
False
,
"record not exists"
)
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
return
(
True
,
None
)
monitorEvmManager
=
MonitorEvmResource
()
\ No newline at end of file
tools/build_out/controllers/monitorImage.py
View file @
3922979c
#!/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
#
from webcreator.response import ResponseCode, response_result
class
MonitorImageResource
(
object
):
def
__init__
(
self
):
...
...
@@ -16,8 +13,8 @@ class MonitorImageResource(object):
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
return
(
True
,
result
)
return
(
False
,
result
)
def
getList
(
self
,
params
):
# handle business
...
...
@@ -25,9 +22,7 @@ class MonitorImageResource(object):
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
return
(
True
,
result
.
items
,
result
.
total
)
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
...
...
@@ -37,20 +32,20 @@ class MonitorImageResource(object):
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
elif
result
and
result
.
is_delete
==
False
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
return
(
False
,
"record code exists"
)
result
=
MonitorImageModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
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
return
(
False
,
"record not exists"
)
if
params
:
for
key
,
value
in
params
.
items
():
...
...
@@ -58,21 +53,21 @@ class MonitorImageResource(object):
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
else
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
return
(
False
,
"params is null"
)
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
MonitorImageModel
.
query
.
filter
(
MonitorImageModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
return
(
False
,
"record not exists"
)
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
return
(
True
,
None
)
monitorImageManager
=
MonitorImageResource
()
\ No newline at end of file
tools/build_out/controllers/monitorLvgl.py
View file @
3922979c
#!/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
#
from webcreator.response import ResponseCode, response_result
class
MonitorLvglResource
(
object
):
def
__init__
(
self
):
...
...
@@ -16,8 +13,8 @@ class MonitorLvglResource(object):
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
return
(
True
,
result
)
return
(
False
,
result
)
def
getList
(
self
,
params
):
# handle business
...
...
@@ -25,9 +22,7 @@ class MonitorLvglResource(object):
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
return
(
True
,
result
.
items
,
result
.
total
)
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
...
...
@@ -37,20 +32,20 @@ class MonitorLvglResource(object):
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
elif
result
and
result
.
is_delete
==
False
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
return
(
False
,
"record code exists"
)
result
=
MonitorLvglModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
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
return
(
False
,
"record not exists"
)
if
params
:
for
key
,
value
in
params
.
items
():
...
...
@@ -58,21 +53,21 @@ class MonitorLvglResource(object):
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
else
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
return
(
False
,
"params is null"
)
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
MonitorLvglModel
.
query
.
filter
(
MonitorLvglModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
return
(
False
,
"record not exists"
)
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
return
(
True
,
None
)
monitorLvglManager
=
MonitorLvglResource
()
\ No newline at end of file
tools/build_out/controllers/monitorSystem.py
View file @
3922979c
#!/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
#
from webcreator.response import ResponseCode, response_result
class
MonitorSystemResource
(
object
):
def
__init__
(
self
):
...
...
@@ -16,8 +13,8 @@ class MonitorSystemResource(object):
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
return
(
True
,
result
)
return
(
False
,
result
)
def
getList
(
self
,
params
):
# handle business
...
...
@@ -25,9 +22,7 @@ class MonitorSystemResource(object):
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
return
(
True
,
result
.
items
,
result
.
total
)
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
...
...
@@ -37,20 +32,20 @@ class MonitorSystemResource(object):
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
elif
result
and
result
.
is_delete
==
False
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
return
(
False
,
"record code exists"
)
result
=
MonitorSystemModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
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
return
(
False
,
"record not exists"
)
if
params
:
for
key
,
value
in
params
.
items
():
...
...
@@ -58,21 +53,21 @@ class MonitorSystemResource(object):
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
else
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
return
(
False
,
"params is null"
)
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
MonitorSystemModel
.
query
.
filter
(
MonitorSystemModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
return
(
False
,
"record not exists"
)
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
return
(
True
,
None
)
monitorSystemManager
=
MonitorSystemResource
()
\ No newline at end of file
tools/build_out/controllers/monitorWatch.py
View file @
3922979c
#!/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
#
from webcreator.response import ResponseCode, response_result
class
MonitorWatchResource
(
object
):
def
__init__
(
self
):
...
...
@@ -16,8 +13,8 @@ class MonitorWatchResource(object):
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
return
(
True
,
result
)
return
(
False
,
result
)
def
getList
(
self
,
params
):
# handle business
...
...
@@ -25,9 +22,7 @@ class MonitorWatchResource(object):
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
return
(
True
,
result
.
items
,
result
.
total
)
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
...
...
@@ -37,20 +32,20 @@ class MonitorWatchResource(object):
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
elif
result
and
result
.
is_delete
==
False
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
return
(
False
,
"record code exists"
)
result
=
MonitorWatchModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
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
return
(
False
,
"record not exists"
)
if
params
:
for
key
,
value
in
params
.
items
():
...
...
@@ -58,21 +53,21 @@ class MonitorWatchResource(object):
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
return
(
True
,
None
)
else
:
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
return
(
False
,
"params is null"
)
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
MonitorWatchModel
.
query
.
filter
(
MonitorWatchModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
return
(
False
,
"record not exists"
)
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
return
(
True
,
None
)
monitorWatchManager
=
MonitorWatchResource
()
\ No newline at end of file
tools/build_out/controllers/package.20210709005815.py
deleted
100644 → 0
View file @
d109566c
from
datetime
import
datetime
from
application.app
import
db
from
models.package
import
PackageModel
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
PackageResource
(
object
):
def
__init__
(
self
):
super
()
.
__init__
()
def
get
(
self
,
uuid
,
params
):
# handle business
filters
=
[
PackageModel
.
is_delete
==
False
,
PackageModel
.
uuid
==
uuid
]
result
=
PackageModel
.
query
.
filter
(
*
filters
)
.
first
()
if
result
:
return
(
True
,
result
)
return
(
False
,
result
)
def
getList
(
self
,
params
):
# handle business
logger
.
warn
(
params
)
filters
=
[
PackageModel
.
is_delete
==
False
]
result
=
PackageModel
.
query
.
filter
(
*
filters
)
.
order_by
(
PackageModel
.
create_at
)
.
paginate
(
params
.
get
(
'page'
,
1
),
params
.
get
(
'pageSize'
,
10
),
error_out
=
False
)
return
(
True
,
result
.
items
,
result
.
total
)
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
result
=
PackageModel
.
query
.
filter
(
PackageModel
.
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
,
None
)
elif
result
and
result
.
is_delete
==
False
:
return
(
False
,
"record code exists"
)
result
=
PackageModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
(
True
,
None
)
def
put
(
self
,
uuid
,
params
,
jwt
=
{}):
# handle business
result
=
PackageModel
.
query
.
filter
(
PackageModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
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
,
None
)
else
:
return
(
False
,
"params is null"
)
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
PackageModel
.
query
.
filter
(
PackageModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
result
.
is_delete
=
True
db
.
session
.
delete
(
result
)
db
.
session
.
commit
()
return
(
True
,
None
)
packageManager
=
PackageResource
()
\ No newline at end of file
tools/build_out/controllers/package.20210714181414.py
0 → 100644
View file @
3922979c
'''
Author: your name
Date: 2021-06-30 18:03:41
LastEditTime: 2021-07-12 11:11:49
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\
controllers
\
package.py
'''
#!/usr/bin/env python
# -*- coding: utf_8 -*-
import
os
import
re
import
shutil
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.utils.epk
import
EpkApp
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
class
PackageResource
(
object
):
def
__init__
(
self
):
super
()
.
__init__
()
def
get
(
self
,
uuid
,
params
):
# handle business
filters
=
[
PackageModel
.
is_delete
==
False
,
PackageModel
.
uuid
==
uuid
]
result
=
PackageModel
.
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
=
[
PackageModel
.
is_delete
==
False
]
result
=
PackageModel
.
query
.
filter
(
*
filters
)
.
order_by
(
PackageModel
.
create_at
)
.
paginate
(
params
.
get
(
'page'
,
1
),
params
.
get
(
'pageSize'
,
10
),
error_out
=
False
)
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
user
=
UserModel
.
query
.
filter
(
id
=
params
.
get
(
'user'
))
.
onr_or_none
()
if
not
user
:
return
False
,
ResponseCode
.
USER_NOT_EXISTS
temp
=
{}
if
user
.
role
==
"administrator"
:
temp
.
update
({
"is_delete"
:
False
})
else
:
temp
.
update
({
"create_by"
:
user
.
id
,
"is_delete"
:
False
})
if
"scope_type"
in
params
and
params
.
get
(
"scope_type"
)
==
"list"
:
result
=
PackageModel
.
query
.
filter_by
(
**
temp
)
.
order_by
(
PackageModel
.
create_at
.
desc
())
temp
=
[]
for
item
in
result
:
temp
.
append
({
"name"
:
item
.
app
.
app_name
,
"uuid"
:
str
(
item
.
uuid
)
})
return
temp
,
len
(
temp
),
"get build_logs {}."
.
format
(
"success"
if
temp
else
"fail"
)
result
=
PackageModel
.
query
.
filter_by
(
**
temp
)
.
order_by
(
PackageModel
.
create_at
.
desc
())
.
paginate
(
params
.
get
(
"pagenum"
,
1
),
params
.
get
(
"pagesize"
,
10
),
error_out
=
False
)
if
result
.
total
and
len
(
result
.
items
):
temp
=
[]
for
item
in
result
.
items
:
t
=
item
.
to_dict
()
t
.
update
({
"create_at"
:
item
.
create_at
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
if
item
.
create_at
else
None
,
"update_at"
:
item
.
update_at
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
if
item
.
update_at
else
None
,
})
temp
.
append
(
t
)
return
(
temp
,
result
.
total
),
ResponseCode
.
HTTP_SUCCESS
return
result
,
ResponseCode
.
HTTP_NO_DATA
def
post
(
self
,
params
,
jwt
=
{}):
# 判断用户是否存在
user
=
UserModel
.
query
.
filter
(
UserModel
.
id
==
params
.
get
(
'user'
))
if
not
user
:
return
False
,
ResponseCode
.
USER_NOT_EXISTS
# 判断app是否存在
app
=
AppModel
.
query
.
filter
(
AppModel
.
id
==
params
.
get
(
"app"
))
if
not
app
:
return
False
,
ResponseCode
.
HTTP_NOT_FOUND
# 根据应用查找有哪些源文件
source_files
=
AnnexModel
.
query
.
filter
(
AnnexModel
.
app
==
app
.
id
)
.
all
()
if
not
source_files
:
return
None
,
ResponseCode
.
HTTP_NO_DATA
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
,
"uploads"
,
"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
)
app_files
=
[]
for
sf
in
source_files
:
target_file
=
os
.
sep
.
join
([
config
.
UPLOAD_ROOT_DIR
,
sf
.
path
])
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
.
move
(
os
.
path
.
normpath
(
target_file
),
dst_file
)
app_files
.
append
([
sf
.
id
,
dst_file
])
# 打包成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
()
if
app_info
:
app_info
[
'md5'
]
=
str
(
app_info
[
'md5'
])
# 更新数据库对应文件路径
# for sf in source_files:
# for af in app_files:
# if sf.id == af[0]:
# t = os.path.normpath(af[1].replace(config.UPLOAD_ROOT_DIR, "")).replace('\\', '/')
# sf.set(path=t)
# db.session.flush()
# db.session.commit()
epk_path
=
os
.
sep
.
join
([
target_dir
.
replace
(
config
.
UPLOAD_ROOT_DIR
,
""
),
"{}.epk"
.
format
(
app
.
app_name
)])
.
replace
(
'
\\
'
,
'/'
)
# handle business
# result = PackageModel.query.filter(PackageModel.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
=
PackageModel
(
app
=
app
.
id
,
file_path
=
epk_path
,
package_info
=
app_info
,
app_version
=
params
.
get
(
"app_version"
),
create_by
=
user
.
id
,
create_at
=
datetime
.
now
(),
update_by
=
user
.
id
,
update_at
=
datetime
.
now
())
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
put
(
self
,
uuid
,
params
,
jwt
=
{}):
# handle business
result
=
PackageModel
.
query
.
filter
(
PackageModel
.
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
=
PackageModel
.
query
.
filter
(
PackageModel
.
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
packageManager
=
PackageResource
()
\ No newline at end of file
tools/build_out/controllers/upload.py
deleted
100644 → 0
View file @
d109566c
#!/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/controllers/user.20210709005815.py
deleted
100644 → 0
View file @
d109566c
from
datetime
import
datetime
from
application.app
import
db
from
models.user
import
UserModel
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
UserResource
(
object
):
def
__init__
(
self
):
super
()
.
__init__
()
def
get
(
self
,
uuid
,
params
):
# handle business
filters
=
[
UserModel
.
is_delete
==
False
,
UserModel
.
uuid
==
uuid
]
result
=
UserModel
.
query
.
filter
(
*
filters
)
.
first
()
if
result
:
return
(
True
,
result
)
return
(
False
,
result
)
def
getList
(
self
,
params
):
# handle business
logger
.
warn
(
params
)
filters
=
[
UserModel
.
is_delete
==
False
]
result
=
UserModel
.
query
.
filter
(
*
filters
)
.
order_by
(
UserModel
.
create_at
)
.
paginate
(
params
.
get
(
'page'
,
1
),
params
.
get
(
'pageSize'
,
10
),
error_out
=
False
)
return
(
True
,
result
.
items
,
result
.
total
)
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
result
=
UserModel
.
query
.
filter
(
UserModel
.
app_name
==
params
.
get
(
'app_name'
))
.
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
,
None
)
elif
result
and
result
.
is_delete
==
False
:
return
(
False
,
"record code exists"
)
result
=
UserModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
(
True
,
None
)
def
put
(
self
,
uuid
,
params
,
jwt
=
{}):
# handle business
result
=
UserModel
.
query
.
filter
(
UserModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
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
,
None
)
else
:
return
(
False
,
"params is null"
)
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
UserModel
.
query
.
filter
(
UserModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
result
.
is_delete
=
True
db
.
session
.
delete
(
result
)
db
.
session
.
commit
()
return
(
True
,
None
)
userManager
=
UserResource
()
\ No newline at end of file
tools/build_out/controllers/user.py
View file @
3922979c
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
datetime
import
datetime
from
application.app
import
db
from
models.user
import
UserModel
from
webcreator.log
import
logger
# from webcreator.response import ResponseCode, response_result
from
webcreator.response
import
ResponseCode
class
UserResource
(
object
):
def
__init__
(
self
):
...
...
@@ -13,8 +16,8 @@ class UserResource(object):
filters
=
[
UserModel
.
is_delete
==
False
,
UserModel
.
uuid
==
uuid
]
result
=
UserModel
.
query
.
filter
(
*
filters
)
.
first
()
if
result
:
return
(
True
,
result
)
return
(
False
,
result
)
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
getList
(
self
,
params
):
# handle business
...
...
@@ -22,30 +25,37 @@ class UserResource(object):
filters
=
[
UserModel
.
is_delete
==
False
]
result
=
UserModel
.
query
.
filter
(
*
filters
)
.
order_by
(
UserModel
.
create_at
)
.
paginate
(
params
.
get
(
'page'
,
1
),
params
.
get
(
'pageSize'
,
10
),
error_out
=
False
)
return
(
True
,
result
.
items
,
result
.
total
)
if
result
:
return
result
,
ResponseCode
.
HTTP_SUCCESS
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
def
post
(
self
,
params
,
jwt
=
{}):
# handle business
result
=
UserModel
.
query
.
filter
(
UserModel
.
a
pp_name
==
params
.
get
(
'app_name
'
))
.
first
()
result
=
UserModel
.
query
.
filter
(
UserModel
.
a
ccount
==
params
.
get
(
'account
'
))
.
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
,
None
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
elif
result
and
result
.
is_delete
==
False
:
return
(
False
,
"record code exists"
)
return
False
,
ResponseCode
.
USER_EXISTS
# 密码使用md5加密,可以使用元编程模式劫持,不用手动一个个修改了
# params.update({ "password": utils.md5_encryption(params.get("password")) })
result
=
UserModel
(
**
params
)
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
return
(
True
,
None
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
put
(
self
,
uuid
,
params
,
jwt
=
{}):
logger
.
info
(
uuid
)
logger
.
info
(
params
)
# handle business
result
=
UserModel
.
query
.
filter
(
UserModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
if
params
:
for
key
,
value
in
params
.
items
():
...
...
@@ -53,21 +63,21 @@ class UserResource(object):
result
.
update_by
=
jwt
.
get
(
"id"
,
""
)
result
.
update_date
=
datetime
.
now
()
db
.
session
.
commit
()
return
(
True
,
None
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
else
:
return
(
False
,
"params is null"
)
return
False
,
ResponseCode
.
HTTP_INVAILD_REQUEST
def
delete
(
self
,
uuid
,
jwt
=
{}):
# handle business
result
=
UserModel
.
query
.
filter
(
UserModel
.
uuid
==
uuid
)
.
first
()
if
not
result
:
return
(
False
,
"record not exists"
)
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
,
None
)
return
True
,
ResponseCode
.
HTTP_SUCCESS
userManager
=
UserResource
()
\ No newline at end of file
userManager
=
UserResource
()
tools/build_out/logs/running.log
deleted
100644 → 0
View file @
d109566c
[2021-06-30 18:15:33,651][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Restarting with stat
[2021-06-30 18:15:34,787][WARNING][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger is active!
[2021-06-30 18:15:34,815][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger PIN: 182-666-074
[2021-06-30 18:15:34,946][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
[2021-06-30 18:20:06,694][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Restarting with stat
[2021-06-30 18:20:07,791][WARNING][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger is active!
[2021-06-30 18:20:07,815][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger PIN: 182-666-074
[2021-06-30 18:20:12,000][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
[2021-06-30 18:21:29,461][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Detected change in 'D:\\projects\\scriptiot\\evm-store\\tools\\resources\\application\\app.py', reloading
[2021-06-30 18:21:29,559][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Restarting with stat
[2021-06-30 18:21:30,703][WARNING][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger is active!
[2021-06-30 18:21:30,726][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger PIN: 182-666-074
[2021-06-30 18:21:33,774][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
[2021-06-30 18:23:13,828][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Detected change in 'D:\\projects\\scriptiot\\evm-store\\tools\\build_out\\application\\__init__.py', reloading
[2021-06-30 18:23:13,950][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Restarting with stat
[2021-06-30 18:23:15,324][WARNING][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger is active!
[2021-06-30 18:23:15,351][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger PIN: 182-666-074
[2021-06-30 18:23:18,915][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
[2021-06-30 18:25:15,324][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Detected change in 'D:\\projects\\scriptiot\\evm-store\\tools\\build_out\\controllers\\area.py', reloading
[2021-06-30 18:25:15,428][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Restarting with stat
[2021-06-30 18:25:16,742][WARNING][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger is active!
[2021-06-30 18:25:16,764][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger PIN: 182-666-074
[2021-06-30 18:25:20,154][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
[2021-07-14 17:51:16,692][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Restarting with stat
[2021-07-14 17:51:17,865][WARNING][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger is active!
[2021-07-14 17:51:17,886][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger PIN: 589-639-847
[2021-07-14 17:51:23,161][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
[2021-07-14 18:00:55,339][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Detected change in 'D:\\projects\\scriptiot\\evm-store\\tools\\build_out\\webcreator\\response.py', reloading
[2021-07-14 18:00:55,461][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Restarting with stat
[2021-07-14 18:00:56,719][WARNING][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger is active!
[2021-07-14 18:00:56,738][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger PIN: 589-639-847
[2021-07-14 18:01:00,332][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
[2021-07-14 18:01:24,867][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Detected change in 'D:\\projects\\scriptiot\\evm-store\\tools\\resources\\webcreator\\response.py', reloading
[2021-07-14 18:01:24,981][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Restarting with stat
[2021-07-14 18:01:26,393][WARNING][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger is active!
[2021-07-14 18:01:26,413][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger PIN: 589-639-847
[2021-07-14 18:01:30,183][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
[2021-07-14 18:02:54,384][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Detected change in 'D:\\projects\\scriptiot\\evm-store\\tools\\build_out\\application\\config.py', reloading
[2021-07-14 18:02:54,483][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Restarting with stat
[2021-07-14 18:02:55,771][WARNING][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger is active!
[2021-07-14 18:02:55,793][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger PIN: 589-639-847
[2021-07-14 18:02:59,702][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
[2021-07-14 18:03:16,082][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Detected change in 'D:\\projects\\scriptiot\\evm-store\\tools\\build_out\\application\\signal_manager.py', reloading
[2021-07-14 18:03:16,184][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Restarting with stat
[2021-07-14 18:03:17,430][WARNING][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger is active!
[2021-07-14 18:03:17,449][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger PIN: 589-639-847
[2021-07-14 18:03:21,152][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
[2021-07-14 18:03:33,842][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Detected change in 'D:\\projects\\scriptiot\\evm-store\\tools\\build_out\\application\\app.py', reloading
[2021-07-14 18:03:33,948][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Restarting with stat
[2021-07-14 18:03:35,301][WARNING][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger is active!
[2021-07-14 18:03:35,321][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger PIN: 589-639-847
[2021-07-14 18:03:39,079][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
[2021-07-14 18:04:42,078][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Detected change in 'D:\\projects\\scriptiot\\evm-store\\tools\\gen_code.py', reloading
[2021-07-14 18:04:42,178][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Restarting with stat
[2021-07-14 18:04:43,390][WARNING][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger is active!
[2021-07-14 18:04:43,411][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Debugger PIN: 589-639-847
[2021-07-14 18:04:47,567][ INFO][in D:\projects\scriptiot\evm-store\tools\venv\lib\site-packages\werkzeug\_internal.py -> _log line:225] * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
tools/build_out/models/annex.py
View file @
3922979c
'''
Author: your name
Date: 2021-07-1
1 01:47
:14
LastEditTime: 2021-07-1
2 01:56:38
Date: 2021-07-1
4 18:14
:14
LastEditTime: 2021-07-1
4 18:35:57
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 -*-
# -*- coding: utf-8 -*-
from
application.app
import
db
,
ma
from
.base
import
PrimaryModel
...
...
@@ -19,26 +18,26 @@ class AnnexModel(PrimaryModel):
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
)
size
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
)
# __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
):
def
__init__
(
self
,
app
,
title
,
path
,
size
,
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
.
create_at
=
create_at
self
.
update_at
=
update_at
def
__repr__
(
self
):
return
'<AnnexModel
%
r>'
%
(
self
.
app
)
def
to_
dict
(
self
):
def
to_
json
(
self
):
return
{
'app'
:
self
.
app
,
'title'
:
self
.
title
,
...
...
tools/build_out/models/app.py
View file @
3922979c
...
...
@@ -13,17 +13,17 @@ class AppModel(PrimaryModel):
category
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
category_2th
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
developer
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
download_url
=
db
.
Column
(
db
.
String
(
20
),
nullable
=
False
)
download_url
=
db
.
Column
(
db
.
String
(
20
),
nullable
=
False
,
default
=
''
)
app_file_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
app_screen_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
app_arch
=
db
.
Column
(
db
.
String
(
20
),
nullable
=
False
)
app_review
=
db
.
Column
(
db
.
String
(
100
),
nullable
=
False
)
app_arch
=
db
.
Column
(
db
.
String
(
20
),
nullable
=
False
,
default
=
''
)
app_review
=
db
.
Column
(
db
.
String
(
100
),
nullable
=
False
,
default
=
''
)
# __table_args__ = (
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# )
def
__init__
(
self
,
app_name
,
app_icon
,
app_version
,
category
,
category_2th
,
developer
,
download_url
,
app_file_size
,
app_screen_size
,
app_arch
,
app_review
):
def
__init__
(
self
,
app_name
,
app_icon
,
app_version
,
category
=
0
,
category_2th
=
0
,
developer
=
0
,
download_url
=
''
,
app_file_size
=
0
,
app_screen_size
=
0
,
app_arch
=
''
,
app_review
=
''
):
self
.
app_name
=
app_name
self
.
app_icon
=
app_icon
self
.
app_version
=
app_version
...
...
tools/build_out/models/area.py
View file @
3922979c
...
...
@@ -31,7 +31,7 @@ class AreaModel(PrimaryModel):
def
__repr__
(
self
):
return
'<AreaModel
%
r>'
%
(
self
.
areaCode
)
def
to_
json
(
self
):
def
to_
dict
(
self
):
return
{
'areaCode'
:
self
.
areaCode
,
'areaName'
:
self
.
areaName
,
...
...
tools/build_out/models/device.py
View file @
3922979c
#!/usr/bin/env python
# -*- coding: utf_8 -*-
# -*- coding: utf-8 -*-
from
application.app
import
db
,
ma
from
.base
import
PrimaryModel
...
...
@@ -17,7 +16,7 @@ class DeviceModel(PrimaryModel):
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# )
def
__init__
(
self
,
imei
,
name
=
''
,
type
=
''
,
desc
=
''
):
def
__init__
(
self
,
imei
,
name
,
type
,
desc
):
self
.
imei
=
imei
self
.
name
=
name
self
.
type
=
type
...
...
@@ -26,7 +25,7 @@ class DeviceModel(PrimaryModel):
def
__repr__
(
self
):
return
'<DeviceModel
%
r>'
%
(
self
.
imei
)
def
to_
dict
(
self
):
def
to_
json
(
self
):
return
{
'imei'
:
self
.
imei
,
'name'
:
self
.
name
,
...
...
tools/build_out/models/login.py
View file @
3922979c
# -*- coding: utf-8 -*-
#!/usr/bin/env python
# -*- coding: utf_8 -*-
import
json
from
application.app
import
db
,
ma
from
.base
import
PrimaryModel
from
.base
import
PrimaryModel
from
marshmallow
import
Schema
,
fields
,
INCLUDE
,
EXCLUDE
from
webcreator.log
import
logger
class
LoginModel
(
PrimaryModel
):
__tablename__
=
'evm_login'
...
...
@@ -26,10 +29,19 @@ class LoginModel(PrimaryModel):
self
.
geo_location
=
geo_location
self
.
operator
=
operator
# def __getattr__(self, key):
# return self.__dict__[key]
# def __getitem__(self, key):
# return self.get(key)
# def __getattribute__(self, value):
# return value
def
__repr__
(
self
):
return
'<LoginModel
%
r>'
%
(
self
.
user
)
def
to_
json
(
self
):
def
to_
dict
(
self
):
return
{
'login_at'
:
self
.
login_at
,
'user_agent'
:
self
.
user_agent
,
...
...
@@ -58,12 +70,12 @@ class GetListLoginSchema(ma.SQLAlchemySchema):
page
=
fields
.
Integer
(
required
=
False
)
pageSize
=
fields
.
Integer
(
required
=
False
)
user
=
ma
.
auto_field
(
)
login_at
=
ma
.
auto_field
(
)
user_agent
=
ma
.
auto_field
(
)
ip
=
ma
.
auto_field
(
)
geo_location
=
ma
.
auto_field
(
)
operator
=
ma
.
auto_field
(
)
user
=
fields
.
Integer
(
required
=
False
)
login_at
=
fields
.
String
(
required
=
False
)
user_agent
=
fields
.
String
(
required
=
False
)
ip
=
fields
.
String
(
required
=
False
)
geo_location
=
fields
.
String
(
required
=
False
)
operator
=
fields
.
String
(
required
=
False
)
getListLoginSchema
=
GetListLoginSchema
()
getListLoginsSchema
=
GetListLoginSchema
(
many
=
True
)
...
...
@@ -74,11 +86,11 @@ class GetLoginSchema(ma.SQLAlchemySchema):
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
LoginModel
user
=
ma
.
auto_field
(
)
login_at
=
ma
.
auto_field
(
)
user_agent
=
ma
.
auto_field
(
)
ip
=
ma
.
auto_field
(
)
geo_location
=
ma
.
auto_field
(
)
operator
=
ma
.
auto_field
(
)
user
=
fields
.
Integer
(
required
=
False
)
login_at
=
fields
.
String
(
required
=
False
)
user_agent
=
fields
.
String
(
required
=
False
)
ip
=
fields
.
String
(
required
=
False
)
geo_location
=
fields
.
String
(
required
=
False
)
operator
=
fields
.
String
(
required
=
False
)
getLoginSchema
=
GetLoginSchema
()
tools/build_out/models/monitorEvm.py
View file @
3922979c
#!/usr/bin/env python
# -*- coding: utf_8 -*-
# -*- 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
_e
vm'
__tablename__
=
'evm_monitor
E
vm'
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
)
heap_map_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
)
heap_total_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
heap_used_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
)
stack_total_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
)
stack_used_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
# __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
):
def
__init__
(
self
,
watch
,
heap_map_size
,
heap_total_size
,
heap_used_size
,
stack_total_size
,
stack_used_size
):
self
.
watch
=
watch
self
.
heap_map_size
=
heap_map_size
self
.
heap_total_size
=
heap_total_size
...
...
@@ -30,7 +29,7 @@ class MonitorEvmModel(PrimaryModel):
def
__repr__
(
self
):
return
'<MonitorEvmModel
%
r>'
%
(
self
.
watch
)
def
to_
dict
(
self
):
def
to_
json
(
self
):
return
{
'watch'
:
self
.
watch
,
'heap_map_size'
:
self
.
heap_map_size
,
...
...
tools/build_out/models/monitorImage.py
View file @
3922979c
#!/usr/bin/env python
# -*- coding: utf_8 -*-
# -*- 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
_i
mage'
__tablename__
=
'evm_monitor
I
mage'
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
)
length
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
)
png_uncompressed_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
png_total_count
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
)
png_file_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
)
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
=
''
):
def
__init__
(
self
,
watch
,
length
,
png_uncompressed_size
,
png_total_count
,
png_file_size
,
uri
):
self
.
watch
=
watch
self
.
length
=
length
self
.
png_uncompressed_size
=
png_uncompressed_size
...
...
@@ -30,7 +29,7 @@ class MonitorImageModel(PrimaryModel):
def
__repr__
(
self
):
return
'<MonitorImageModel
%
r>'
%
(
self
.
watch
)
def
to_
dict
(
self
):
def
to_
json
(
self
):
return
{
'watch'
:
self
.
watch
,
'length'
:
self
.
length
,
...
...
tools/build_out/models/monitorLvgl.py
View file @
3922979c
#!/usr/bin/env python
# -*- coding: utf_8 -*-
# -*- 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
_l
vgl'
__tablename__
=
'evm_monitor
L
vgl'
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
)
total_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
)
free_cnt
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
free_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
)
free_biggest_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
used_cnt
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
used_pct
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
frag_pct
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
# __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
):
def
__init__
(
self
,
watch
,
total_size
,
free_cnt
,
free_size
,
free_biggest_size
,
used_cnt
,
used_pct
,
frag_pct
):
self
.
watch
=
watch
self
.
total_size
=
total_size
self
.
free_cnt
=
free_cnt
...
...
@@ -34,7 +33,7 @@ class MonitorLvglModel(PrimaryModel):
def
__repr__
(
self
):
return
'<MonitorLvglModel
%
r>'
%
(
self
.
watch
)
def
to_
dict
(
self
):
def
to_
json
(
self
):
return
{
'watch'
:
self
.
watch
,
'total_size'
:
self
.
total_size
,
...
...
tools/build_out/models/monitorSystem.py
View file @
3922979c
#!/usr/bin/env python
# -*- coding: utf_8 -*-
# -*- 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
_s
ystem'
__tablename__
=
'evm_monitor
S
ystem'
watch
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
free_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
,
default
=
0
)
free_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
True
)
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
=
''
)
...
...
@@ -18,7 +17,7 @@ class MonitorSystemModel(PrimaryModel):
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# )
def
__init__
(
self
,
watch
,
free_size
=
0
,
host
=
''
,
path
=
''
,
protocol
=
''
):
def
__init__
(
self
,
watch
,
free_size
,
host
,
path
,
protocol
):
self
.
watch
=
watch
self
.
free_size
=
free_size
self
.
host
=
host
...
...
@@ -28,7 +27,7 @@ class MonitorSystemModel(PrimaryModel):
def
__repr__
(
self
):
return
'<MonitorSystemModel
%
r>'
%
(
self
.
watch
)
def
to_
dict
(
self
):
def
to_
json
(
self
):
return
{
'watch'
:
self
.
watch
,
'free_size'
:
self
.
free_size
,
...
...
tools/build_out/models/monitorWatch.py
View file @
3922979c
#!/usr/bin/env python
# -*- coding: utf_8 -*-
# -*- 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
_w
atch'
__tablename__
=
'evm_monitor
W
atch'
imei
=
db
.
Column
(
db
.
String
(
20
),
index
=
True
,
nullable
=
False
,
default
=
''
)
...
...
@@ -14,13 +13,13 @@ class MonitorWatchModel(PrimaryModel):
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# )
def
__init__
(
self
,
imei
=
''
):
def
__init__
(
self
,
imei
):
self
.
imei
=
imei
def
__repr__
(
self
):
return
'<MonitorWatchModel
%
r>'
%
(
self
.
imei
)
def
to_
dict
(
self
):
def
to_
json
(
self
):
return
{
'imei'
:
self
.
imei
,
}
...
...
tools/build_out/models/package.20210714181414.py
0 → 100644
View file @
3922979c
'''
Author: your name
Date: 2021-06-30 18:03:41
LastEditTime: 2021-07-12 01:59:31
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\
models
\
package.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
PackageModel
(
PrimaryModel
):
__tablename__
=
'evm_package'
app
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
app_version
=
db
.
Column
(
db
.
String
(
200
),
nullable
=
False
)
package_info
=
db
.
Column
(
db
.
String
(
20
),
nullable
=
False
)
file_path
=
db
.
Column
(
db
.
String
(
200
),
nullable
=
False
)
source
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
user_agent
=
db
.
Column
(
db
.
String
(
200
),
nullable
=
False
)
download_url
=
db
.
Column
(
db
.
String
(
200
),
nullable
=
False
)
ip
=
db
.
Column
(
db
.
String
(
128
),
nullable
=
False
)
geo_location
=
db
.
Column
(
db
.
String
(
200
),
nullable
=
False
)
operator
=
db
.
Column
(
db
.
String
(
50
),
nullable
=
False
)
# __table_args__ = (
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# )
def
__init__
(
self
,
app
,
app_version
,
package_info
,
file_path
,
source
=
""
,
user_agent
=
""
,
download_url
=
""
,
ip
=
""
,
geo_location
=
""
,
operator
=
""
,
create_by
=
None
,
create_at
=
None
,
update_by
=
None
,
update_at
=
None
):
self
.
app
=
app
self
.
app_version
=
app_version
self
.
package_info
=
package_info
self
.
file_path
=
file_path
self
.
source
=
source
self
.
user_agent
=
user_agent
self
.
download_url
=
download_url
self
.
ip
=
ip
self
.
geo_location
=
geo_location
self
.
operator
=
operator
self
.
create_by
=
create_by
self
.
create_at
=
create_at
self
.
update_by
=
update_by
self
.
update_at
=
update_at
def
__repr__
(
self
):
return
'<PackageModel
%
r>'
%
(
self
.
app
)
def
to_dict
(
self
):
return
{
'app_version'
:
self
.
app_version
,
'package_info'
:
self
.
package_info
,
'file_path'
:
self
.
file_path
,
'source'
:
self
.
source
,
'user_agent'
:
self
.
user_agent
,
'download_url'
:
self
.
download_url
,
'ip'
:
self
.
ip
,
'geo_location'
:
self
.
geo_location
,
'operator'
:
self
.
operator
,
}
class
GetListPackageSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
PackageModel
page
=
fields
.
Integer
(
required
=
False
)
pageSize
=
fields
.
Integer
(
required
=
False
)
app
=
ma
.
auto_field
()
app_version
=
ma
.
auto_field
()
package_info
=
ma
.
auto_field
()
file_path
=
ma
.
auto_field
()
source
=
ma
.
auto_field
()
user_agent
=
ma
.
auto_field
()
download_url
=
ma
.
auto_field
()
ip
=
ma
.
auto_field
()
geo_location
=
ma
.
auto_field
()
operator
=
ma
.
auto_field
()
getListPackageSchema
=
GetListPackageSchema
()
getListPackagesSchema
=
GetListPackageSchema
(
many
=
True
)
class
GetPackageSchema
(
ma
.
SQLAlchemySchema
):
class
Meta
:
# unknown = INCLUDE # 未知字段默认包含
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
PackageModel
app
=
ma
.
auto_field
()
app_version
=
ma
.
auto_field
()
package_info
=
ma
.
auto_field
()
file_path
=
ma
.
auto_field
()
source
=
ma
.
auto_field
()
user_agent
=
ma
.
auto_field
()
download_url
=
ma
.
auto_field
()
ip
=
ma
.
auto_field
()
geo_location
=
ma
.
auto_field
()
operator
=
ma
.
auto_field
()
getPackageSchema
=
GetPackageSchema
()
tools/build_out/models/package.py
View file @
3922979c
'''
Author: your name
Date: 2021-06-30 18:03:41
LastEditTime: 2021-07-14 18:35:01
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\
models
\
package.py
'''
# -*- coding: utf-8 -*-
from
application.app
import
db
,
ma
...
...
@@ -22,7 +30,7 @@ class PackageModel(PrimaryModel):
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# )
def
__init__
(
self
,
app
,
app_version
,
package_info
,
file_path
,
source
,
user_agent
,
download_url
,
ip
,
geo_location
,
operator
):
def
__init__
(
self
,
app
,
app_version
,
package_info
,
file_path
,
source
=
0
,
user_agent
=
''
,
download_url
=
''
,
ip
=
'127.0.0.1'
,
geo_location
=
''
,
operator
=
''
,
create_by
=
None
,
create_at
=
None
,
update_by
=
None
,
update_at
=
None
):
self
.
app
=
app
self
.
app_version
=
app_version
self
.
package_info
=
package_info
...
...
@@ -33,6 +41,10 @@ class PackageModel(PrimaryModel):
self
.
ip
=
ip
self
.
geo_location
=
geo_location
self
.
operator
=
operator
self
.
create_by
=
create_by
self
.
update_by
=
update_by
self
.
create_at
=
create_at
self
.
update_at
=
update_at
def
__repr__
(
self
):
return
'<PackageModel
%
r>'
%
(
self
.
app
)
...
...
tools/build_out/models/user.py
View file @
3922979c
# -*- coding: utf-8 -*-
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
application.app
import
db
,
ma
from
.base
import
PrimaryModel
from
.base
import
PrimaryModel
from
marshmallow
import
Schema
,
fields
,
INCLUDE
,
EXCLUDE
from
webcreator
import
utils
from
webcreator.log
import
logger
class
UserModel
(
PrimaryModel
):
__tablename__
=
'evm_user'
app_name
=
db
.
Column
(
db
.
String
(
70
),
index
=
True
,
nullable
=
False
)
app_icon
=
db
.
Column
(
db
.
String
(
200
),
nullable
=
False
)
app_version
=
db
.
Column
(
db
.
String
(
20
),
nullable
=
False
)
category
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
category_2th
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
developer
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
download_url
=
db
.
Column
(
db
.
String
(
20
),
nullable
=
False
)
app_file_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
app_screen_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
app_arch
=
db
.
Column
(
db
.
String
(
20
),
nullable
=
False
)
app_review
=
db
.
Column
(
db
.
String
(
100
),
nullable
=
False
)
username
=
db
.
Column
(
db
.
String
(
70
),
index
=
True
,
nullable
=
False
)
account
=
db
.
Column
(
db
.
String
(
200
),
nullable
=
False
)
password
=
db
.
Column
(
db
.
String
(
20
),
nullable
=
False
)
role
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
,
default
=
0
)
email
=
db
.
Column
(
db
.
String
,
nullable
=
False
,
default
=
''
)
phone
=
db
.
Column
(
db
.
String
,
nullable
=
False
,
default
=
''
)
# __table_args__ = (
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# )
def
__init__
(
self
,
app_name
,
app_icon
,
app_version
,
category
,
category_2th
,
developer
,
download_url
,
app_file_size
,
app_screen_size
,
app_arch
,
app_review
):
self
.
app_name
=
app_name
self
.
app_icon
=
app_icon
self
.
app_version
=
app_version
self
.
category
=
category
self
.
category_2th
=
category_2th
self
.
developer
=
developer
self
.
download_url
=
download_url
self
.
app_file_size
=
app_file_size
self
.
app_screen_size
=
app_screen_size
self
.
app_arch
=
app_arch
self
.
app_review
=
app_review
def
__init__
(
self
,
username
,
account
,
password
,
role
=
0
,
email
=
''
,
phone
=
''
):
self
.
username
=
username
self
.
account
=
account
self
.
password
=
password
self
.
role
=
role
self
.
email
=
email
self
.
phone
=
phone
def
__setattr__
(
self
,
key
,
value
):
# logger.info(f"execute __setattr__:key={key}, value={value}")
if
key
==
'password'
:
self
.
__dict__
[
key
]
=
utils
.
md5_encryption
(
value
)
else
:
self
.
__dict__
[
key
]
=
value
def
__repr__
(
self
):
return
'<UserModel
%
r>'
%
(
self
.
app_
name
)
return
'<UserModel
%
r>'
%
(
self
.
user
name
)
def
to_
json
(
self
):
def
to_
dict
(
self
):
return
{
'app_name'
:
self
.
app_name
,
'app_icon'
:
self
.
app_icon
,
'app_version'
:
self
.
app_version
,
'category'
:
self
.
category
,
'category_2th'
:
self
.
category_2th
,
'developer'
:
self
.
developer
,
'download_url'
:
self
.
download_url
,
'app_file_size'
:
self
.
app_file_size
,
'app_screen_size'
:
self
.
app_screen_size
,
'app_arch'
:
self
.
app_arch
,
'app_review'
:
self
.
app_review
,
'username'
:
self
.
username
,
'account'
:
self
.
account
,
'password'
:
self
.
password
,
'role'
:
self
.
role
,
'email'
:
self
.
email
,
'phone'
:
self
.
phone
,
}
...
...
@@ -61,15 +56,9 @@ class PostUserSchema(ma.SQLAlchemySchema):
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
UserModel
app_name
=
ma
.
auto_field
()
app_icon
=
ma
.
auto_field
()
app_version
=
ma
.
auto_field
()
category
=
ma
.
auto_field
()
category_2th
=
ma
.
auto_field
()
developer
=
ma
.
auto_field
()
app_screen_size
=
ma
.
auto_field
()
app_arch
=
ma
.
auto_field
()
app_review
=
ma
.
auto_field
()
username
=
ma
.
auto_field
()
account
=
ma
.
auto_field
()
password
=
ma
.
auto_field
()
postUserSchema
=
PostUserSchema
()
...
...
@@ -88,13 +77,9 @@ class GetListUserSchema(ma.SQLAlchemySchema):
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
UserModel
page
=
fields
.
Integer
(
required
=
False
)
pageSize
=
fields
.
Integer
(
required
=
False
)
app_name
=
ma
.
auto_field
()
app_version
=
ma
.
auto_field
()
category
=
ma
.
auto_field
()
category_2th
=
ma
.
auto_field
()
app_arch
=
ma
.
auto_field
()
uuid
=
ma
.
auto_field
()
username
=
ma
.
auto_field
()
account
=
ma
.
auto_field
()
getListUserSchema
=
GetListUserSchema
()
getListUsersSchema
=
GetListUserSchema
(
many
=
True
)
...
...
@@ -105,11 +90,8 @@ class GetUserSchema(ma.SQLAlchemySchema):
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
UserModel
app_name
=
ma
.
auto_field
()
app_version
=
ma
.
auto_field
()
category
=
ma
.
auto_field
()
category_2th
=
ma
.
auto_field
()
app_arch
=
ma
.
auto_field
()
username
=
ma
.
auto_field
()
account
=
ma
.
auto_field
()
getUserSchema
=
GetUserSchema
()
...
...
@@ -119,13 +101,8 @@ class PutUserSchema(ma.SQLAlchemySchema):
unknown
=
EXCLUDE
# 未知字段默认排除
model
=
UserModel
app_name
=
ma
.
auto_field
()
app_icon
=
ma
.
auto_field
()
app_version
=
ma
.
auto_field
()
app_screen_size
=
ma
.
auto_field
()
app_arch
=
ma
.
auto_field
()
app_review
=
ma
.
auto_field
()
category
=
ma
.
auto_field
()
category_2th
=
ma
.
auto_field
()
account
=
fields
.
String
(
required
=
False
,
allow_none
=
True
)
username
=
fields
.
String
(
required
=
False
,
allow_none
=
True
)
password
=
fields
.
String
(
required
=
False
,
allow_none
=
True
)
putUserSchema
=
PutUserSchema
()
tools/build_out/result.json
deleted
100644 → 0
View file @
d109566c
{
"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/__init__.20210709130326.py
deleted
100644 → 0
View file @
d109566c
# -*- coding: utf-8 -*-
tools/build_out/views/__init__.20210714181414.py
0 → 100644
View file @
3922979c
#!/usr/bin/env python
# -*- coding: utf_8 -*-
from
flask
import
Blueprint
from
flask_restful
import
Api
from
.
import
area
from
.
import
app
from
.
import
package
from
.
import
user
from
.
import
login
from
.
import
device
from
.
import
annex
from
.
import
file
from
.
import
monitorWatch
from
.
import
monitorSystem
from
.
import
monitorLvgl
from
.
import
monitorImage
from
.
import
monitorEvm
api_v1
=
Blueprint
(
'api_v1'
,
__name__
)
api
=
Api
(
api_v1
)
api
.
add_resource
(
area
.
AreaResource
,
'/area/<string:uuid>'
)
api
.
add_resource
(
area
.
AreaResourceList
,
'/area'
)
api
.
add_resource
(
app
.
AppResource
,
'/app/<string:uuid>'
)
api
.
add_resource
(
app
.
AppResourceList
,
'/app'
)
api
.
add_resource
(
package
.
PackageResource
,
'/package/<string:uuid>'
)
api
.
add_resource
(
package
.
PackageResourceList
,
'/package'
)
api
.
add_resource
(
user
.
UserResource
,
'/user/<string:uuid>'
)
api
.
add_resource
(
user
.
UserResourceList
,
'/user'
)
api
.
add_resource
(
login
.
LoginResource
,
'/login/<string:uuid>'
)
api
.
add_resource
(
login
.
LoginResourceList
,
'/login'
)
api
.
add_resource
(
device
.
DeviceResource
,
'/device/<string:uuid>'
)
api
.
add_resource
(
device
.
DeviceResourceList
,
'/device'
)
api
.
add_resource
(
annex
.
AnnexResource
,
'/annex/<string:uuid>'
)
api
.
add_resource
(
annex
.
AnnexResourceList
,
'/annex'
)
api
.
add_resource
(
file
.
FileInit
,
"/file-manager/initialize"
)
api
.
add_resource
(
file
.
FileContent
,
"/file-manager/content"
)
api
.
add_resource
(
file
.
FileDisk
,
"/file-manager/disk"
)
api
.
add_resource
(
file
.
FileTree
,
"/file-manager/tree"
)
api
.
add_resource
(
file
.
FileDownload
,
"/file-manager/download"
)
api
.
add_resource
(
file
.
FilePrview
,
"/file-manager/preview"
)
api
.
add_resource
(
monitorWatch
.
MonitorWatchResource
,
'/monitorWatch/<string:uuid>'
)
api
.
add_resource
(
monitorWatch
.
MonitorWatchResourceList
,
'/monitorWatch'
)
api
.
add_resource
(
monitorSystem
.
MonitorSystemResource
,
'/monitorSystem/<string:uuid>'
)
api
.
add_resource
(
monitorSystem
.
MonitorSystemResourceList
,
'/monitorSystem'
)
api
.
add_resource
(
monitorLvgl
.
MonitorLvglResource
,
'/monitorLvgl/<string:uuid>'
)
api
.
add_resource
(
monitorLvgl
.
MonitorLvglResourceList
,
'/monitorLvgl'
)
api
.
add_resource
(
monitorImage
.
MonitorImageResource
,
'/monitorImage/<string:uuid>'
)
api
.
add_resource
(
monitorImage
.
MonitorImageResourceList
,
'/monitorImage'
)
api
.
add_resource
(
monitorEvm
.
MonitorEvmResource
,
'/monitorEvm/<string:uuid>'
)
api
.
add_resource
(
monitorEvm
.
MonitorEvmResourceList
,
'/monitorEvm'
)
tools/build_out/views/__init__.py
View file @
3922979c
...
...
@@ -7,6 +7,13 @@ from . import app
from
.
import
package
from
.
import
user
from
.
import
login
from
.
import
device
from
.
import
annex
from
.
import
monitorWatch
from
.
import
monitorSystem
from
.
import
monitorLvgl
from
.
import
monitorImage
from
.
import
monitorEvm
api_v1
=
Blueprint
(
'api_v1'
,
__name__
)
...
...
@@ -27,3 +34,24 @@ api.add_resource(user.UserResourceList, '/user')
api
.
add_resource
(
login
.
LoginResource
,
'/login/<string:uuid>'
)
api
.
add_resource
(
login
.
LoginResourceList
,
'/login'
)
api
.
add_resource
(
device
.
DeviceResource
,
'/device/<string:uuid>'
)
api
.
add_resource
(
device
.
DeviceResourceList
,
'/device'
)
api
.
add_resource
(
annex
.
AnnexResource
,
'/annex/<string:uuid>'
)
api
.
add_resource
(
annex
.
AnnexResourceList
,
'/annex'
)
api
.
add_resource
(
monitorWatch
.
MonitorWatchResource
,
'/monitorWatch/<string:uuid>'
)
api
.
add_resource
(
monitorWatch
.
MonitorWatchResourceList
,
'/monitorWatch'
)
api
.
add_resource
(
monitorSystem
.
MonitorSystemResource
,
'/monitorSystem/<string:uuid>'
)
api
.
add_resource
(
monitorSystem
.
MonitorSystemResourceList
,
'/monitorSystem'
)
api
.
add_resource
(
monitorLvgl
.
MonitorLvglResource
,
'/monitorLvgl/<string:uuid>'
)
api
.
add_resource
(
monitorLvgl
.
MonitorLvglResourceList
,
'/monitorLvgl'
)
api
.
add_resource
(
monitorImage
.
MonitorImageResource
,
'/monitorImage/<string:uuid>'
)
api
.
add_resource
(
monitorImage
.
MonitorImageResourceList
,
'/monitorImage'
)
api
.
add_resource
(
monitorEvm
.
MonitorEvmResource
,
'/monitorEvm/<string:uuid>'
)
api
.
add_resource
(
monitorEvm
.
MonitorEvmResourceList
,
'/monitorEvm'
)
tools/build_out/views/annex.py
View file @
3922979c
#!/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
...
...
@@ -26,16 +23,16 @@ class AnnexResourceList(Resource):
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getListAnnexSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetListAnnex
.
emit
(
data
)
result
=
signalManager
.
actionGetListAnnex
.
emit
(
data
)
json_dumps
=
getListAnnexSchema
.
dump
(
result
)
if
result
:
json_dumps
=
getListAnnexsSchema
.
dump
(
result
.
items
)
if
result
[
0
]
:
json_dumps
=
getListAnnexsSchema
.
dump
(
result
[
1
]
)
logger
.
warn
(
json_dumps
)
return
response_result
(
message
,
data
=
json_dumps
,
count
=
result
.
total
)
return
response_result
(
message
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
,
count
=
result
[
2
]
)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
class
AnnexResource
(
Resource
):
def
__init__
(
self
):
...
...
@@ -54,14 +51,14 @@ class AnnexResource(Resource):
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
)
result
=
signalManager
.
actionGetAnnex
.
emit
(
uuid
,
data
)
if
result
[
0
]
:
json_dumps
=
getAnnexSchema
.
dump
(
result
[
1
]
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
)
return
response_result
(
ResponseCode
.
NO_DATA
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
@
jwt_required
(
locations
=
[
"headers"
])
...
...
@@ -70,8 +67,10 @@ class AnnexResource(Resource):
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
)
result
=
signalManager
.
actionDeleteAnnex
.
emit
(
uuid
)
if
result
[
0
]
==
True
:
return
response_result
(
ResponseCode
.
OK
)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
,
msg
=
result
[
1
])
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
tools/build_out/views/app.20210714181414.py
0 → 100644
View file @
3922979c
#!/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.app
import
postAppSchema
,
deleteAppSchema
,
getListAppSchema
,
getListAppsSchema
,
getAppSchema
,
putAppSchema
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
AppResourceList
(
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
=
getListAppSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetListApp
.
emit
(
data
)
json_dumps
=
getListAppSchema
.
dump
(
result
)
if
result
:
json_dumps
=
getListAppsSchema
.
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
=
postAppSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionPostApp
.
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
AppResource
(
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
=
getAppSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetApp
.
emit
(
uuid
,
data
)
if
result
:
json_dumps
=
getAppSchema
.
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
=
putAppSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionPutApp
.
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 = deleteAppSchema.load(json_payload)
result
,
message
=
signalManager
.
actionDeleteApp
.
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/area.py
View file @
3922979c
...
...
@@ -28,11 +28,11 @@ class AreaResourceList(Resource):
if
result
[
0
]:
json_dumps
=
getListAreasSchema
.
dump
(
result
[
1
])
logger
.
warn
(
json_dumps
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
,
count
=
result
[
2
])
return
response_result
(
ResponseCode
.
REQUEST_ERROR
)
return
response_result
(
ResponseCode
.
HTTP_SUCCESS
,
data
=
json_dumps
,
count
=
result
[
2
])
return
response_result
(
ResponseCode
.
HTTP_INVAILD_REQUEST
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
@
jwt_required
(
locations
=
[
"headers"
])
def
post
(
self
):
...
...
@@ -42,12 +42,12 @@ class AreaResourceList(Resource):
result
=
signalManager
.
actionPostArea
.
emit
(
data
)
if
result
[
0
]
==
False
:
# json_dumps = postAreaSchema.dump(result)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
,
msg
=
result
[
1
])
return
response_result
(
ResponseCode
.
HTTP_INVAILD_REQUEST
,
msg
=
result
[
1
])
logger
.
warn
(
result
)
return
response_result
(
ResponseCode
.
OK
)
return
response_result
(
ResponseCode
.
HTTP_SUCCESS
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
class
AreaResource
(
Resource
):
...
...
@@ -70,11 +70,11 @@ class AreaResource(Resource):
result
=
signalManager
.
actionGetArea
.
emit
(
uuid
,
data
)
if
result
[
0
]:
json_dumps
=
getAreaSchema
.
dump
(
result
[
1
])
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
)
return
response_result
(
ResponseCode
.
NO_DATA
)
return
response_result
(
ResponseCode
.
HTTP_SUCCESS
,
data
=
json_dumps
)
return
response_result
(
ResponseCode
.
HTTP_NOT_FOUND
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
@
jwt_required
(
locations
=
[
"headers"
])
...
...
@@ -86,11 +86,11 @@ class AreaResource(Resource):
result
=
signalManager
.
actionPutArea
.
emit
(
uuid
,
data
)
if
result
[
0
]
==
True
:
# json_dumps = putAreaSchema.dump(result)
return
response_result
(
ResponseCode
.
OK
)
return
response_result
(
ResponseCode
.
HTTP_SUCCESS
)
return
response_result
(
ResponseCode
.
NOTHING_CHANGE
,
msg
=
result
[
1
])
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
@
jwt_required
(
locations
=
[
"headers"
])
...
...
@@ -101,8 +101,8 @@ class AreaResource(Resource):
# data = deleteAreaSchema.load(json_payload)
result
=
signalManager
.
actionDeleteArea
.
emit
(
uuid
)
if
result
[
0
]
==
True
:
return
response_result
(
ResponseCode
.
OK
)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
,
msg
=
result
[
1
])
return
response_result
(
ResponseCode
.
HTTP_SUCCESS
)
return
response_result
(
ResponseCode
.
HTTP_INVAILD_REQUEST
,
msg
=
result
[
1
])
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
tools/build_out/views/device.py
View file @
3922979c
#!/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
...
...
@@ -26,29 +23,31 @@ class DeviceResourceList(Resource):
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getListDeviceSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetListDevice
.
emit
(
data
)
result
=
signalManager
.
actionGetListDevice
.
emit
(
data
)
json_dumps
=
getListDeviceSchema
.
dump
(
result
)
if
result
:
json_dumps
=
getListDevicesSchema
.
dump
(
result
.
items
)
if
result
[
0
]
:
json_dumps
=
getListDevicesSchema
.
dump
(
result
[
1
]
)
logger
.
warn
(
json_dumps
)
return
response_result
(
message
,
data
=
json_dumps
,
count
=
result
.
total
)
return
response_result
(
message
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
,
count
=
result
[
2
]
)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_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
)
result
=
signalManager
.
actionPostDevice
.
emit
(
data
)
if
result
[
0
]
==
False
:
# json_dumps = postDeviceSchema.dump(result)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
,
msg
=
result
[
1
])
logger
.
warn
(
result
)
return
response_result
(
ResponseCode
.
OK
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
class
DeviceResource
(
Resource
):
...
...
@@ -68,14 +67,14 @@ class DeviceResource(Resource):
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
)
result
=
signalManager
.
actionGetDevice
.
emit
(
uuid
,
data
)
if
result
[
0
]
:
json_dumps
=
getDeviceSchema
.
dump
(
result
[
1
]
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
)
return
response_result
(
ResponseCode
.
NO_DATA
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
@
jwt_required
(
locations
=
[
"headers"
])
...
...
@@ -84,13 +83,14 @@ class DeviceResource(Resource):
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
)
result
=
signalManager
.
actionPutDevice
.
emit
(
uuid
,
data
)
if
result
[
0
]
==
True
:
# json_dumps = putDeviceSchema.dump(result)
return
response_result
(
ResponseCode
.
OK
)
return
response_result
(
ResponseCode
.
NOTHING_CHANGE
,
msg
=
result
[
1
])
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
@
jwt_required
(
locations
=
[
"headers"
])
...
...
@@ -99,8 +99,10 @@ class DeviceResource(Resource):
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
)
result
=
signalManager
.
actionDeleteDevice
.
emit
(
uuid
)
if
result
[
0
]
==
True
:
return
response_result
(
ResponseCode
.
OK
)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
,
msg
=
result
[
1
])
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
tools/build_out/views/login.py
View file @
3922979c
#!/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
marshmallow.exceptions
import
ValidationError
from
application.signal_manager
import
signalManager
from
models.login
import
postLoginSchema
,
getListLoginSchema
,
getListLoginsSchema
,
getLoginSchema
from
webcreator.log
import
logger
...
...
@@ -23,30 +27,37 @@ class LoginResourceList(Resource):
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getListLoginSchema
.
load
(
json_payload
)
result
=
signalManager
.
actionGetListLogin
.
emit
(
data
)
result
,
message
=
signalManager
.
actionGetListLogin
.
emit
(
data
)
json_dumps
=
getListLoginSchema
.
dump
(
result
)
if
result
[
0
]:
json_dumps
=
getListLoginsSchema
.
dump
(
result
[
1
])
logger
.
warn
(
json_dumps
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
,
count
=
result
[
2
])
return
response_result
(
ResponseCode
.
REQUEST_ERROR
)
if
result
:
json_dumps
=
getListLoginsSchema
.
dump
(
result
.
items
)
return
response_result
(
message
,
data
=
json_dumps
,
count
=
result
.
total
)
return
response_result
(
message
)
except
ValidationError
as
e
:
return
response_result
(
ResponseCode
.
HTTP_INVAILD_REQUEST
,
data
=
e
.
messages
)
except
Exception
as
e
:
data
=
None
if
hasattr
(
e
,
'args'
):
data
=
e
.
args
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
DB_ERROR
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
,
data
=
data
)
def
post
(
self
):
try
:
json_payload
=
request
.
json
data
=
postLoginSchema
.
load
(
json_payload
)
result
=
signalManager
.
actionPostLogin
.
emit
(
data
)
if
result
[
0
]
==
False
:
# json_dumps = postLoginSchema.dump(result
)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
,
msg
=
result
[
1
]
)
logger
.
warn
(
result
)
return
response_result
(
ResponseCode
.
OK
)
# 更新data,插入ip信息,如果没有转发ip,那么则获取请求ip
data
.
update
({
"ip"
:
request
.
headers
.
get
(
'X-Forwarded-For'
,
request
.
remote_addr
),
"user_agent"
:
request
.
headers
.
get
(
'User-Agent'
,
""
)
})
result
,
message
=
signalManager
.
actionPostLogin
.
emit
(
data
)
return
response_result
(
message
,
data
=
result
)
except
ValidationError
as
e
:
return
response_result
(
ResponseCode
.
HTTP_INVAILD_REQUEST
,
data
=
e
.
messages
)
except
Exception
as
e
:
data
=
None
if
hasattr
(
e
,
'args'
):
data
=
e
.
args
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
DB_ERROR
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
,
data
=
data
)
class
LoginResource
(
Resource
):
...
...
@@ -66,11 +77,11 @@ class LoginResource(Resource):
json_payload
=
request
.
json
print
(
"========>"
,
uuid
,
json_payload
)
data
=
getLoginSchema
.
load
(
json_payload
)
result
=
signalManager
.
actionGetLogin
.
emit
(
uuid
,
data
)
if
result
[
0
]
:
json_dumps
=
getLoginSchema
.
dump
(
result
[
1
]
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
)
return
response_result
(
ResponseCode
.
NO_DATA
)
result
,
message
=
signalManager
.
actionGetLogin
.
emit
(
uuid
,
data
)
if
result
:
json_dumps
=
getLoginSchema
.
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
.
DB
_ERROR
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
tools/build_out/views/monitorEvm.py
View file @
3922979c
#!/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
...
...
@@ -26,16 +23,16 @@ class MonitorEvmResourceList(Resource):
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getListMonitorEvmSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetListMonitorEvm
.
emit
(
data
)
result
=
signalManager
.
actionGetListMonitorEvm
.
emit
(
data
)
json_dumps
=
getListMonitorEvmSchema
.
dump
(
result
)
if
result
:
json_dumps
=
getListMonitorEvmsSchema
.
dump
(
result
.
items
)
if
result
[
0
]
:
json_dumps
=
getListMonitorEvmsSchema
.
dump
(
result
[
1
]
)
logger
.
warn
(
json_dumps
)
return
response_result
(
message
,
data
=
json_dumps
,
count
=
result
.
total
)
return
response_result
(
message
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
,
count
=
result
[
2
]
)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
class
MonitorEvmResource
(
Resource
):
def
__init__
(
self
):
...
...
@@ -54,11 +51,11 @@ class MonitorEvmResource(Resource):
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
)
result
=
signalManager
.
actionGetMonitorEvm
.
emit
(
uuid
,
data
)
if
result
[
0
]
:
json_dumps
=
getMonitorEvmSchema
.
dump
(
result
[
1
]
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
)
return
response_result
(
ResponseCode
.
NO_DATA
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
tools/build_out/views/monitorImage.py
View file @
3922979c
#!/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
...
...
@@ -26,16 +23,16 @@ class MonitorImageResourceList(Resource):
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getListMonitorImageSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetListMonitorImage
.
emit
(
data
)
result
=
signalManager
.
actionGetListMonitorImage
.
emit
(
data
)
json_dumps
=
getListMonitorImageSchema
.
dump
(
result
)
if
result
:
json_dumps
=
getListMonitorImagesSchema
.
dump
(
result
.
items
)
if
result
[
0
]
:
json_dumps
=
getListMonitorImagesSchema
.
dump
(
result
[
1
]
)
logger
.
warn
(
json_dumps
)
return
response_result
(
message
,
data
=
json_dumps
,
count
=
result
.
total
)
return
response_result
(
message
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
,
count
=
result
[
2
]
)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
class
MonitorImageResource
(
Resource
):
def
__init__
(
self
):
...
...
@@ -54,11 +51,11 @@ class MonitorImageResource(Resource):
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
)
result
=
signalManager
.
actionGetMonitorImage
.
emit
(
uuid
,
data
)
if
result
[
0
]
:
json_dumps
=
getMonitorImageSchema
.
dump
(
result
[
1
]
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
)
return
response_result
(
ResponseCode
.
NO_DATA
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
tools/build_out/views/monitorLvgl.py
View file @
3922979c
#!/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
...
...
@@ -26,16 +23,16 @@ class MonitorLvglResourceList(Resource):
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getListMonitorLvglSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetListMonitorLvgl
.
emit
(
data
)
result
=
signalManager
.
actionGetListMonitorLvgl
.
emit
(
data
)
json_dumps
=
getListMonitorLvglSchema
.
dump
(
result
)
if
result
:
json_dumps
=
getListMonitorLvglsSchema
.
dump
(
result
.
items
)
if
result
[
0
]
:
json_dumps
=
getListMonitorLvglsSchema
.
dump
(
result
[
1
]
)
logger
.
warn
(
json_dumps
)
return
response_result
(
message
,
data
=
json_dumps
,
count
=
result
.
total
)
return
response_result
(
message
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
,
count
=
result
[
2
]
)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
class
MonitorLvglResource
(
Resource
):
def
__init__
(
self
):
...
...
@@ -54,11 +51,11 @@ class MonitorLvglResource(Resource):
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
)
result
=
signalManager
.
actionGetMonitorLvgl
.
emit
(
uuid
,
data
)
if
result
[
0
]
:
json_dumps
=
getMonitorLvglSchema
.
dump
(
result
[
1
]
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
)
return
response_result
(
ResponseCode
.
NO_DATA
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
tools/build_out/views/monitorSystem.py
View file @
3922979c
#!/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
...
...
@@ -26,16 +23,16 @@ class MonitorSystemResourceList(Resource):
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getListMonitorSystemSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetListMonitorSystem
.
emit
(
data
)
result
=
signalManager
.
actionGetListMonitorSystem
.
emit
(
data
)
json_dumps
=
getListMonitorSystemSchema
.
dump
(
result
)
if
result
:
json_dumps
=
getListMonitorSystemsSchema
.
dump
(
result
.
items
)
if
result
[
0
]
:
json_dumps
=
getListMonitorSystemsSchema
.
dump
(
result
[
1
]
)
logger
.
warn
(
json_dumps
)
return
response_result
(
message
,
data
=
json_dumps
,
count
=
result
.
total
)
return
response_result
(
message
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
,
count
=
result
[
2
]
)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
class
MonitorSystemResource
(
Resource
):
def
__init__
(
self
):
...
...
@@ -54,11 +51,11 @@ class MonitorSystemResource(Resource):
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
)
result
=
signalManager
.
actionGetMonitorSystem
.
emit
(
uuid
,
data
)
if
result
[
0
]
:
json_dumps
=
getMonitorSystemSchema
.
dump
(
result
[
1
]
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
)
return
response_result
(
ResponseCode
.
NO_DATA
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
tools/build_out/views/monitorWatch.py
View file @
3922979c
#!/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
...
...
@@ -26,16 +23,16 @@ class MonitorWatchResourceList(Resource):
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getListMonitorWatchSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetListMonitorWatch
.
emit
(
data
)
result
=
signalManager
.
actionGetListMonitorWatch
.
emit
(
data
)
json_dumps
=
getListMonitorWatchSchema
.
dump
(
result
)
if
result
:
json_dumps
=
getListMonitorWatchsSchema
.
dump
(
result
.
items
)
if
result
[
0
]
:
json_dumps
=
getListMonitorWatchsSchema
.
dump
(
result
[
1
]
)
logger
.
warn
(
json_dumps
)
return
response_result
(
message
,
data
=
json_dumps
,
count
=
result
.
total
)
return
response_result
(
message
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
,
count
=
result
[
2
]
)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
class
MonitorWatchResource
(
Resource
):
def
__init__
(
self
):
...
...
@@ -54,11 +51,11 @@ class MonitorWatchResource(Resource):
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
)
result
=
signalManager
.
actionGetMonitorWatch
.
emit
(
uuid
,
data
)
if
result
[
0
]
:
json_dumps
=
getMonitorWatchSchema
.
dump
(
result
[
1
]
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
)
return
response_result
(
ResponseCode
.
NO_DATA
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
tools/build_out/views/
file
.py
→
tools/build_out/views/
package.20210714181414
.py
View file @
3922979c
'''
Author: your name
Date: 2021-07-09 12:39:40
LastEditTime: 2021-07-09 12:40:18
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\v
iews
\f
ile.py
'''
#!/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.
login
import
postLoginSchema
,
getListLoginSchema
,
getListLoginsSchema
,
getLogin
Schema
from
models.
package
import
getListPackageSchema
,
getListPackagesSchema
,
getPackage
Schema
from
webcreator.log
import
logger
from
webcreator.response
import
ResponseCode
,
response_result
class
Fil
eResourceList
(
Resource
):
class
Packag
eResourceList
(
Resource
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
...
...
@@ -30,34 +25,19 @@ class FileResourceList(Resource):
try
:
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getList
Login
Schema
.
load
(
json_payload
)
result
=
signalManager
.
actionGetListLogin
.
emit
(
data
)
json_dumps
=
getList
Login
Schema
.
dump
(
result
)
if
result
[
0
]
:
json_dumps
=
getList
LoginsSchema
.
dump
(
result
[
1
]
)
data
=
getList
Package
Schema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetListPackage
.
emit
(
data
)
json_dumps
=
getList
Package
Schema
.
dump
(
result
)
if
result
:
json_dumps
=
getList
PackagesSchema
.
dump
(
result
.
items
)
logger
.
warn
(
json_dumps
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
,
count
=
result
[
2
]
)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
)
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
.
DB_ERROR
)
def
post
(
self
):
try
:
json_payload
=
request
.
json
data
=
postLoginSchema
.
load
(
json_payload
)
result
=
signalManager
.
actionPostLogin
.
emit
(
data
)
if
result
[
0
]
==
False
:
# json_dumps = postLoginSchema.dump(result)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
,
msg
=
result
[
1
])
logger
.
warn
(
result
)
return
response_result
(
ResponseCode
.
OK
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
DB_ERROR
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
class
Fil
eResource
(
Resource
):
class
Packag
eResource
(
Resource
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
...
...
@@ -73,12 +53,12 @@ class FileResource(Resource):
try
:
json_payload
=
request
.
json
print
(
"========>"
,
uuid
,
json_payload
)
data
=
get
Login
Schema
.
load
(
json_payload
)
result
=
signalManager
.
actionGetLogin
.
emit
(
uuid
,
data
)
if
result
[
0
]
:
json_dumps
=
get
LoginSchema
.
dump
(
result
[
1
]
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
)
return
response_result
(
ResponseCode
.
NO_DATA
)
data
=
get
Package
Schema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetPackage
.
emit
(
uuid
,
data
)
if
result
:
json_dumps
=
get
PackageSchema
.
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
.
DB
_ERROR
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
tools/build_out/views/user.py
View file @
3922979c
#!/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
...
...
@@ -23,31 +26,28 @@ class UserResourceList(Resource):
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getListUserSchema
.
load
(
json_payload
)
result
=
signalManager
.
actionGetListUser
.
emit
(
data
)
result
,
message
=
signalManager
.
actionGetListUser
.
emit
(
data
)
json_dumps
=
getListUserSchema
.
dump
(
result
)
if
result
[
0
]
:
json_dumps
=
getListUsersSchema
.
dump
(
result
[
1
]
)
if
result
:
json_dumps
=
getListUsersSchema
.
dump
(
result
.
items
)
logger
.
warn
(
json_dumps
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
,
count
=
result
[
2
]
)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
)
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
.
DB
_ERROR
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
@
jwt_required
(
locations
=
[
"headers"
])
def
post
(
self
):
try
:
json_payload
=
request
.
json
data
=
postUserSchema
.
load
(
json_payload
)
result
=
signalManager
.
actionPostUser
.
emit
(
data
)
if
result
[
0
]
==
False
:
# json_dumps = postUserSchema.dump(result)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
,
msg
=
result
[
1
])
logger
.
warn
(
result
)
return
response_result
(
ResponseCode
.
OK
)
result
,
message
=
signalManager
.
actionPostUser
.
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
.
DB
_ERROR
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
class
UserResource
(
Resource
):
...
...
@@ -67,30 +67,26 @@ class UserResource(Resource):
json_payload
=
request
.
json
print
(
"========>"
,
uuid
,
json_payload
)
data
=
getUserSchema
.
load
(
json_payload
)
result
=
signalManager
.
actionGetUser
.
emit
(
uuid
,
data
)
if
result
[
0
]
:
json_dumps
=
getUserSchema
.
dump
(
result
[
1
]
)
return
response_result
(
ResponseCode
.
OK
,
data
=
json_dumps
)
return
response_result
(
ResponseCode
.
NO_DATA
)
result
,
message
=
signalManager
.
actionGetUser
.
emit
(
uuid
,
data
)
if
result
:
json_dumps
=
getUserSchema
.
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
.
DB
_ERROR
)
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
=
putUserSchema
.
load
(
json_payload
)
result
=
signalManager
.
actionPutUser
.
emit
(
uuid
,
data
)
if
result
[
0
]
==
True
:
# json_dumps = putUserSchema.dump(result)
return
response_result
(
ResponseCode
.
OK
)
return
response_result
(
ResponseCode
.
NOTHING_CHANGE
,
msg
=
result
[
1
])
result
,
message
=
signalManager
.
actionPutUser
.
emit
(
uuid
,
data
)
return
response_result
(
message
,
data
=
result
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
@
jwt_required
(
locations
=
[
"headers"
])
...
...
@@ -99,10 +95,8 @@ class UserResource(Resource):
json_payload
=
request
.
json
print
(
"========>"
,
uuid
,
json_payload
)
# data = deleteUserSchema.load(json_payload)
result
=
signalManager
.
actionDeleteUser
.
emit
(
uuid
)
if
result
[
0
]
==
True
:
return
response_result
(
ResponseCode
.
OK
)
return
response_result
(
ResponseCode
.
REQUEST_ERROR
,
msg
=
result
[
1
])
result
,
message
=
signalManager
.
actionDeleteUser
.
emit
(
uuid
)
return
response_result
(
message
,
data
=
result
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
DB
_ERROR
)
return
response_result
(
ResponseCode
.
HTTP_SERVER
_ERROR
)
tools/build_out/webcreator/event.py
View file @
3922979c
'''
Author: your name
Date: 2021-06-15 17:40:14
LastEditTime: 2021-0
6-30 17:22:4
4
LastEditTime: 2021-0
7-14 18:28:5
4
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\r
esources
\
webcreator
\
event.py
'''
# -*- coding: utf_8 -*-
############################
# 信号槽
############################
class
PySignal
(
object
):
"""
Simple event class used to provide hooks for different types of events in Locust.
...
...
tools/build_out/webcreator/log.py
View file @
3922979c
'''
Author: your name
Date: 2021-04-22 18:04:15
LastEditTime: 2021-07-
09 00:52:08
LastEditors:
your name
LastEditTime: 2021-07-
14 18:28:45
LastEditors:
Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\r
esources
\
webcreator
\
log.py
'''
# -*- coding: utf_8 -*-
############################
# Log
# 日志
############################
import
os
import
logging
from
logging.handlers
import
RotatingFileHandler
...
...
tools/build_out/webcreator/utils/ccode.py
View file @
3922979c
'''
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
...
...
@@ -37,7 +29,7 @@ def cstr_encode(text, splitLines=True, escapePercent=False):
if
splitLines
:
output
+=
"
\\
n
\"\n\"
"
else
:
output
+=
"
\\
n"
;
output
+=
"
\\
n"
;
elif
text
[
i
]
==
'
\r
'
:
output
+=
"
\\
r"
elif
text
[
i
]
==
'
\t
'
:
...
...
tools/build_out/webcreator/webscoket.py
View file @
3922979c
'''
Author: your name
Date: 2021-06-30 17:43:46
LastEditTime: 2021-07-14 18:37:35
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\
webcreator
\
webscoket.py
'''
#!/usr/bin/env python
# -*- coding: utf_8 -*-
import
websocket
from
flask
import
json
from
tornado.websocket
import
WebSocketHandler
,
WebSocketClosedError
from
utils
import
ObjectDict
from
.
utils
import
ObjectDict
from
.log
import
logger
...
...
@@ -90,21 +97,3 @@ class ThreadNotifyHandler(BaseWebsocket):
def
on_message
(
self
,
message
):
NotifyHandler
.
boardcastMessage
(
message
)
class
Wsclient
(
object
):
"""
用于和ThreadNotifyHandler建立websocket连接的客户端
使用方式:在子线程中建立到达threadnotify路由的websocket客户端如
wsclient = Wsclient()
wsclient.send(WebsocketResponse("dashboard", 0, "success", data=cache))
"""
def
__init__
(
self
):
super
(
Wsclient
,
self
)
.
__init__
()
self
.
wsclient
=
websocket
.
WebSocket
()
self
.
wsclient
.
connect
(
"ws://localhost:7777/ws/api/v1/threadnotify"
)
def
send
(
self
,
msg
):
if
isinstance
(
msg
,
dict
):
msg
=
json
.
dumps
(
msg
)
self
.
wsclient
.
send
(
msg
)
tools/logs/running.log
0 → 100644
View file @
3922979c
[2021-07-14 18:14:14,257][ INFO][in gen_code.py -> copyFiles line:107] copy files finished!
tools/modules/file-manager.py
deleted
100644 → 0
View file @
d109566c
import
pprint
import
base64
from
pathlib
import
Path
import
json
disk_root
=
"D:
\\
projects
\\
scriptiot
\\
evm_app_store_files"
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
'''
@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
'''
@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"
})
# print("//////////", child.is_dir(), child.resolve(), child.name, child.parent, child.root, child.relative_to(rp))
pprint
.
pprint
(
result
)
return
result
def
selectDisk
(
self
,
disk
):
print
(
disk
)
return
True
def
download
(
self
,
disk
):
print
(
disk
)
return
True
def
preview
(
self
,
disk
,
target_file
):
# 预览图片
img_stream
=
None
if
not
target_file
:
target_file
=
'./evue_photo.png'
with
open
(
target_file
,
'rb'
)
as
img_f
:
img_stream
=
img_f
.
read
()
img_stream
=
base64
.
b64encode
(
img_stream
)
.
decode
()
print
(
disk
,
target_file
)
return
img_stream
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
)
\ No newline at end of file
tools/
build_out/controllers/file_manager
.py
→
tools/
modules/file
.py
View file @
3922979c
...
...
@@ -2,8 +2,14 @@ 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
=
"D:
\\
projects
\\
scriptiot
\\
evm_app_store_files"
disk_root
=
config
.
UPLOAD_ROOT_DIR
logger
.
info
(
disk_root
)
class
FileManager
(
object
):
def
__init__
(
self
)
->
None
:
...
...
@@ -42,7 +48,7 @@ class FileManager(object):
child
.
name
:
{
"driver"
:
"local"
}
})
return
result
return
result
,
ResponseCode
.
HTTP_SUCCESS
'''
@description: 获取当前类别的目录信息
...
...
@@ -89,7 +95,7 @@ class FileManager(object):
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
...
...
@@ -122,7 +128,7 @@ class FileManager(object):
f
.
write
(
json
.
dumps
(
result
,
ensure_ascii
=
True
))
pprint
.
pprint
(
result
)
return
result
return
result
,
ResponseCode
.
HTTP_SUCCESS
'''
@description: 获取目录结构树
...
...
@@ -167,29 +173,86 @@ class FileManager(object):
"timestamp"
:
int
(
child
.
stat
()
.
st_mtime
),
"type"
:
"dir"
})
# print("//////////", child.is_dir(), child.resolve(), child.name, child.parent, child.root, child.relative_to(rp))
pprint
.
pprint
(
result
)
return
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
selectDisk
(
self
,
disk
):
def
delete
(
self
,
disk
):
# delete file
print
(
disk
)
return
True
return
True
,
ResponseCode
.
HTTP_SUCCESS
def
download
(
self
,
disk
):
def
copy
(
self
,
disk
):
# copy file
print
(
disk
)
return
True
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
):
# 预览图片
img_stream
=
None
if
not
target_file
:
target_file
=
'./evue_photo.png'
with
open
(
target_file
,
'rb'
)
as
img_f
:
img_stream
=
img_f
.
read
()
img_stream
=
base64
.
b64encode
(
img_stream
)
.
decode
()
print
(
disk
,
target_file
)
return
img_stream
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
()
...
...
@@ -204,7 +267,7 @@ if __name__ == "__main__":
result
=
fileManager
.
initialize
()
print
(
"----->"
,
result
)
result
=
fileManager
.
content
(
"uploads"
,
"evueapps/evm"
)
print
(
">>>>>>"
,
result
)
...
...
@@ -212,4 +275,4 @@ if __name__ == "__main__":
print
(
"=====>"
,
result
)
result
=
fileManager
.
preview
(
"uploads"
,
"evueapps/evm"
)
print
(
"$$$$$>"
,
result
)
\ No newline at end of file
print
(
"$$$$$>"
,
result
)
tools/resources/application/app.py
View file @
3922979c
...
...
@@ -32,7 +32,7 @@ handle_user_exception = app.handle_user_exception
def
expired_token_callback
(
jwt_header
,
jwt_payload
):
logger
.
info
(
jwt_payload
)
return
jsonify
({
'code'
:
401
1
,
'code'
:
401
,
'msg'
:
'token expired'
,
'data'
:
jwt_header
})
...
...
@@ -41,7 +41,7 @@ def expired_token_callback(jwt_header, jwt_payload):
@
jwt
.
invalid_token_loader
def
invalid_token_callback
(
error
):
# we have to keep the argument here, since it's passed in by the caller internally
return
jsonify
({
'code'
:
401
2
,
'code'
:
401
,
'msg'
:
'invalid token'
,
'data'
:
error
})
...
...
@@ -50,7 +50,7 @@ def invalid_token_callback(error): # we have to keep the argument here, since i
@
jwt
.
unauthorized_loader
def
unauthorized_callback
(
error
):
return
jsonify
({
'code'
:
401
3
,
'code'
:
401
,
'msg'
:
'unauthorized'
,
'data'
:
error
})
...
...
@@ -60,13 +60,13 @@ def _custom_abort(http_status_code, **kwargs):
自定义abort 400响应数据格式
"""
if
http_status_code
==
400
:
message
=
kwargs
.
get
(
'm
essage
'
)
message
=
kwargs
.
get
(
'm
sg
'
)
if
isinstance
(
message
,
dict
):
param
,
info
=
list
(
message
.
items
())[
0
]
data
=
'{}:{}!'
.
format
(
param
,
info
)
return
abort
(
jsonify
(
response_result
(
ResponseCode
.
PARAMETER_ERROR
,
data
=
data
)))
return
abort
(
jsonify
(
response_result
(
ResponseCode
.
HTTP_INVAILD_REQUEST
,
data
=
data
)))
else
:
return
abort
(
jsonify
(
response_result
(
ResponseCode
.
PARAMETER_ERROR
,
data
=
message
)))
return
abort
(
jsonify
(
response_result
(
ResponseCode
.
HTTP_INVAILD_REQUEST
,
data
=
message
)))
# return { 'code': http_status_code, 'msg': kwargs.get('message') }
return
abort
(
http_status_code
)
...
...
tools/resources/application/config.py
View file @
3922979c
'''
Author: your name
Date: 2021-06-30 17:43:46
LastEditTime: 2021-07-14 18:40:19
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\a
pplication
\
config.py
'''
# -*- coding: utf-8 -*-
import
os
import
multiprocessing
MODE
=
'develop'
# develop: 开发模式; production: 生产模式
UPLOAD_ROOT_DIR
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'assets'
,
'upload'
)
EXPORT_ROOT_DIR
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'assets'
,
'export'
)
UPLOAD_ALLOWED
=
set
([
'doc'
,
'docs'
,
'csv'
,
'xls'
,
'xlsx'
])
class
ProductionConfig
(
object
):
EPK_DIR
=
"D:
\\
projects
\\
scriptiot
\\
evm_app_store_files
\\
epks"
UPLOAD_ROOT_DIR
=
"D:
\\
projects
\\
scriptiot
\\
evm_app_store_files"
UPLOAD_ALLOWED
=
set
([
'doc'
,
'docs'
,
'csv'
,
'xls'
,
'xlsx'
])
BIND
=
'127.0.0.1:3000'
WORKERS
=
multiprocessing
.
cpu_count
()
*
2
+
1
WORKER_CONNECTIONS
=
10000
...
...
@@ -22,7 +30,7 @@ class ProductionConfig(object):
REDIS_PORT
=
6379
REDIS_PASSWORD
=
''
REDIS_MAX_CONNECTIONS
=
100
JWT_HEADER_NAME
=
'Auth'
JWT_HEADER_NAME
=
'Auth
orization
'
JWT_HEADER_TYPE
=
'Bearer'
JWT_SECRET_KEY
=
'6UdxRgs2hvWpTLmj027d5vt7dXXQX'
JWT_ACCESS_TOKEN_EXPIRES
=
7200
...
...
@@ -44,6 +52,9 @@ class ProductionConfig(object):
class
DevelopConfig
(
object
):
EPK_DIR
=
"D:
\\
projects
\\
scriptiot
\\
evm_app_store_files
\\
epks"
UPLOAD_ROOT_DIR
=
"D:
\\
projects
\\
scriptiot
\\
evm_app_store_files"
UPLOAD_ALLOWED
=
set
([
'doc'
,
'docs'
,
'csv'
,
'xls'
,
'xlsx'
])
BIND
=
'127.0.0.1:3000'
WORKERS
=
2
WORKER_CONNECTIONS
=
1000
...
...
@@ -58,7 +69,7 @@ class DevelopConfig(object):
REDIS_PORT
=
6379
REDIS_PASSWORD
=
''
REDIS_MAX_CONNECTIONS
=
100
JWT_HEADER_NAME
=
'Auth'
JWT_HEADER_NAME
=
'Auth
orization
'
JWT_HEADER_TYPE
=
'Bearer'
JWT_SECRET_KEY
=
'6UdxRgs2hvWpTLmj027d5vt7dXXQX'
JWT_ACCESS_TOKEN_EXPIRES
=
7200
...
...
tools/resources/webcreator/event.py
View file @
3922979c
...
...
@@ -8,10 +8,6 @@ FilePath: \evm-store\tools\resources\webcreator\event.py
'''
# -*- coding: utf_8 -*-
############################
# 信号槽
############################
class
PySignal
(
object
):
"""
Simple event class used to provide hooks for different types of events in Locust.
...
...
tools/resources/webcreator/log.py
View file @
3922979c
'''
Author: your name
Date: 2021-04-22 18:04:15
LastEditTime: 2021-07-
09 00:52:0
8
LastEditors:
your name
LastEditTime: 2021-07-
14 18:38:2
8
LastEditors:
Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\r
esources
\
webcreator
\
log.py
'''
# -*- coding: utf_8 -*-
############################
# Log
# 日志
############################
import
os
import
logging
from
logging.handlers
import
RotatingFileHandler
...
...
tools/resources/webcreator/utils/ccode.py
0 → 100644
View file @
3922979c
# -*- 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/resources/webcreator/utils/epk.py
0 → 100644
View file @
3922979c
#-*- 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/resources/webcreator/utils/epk_2.0.py
0 → 100644
View file @
3922979c
#-*- 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/resources/webcreator/utils/lib/eheatshrink.dll
0 → 100644
View file @
3922979c
File added
tools/resources/webcreator/utils/lib/libeheatshrink.so
0 → 100644
View file @
3922979c
File added
tools/resources/webcreator/utils/tools_epk_1.0.py
0 → 100644
View file @
3922979c
#-*- 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
])
tools/resources/webcreator/webscoket.py
View file @
3922979c
'''
Author: your name
Date: 2021-06-15 17:40:19
LastEditTime: 2021-07-14 18:38:12
LastEditors: your name
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\r
esources
\
webcreator
\
webscoket.py
'''
#!/usr/bin/env python
# -*- coding: utf_8 -*-
import
websocket
from
flask
import
json
from
tornado.websocket
import
WebSocketHandler
,
WebSocketClosedError
from
utils
import
ObjectDict
from
.
utils
import
ObjectDict
from
.log
import
logger
...
...
@@ -90,21 +97,3 @@ class ThreadNotifyHandler(BaseWebsocket):
def
on_message
(
self
,
message
):
NotifyHandler
.
boardcastMessage
(
message
)
class
Wsclient
(
object
):
"""
用于和ThreadNotifyHandler建立websocket连接的客户端
使用方式:在子线程中建立到达threadnotify路由的websocket客户端如
wsclient = Wsclient()
wsclient.send(WebsocketResponse("dashboard", 0, "success", data=cache))
"""
def
__init__
(
self
):
super
(
Wsclient
,
self
)
.
__init__
()
self
.
wsclient
=
websocket
.
WebSocket
()
self
.
wsclient
.
connect
(
"ws://localhost:7777/ws/api/v1/threadnotify"
)
def
send
(
self
,
msg
):
if
isinstance
(
msg
,
dict
):
msg
=
json
.
dumps
(
msg
)
self
.
wsclient
.
send
(
msg
)
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