Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
sun
Commits
6c65e5d9
Commit
6c65e5d9
authored
Feb 16, 2019
by
张永
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
19754200
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
161 additions
and
7 deletions
+161
-7
channel_build.py
api/channel_build.py
+132
-7
requirements.txt
requirements.txt
+2
-0
channel_task.py
utils/channel_task.py
+27
-0
No files found.
api/channel_build.py
View file @
6c65e5d9
...
...
@@ -4,6 +4,7 @@ from helios.rpc.exceptions import RPCFaultException
from
utils.base
import
APIView
from
utils.channel_package_tools
import
ChannelPackage
from
utils.logger
import
error_logger
from
utils.channel_task
import
version_release_task
class
Vendor
(
APIView
):
...
...
@@ -15,10 +16,10 @@ class Vendor(APIView):
"""
query
=
request
.
GET
.
get
(
'q'
,
''
)
page
=
int
(
request
.
GET
.
get
(
'page'
,
1
))
limit
=
int
(
request
.
GET
.
get
(
'limi
t'
,
30
))
offset
=
int
(
request
.
GET
.
get
(
'offse
t'
,
30
))
data
=
request
.
rpc
.
origin
[
'endpoint'
](
query
=
query
,
page
=
page
,
limit
=
limit
,
query
=
query
,
start
=
(
page
-
1
)
*
offset
,
offset
=
offset
)
.
unwrap
()
return
data
...
...
@@ -31,10 +32,12 @@ class ChannelList(APIView):
:return:
"""
page
=
int
(
request
.
GET
.
get
(
'page'
,
1
))
limi
t
=
int
(
request
.
GET
.
get
(
'limit'
,
10
))
offse
t
=
int
(
request
.
GET
.
get
(
'limit'
,
10
))
filters
=
self
.
handle_filter
(
request
.
GET
.
get
(
'filter'
,
""
))
try
:
channel_list
=
self
.
rpc
[
'endpoint'
](
offset
=
(
page
-
1
)
*
limit
,
limit
=
limit
,
filters
=
filters
)
.
unwrap
()
channel_list
=
self
.
rpc
[
'endpoint'
](
start
=
(
page
-
1
)
*
offset
,
offset
=
offset
,
filters
=
filters
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'获取渠道列表失败:
%
s'
,
e
)
raise
e
...
...
@@ -99,6 +102,7 @@ class Channel(APIView):
)
.
unwrap
()
except
RPCFaultException
as
e
:
raise
e
return
self
.
write_success
(
message
=
'操作成功'
,
data
=
{})
else
:
# 创建渠道信息
try
:
self
.
rpc
[
'endpoint'
](
...
...
@@ -106,6 +110,7 @@ class Channel(APIView):
)
.
unwrap
()
except
RPCFaultException
as
e
:
raise
e
return
self
.
write_success
(
message
=
'操作成功'
,
data
=
{})
class
ChannelPacked
(
APIView
):
...
...
@@ -147,13 +152,133 @@ class ChannelPacked(APIView):
error_logger
.
error
(
u'参数不完整'
)
return
self
.
write_fail
(
code
=
ERROR
.
ARG_MISS
,
message
=
'参数不完整'
)
version2channel
=
self
.
rpc
[
'endpoint'
](
id
=
version2channel_id
)
.
unwrap
()
# get
# get version-channel object
version2channel
=
self
.
rpc
[
'endpoint'
](
id
=
version2channel_id
)
.
unwrap
()
version
=
version2channel
[
'version'
]
channel
=
version2channel
[
'channel'
]
ChannelPackage
.
publish_apk
(
channel
,
version
)
try
:
self
.
rpc
[
'endpoint'
](
id
=
version2channel_id
)
.
unwrap
()
#
edit
self
.
rpc
[
'endpoint'
](
id
=
version2channel_id
)
.
unwrap
()
#
发布完成 修改状态
except
RPCFaultException
as
e
:
error_logger
.
error
(
u'
获取渠道打包列表
失败:
%
s'
,
e
)
error_logger
.
error
(
u'
发布
失败:
%
s'
,
e
)
return
self
.
write_fail
(
code
=-
1
,
message
=
'发布失败!'
)
return
self
.
write_success
(
data
=
{},
message
=
'发布成功!'
)
class
VersionPackedChannel
(
APIView
):
def
get
(
self
,
request
):
"""
当前版本所有已打包渠道列表
:param request:
:return:
"""
version_id
=
request
.
GET
.
get
(
'version__id'
,
''
)
page
=
int
(
request
.
GET
.
get
(
'page'
,
1
))
offset
=
int
(
request
.
GET
.
get
(
'offset'
,
10
))
if
version_id
:
version
=
self
.
rpc
[
'endpoint'
](
version_id
=
version_id
)
.
unwrap
()
# 母包地址 由七牛上传返回
base_apk_url
=
ChannelPackage
.
apk_url
(
channel
=
''
,
version
=
version
[
'version'
])
else
:
base_apk_url
=
''
version
=
{}
version2channels
=
self
.
rpc
[
'endpoint'
](
version_id
=
version
,
start
=
(
page
-
1
)
*
offset
,
offset
=
offset
)
.
unwrap
()
data
=
{
'version'
:
[{
'version'
:
item
.
get
(
'version'
),
'name'
:
item
.
get
(
'name'
),
'packed_time'
:
item
.
get
(
'packed_time'
),
'download_url'
:
''
,
'release_time'
:
item
.
get
(
'release_time'
),
'is_released'
:
item
.
get
(
'is_released'
),
}
for
item
in
version2channels
],
'base_apk_url'
:
base_apk_url
,
}
return
self
.
write_success
(
data
=
data
)
class
VersionList
(
APIView
):
def
get
(
self
,
request
):
"""
所有版本列表
:param request:
:return:
"""
page
=
int
(
request
.
GET
.
get
(
'page'
,
1
))
offset
=
int
(
request
.
GET
.
get
(
'offset'
,
10
))
filters
=
self
.
handle_filter
(
request
.
GET
.
get
(
'filter'
,
""
))
try
:
version_list
=
self
.
rpc
[
'endpoint'
](
start
=
(
page
-
1
)
*
offset
,
offset
=
offset
,
filters
=
filters
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'获取版本列表失败:
%
s'
,
e
)
raise
e
data
=
[
{
'version'
:
item
.
get
(
'version'
),
'MD5'
:
item
.
get
(
'MD5'
),
'release_time'
:
item
.
get
(
'release_time'
),
}
for
item
in
version_list
]
return
self
.
write_success
(
data
=
data
)
class
VersionDetailUpdate
(
APIView
):
def
get
(
self
,
request
):
"""
版本详情
:param request:
:return:
"""
version_id
=
request
.
GET
.
get
(
'version_id'
)
if
not
version_id
:
error_logger
.
error
(
u'参数不完整'
)
return
self
.
write_fail
(
code
=
ERROR
.
ARG_MISS
,
message
=
'参数不完整'
)
version_info
=
self
.
rpc
[
'endpoint'
](
version_id
=
version_id
)
.
unwrap
()
data
=
{
'version'
:
version_info
[
'version'
],
'release_time'
:
version_info
[
'release_time'
],
'md5'
:
version_info
[
'md5'
],
'description'
:
version_info
[
'description'
],
}
return
self
.
write_success
(
data
=
data
,
message
=
'操作成功'
)
def
post
(
self
,
request
):
"""
版本信息编辑 只允许修改描述
:param request:
:return:
"""
version_id
=
request
.
POST
.
get
(
'version_id'
)
desc
=
request
.
POST
.
get
(
'desc'
)
if
not
version_id
:
error_logger
.
error
(
u'参数不完整'
)
return
self
.
write_fail
(
code
=
ERROR
.
ARG_MISS
,
message
=
'参数不完整'
)
try
:
self
.
rpc
[
'endpoint'
](
version_id
=
version_id
,
description
=
desc
)
except
RPCFaultException
as
e
:
error_logger
.
error
(
e
)
return
self
.
write_fail
(
code
=-
1
,
message
=
'操作失败'
)
return
self
.
write_success
(
data
=
{},
message
=
'操作成功'
)
class
BatchPublishVersion
(
APIView
):
def
post
(
self
,
request
):
"""
批量发布 并邮件通知
:param request:
:return:
"""
version_id
=
request
.
POST
.
get
(
'version_id'
)
if
not
version_id
:
error_logger
.
error
(
u'参数不完整'
)
return
self
.
write_fail
(
code
=
ERROR
.
ARG_MISS
,
message
=
'参数不完整'
)
try
:
packed_channels
=
self
.
rpc
[
'endpoint'
](
version_id
=
version_id
)
.
unwrap
()
except
RPCFaultException
as
e
:
error_logger
.
error
(
u'获取渠道失败
%
s'
,
e
)
return
self
.
write_fail
(
code
=-
1
,
message
=
'获取渠道失败!'
)
version_release_task
.
delay
(
packed_channels
)
return
self
.
write_success
(
data
=
{},
message
=
'操作成功'
)
requirements.txt
View file @
6c65e5d9
...
...
@@ -15,3 +15,4 @@ git+ssh://git@git.wanmeizhensuo.com/system/gm-tracer.git@v0.1.2
git+ssh://git@git.wanmeizhensuo.com/alpha/alpha-types.git@master
filetype
==1.0.2
Pillow
==5.4.1
celery
==4.2.1
\ No newline at end of file
utils/channel_task.py
0 → 100644
View file @
6c65e5d9
from
celery
import
shared_task
from
middleware.rpc
import
rpc_invoker
from
utils.channel_package_tools
import
ChannelPackage
from
utils.logger
import
log_error
@shared_task
def
version_release_task
(
packed_channels
):
# 一键发布,发布完成邮件通知
rpc
=
rpc_invoker
channels
=
[]
for
vtc
in
packed_channels
:
version
=
vtc
[
'version'
]
channel
=
vtc
[
'channel'
]
vtc_id
=
vtc
[
'id'
]
try
:
ChannelPackage
.
publish_apk
(
channel
,
version
)
rpc
[
'endpoint'
](
version_id
=
vtc_id
)
.
unwrap
()
channels
.
append
(
channel
)
except
:
log_error
()
raise
# send email
rpc
.
origin
[
'hera/channelbuild/version_release_notify'
](
version
=
version
,
channels
=
channels
,
)
.
unwrap
()
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