mainPalio.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  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. def change_logo(path_dest, logo, logo_float=None):
  156. img_path = "app/src/main/res/drawable/ic_launcher.png"
  157. img_path = os.path.join(path_dest, img_path)
  158. img_notif = "app/src/main/res/drawable-v24/pb_ball.png"
  159. img_notif = os.path.join(path_dest, img_notif)
  160. img_path_float = "app/src/main/res/drawable/pb_button.png"
  161. img_path_float = os.path.join(path_dest, img_path_float)
  162. if isinstance(logo, str):
  163. logo = requests.get('https://newuniverse.io/dashboardv2/uploads/logo/{}'.format(logo))
  164. with open(img_path, "wb") as f:
  165. f.write(logo.content)
  166. with open(img_path, "rb") as f:
  167. logo = Image.open(f)
  168. logo = logo.resize((512, 512))
  169. if logo_float:
  170. logo_float = requests.get('https://newuniverse.io/dashboardv2/uploads/logofloat/{}'.format(logo_float))
  171. with open(img_path_float, "wb") as f:
  172. f.write(logo_float.content)
  173. with open(img_path_float, "rb") as f:
  174. logo_float = Image.open(f)
  175. logo_float = logo_float.resize((150, 150))
  176. else:
  177. logo = Image.open(logo)
  178. logo = logo.resize((512, 512))
  179. if logo_float:
  180. logo_float = Image.open(logo_float)
  181. logo_float = logo_float.resize((150, 150))
  182. logo.save(img_path, "PNG")
  183. if logo_float:
  184. logo_float.save(img_path_float, "PNG")
  185. logo_float.save(img_notif, "PNG")
  186. def change_tab(path_dest, tabs, tab_icon, package, tab3_mode, tab_amount):
  187. default_tab_icon = ["tab1.png", "tab2.png", "tab3.png", "tab4.png"]
  188. for i in range(4):
  189. if not tab_icon[i]:
  190. continue
  191. img_path = "app/src/main/res/drawable-v24"
  192. img_path = os.path.join(path_dest, img_path, default_tab_icon[i])
  193. if isinstance(tab_icon[i], str):
  194. logo = requests.get('https://newuniverse.io/dashboardv2/uploads/tab_icon/{}'.format(tab_icon[i]))
  195. with open(img_path, "wb") as f:
  196. f.write(logo.content)
  197. with open(img_path, "rb") as f:
  198. logo = Image.open(f)
  199. logo = logo.resize((150, 150))
  200. logo.save(img_path, "PNG")
  201. else:
  202. logo = Image.open(tab_icon[i])
  203. logo = logo.resize((150, 150))
  204. logo.save(img_path, "PNG")
  205. path_package_id = package.replace(".", "/")
  206. code_path = "app/src/main/java/"
  207. sobj_code_path = os.path.join(path_dest, code_path, path_package_id, "SObj.java")
  208. print(sobj_code_path)
  209. with open(sobj_code_path, "r") as f:
  210. file_source = f.read()
  211. replaced = file_source.replace("1,2,3,4", ",".join(tabs))
  212. with open(sobj_code_path, "w") as f:
  213. f.write(replaced)
  214. main_code_path = os.path.join(path_dest, code_path, path_package_id, "MainActivity.java")
  215. with open(main_code_path, "r") as f:
  216. file_source = f.read()
  217. replaced = file_source.replace('tab3 = "0"', 'tab3 = "{}"'.format(tab3_mode))
  218. with open(main_code_path, "w") as f:
  219. f.write(replaced)
  220. prefs_code_path = os.path.join(path_dest, code_path, path_package_id, "util/PrefsUtil.java")
  221. with open(prefs_code_path, "r") as f:
  222. file_source = f.read()
  223. replaced = file_source.replace('DEFAULT_TAB_AMOUNT = "4"', 'DEFAULT_TAB_AMOUNT = "{}"'.format(tab_amount))
  224. with open(prefs_code_path, "w") as f:
  225. f.write(replaced)
  226. def change_fb(path_dest, fb_icon):
  227. default_fb_icon = ["pb_button_chat.png", "pb_button_call.png", "pb_button_cc.png", "pb_button_stream.png", "nexilis_fb_04.png"]
  228. for i in range(5):
  229. if not fb_icon[i]:
  230. continue
  231. img_path = "app/src/main/res/drawable-nodpi"
  232. img_path = os.path.join(path_dest, img_path, default_fb_icon[i])
  233. if isinstance(fb_icon[i], str):
  234. logo = requests.get('https://newuniverse.io/dashboardv2/uploads/fb_icon/{}'.format(fb_icon[i]))
  235. with open(img_path, "wb") as f:
  236. f.write(logo.content)
  237. with open(img_path, "rb") as f:
  238. logo = Image.open(f)
  239. logo = logo.resize((150, 150))
  240. logo.save(img_path, "PNG")
  241. else:
  242. logo = Image.open(fb_icon[i])
  243. logo = logo.resize((150, 150))
  244. logo.save(img_path, "PNG")
  245. def change_background(path_dest, background):
  246. if isinstance(background, str):
  247. background = background.split(",")
  248. for i,b in enumerate(background):
  249. n = i+1
  250. img_path = "app/src/main/res/drawable-nodpi-v4/pb_lbackground_{}.png".format(n)
  251. img_path = os.path.join(path_dest, img_path)
  252. logo = requests.get('https://newuniverse.io/dashboardv2/uploads/background/{}'.format(b))
  253. with open(img_path, "wb") as f:
  254. f.write(logo.content)
  255. with open(img_path, "rb") as f:
  256. logo = Image.open(f)
  257. logo = logo.resize((600, 1250))
  258. logo.save(img_path, "PNG")
  259. else:
  260. img_path = "app/src/main/res/drawable-nodpi-v4/pb_lbackground_1.png"
  261. logo = Image.open(background)
  262. logo = logo.resize((600, 1250))
  263. logo.save(img_path, "PNG")
  264. def change_access(path_dest, access_model, package):
  265. access = ["CPAAS_MODE_FLOATING", "CPAAS_MODE_DOCKED", "CPAAS_MODE_BURGER"]
  266. path_package_id = package.replace(".", "/")
  267. code_path = "app/src/main/java/"
  268. code_path = os.path.join(path_dest, code_path, path_package_id, "util", "PrefsUtil.java")
  269. print(code_path)
  270. with open(code_path, "r") as f:
  271. file_source = f.read()
  272. replaced = file_source.replace("= CPAAS_MODE_DOCKED", "= {}".format(access[access_model]))
  273. with open(code_path, "w") as f:
  274. f.write(replaced)
  275. pass
  276. def change_certificate(path_dest, key, keyfile, keytool):
  277. keyfile_name = "{}.keystore".format(key["alias"])
  278. keyfile_path = os.path.join(path_dest, keyfile_name)
  279. if keyfile:
  280. keyfile.save(keyfile_path)
  281. else:
  282. vprint("keytool run")
  283. os.chdir(path_dest)
  284. vprint("current working directory: ", os.getcwd())
  285. dname = "CN={}, OU={}, O={}, L={}, S={}, C={}".format(key["common_name"], key["organization_unit"],
  286. key["organization_name"], key["locality_name"],
  287. key["state_name"], key["country"])
  288. cmd = [keytool, "-genkey", "-v", "-keystore", keyfile_path, "-alias", key["alias"], "-keyalg", "RSA",
  289. "-keysize", "2048",
  290. "-validity", "10000", "-dname", dname, "-storepass", key["store_password"], "-keypass", key["key_password"]]
  291. vprint(cmd)
  292. subprocess.run(cmd)
  293. vprint("keytool end")
  294. build_gradle = os.path.join(path_dest, 'app/build.gradle')
  295. with open(build_gradle, "r") as f:
  296. file_source = f.read()
  297. replaced = file_source.replace("allyourbase", key["store_password"])
  298. replaced = replaced.replace("arebelongto", key["key_password"])
  299. replaced = replaced.replace("key-qmeralite", key["alias"])
  300. with open(build_gradle, "w") as f:
  301. f.write(replaced)
  302. def run_build(path_dest):
  303. gradlew = os.path.join(path_dest, "gradlew")
  304. ret = subprocess.run([gradlew, 'assembleRelease'])
  305. if ret.returncode == 0:
  306. ret = subprocess.run([gradlew, 'bundleRelease'])
  307. return ret.returncode
  308. def deliver_apk(path_dest, package_id, key, key_exists):
  309. apk_dir = os.path.join(path_dest, 'app/build/outputs/apk/release/app-release.apk')
  310. aab_dir = os.path.join(path_dest, 'app/build/outputs/bundle/release/app-release.aab')
  311. keystore_name = '{}.keystore'.format(key["alias"])
  312. keystore_dir = os.path.join(path_dest, keystore_name)
  313. timenow = time.time()
  314. apk_name = "{}{}.apk".format(package_id, timenow)
  315. aab_name = "{}{}.aab".format(package_id, timenow)
  316. zip_name = "{}{}.zip".format(package_id, timenow)
  317. new_apk_dir = os.path.join(app.apk_folder, apk_name)
  318. new_aab_dir = os.path.join(app.apk_folder, aab_name)
  319. new_dir = os.path.join(app.apk_folder, zip_name)
  320. vprint(apk_dir)
  321. try:
  322. shutil.move(apk_dir, new_apk_dir)
  323. shutil.move(aab_dir, new_aab_dir)
  324. with ZipFile(new_dir, 'w') as zip_file:
  325. zip_file.write(new_apk_dir, os.path.basename(new_apk_dir))
  326. zip_file.write(new_aab_dir, os.path.basename(new_aab_dir))
  327. if not key_exists:
  328. zip_file.write(keystore_dir, os.path.basename(keystore_dir))
  329. os.remove(new_apk_dir)
  330. os.remove(new_aab_dir)
  331. project_path = os.path.join(app.temp_folder, package_id)
  332. shutil.rmtree(project_path)
  333. return {"name": zip_name}
  334. except Exception as e:
  335. return str(e)
  336. def change_version(path_dest, version_code, version_name):
  337. build_gradle = os.path.join(path_dest, 'app/build.gradle')
  338. with open(build_gradle, "r") as f:
  339. file_source = f.read()
  340. replaced = file_source.replace("versionCode 3", "versionCode {}".format(version_code))
  341. replaced = replaced.replace('versionName "3.0"', 'versionName "{}"'.format(version_name))
  342. with open(build_gradle, "w") as f:
  343. f.write(replaced)
  344. @app.route('/', methods=["GET", "POST"])
  345. def build_apk():
  346. vprint('==============================================================')
  347. if request.method == 'POST':
  348. logo = None
  349. logo_float = None
  350. app_name = "NexilisLite"
  351. package_id = "com.app.nexilis"
  352. acc = None
  353. url = None
  354. keystore = None
  355. key_exists = False
  356. # tabs = ["1", "2", "3", "4"]
  357. tabs = []
  358. tab3_mode = "0"
  359. tab_icon = [None, None, None, None]
  360. fb_icon = [None, None, None, None, None]
  361. background = None
  362. version_code = "1"
  363. version_name = "1.0.0"
  364. font = 0
  365. tab_amount = 4
  366. key = {"alias": "nexilislite", "store_password": "allyourbase", "key_password": "arebelongto", "common_name": "all", "organization_unit": "your",
  367. "organization_name": "base", "locality_name": "are", "state_name": "belong", "country": "to"}
  368. if 'logo' in request.files:
  369. logo = request.files['logo']
  370. vprint(type(logo))
  371. elif 'logo' in request.form:
  372. logo = request.form['logo']
  373. vprint(type(logo))
  374. if 'logofloat' in request.files:
  375. logo_float = request.files['logofloat']
  376. vprint(type(logo_float))
  377. elif 'logofloat' in request.form:
  378. logo_float = request.form['logofloat']
  379. vprint(type(logo_float))
  380. if 'app_name' in request.files:
  381. app_name = request.files['app_name']
  382. vprint(app_name)
  383. elif 'app_name' in request.form:
  384. app_name = request.form['app_name']
  385. vprint(app_name)
  386. if 'package_id' in request.files:
  387. package_id = request.files['package_id']
  388. vprint(package_id)
  389. elif 'package_id' in request.form:
  390. package_id = request.form['package_id']
  391. vprint(package_id)
  392. if 'acc' in request.files:
  393. acc = request.files['acc']
  394. vprint(acc)
  395. elif 'acc' in request.form:
  396. acc = request.form['acc']
  397. vprint(acc)
  398. if 'url' in request.files:
  399. url = request.files['url']
  400. vprint(url)
  401. elif 'url' in request.form:
  402. url = request.form['url']
  403. vprint(url)
  404. if 'keystore' in request.files:
  405. keystore = request.files['keystore']
  406. key_exists = True
  407. elif 'keystore' in request.form:
  408. keystore = request.form['keystore']
  409. key_exists = True
  410. if 'alias' in request.form:
  411. if request.form['alias']:
  412. key["alias"] = request.form['alias']
  413. if 'store_password' in request.form:
  414. if request.form['store_password']:
  415. key["store_password"] = request.form['store_password']
  416. if 'key_password' in request.form:
  417. if request.form['key_password']:
  418. key["key_password"] = request.form['key_password']
  419. if keystore:
  420. if 'common_name' in request.form:
  421. if request.form['common_name']:
  422. key["common_name"] = request.form['common_name']
  423. if 'organization_unit' in request.form:
  424. if request.form['organization_unit']:
  425. key["organization_unit"] = request.form['organization_unit']
  426. if 'organization_name' in request.form:
  427. if request.form['organization_name']:
  428. key["organization_name"] = request.form['organization_name']
  429. if 'locality_name' in request.form:
  430. if request.form['locality_name']:
  431. key["locality_name"] = request.form['locality_name']
  432. if 'state_name' in request.form:
  433. if request.form['state_name']:
  434. key["state_name"] = request.form['state_name']
  435. if 'country' in request.form:
  436. if request.form['country']:
  437. key["country"] = request.form['country']
  438. tabs.append(request.form["tab1"])
  439. tabs.append(request.form["tab2"])
  440. if request.form['tab3']:
  441. tabs.append(request.form["tab3"])
  442. if request.form['tab4']:
  443. tabs.append(request.form["tab4"])
  444. if 'tab1_icon' in request.files:
  445. tab_icon[0] = request.files['tab1_icon']
  446. elif 'tab1_icon' in request.form:
  447. tab_icon[0] = request.form['tab1_icon']
  448. if 'tab2_icon' in request.files:
  449. tab_icon[1] = request.files['tab2_icon']
  450. elif 'tab2_icon' in request.form:
  451. tab_icon[1] = request.form['tab2_icon']
  452. if 'tab3_icon' in request.files:
  453. tab_icon[2] = request.files['tab3_icon']
  454. elif 'tab3_icon' in request.form:
  455. tab_icon[2] = request.form['tab3_icon']
  456. if 'tab4_icon' in request.files:
  457. tab_icon[3] = request.files['tab4_icon']
  458. elif 'tab4_icon' in request.form:
  459. tab_icon[3] = request.form['tab4_icon']
  460. if 'fb1_icon' in request.files:
  461. fb_icon[0] = request.files['fb1_icon']
  462. elif 'fb1_icon' in request.form:
  463. fb_icon[0] = request.form['fb1_icon']
  464. if 'fb2_icon' in request.files:
  465. fb_icon[1] = request.files['fb2_icon']
  466. elif 'fb2_icon' in request.form:
  467. fb_icon[1] = request.form['fb2_icon']
  468. if 'fb3_icon' in request.files:
  469. fb_icon[2] = request.files['fb3_icon']
  470. elif 'fb3_icon' in request.form:
  471. fb_icon[2] = request.form['fb3_icon']
  472. if 'fb4_icon' in request.files:
  473. fb_icon[3] = request.files['fb4_icon']
  474. elif 'fb4_icon' in request.form:
  475. fb_icon[3] = request.form['fb4_icon']
  476. if 'fb5_icon' in request.files:
  477. fb_icon[4] = request.files['fb5_icon']
  478. elif 'fb5_icon' in request.form:
  479. fb_icon[4] = request.form['fb5_icon']
  480. vprint("fb_icon: {}".format(fb_icon))
  481. access_model = int(request.form['access_model'])
  482. if 'tab3_mode' in request.form:
  483. tab3_mode = request.form['tab3_mode']
  484. if 'tab_amount' in request.form:
  485. tab_amount = int(request.form['tab_amount'])
  486. if 'font' in request.form:
  487. font = int(request.form['font'])
  488. if 'background' in request.files:
  489. background = request.files['background']
  490. elif 'background' in request.form:
  491. background = request.form['background']
  492. if 'version_code' in request.form:
  493. version_code = request.form['version_code']
  494. if 'version_name' in request.form:
  495. version_name = request.form['version_name']
  496. else:
  497. version_name = "1.0.{}".format(version_code)
  498. path_dest, c_code_path = create_folder(package_id)
  499. vprint("path_dest: " + path_dest)
  500. vprint("c_code_path: " + c_code_path)
  501. if acc:
  502. change_acc(c_code_path, acc)
  503. if url:
  504. change_url(c_code_path, url)
  505. change_name(path_dest, app_name)
  506. change_certificate(path_dest, key, keystore, app.keytool)
  507. change_package(path_dest, package_id)
  508. change_version(path_dest, version_code,version_name)
  509. change_font(path_dest, font, package_id)
  510. if logo:
  511. change_logo(path_dest, logo, logo_float)
  512. if background:
  513. change_background(path_dest, background)
  514. change_fb(path_dest, fb_icon)
  515. change_access(path_dest, access_model, package_id)
  516. change_tab(path_dest, tabs, tab_icon, package_id, tab3_mode, tab_amount)
  517. os.chdir(path_dest)
  518. return_code = run_build(path_dest)
  519. if (return_code == 0):
  520. return deliver_apk(path_dest, package_id, key, key_exists)
  521. return "h"
  522. else:
  523. if 'e' in request.args:
  524. return request.args['e']
  525. return "Hello World!"
  526. if __name__ == '__main__':
  527. app.run(host='0.0.0.0', port=8092, debug=app.verbose, ssl_context=app.ssl)