mainPalio2.py 24 KB

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