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
5e559b46
Commit
5e559b46
authored
Mar 16, 2021
by
wanliofficial
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
4451a647
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
117 deletions
+60
-117
backend/controller/apps_manager.py
backend/controller/apps_manager.py
+1
-0
backend/controller/download_manager.py
backend/controller/download_manager.py
+20
-79
backend/model/annex.py
backend/model/annex.py
+1
-1
backend/model/apps.py
backend/model/apps.py
+36
-36
backend/view/download.py
backend/view/download.py
+2
-1
No files found.
backend/controller/apps_manager.py
View file @
5e559b46
...
...
@@ -76,6 +76,7 @@ class AppsManager(object):
result
=
Apps
.
get
(
uuid
=
uuid
)
if
result
:
result
.
app_icon
.
delete
()
result
.
delete
()
return
result
,
"delete app {}."
.
format
(
"success"
if
result
else
"fail"
)
...
...
backend/controller/download_manager.py
View file @
5e559b46
...
...
@@ -91,87 +91,28 @@ class DownloadManager(object):
# 此次下载将生成一次下载记录
# 当前还没有校验前端传来的IMEI是否是合法的
epk_path
=
None
epk_path
=
""
app
=
None
with
db_session
:
# 判断应用UUID是否等于evue_launcher
if
data
.
get
(
"id"
)
==
"evue_launcher123"
:
# 按照格式创建文件夹
dir_format
=
datetime
.
now
()
.
strftime
(
"
%
Y
%
m
%
d
%
H
%
M
%
S"
)
build_path
=
os
.
sep
.
join
([
os
.
getcwd
(),
config
.
get
(
"UPLOAD_DIR"
),
conf
.
get
(
'application'
,
'launcher_dir'
),
data
.
get
(
"imei"
),
dir_format
])
if
not
os
.
path
.
exists
(
build_path
):
os
.
makedirs
(
build_path
)
build_source_path
=
os
.
sep
.
join
([
build_path
,
"src"
])
if
not
os
.
path
.
exists
(
build_source_path
):
os
.
mkdir
(
build_source_path
)
# 判断下name为evue_launcher的文件是否存在
# 存在则移动到目标文件夹中
launcher
=
Apps
.
get
(
app_name
=
"evue_launcher"
)
if
launcher
:
# 查找所有关联文件,复制到目标文件夹中
for
f
in
launcher
.
app_annex
:
tf
=
convert_url_to_local_path
(
f
.
path
)
if
not
os
.
path
.
exists
(
tf
):
continue
filename
=
os
.
path
.
basename
(
tf
)
name
,
suffix
=
os
.
path
.
splitext
(
filename
)
name
=
re
.
sub
(
r"_\d{14}$"
,
""
,
name
)
shutil
.
copy
(
tf
,
os
.
sep
.
join
([
build_source_path
,
name
+
suffix
]))
# 根据应用UUID查找相关应用
app
=
Apps
.
get
(
app_name
=
data
.
get
(
"id"
),
is_delete
=
False
)
temp
=
[]
# 读取当前系统所有应用及其资源文件
apps
=
Apps
.
select
()
.
where
(
is_delete
=
False
)
.
order_by
(
Apps
.
sort
)
result_json
=
[]
for
val
in
apps
:
tmp
=
val
.
to_dict
(
with_collections
=
True
,
related_objects
=
True
)
if
val
.
app_build_log
:
temp
.
append
({
'icon'
:
val
.
app_icon
.
title
,
'name'
:
val
.
app_name
,
'url'
:
val
.
app_url
,
'version'
:
val
.
app_version
,
'epk'
:
tmp
.
get
(
"app_build_log"
)[
0
]
.
app_path
,
'category'
:
val
.
category
,
'id'
:
str
(
val
.
uuid
),
})
if
len
(
temp
)
%
4
==
0
and
temp
:
result_json
.
append
(
copy
.
deepcopy
(
temp
))
temp
=
[]
if
temp
:
result_json
.
append
(
copy
.
deepcopy
(
temp
))
json_str
=
json
.
dumps
(
result_json
,
sort_keys
=
False
,
ensure_ascii
=
False
)
with
open
(
os
.
sep
.
join
([
build_source_path
,
'evue_dock_apps.json'
]),
'w'
)
as
json_file
:
json_file
.
write
(
json_str
)
# 打包成EPK文件
epk
=
EpkApp
(
appName
=
"evue_launcher"
,
appDir
=
build_source_path
,
appVersion
=
"1.0"
,
output
=
build_path
)
epk
.
pack
()
epk_path
=
os
.
sep
.
join
([
build_path
,
'evue_launcher.epk'
])
else
:
# 根据应用UUID查找相关应用
app
=
Apps
.
get
(
app_name
=
data
.
get
(
"id"
),
is_delete
=
False
)
if
not
app
:
return
False
,
"app not found"
if
not
app
.
app_build_log
:
return
False
,
"app build file not found"
tmp
=
app
.
to_dict
(
with_collections
=
True
,
related_objects
=
True
)
epk_path
=
convert_url_to_local_path
(
tmp
.
get
(
"app_build_log"
)[
0
]
.
app_path
)
if
not
os
.
path
.
exists
(
epk_path
):
return
False
,
"epk file not found"
# 创建一条下载记录
if
app
:
AppDownload
(
app
=
app
,
imei
=
data
.
get
(
"imei"
))
commit
()
return
epk_path
,
"get dictionary {}."
.
format
(
"success"
if
epk_path
else
"no data"
)
if
not
app
:
return
False
,
"app not found"
tmp
=
app
.
to_dict
(
with_collections
=
True
,
related_objects
=
True
)
if
tmp
.
get
(
"app_build_log"
):
epk_path
=
convert_url_to_local_path
(
tmp
.
get
(
"app_build_log"
)[
0
]
.
app_path
)
if
not
os
.
path
.
exists
(
epk_path
):
return
False
,
"epk file not found"
if
app
:
AppDownload
(
app
=
app
,
imei
=
data
.
get
(
"imei"
))
commit
()
return
epk_path
,
"get dictionary {}."
.
format
(
"success"
if
epk_path
else
"no data"
)
def
getList
(
self
,
data
):
if
not
data
or
len
(
data
)
<=
0
:
...
...
backend/model/annex.py
View file @
5e559b46
...
...
@@ -14,7 +14,7 @@ class Annex(db.Entity):
id
=
PrimaryKey
(
int
,
auto
=
True
)
uuid
=
Required
(
uuid
.
UUID
,
unique
=
True
,
default
=
uuid
.
uuid1
,
index
=
True
)
app
=
Optional
(
"Apps"
,
reverse
=
"app_annex"
)
app_icon
=
Optional
(
"Apps"
,
reverse
=
"app_icon"
)
app_icon
=
Optional
(
"Apps"
,
reverse
=
"app_icon"
,
cascade_delete
=
True
)
title
=
Required
(
str
,
max_len
=
200
)
# 文件名
path
=
Required
(
LongStr
)
# 文件路径
type
=
Required
(
int
,
default
=
0
)
# 文件类型 PNG/JPG/GIF/MP3/MP4/DOCX/XLSX/PPT/PDF...
...
...
backend/model/apps.py
View file @
5e559b46
#!/usr/bin/env python
# -*- coding: utf_8 -*-
import
uuid
from
datetime
import
datetime
from
pony.orm
import
PrimaryKey
,
Required
,
Optional
,
Set
,
LongStr
,
Json
from
app
import
config
from
.
import
fullStackDB
# ********************************
from
.app_users
import
AppUser
# ********************************
db
=
fullStackDB
.
db
class
Apps
(
db
.
Entity
):
_table_
=
"{}"
.
format
(
config
[
'TABLE_PREFIX'
])
+
"apps"
id
=
PrimaryKey
(
int
,
auto
=
True
)
uuid
=
Required
(
uuid
.
UUID
,
unique
=
True
,
default
=
uuid
.
uuid1
,
index
=
True
)
app_name
=
Required
(
str
,
max_len
=
200
)
app_version
=
Optional
(
str
,
default
=
""
)
app_url
=
Optional
(
str
,
default
=
""
)
category
=
Optional
(
str
,
default
=
""
)
app_icon
=
Required
(
"Annex"
,
reverse
=
"app_icon"
)
app_desc
=
Optional
(
str
,
default
=
""
)
app_annex
=
Set
(
"Annex"
,
reverse
=
"app"
)
app_user
=
Optional
(
"AppUser"
,
reverse
=
"app"
)
app_build_log
=
Set
(
"BuildLogs"
,
reverse
=
"app"
)
app_download
=
Set
(
"AppDownload"
,
reverse
=
"app"
)
create_at
=
Required
(
datetime
,
default
=
datetime
.
now
)
create_by
=
Required
(
"User"
,
reverse
=
'apps_creator'
)
# BuildLogs与User一对一关系
update_at
=
Required
(
datetime
,
default
=
datetime
.
now
)
update_by
=
Required
(
"User"
,
reverse
=
'apps_updater'
)
# BuildLogs与User一对一关系
delete_at
=
Optional
(
datetime
)
delete_by
=
Optional
(
"User"
,
reverse
=
'apps_deleter'
)
# BuildLogs与User一对一关系
is_delete
=
Required
(
bool
,
default
=
False
)
#!/usr/bin/env python
# -*- coding: utf_8 -*-
import
uuid
from
datetime
import
datetime
from
pony.orm
import
PrimaryKey
,
Required
,
Optional
,
Set
,
LongStr
,
Json
from
app
import
config
from
.
import
fullStackDB
# ********************************
from
.app_users
import
AppUser
# ********************************
db
=
fullStackDB
.
db
class
Apps
(
db
.
Entity
):
_table_
=
"{}"
.
format
(
config
[
'TABLE_PREFIX'
])
+
"apps"
id
=
PrimaryKey
(
int
,
auto
=
True
)
uuid
=
Required
(
uuid
.
UUID
,
unique
=
True
,
default
=
uuid
.
uuid1
,
index
=
True
)
app_name
=
Required
(
str
,
max_len
=
200
)
app_version
=
Optional
(
str
,
default
=
""
)
app_url
=
Optional
(
str
,
default
=
""
)
category
=
Optional
(
str
,
default
=
""
)
app_icon
=
Optional
(
"Annex"
,
reverse
=
"app_icon"
,
cascade_delete
=
True
)
app_desc
=
Optional
(
str
,
default
=
""
)
app_annex
=
Set
(
"Annex"
,
reverse
=
"app"
,
cascade_delete
=
True
)
app_user
=
Optional
(
"AppUser"
,
reverse
=
"app"
,
cascade_delete
=
True
)
app_build_log
=
Set
(
"BuildLogs"
,
reverse
=
"app"
,
cascade_delete
=
True
)
app_download
=
Set
(
"AppDownload"
,
reverse
=
"app"
,
cascade_delete
=
True
)
create_at
=
Required
(
datetime
,
default
=
datetime
.
now
)
create_by
=
Required
(
"User"
,
reverse
=
'apps_creator'
)
# BuildLogs与User一对一关系
update_at
=
Required
(
datetime
,
default
=
datetime
.
now
)
update_by
=
Required
(
"User"
,
reverse
=
'apps_updater'
)
# BuildLogs与User一对一关系
delete_at
=
Optional
(
datetime
)
delete_by
=
Optional
(
"User"
,
reverse
=
'apps_deleter'
)
# BuildLogs与User一对一关系
is_delete
=
Required
(
bool
,
default
=
False
)
sort
=
Optional
(
int
,
size
=
32
,
default
=
0
)
\ No newline at end of file
backend/view/download.py
View file @
5e559b46
...
...
@@ -59,7 +59,8 @@ def get():
if
os
.
path
.
exists
(
result
):
with
open
(
result
,
"rb"
)
as
f
:
ret
=
f
.
read
()
return
ret
return
ret
return
response_result
(
ResponseCode
.
SERVER_ERROR
,
msg
=
"file not found:
%
s"
%
""
)
except
Exception
as
e
:
traceback
.
print_exc
()
logger
.
error
(
str
(
e
))
...
...
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