Commit f09e993d by sikang

update

parent 724292b0
# -*-coding:utf-8-*-
from utils import Utils
import random
import sys
import os
import re
class BuildConfig:
# 随机生成包名
@staticmethod
def new_appid(app_name):
app_name = app_name.replace(" ", "").lower()
start_name = ["com", "cn", "id", "app", "host", "in"]
middle_name = ["android", "main", "home", "base", "play", "release", "full", "kredit", "cepat",
"saku", "wallet", "coin", "loan", "flash", "pjnm", "indo", "lib"]
# start
pkg_name = start_name[random.randint(
0, len(start_name) - 1)] + "." + app_name
# middle
length = random.randint(1, 3)
for i in range(0, length):
pkg_name += "." + \
middle_name[random.randint(0, len(middle_name) - 1)]
# end
random_str = ''.join(random.sample(
"abcdefghijklmnopqrstuvwxyz", random.randint(4, 8)))
pkg_name += "." + random_str
return pkg_name
# 加载shell变量
@staticmethod
def load_properties(path):
with open(path, "r", encoding="utf-8") as f:
lines = f.readlines()
config = {}
for line in lines:
if "=" in line:
key = Utils.clearStr(line.split("=")[0], ["\"", "\'", "\n"])
value = Utils.clearStr(line.split("=")[1], ["\"", "\'", "\n"])
config[key] = value
return config
# 创建签名文件
@staticmethod
def new_keystore(config):
# 只保留最近10个签名
count = 0
for root, dirs, files in os.walk(config['jks_path']):
for name in files:
count += 1
if count > 10:
os.remove(os.path.join(root, name))
# 创建签名文件
key_name = config['app_name'].replace(" ", "")+config['version_code']
command = "keytool -genkey" + " -alias <key_name> -keypass <key_name> -storepass <key_name>" \
+ " -dname \"CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown\"" \
+ " -keyalg RSA -validity 20000 -keystore <path>/<key_name>.keystore"
command = command.replace("<key_name>", key_name).replace(
"<path>", config["jks_path"])
os.system(command)
# 更新签名配置
jks_path = "%s/%s.keystore" % (config["jks_path"], key_name)
reset = {
"signing_keyAlias": key_name,
"signing_certificate": jks_path,
"signging_certificatePassword": key_name,
"signging_storePassword": key_name,
}
BuildConfig.update_properties(config, reset)
# 更新properties字段
@staticmethod
def update_properties(config, dict):
file_content = ""
replace_line = {}
with open(config['properties'], "r", encoding="utf-8") as f:
file_content = f.read()
for key in dict.keys():
info = re.compile(r''+key+"=(.*)\n")
targetLine = info.search(file_content).group()
newLine = "%s=%s\n" % (key, dict[key])
replace_line[targetLine] = newLine
for key in replace_line.keys():
print(replace_line[key])
file_content = file_content.replace(key, replace_line[key])
with open(config['properties'], "w", encoding="utf-8") as f_w:
f_w.write(file_content)
This diff is collapsed. Click to expand it.
# -*-coding:utf-8-*- # -*-coding:utf-8-*-
from config import BuildConfig from func import Function
from shell import Shell from shell import Shell
import os import os
import shutil import shutil
#properties 配置 # properties 配置
config = BuildConfig.load_properties("../../gradle.properties") config = Function.load_properties("../../gradle.properties")
config['root'] = "../.." config['root'] = "../.."
config['jks_path'] = "../../jks" config['jks_path'] = "../../jks"
config['properties'] = "../../gradle.properties" config['properties'] = "../../gradle.properties"
...@@ -19,39 +19,53 @@ print("3、创建新的签名文件") ...@@ -19,39 +19,53 @@ print("3、创建新的签名文件")
print("4、commit & push project") print("4、commit & push project")
print("5、pull lib_base & cash_plugin_toolbox") print("5、pull lib_base & cash_plugin_toolbox")
print("6、commit & push lib_base") print("6、commit & push lib_base")
print("7、获取签名秘钥散列")
print("8、提交一个渠道包Tag") print("8、提交一个渠道包Tag")
print("11、copy apk") print("11、copy apk")
print("12、马甲包切换")
print("13、打印checklist")
print("14、生成隐协议文件")
print("15、刷新本地协议")
commod = int(input("请输入指令编号:")) command = int(input("请输入指令编号:"))
#命令 # 命令
if commod == 2: if command == 2:
app_name = BuildConfig.new_appid(config['app_name']) app_name = Function.new_appid(config['app_name'])
print(app_name) print(app_name)
elif commod == 3: elif command == 3:
BuildConfig.new_keystore(config) Function.new_keystore(config)
elif commod == 4: elif command == 4:
Shell.push_project(config) Shell.push_project(config)
elif commod == 5: elif command == 5:
Shell.pull_base(config) Shell.pull_base(config)
elif commod == 6: elif command == 6:
Shell.push_base(config) Shell.push_base(config)
elif commod == 8: elif command == 7:
Function.getFbSign(config)
elif command == 8:
Shell.push_with_tag(config) Shell.push_with_tag(config)
elif commod == 11: elif command == 11:
file_name="%s_%s" % (config['corp_id'], config['app_name']) Function.move_apk(config)
apk_local = "%s/resGuardApks/%s.apk" % (config['root'], file_name)
apk1 = "/Users/connor/Documents/apks/%s.apk" % file_name elif command == 12:
apk2 = "/Users/connor/Documents/apks/%s/%s.apk" % (file_name, file_name) Function.cutover(config)
if os.path.exists("/Users/connor/Documents/apks/%s" % file_name): elif command == 13 or command == 133:
shutil.copy(apk_local, apk2) if command == 133:
Function.print_checklist(config, True)
else: else:
shutil.copy(apk_local, apk1) Function.print_checklist(config, False)
elif command == 14:
Function.new_privacy(config)
elif command == 15:
Function.update_local_privacy(config)
# -*-coding:utf-8-*-
import os
import sys
import random
from PIL import Image, ImageDraw, ImageFont
class ScreenMaker:
text = [
"Mudah Diajukan\n Pengisian Data Tidak Rumit",
"Tidak bisa menyelesaikan masalah?\nKhawatir tentang masalah pendanaan?",
"Pinjaman Dana Santai\n Cepat Masuk dalam Rekening",
"Isi informasi dengan mudah dan\nkeluar dari hutan dengan cepat",
"Memberikan anda layanan \n pinjaman berkualitas",
"Membantu Anda mengatasi\n kesulitan keuangan",
"Aliran Dana Untuk Anda\n Uangmu Tercukupi Di Sini",
"Pinjaman Semakin Nyaman\n Kangan Ragu! Unduh APPnya",
"Ambil Keberuntungan Kamu\n Bersama Kami Duitmu Beres",
"Membantu Anda keluar dari masalah\n dan menyelesaikan kesulitan keuangan",
"Hadir Utk Area Indonesia\n Layanan Pelanggan Sapa Ramah"
]
def draw_bg(self, bg_path, logo_path, top_path, output):
img_bg = Image.open(bg_path)
img_logo = Image.open(logo_path)
img_top = Image.open(top_path)
text_h = random.randint(0, 1400)
logo_h = random.randint(0, 1400)
top_h = random.randint(0, 1400)
text_index = random.randint(0, len(self.text)-1)
while abs(logo_h - text_h) < 400 or abs(top_h - text_h) < 400:
logo_h = random.randint(0, 1400)
top_h = random.randint(0, 1400)
# 添加背景
new_img = Image.new(
'RGBA', (img_bg.size[0] * 2, img_bg.size[1]), (0, 0, 0, 0))
new_img.paste(img_bg, (0, 0))
new_img.paste(img_bg, (img_bg.size[0], 0))
img_logo = img_logo.resize((300, 300), Image.ANTIALIAS)
img_top = img_top.resize((700, 342), Image.ANTIALIAS)
# logo随机位置
new_img.paste(img_logo, (random.randint(
0, 700), logo_h), mask=img_logo)
new_img.paste(img_top, (1080, top_h))
# 字体随机大小
font_size = random.randint(120, 180)
font = ImageFont.truetype('Arial.ttf', font_size)
# 添加字体
new_img = new_img.convert('RGBA')
img_text = Image.new('RGBA', new_img.size, (255, 255, 255, 0))
image_draw = ImageDraw.Draw(img_text)
image_draw.text((random.randint(0, 300), text_h),
self.text[text_index], font=font, fill="#FFFFFF")
bg_with_text = Image.alpha_composite(new_img, img_text)
# 裁切图片
screen1 = bg_with_text.crop((0, 0, img_bg.size[0], img_bg.size[1]))
screen2 = bg_with_text.crop(
(img_bg.size[0], 0, img_bg.size[0]*2, img_bg.size[1]))
screen1.save(output+"/screen1.png", "PNG")
screen2.save(output+"/screen2.png", "PNG")
...@@ -45,8 +45,7 @@ andResGuard { ...@@ -45,8 +45,7 @@ andResGuard {
// finalApkBackupPath = "${project.rootDir}/final.apk" // finalApkBackupPath = "${project.rootDir}/final.apk"
android.applicationVariants.all { variant -> android.applicationVariants.all { variant ->
variant.outputs.all { variant.outputs.all {
def appName = "${app_name}".replace(" ","-") finalApkBackupPath = "${project.rootDir}/resGuardApks/${corp_id}_${app_name}_${variant.buildType.name}.apk".replace(" ","_").replace("\'","")
finalApkBackupPath = "${project.rootDir}/resGuardApks/${appName}_${variant.buildType.name}.apk"
} }
} }
......
...@@ -71,7 +71,7 @@ def create_config(read_path, write_path): ...@@ -71,7 +71,7 @@ def create_config(read_path, write_path):
f_w.write(line) f_w.write(line)
output = "/Users/connor/Documents/apks/" + sys.argv[5] + "_" + sys.argv[1]; output = "/Users/connor/Documents/apks/" + sys.argv[5] + "_" + sys.argv[1]
if not os.path.exists(output): if not os.path.exists(output):
os.makedirs(output) os.makedirs(output)
......
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