mainPalio3.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. import time
  2. from flask import Flask, request
  3. import requests
  4. from PIL import ImageFile, Image
  5. import os
  6. import shutil
  7. import subprocess
  8. from zipfile import ZipFile
  9. ImageFile.SAFEBLOCK = 2048 * 2048
  10. app = Flask(__name__)
  11. app.base_project = "/apps/3ps/build_apk/PalioLite"
  12. # app.base_project = "/Users/easysoft/Documents/PalioLite"
  13. app.temp_folder = "/apps/3ps/build_apk/BuildApk"
  14. # app.temp_folder = "/Users/easysoft/BuildApk"
  15. app.apk_folder = "/var/www/html/palio.io/dashboardv2/uploads"
  16. # app.apk_folder = "/Users/easysoft/"
  17. app.verbose = True
  18. app.ssl =('/etc/ssl/star.newuniverse.io/star.newuniverse.io.crt', '/etc/ssl/star.newuniverse.io/STAR_newuniverse_io.key')
  19. #app.ssl =('/etc/ssl/STAR_palio_io/STAR_palio_io.crt', '/etc/ssl/STAR_palio_io/STAR_palio_io.pem')
  20. # app.ssl = None
  21. app.keytool = '/usr/bin/keytool'
  22. app.base_project_name = os.path.basename(app.base_project)
  23. def vprint(*data):
  24. if app.verbose:
  25. print(*data)
  26. def create_folder(package_id):
  27. path = os.path.join(app.temp_folder, package_id)
  28. if not os.path.exists(path):
  29. os.mkdir(path)
  30. else:
  31. shutil.rmtree(path)
  32. os.mkdir(path)
  33. vprint(path)
  34. path_dest = os.path.join(path, app.base_project_name)
  35. if not os.path.exists(path_dest):
  36. shutil.copytree(app.base_project, path_dest)
  37. code_path = "app/src/main/java/"
  38. orig_code = "com/example/qmeralitesamplecode"
  39. path_package_id = package_id.replace(".", "/")
  40. c_code_path = os.path.join(path_dest, code_path, path_package_id)
  41. orig_code_path = os.path.join(path_dest, code_path, orig_code)
  42. if not os.path.exists(c_code_path):
  43. shutil.copytree(orig_code_path, c_code_path)
  44. shutil.rmtree(orig_code_path)
  45. return path_dest, c_code_path
  46. def change_acc(c_code_path, acc):
  47. main_activity = os.path.join(c_code_path, "MainActivity.java")
  48. with open(main_activity, "r") as f:
  49. file_source = f.read()
  50. replaced = file_source.replace("***REPLACE***WITH***YOUR***QMERA***ACCOUNT***", acc)
  51. with open(main_activity, "w") as f:
  52. f.write(replaced)
  53. def change_url(c_code_path, url):
  54. main_activity = os.path.join(c_code_path, "MainActivity.java")
  55. with open(main_activity, "r") as f:
  56. file_source = f.read()
  57. replaced = file_source.replace("https://www.google.com", url)
  58. with open(main_activity, "w") as f:
  59. f.write(replaced)
  60. def change_name(path_dest, name):
  61. manifest = os.path.join(path_dest, "app/src/main/AndroidManifest.xml")
  62. string_res = os.path.join(path_dest, "app/src/main/res/values/strings.xml")
  63. with open(manifest, "r") as f:
  64. file_source = f.read()
  65. replaced = file_source.replace("NexilisLite", name)
  66. with open(manifest, "w") as f:
  67. f.write(replaced)
  68. with open(string_res, "r") as f:
  69. file_source = f.read()
  70. replaced = file_source.replace("Nexilis Sport", name)
  71. with open(string_res, "w") as f:
  72. f.write(replaced)
  73. def change_font(path_dest, font, package):
  74. if font == 1:
  75. path_package_id = package.replace(".", "/")
  76. code_path = "app/src/main/java/"
  77. code_path = os.path.join(path_dest, code_path, path_package_id)
  78. res_path = "app/src/main/res/"
  79. res_path = os.path.join(path_dest, res_path)
  80. javas = [os.path.join(dp, f) for dp, dn, filenames in os.walk(code_path) for f in filenames]
  81. res = [os.path.join(dp, f) for dp, dn, filenames in os.walk(res_path) for f in filenames if "xml" in f]
  82. button_apps_code_path = os.path.join(path_dest, "palio-button-app/src/main/java")
  83. button_apps_res_path = os.path.join(path_dest, "palio-button-app/src/main/res-pba/")
  84. lib_javas = [os.path.join(dp, f) for dp, dn, filenames in os.walk(button_apps_code_path) for f in filenames]
  85. lib_res = [os.path.join(dp, f) for dp, dn, filenames in os.walk(button_apps_res_path) for f in filenames if "xml" in f]
  86. for j in javas:
  87. print(j)
  88. if "ForumFragment.java" in j:
  89. with open(j, "r") as f:
  90. file_source = f.read()
  91. replaced = file_source.replace("pb_poppins", "roboto")
  92. with open(j, "w") as f:
  93. f.write(replaced)
  94. for j in res:
  95. print(j)
  96. with open(j, "r") as f:
  97. file_source = f.read()
  98. replaced = file_source.replace("pb_poppins", "roboto")
  99. with open(j, "w") as f:
  100. f.write(replaced)
  101. for j in lib_javas:
  102. print(j)
  103. with open(j, "r") as f:
  104. file_source = f.read()
  105. replaced = file_source.replace("pb_poppins", "roboto")
  106. with open(j, "w") as f:
  107. f.write(replaced)
  108. for j in lib_res:
  109. print(j)
  110. with open(j, "r") as f:
  111. file_source = f.read()
  112. replaced = file_source.replace("pb_poppins", "roboto")
  113. with open(j, "w") as f:
  114. f.write(replaced)
  115. def change_package(path_dest, package):
  116. build_gradle = os.path.join(path_dest, 'app/build.gradle')
  117. with open(build_gradle, "r") as f:
  118. file_source = f.read()
  119. replaced = file_source.replace("com.example.qmeralitesamplecode", package)
  120. with open(build_gradle, "w") as f:
  121. f.write(replaced)
  122. proguard = os.path.join(path_dest, 'app/proguard-rules.pro')
  123. with open(proguard, "r") as f:
  124. file_source = f.read()
  125. replaced = file_source.replace("com.example.qmeralitesamplecode", package)
  126. with open(proguard, "w") as f:
  127. f.write(replaced)
  128. manifest = os.path.join(path_dest, "app/src/main/AndroidManifest.xml")
  129. with open(manifest, "r") as f:
  130. file_source = f.read()
  131. replaced = file_source.replace("com.example.qmeralitesamplecode", package)
  132. with open(manifest, "w") as f:
  133. f.write(replaced)
  134. path_package_id = package.replace(".", "/")
  135. code_path = "app/src/main/java/"
  136. code_path = os.path.join(path_dest, code_path, path_package_id)
  137. res_path = "app/src/main/res/"
  138. res_path = os.path.join(path_dest, res_path)
  139. javas = [os.path.join(dp, f) for dp, dn, filenames in os.walk(code_path) for f in filenames]
  140. res = [os.path.join(dp, f) for dp, dn, filenames in os.walk(res_path) for f in filenames if "xml" in f]
  141. for j in javas:
  142. print(j)
  143. with open(j, "r") as f:
  144. file_source = f.read()
  145. replaced = file_source.replace("com.example.qmeralitesamplecode", package)
  146. with open(j, "w") as f:
  147. f.write(replaced)
  148. for j in res:
  149. print(j)
  150. with open(j, "r") as f:
  151. file_source = f.read()
  152. replaced = file_source.replace("com.example.qmeralitesamplecode", package)
  153. with open(j, "w") as f:
  154. f.write(replaced)
  155. if package == "com.nexilis.persija" or package == "io.newuniverse.GoToMalls":
  156. string_res = os.path.join(path_dest, "app/src/main/res/values/strings.xml")
  157. string_en_res = os.path.join(path_dest, "app/src/main/res/values-en/strings.xml")
  158. string_id_res = os.path.join(path_dest, "app/src/main/res/values-in/strings.xml")
  159. with open(string_res, "r") as f:
  160. file_source = f.read()
  161. replaced = file_source.replace("Nexilis", "Qmera")
  162. with open(string_res, "w") as f:
  163. f.write(replaced)
  164. with open(string_en_res, "r") as f:
  165. file_source = f.read()
  166. replaced = file_source.replace("Nexilis", "Qmera")
  167. with open(string_en_res, "w") as f:
  168. f.write(replaced)
  169. with open(string_id_res, "r") as f:
  170. file_source = f.read()
  171. replaced = file_source.replace("Nexilis", "Qmera")
  172. with open(string_id_res, "w") as f:
  173. f.write(replaced)
  174. old_img_powered = "app/src/main/res/drawable/pb_powered_button.png"
  175. old_img_powered = os.path.join(path_dest, old_img_powered)
  176. old_new_img_powered = "app/src/main/res/drawable/pb_powered_button_temp.png"
  177. old_new_img_powered = os.path.join(path_dest, old_new_img_powered)
  178. shutil.move(old_img_powered, old_new_img_powered)
  179. img_powered = "app/src/main/res/drawable/pb_powered_button1.png"
  180. img_powered = os.path.join(path_dest, img_powered)
  181. new_img_powered = "app/src/main/res/drawable/pb_powered_button.png"
  182. new_img_powered = os.path.join(path_dest, new_img_powered)
  183. shutil.move(img_powered, new_img_powered)
  184. def change_logo(path_dest, logo, logo_float=None):
  185. img_path = "app/src/main/res/drawable/ic_launcher.png"
  186. img_path = os.path.join(path_dest, img_path)
  187. img_notif = "app/src/main/res/drawable-v24/pb_ball.png"
  188. img_notif = os.path.join(path_dest, img_notif)
  189. img_path_float = "app/src/main/res/drawable/pb_button.png"
  190. img_path_float = os.path.join(path_dest, img_path_float)
  191. if isinstance(logo, str):
  192. logo = requests.get('https://newuniverse.io/dashboardv2/uploads/logo/{}'.format(logo))
  193. with open(img_path, "wb") as f:
  194. f.write(logo.content)
  195. with open(img_path, "rb") as f:
  196. logo = Image.open(f)
  197. logo = logo.resize((512, 512))
  198. if logo_float:
  199. logo_float = requests.get('https://newuniverse.io/dashboardv2/uploads/logofloat/{}'.format(logo_float))
  200. with open(img_path_float, "wb") as f:
  201. f.write(logo_float.content)
  202. with open(img_path_float, "rb") as f:
  203. logo_float = Image.open(f)
  204. logo_float = logo_float.resize((150, 150))
  205. else:
  206. logo = Image.open(logo)
  207. logo = logo.resize((512, 512))
  208. if logo_float:
  209. logo_float = Image.open(logo_float)
  210. logo_float = logo_float.resize((150, 150))
  211. logo.save(img_path, "PNG")
  212. if logo_float:
  213. logo_float.save(img_path_float, "PNG")
  214. logo_float.save(img_notif, "PNG")
  215. def change_tab(path_dest, tabs, tab_icon, package, tab3_mode, tab_amount):
  216. default_tab_icon = ["tab1.png", "tab2.png", "tab3.png", "tab4.png"]
  217. for i in range(4):
  218. if not tab_icon[i]:
  219. continue
  220. img_path = "app/src/main/res/drawable-v24"
  221. img_path = os.path.join(path_dest, img_path, default_tab_icon[i])
  222. if isinstance(tab_icon[i], str):
  223. logo = requests.get('https://newuniverse.io/dashboardv2/uploads/tab_icon/{}'.format(tab_icon[i]))
  224. with open(img_path, "wb") as f:
  225. f.write(logo.content)
  226. with open(img_path, "rb") as f:
  227. logo = Image.open(f)
  228. logo = logo.resize((150, 150))
  229. logo.save(img_path, "PNG")
  230. else:
  231. logo = Image.open(tab_icon[i])
  232. logo = logo.resize((150, 150))
  233. logo.save(img_path, "PNG")
  234. path_package_id = package.replace(".", "/")
  235. code_path = "app/src/main/java/"
  236. sobj_code_path = os.path.join(path_dest, code_path, path_package_id, "SObj.java")
  237. print(sobj_code_path)
  238. with open(sobj_code_path, "r") as f:
  239. file_source = f.read()
  240. replaced = file_source.replace("1,2,3,4", ",".join(tabs))
  241. with open(sobj_code_path, "w") as f:
  242. f.write(replaced)
  243. main_code_path = os.path.join(path_dest, code_path, path_package_id, "MainActivity.java")
  244. with open(main_code_path, "r") as f:
  245. file_source = f.read()
  246. replaced = file_source.replace('tab3 = "0"', 'tab3 = "{}"'.format(tab3_mode))
  247. with open(main_code_path, "w") as f:
  248. f.write(replaced)
  249. prefs_code_path = os.path.join(path_dest, code_path, path_package_id, "util/PrefsUtil.java")
  250. with open(prefs_code_path, "r") as f:
  251. file_source = f.read()
  252. replaced = file_source.replace('DEFAULT_TAB_AMOUNT = "4"', 'DEFAULT_TAB_AMOUNT = "{}"'.format(tab_amount))
  253. with open(prefs_code_path, "w") as f:
  254. f.write(replaced)
  255. def change_fb(path_dest, fb_icon):
  256. default_fb_icon = ["pb_button_chat.png", "pb_button_call.png", "pb_button_cc.png", "pb_button_stream.png", "nexilis_fb_04.png"]
  257. for i in range(5):
  258. if not fb_icon[i]:
  259. continue
  260. img_path = "app/src/main/res/drawable-nodpi"
  261. img_path = os.path.join(path_dest, img_path, default_fb_icon[i])
  262. if isinstance(fb_icon[i], str):
  263. logo = requests.get('https://newuniverse.io/dashboardv2/uploads/fb_icon/{}'.format(fb_icon[i]))
  264. with open(img_path, "wb") as f:
  265. f.write(logo.content)
  266. with open(img_path, "rb") as f:
  267. logo = Image.open(f)
  268. logo = logo.resize((150, 150))
  269. logo.save(img_path, "PNG")
  270. else:
  271. logo = Image.open(fb_icon[i])
  272. logo = logo.resize((150, 150))
  273. logo.save(img_path, "PNG")
  274. def change_background(path_dest, background):
  275. if isinstance(background, str):
  276. background = background.split(",")
  277. for i,b in enumerate(background):
  278. n = i+1
  279. img_path = "app/src/main/res/drawable-nodpi-v4/pb_lbackground_{}.png".format(n)
  280. img_path = os.path.join(path_dest, img_path)
  281. logo = requests.get('https://newuniverse.io/dashboardv2/uploads/background/{}'.format(b))
  282. with open(img_path, "wb") as f:
  283. f.write(logo.content)
  284. with open(img_path, "rb") as f:
  285. logo = Image.open(f)
  286. logo = logo.resize((600, 1250))
  287. logo.save(img_path, "PNG")
  288. else:
  289. img_path = "app/src/main/res/drawable-nodpi-v4/pb_lbackground_1.png"
  290. logo = Image.open(background)
  291. logo = logo.resize((600, 1250))
  292. logo.save(img_path, "PNG")
  293. def change_access(path_dest, access_model, package):
  294. access = ["CPAAS_MODE_FLOATING", "CPAAS_MODE_DOCKED", "CPAAS_MODE_BURGER"]
  295. path_package_id = package.replace(".", "/")
  296. code_path = "app/src/main/java/"
  297. code_path = os.path.join(path_dest, code_path, path_package_id, "util", "PrefsUtil.java")
  298. print(code_path)
  299. with open(code_path, "r") as f:
  300. file_source = f.read()
  301. replaced = file_source.replace("= CPAAS_MODE_DOCKED", "= {}".format(access[access_model]))
  302. with open(code_path, "w") as f:
  303. f.write(replaced)
  304. pass
  305. def change_certificate(path_dest, key, keyfile, keytool):
  306. keyfile_name = "{}.keystore".format(key["alias"])
  307. keyfile_path = os.path.join(path_dest, keyfile_name)
  308. if keyfile:
  309. keyfile.save(keyfile_path)
  310. else:
  311. vprint("keytool run")
  312. os.chdir(path_dest)
  313. vprint("current working directory: ", os.getcwd())
  314. dname = "CN={}, OU={}, O={}, L={}, S={}, C={}".format(key["common_name"], key["organization_unit"],
  315. key["organization_name"], key["locality_name"],
  316. key["state_name"], key["country"])
  317. cmd = [keytool, "-genkey", "-v", "-keystore", keyfile_path, "-alias", key["alias"], "-keyalg", "RSA",
  318. "-keysize", "2048",
  319. "-validity", "10000", "-dname", dname, "-storepass", key["store_password"], "-keypass", key["key_password"]]
  320. vprint(cmd)
  321. subprocess.run(cmd)
  322. vprint("keytool end")
  323. build_gradle = os.path.join(path_dest, 'app/build.gradle')
  324. with open(build_gradle, "r") as f:
  325. file_source = f.read()
  326. replaced = file_source.replace("allyourbase", key["store_password"])
  327. replaced = replaced.replace("arebelongto", key["key_password"])
  328. replaced = replaced.replace("key-qmeralite", key["alias"])
  329. with open(build_gradle, "w") as f:
  330. f.write(replaced)
  331. def run_build(path_dest):
  332. gradlew = os.path.join(path_dest, "gradlew")
  333. ret = subprocess.run([gradlew, 'assembleRelease'])
  334. if ret.returncode == 0:
  335. ret = subprocess.run([gradlew, 'bundleRelease'])
  336. return ret.returncode
  337. def deliver_apk(path_dest, package_id, key, key_exists):
  338. apk_dir = os.path.join(path_dest, 'app/build/outputs/apk/release/app-release.apk')
  339. aab_dir = os.path.join(path_dest, 'app/build/outputs/bundle/release/app-release.aab')
  340. keystore_name = '{}.keystore'.format(key["alias"])
  341. keystore_dir = os.path.join(path_dest, keystore_name)
  342. timenow = time.time()
  343. apk_name = "{}{}.apk".format(package_id, timenow)
  344. aab_name = "{}{}.aab".format(package_id, timenow)
  345. zip_name = "{}{}.zip".format(package_id, timenow)
  346. new_apk_dir = os.path.join(app.apk_folder, apk_name)
  347. new_aab_dir = os.path.join(app.apk_folder, aab_name)
  348. new_dir = os.path.join(app.apk_folder, zip_name)
  349. vprint(apk_dir)
  350. try:
  351. shutil.move(apk_dir, new_apk_dir)
  352. shutil.move(aab_dir, new_aab_dir)
  353. with ZipFile(new_dir, 'w') as zip_file:
  354. zip_file.write(new_apk_dir, os.path.basename(new_apk_dir))
  355. zip_file.write(new_aab_dir, os.path.basename(new_aab_dir))
  356. if not key_exists:
  357. zip_file.write(keystore_dir, os.path.basename(keystore_dir))
  358. os.remove(new_apk_dir)
  359. os.remove(new_aab_dir)
  360. project_path = os.path.join(app.temp_folder, package_id)
  361. shutil.rmtree(project_path)
  362. return {"name": zip_name}
  363. except Exception as e:
  364. return str(e)
  365. def change_version(path_dest, version_code, version_name):
  366. build_gradle = os.path.join(path_dest, 'app/build.gradle')
  367. with open(build_gradle, "r") as f:
  368. file_source = f.read()
  369. replaced = file_source.replace("versionCode 3", "versionCode {}".format(version_code))
  370. replaced = replaced.replace('versionName "3.0"', 'versionName "{}"'.format(version_name))
  371. with open(build_gradle, "w") as f:
  372. f.write(replaced)
  373. @app.route('/', methods=["GET", "POST"])
  374. def build_apk():
  375. vprint('==============================================================')
  376. if request.method == 'POST':
  377. logo = None
  378. logo_float = None
  379. app_name = "NexilisLite"
  380. package_id = "com.app.nexilis"
  381. acc = None
  382. url = None
  383. keystore = None
  384. key_exists = False
  385. # tabs = ["1", "2", "3", "4"]
  386. tabs = []
  387. tab3_mode = "0"
  388. tab_icon = [None, None, None, None]
  389. fb_icon = [None, None, None, None, None]
  390. background = None
  391. version_code = "1"
  392. version_name = "1.0.0"
  393. font = 0
  394. tab_amount = 4
  395. key = {"alias": "nexilislite", "store_password": "allyourbase", "key_password": "arebelongto", "common_name": "all", "organization_unit": "your",
  396. "organization_name": "base", "locality_name": "are", "state_name": "belong", "country": "to"}
  397. if 'logo' in request.files:
  398. logo = request.files['logo']
  399. vprint(type(logo))
  400. elif 'logo' in request.form:
  401. logo = request.form['logo']
  402. vprint(type(logo))
  403. if 'logofloat' in request.files:
  404. logo_float = request.files['logofloat']
  405. vprint(type(logo_float))
  406. elif 'logofloat' in request.form:
  407. logo_float = request.form['logofloat']
  408. vprint(type(logo_float))
  409. if 'app_name' in request.files:
  410. app_name = request.files['app_name']
  411. vprint(app_name)
  412. elif 'app_name' in request.form:
  413. app_name = request.form['app_name']
  414. vprint(app_name)
  415. if 'package_id' in request.files:
  416. package_id = request.files['package_id']
  417. vprint(package_id)
  418. elif 'package_id' in request.form:
  419. package_id = request.form['package_id']
  420. vprint(package_id)
  421. if 'acc' in request.files:
  422. acc = request.files['acc']
  423. vprint(acc)
  424. elif 'acc' in request.form:
  425. acc = request.form['acc']
  426. vprint(acc)
  427. if 'url' in request.files:
  428. url = request.files['url']
  429. vprint(url)
  430. elif 'url' in request.form:
  431. url = request.form['url']
  432. vprint(url)
  433. if 'keystore' in request.files:
  434. keystore = request.files['keystore']
  435. key_exists = True
  436. elif 'keystore' in request.form:
  437. keystore = request.form['keystore']
  438. key_exists = True
  439. if 'alias' in request.form:
  440. if request.form['alias']:
  441. key["alias"] = request.form['alias']
  442. if 'store_password' in request.form:
  443. if request.form['store_password']:
  444. key["store_password"] = request.form['store_password']
  445. if 'key_password' in request.form:
  446. if request.form['key_password']:
  447. key["key_password"] = request.form['key_password']
  448. if keystore:
  449. if 'common_name' in request.form:
  450. if request.form['common_name']:
  451. key["common_name"] = request.form['common_name']
  452. if 'organization_unit' in request.form:
  453. if request.form['organization_unit']:
  454. key["organization_unit"] = request.form['organization_unit']
  455. if 'organization_name' in request.form:
  456. if request.form['organization_name']:
  457. key["organization_name"] = request.form['organization_name']
  458. if 'locality_name' in request.form:
  459. if request.form['locality_name']:
  460. key["locality_name"] = request.form['locality_name']
  461. if 'state_name' in request.form:
  462. if request.form['state_name']:
  463. key["state_name"] = request.form['state_name']
  464. if 'country' in request.form:
  465. if request.form['country']:
  466. key["country"] = request.form['country']
  467. tabs.append(request.form["tab1"])
  468. tabs.append(request.form["tab2"])
  469. if request.form['tab3']:
  470. tabs.append(request.form["tab3"])
  471. if request.form['tab4']:
  472. tabs.append(request.form["tab4"])
  473. if 'tab1_icon' in request.files:
  474. tab_icon[0] = request.files['tab1_icon']
  475. elif 'tab1_icon' in request.form:
  476. tab_icon[0] = request.form['tab1_icon']
  477. if 'tab2_icon' in request.files:
  478. tab_icon[1] = request.files['tab2_icon']
  479. elif 'tab2_icon' in request.form:
  480. tab_icon[1] = request.form['tab2_icon']
  481. if 'tab3_icon' in request.files:
  482. tab_icon[2] = request.files['tab3_icon']
  483. elif 'tab3_icon' in request.form:
  484. tab_icon[2] = request.form['tab3_icon']
  485. if 'tab4_icon' in request.files:
  486. tab_icon[3] = request.files['tab4_icon']
  487. elif 'tab4_icon' in request.form:
  488. tab_icon[3] = request.form['tab4_icon']
  489. if 'fb1_icon' in request.files:
  490. fb_icon[0] = request.files['fb1_icon']
  491. elif 'fb1_icon' in request.form:
  492. fb_icon[0] = request.form['fb1_icon']
  493. if 'fb2_icon' in request.files:
  494. fb_icon[1] = request.files['fb2_icon']
  495. elif 'fb2_icon' in request.form:
  496. fb_icon[1] = request.form['fb2_icon']
  497. if 'fb3_icon' in request.files:
  498. fb_icon[2] = request.files['fb3_icon']
  499. elif 'fb3_icon' in request.form:
  500. fb_icon[2] = request.form['fb3_icon']
  501. if 'fb4_icon' in request.files:
  502. fb_icon[3] = request.files['fb4_icon']
  503. elif 'fb4_icon' in request.form:
  504. fb_icon[3] = request.form['fb4_icon']
  505. if 'fb5_icon' in request.files:
  506. fb_icon[4] = request.files['fb5_icon']
  507. elif 'fb5_icon' in request.form:
  508. fb_icon[4] = request.form['fb5_icon']
  509. vprint("fb_icon: {}".format(fb_icon))
  510. access_model = int(request.form['access_model'])
  511. if 'tab3_mode' in request.form:
  512. tab3_mode = request.form['tab3_mode']
  513. if 'tab_amount' in request.form:
  514. tab_amount = int(request.form['tab_amount'])
  515. if 'font' in request.form:
  516. font = int(request.form['font'])
  517. if 'background' in request.files:
  518. background = request.files['background']
  519. elif 'background' in request.form:
  520. background = request.form['background']
  521. if 'version_code' in request.form:
  522. version_code = request.form['version_code']
  523. if 'version_name' in request.form:
  524. version_name = request.form['version_name']
  525. else:
  526. version_name = "1.0.{}".format(version_code)
  527. path_dest, c_code_path = create_folder(package_id)
  528. vprint("path_dest: " + path_dest)
  529. vprint("c_code_path: " + c_code_path)
  530. if acc:
  531. change_acc(c_code_path, acc)
  532. if url:
  533. change_url(c_code_path, url)
  534. change_name(path_dest, app_name)
  535. change_certificate(path_dest, key, keystore, app.keytool)
  536. change_package(path_dest, package_id)
  537. change_version(path_dest, version_code,version_name)
  538. change_font(path_dest, font, package_id)
  539. if logo:
  540. change_logo(path_dest, logo, logo_float)
  541. if background:
  542. change_background(path_dest, background)
  543. change_fb(path_dest, fb_icon)
  544. change_access(path_dest, access_model, package_id)
  545. change_tab(path_dest, tabs, tab_icon, package_id, tab3_mode, tab_amount)
  546. os.chdir(path_dest)
  547. return_code = run_build(path_dest)
  548. if (return_code == 0):
  549. return deliver_apk(path_dest, package_id, key, key_exists)
  550. return "h"
  551. else:
  552. if 'e' in request.args:
  553. return request.args['e']
  554. return "Hello World!"
  555. if __name__ == '__main__':
  556. app.run(host='0.0.0.0', port=8072, debug=app.verbose, ssl_context=app.ssl)