Commit 43b47139 authored by 张永's avatar 张永

alpha渠道打包

parent 6c65e5d9
This diff is collapsed.
...@@ -15,4 +15,5 @@ git+ssh://git@git.wanmeizhensuo.com/system/gm-tracer.git@v0.1.2 ...@@ -15,4 +15,5 @@ git+ssh://git@git.wanmeizhensuo.com/system/gm-tracer.git@v0.1.2
git+ssh://git@git.wanmeizhensuo.com/alpha/alpha-types.git@master git+ssh://git@git.wanmeizhensuo.com/alpha/alpha-types.git@master
filetype==1.0.2 filetype==1.0.2
Pillow==5.4.1 Pillow==5.4.1
celery==4.2.1 celery==4.2.1
\ No newline at end of file requests==2.21.0
\ No newline at end of file
...@@ -158,4 +158,9 @@ OPERATOR_PASSWORD = 123456 ...@@ -158,4 +158,9 @@ OPERATOR_PASSWORD = 123456
# 图片下载的存储路径 # 图片下载的存储路径
DOWNLOAD_IMAGE_PATH = u'/data/header-images/' DOWNLOAD_IMAGE_PATH = u'/data/header-images/'
# # apk 七牛上传空间
APK_SCOPE = 'download'
APK_DOMAIN = 'http://dl.igengmei.com/'
DEFAULT_CHANNEL = 'benzhan'
APK_RELEASE_DIR = 'sun'
APK_BUILD_DIR = 'sun_build'
from celery import shared_task from celery import shared_task
from django.conf import settings
import requests
from gm_upload.utils.qiniu_tool import QiniuTool
from middleware.rpc import rpc_invoker from middleware.rpc import rpc_invoker
from utils.channel_package_tools import ChannelPackage from utils.channel_package_tools import ChannelPackage
from utils.logger import log_error from utils.logger import log_error, info_logger
@shared_task @shared_task
def version_release_task(packed_channels): # 一键发布,发布完成邮件通知 def version_release_task(packed_channels, version_id=None, version=None): # 一键发布,发布完成邮件通知
rpc = rpc_invoker rpc = rpc_invoker
channels = [] version = version
for vtc in packed_channels: channel_ids = list()
version = vtc['version'] for version2channel in packed_channels:
channel = vtc['channel'] channel = version2channel['url_name']
vtc_id = vtc['id'] channel_ids.append(version2channel.get('id'))
try: try:
ChannelPackage.publish_apk(channel, version) ChannelPackage.publish_apk(channel, version)
rpc['endpoint'](version_id=vtc_id).unwrap()
channels.append(channel)
except: except:
log_error() log_error()
raise raise Exception('发布失败')
# send email # 发布
rpc.origin['hera/channelbuild/version_release_notify']( rpc['sun/channel_build/version/release'](
version=version, version_id=version_id, channel_ids=channel_ids
channels=channels,
).unwrap() ).unwrap()
# email notify
# rpc.origin['endpoint'](version=version, channels=channels).unwrap()
@shared_task
def channel_build_one(version=None, channel=None, data=None):
url = ChannelPackage.apk_url('', version)
r = requests.get(url)
chn_pkg = ChannelPackage(r.content, version)
build_one_channel(chn_pkg, channel)
@shared_task
def channel_build(version=None, channels=None, data=None):
url = ChannelPackage.apk_key('', version)
QiniuTool.delete(url, settings.APK_SCOPE)
QiniuTool.upload(data, url, settings.APK_SCOPE)
if channels is None:
channels = [settings.DEFAULT_CHANNEL]
elif settings.DEFAULT_CHANNEL not in channels:
channels.append(settings.DEFAULT_CHANNEL)
info_logger.debug(channels)
chn_pkg = ChannelPackage(data, version)
# 遍历渠道号并创建对应渠道号的apk文件
for channel in channels:
build_one_channel(chn_pkg, channel)
def build_one_channel(pkg_obj, channel):
info_logger.debug(channel)
if not channel:
return
channel = channel.strip()
ret = pkg_obj.upload_apk(channel)
info_logger.debug(ret)
if 'file' in ret:
# TODO 打包
rpc_invoker['endpoint'](
version=pkg_obj.version, channel=channel
).unwrap()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment