mainIOS.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  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 = "/Users/easysoft/Documents/AppBuilder/appbuilder-ios/AppBuilder"
  12. app.nexilis_lite = "/Users/easysoft/Documents/AppBuilder/appbuilder-ios/NexilisLite"
  13. app.temp_folder = "/Users/easysoft/Documents/BuildIos"
  14. app.app_folder = "/Users/easysoft/Documents"
  15. app.asset_folder = "/Users/easysoft/Documents/BuildIosAssets"
  16. app.verbose = True
  17. app.ssl = None
  18. app.keytool = '/usr/bin/keytool'
  19. app.username = "easysoft"
  20. # app.ios_platform_ids = ["bb8f256703e8fbe84da414cee20cb4d0eca3388d"]
  21. app.ios_platform_ids = []
  22. app.app_name = "AppBuilder"
  23. app.package_id = "io.newuniverse.AppBuilder"
  24. app.version_code = "1"
  25. app.version_name = "1.0.0"
  26. app.base_project_name = os.path.basename(app.base_project)
  27. def vprint(*data):
  28. if app.verbose:
  29. print(*data)
  30. def create_folder(package_id,app_name):
  31. path = os.path.join(app.temp_folder, package_id)
  32. if not os.path.exists(path):
  33. os.mkdir(path)
  34. else:
  35. shutil.rmtree(path)
  36. os.mkdir(path)
  37. vprint(path)
  38. lib_dest = os.path.join(path, "NexilisLite")
  39. if not os.path.exists(lib_dest):
  40. shutil.copytree(app.nexilis_lite, lib_dest)
  41. path_dest = os.path.join(path, app.base_project_name)
  42. if not os.path.exists(path_dest):
  43. shutil.copytree(app.base_project, path_dest)
  44. c_code_path = os.path.join(path_dest,app_name)
  45. orig_code_path = os.path.join(path_dest,"AppBuilder")
  46. if not os.path.exists(c_code_path):
  47. shutil.copytree(orig_code_path, c_code_path)
  48. shutil.rmtree(orig_code_path)
  49. return path_dest, c_code_path, lib_dest
  50. def change_acc(c_code_path, acc):
  51. main_activity = os.path.join(c_code_path, "AppDelegate.swift")
  52. with open(main_activity, "r") as f:
  53. file_source = f.read()
  54. replaced = file_source.replace("***REPLACE***WITH***YOUR***ACCOUNT***", acc)
  55. with open(main_activity, "w") as f:
  56. f.write(replaced)
  57. def change_url(c_code_path, url):
  58. main_activity = os.path.join(c_code_path, "ViewController.swift")
  59. with open(main_activity, "r") as f:
  60. file_source = f.read()
  61. replaced = file_source.replace("https://www.google.com", url)
  62. with open(main_activity, "w") as f:
  63. f.write(replaced)
  64. def change_name(path_dest, app_name, package_id):
  65. xcproj = os.path.join(path_dest, "{}.xcodeproj".format(app_name))
  66. xcwork = os.path.join(path_dest, "{}.xcworkspace".format(app_name))
  67. shutil.move(os.path.join(path_dest, "AppBuilder.xcodeproj"), xcproj)
  68. # shutil.move(os.path.join(path_dest, "AppBuilder.xcworkspace"), xcwork)
  69. xcshareddata = os.path.join(xcproj, "xcshareddata/xcschemes", "{}.xcscheme".format(app_name))
  70. shutil.move(os.path.join(xcproj, "xcshareddata/xcschemes", "AppBuilder.xcscheme"), xcshareddata)
  71. podfile = os.path.join(path_dest, "Podfile")
  72. with open(podfile, "r") as f:
  73. file_source = f.read()
  74. replaced = file_source.replace("AppBuilder", app_name)
  75. with open(podfile, "w") as f:
  76. f.write(replaced)
  77. info_plist = os.path.join(path_dest,app_name,"Info.plist")
  78. with open(info_plist, "r") as f:
  79. file_source = f.read()
  80. replaced = file_source.replace("AppBuilder", app_name)
  81. with open(info_plist, "w") as f:
  82. f.write(replaced)
  83. main_stry = os.path.join(path_dest, app_name, "Base.lproj/Main.storyboard")
  84. with open(main_stry, "r") as f:
  85. file_source = f.read()
  86. replaced = file_source.replace("AppBuilder", app_name)
  87. with open(main_stry, "w") as f:
  88. f.write(replaced)
  89. project = os.path.join(xcproj, "project.pbxproj")
  90. package_rep = "io.newuniverse.{}".format(app_name)
  91. with open(project, "r") as f:
  92. file_source = f.read()
  93. replaced = file_source.replace("AppBuilder", app_name)
  94. replaced = replaced.replace(package_rep, package_id)
  95. with open(project, "w") as f:
  96. f.write(replaced)
  97. with open(xcshareddata, "r") as f:
  98. file_source = f.read()
  99. replaced = file_source.replace("AppBuilder", app_name)
  100. with open(xcshareddata, "w") as f:
  101. f.write(replaced)
  102. xcuserdata = os.path.join(xcproj, "xcuserdata/{}.xcuserdatad/xcschemes/xcschememanagement.plist".format(app.username))
  103. try:
  104. with open(xcuserdata, "r") as f:
  105. file_source = f.read()
  106. replaced = file_source.replace("AppBuilder", app_name)
  107. with open(xcuserdata, "w") as f:
  108. f.write(replaced)
  109. except FileNotFoundError:
  110. pass
  111. os.chdir(path_dest)
  112. subprocess.run(["pod", "install"])
  113. contentsw = os.path.join(xcwork, "contents.xcworkspacedata")
  114. with open(contentsw, "r") as f:
  115. file_source = f.read()
  116. replaced = file_source.replace("AppBuilder", app_name)
  117. with open(contentsw, "w") as f:
  118. f.write(replaced)
  119. def change_certificate(path_dest, key, keystore, keytool):
  120. pass
  121. def change_package(path_dest, package_id):
  122. pass
  123. def change_version(path_dest, app_name, version_code, version_name):
  124. project = os.path.join(path_dest, '{}.xcodeproj'.format(app_name), 'project.pbxproj')
  125. with open(project, "r") as f:
  126. file_source = f.read()
  127. replaced = file_source.replace("CURRENT_PROJECT_VERSION = 1;", "CURRENT_PROJECT_VERSION = {};".format(version_code))
  128. replaced = replaced.replace('MARKETING_VERSION = 1.0.0;', 'MARKETING_VERSION = {};'.format(version_name))
  129. with open(project, "w") as f:
  130. f.write(replaced)
  131. def change_font(c_code_path, font):
  132. prefs_path = os.path.join(c_code_path, "AppDelegate.swift")
  133. with open(prefs_path, "r") as f:
  134. file_source = f.read()
  135. replaced = file_source.replace("FONT_SELECT = 0", "FONT_SELECT = {}".format(font))
  136. with open(prefs_path, "w") as f:
  137. f.write(replaced)
  138. pass
  139. def change_logo(c_code_path, lib_dest, logo, logo_float=None):
  140. app_icon_set = [29,40,57,58,60,80,87,114,120,180,1024]
  141. app_icon_dir = os.path.join(c_code_path, 'Assets.xcassets/AppIcon.appiconset')
  142. app_float_dir = os.path.join(lib_dest, 'NexilisLite/Resource/Assets.xcassets/pb_button.imageset')
  143. app_launch_dir = os.path.join(c_code_path, 'Assets.xcassets/pb_icon.imageset')
  144. if isinstance(logo, str):
  145. # try:
  146. # logo_url = requests.get('https://newuniverse.io/dashboardv2/uploads/logo/{}'.format(logo))
  147. # for size in app_icon_set:
  148. # img_path = os.path.join(app_icon_dir, "{}.png".format(size))
  149. # with open(img_path, "wb") as f:
  150. # f.write(logo_url.content)
  151. # with open(img_path, "rb") as f:
  152. # l = Image.open(f)
  153. # l = l.resize((size, size))
  154. # l.save(img_path, "PNG")
  155. # except:
  156. try:
  157. logo_path = os.path.join(app.asset_folder, "logo", "{}".format(logo))
  158. for size in app_icon_set:
  159. img_path = os.path.join(app_icon_dir, "{}.png".format(size))
  160. with open(logo_path, "rb") as f:
  161. l = Image.open(f)
  162. l = l.resize((size, size))
  163. l.save(img_path, "PNG")
  164. except:
  165. print("error logo: {}".format(logo))
  166. return
  167. if logo_float:
  168. # try:
  169. # logo_float_url = requests.get('https://newuniverse.io/dashboardv2/uploads/logofloat/{}'.format(logo_float))
  170. # img_path = os.path.join(app_float_dir, "pb_ball.png")
  171. # with open(img_path, "wb") as f:
  172. # f.write(logo_float_url.content)
  173. # with open(img_path, "rb") as f:
  174. # l = Image.open(f)
  175. # l = l.resize((512, 512))
  176. # l.save(img_path, "PNG")
  177. # except:
  178. try:
  179. logo_launch_path = os.path.join(app.asset_folder, "logofloat", "{}".format(logo_float))
  180. img_path = os.path.join(app_launch_dir, "nexilis_icon.png".format(size))
  181. with open(logo_launch_path, "rb") as f:
  182. l = Image.open(f)
  183. l = l.resize((size, size))
  184. l.save(img_path, "PNG")
  185. except:
  186. print("error logolaunch: {}".format(logo_float))
  187. return
  188. try:
  189. logo_float_path = os.path.join(app.asset_folder, "logofloat", "{}".format(logo_float))
  190. img_path = os.path.join(app_float_dir, "pb_button.png".format(size))
  191. with open(logo_float_path, "rb") as f:
  192. l = Image.open(f)
  193. l = l.resize((size, size))
  194. l.save(img_path, "PNG")
  195. except:
  196. print("error logofloat: {}".format(logo_float))
  197. return
  198. else:
  199. logo = Image.open(logo)
  200. for size in app_icon_set:
  201. img_path = os.path.join(app_icon_dir, "{}.png".format(size))
  202. logo_resized = logo.resize((size,size))
  203. logo_resized.save(img_path, "PNG")
  204. if logo_float:
  205. logo_float = Image.open(logo_float)
  206. img_path = os.path.join(app_float_dir, "nexilis_icon.png")
  207. logo_float_resized = logo_float.resize((512,512))
  208. logo_float_resized.save(img_path, "PNG")
  209. def change_background(c_code_path, background):
  210. assets_dir = os.path.join(c_code_path, "Assets.xcassets")
  211. img_src_path_1 = os.path.join(assets_dir, "pb_lbackground_1.imageset")
  212. if isinstance(background, str):
  213. background = background.split(",")
  214. for i, b in enumerate(background):
  215. n = i + 1
  216. print(b)
  217. img_src_path = os.path.join(assets_dir, "pb_lbackground_{}.imageset".format(n))
  218. print(img_src_path)
  219. if n != 1:
  220. shutil.copytree(img_src_path_1,img_src_path)
  221. os.remove(os.path.join(img_src_path,"pb_lbackground_1.png"))
  222. contents_json = os.path.join(img_src_path, "Contents.json")
  223. with open(contents_json, "r") as f:
  224. file_source = f.read()
  225. replaced = file_source.replace("lbackground_1", "lbackground_{}".format(n))
  226. with open(contents_json, "w") as f:
  227. f.write(replaced)
  228. img_path = os.path.join(img_src_path, "pb_lbackground_{}.png".format(n))
  229. # try:
  230. # background_url = requests.get('https://newuniverse.io/dashboardv2/uploads/background/{}'.format(b))
  231. # with open(img_path, "wb") as f:
  232. # f.write(background_url.content)
  233. # with open(img_path, "rb") as f:
  234. # l = Image.open(f)
  235. # l = l.resize((600, 1250))
  236. # l.save(img_path, "PNG")
  237. # except:
  238. try:
  239. background_path = os.path.join(app.asset_folder, "background", "{}".format(b))
  240. with open(background_path, "rb") as f:
  241. l = Image.open(f)
  242. l = l.resize((600, 1250))
  243. l.save(img_path, "PNG")
  244. except:
  245. print("error background: {}".format(b))
  246. return
  247. second_tab = os.path.join(c_code_path, "SecondTabViewController.swift")
  248. fourth_tab = os.path.join(c_code_path, "FourthTabViewController.swift")
  249. with open(second_tab, "r") as f:
  250. file_source = f.read()
  251. replaced = file_source.replace("1..<2", "1..<{}".format(len(background) + 1))
  252. with open(second_tab, "w") as f:
  253. f.write(replaced)
  254. with open(fourth_tab, "r") as f:
  255. file_source = f.read()
  256. replaced = file_source.replace("1..<2", "1..<{}".format(len(background) + 1))
  257. with open(fourth_tab, "w") as f:
  258. f.write(replaced)
  259. else:
  260. img_path = os.path.join(img_src_path_1, "pb_lbackground_1.png")
  261. logo = Image.open(background)
  262. logo = logo.resize((600, 1250))
  263. logo.save(img_path, "PNG")
  264. def change_fb(lib_dest, fb_icon):
  265. default_fb_icon = ["pb_button_chat", "pb_button_call", "pb_button_cc", "pb_button_post", "pb_button_stream"]
  266. for i in range(5):
  267. if not fb_icon[i]:
  268. continue
  269. img_path = "NexilisLite/Resource/Assets.xcassets"
  270. img_path = os.path.join(lib_dest, img_path, "{}.imageset".format(default_fb_icon[i]), "{}.png".format(default_fb_icon[i]))
  271. if isinstance(fb_icon[i], str):
  272. # try:
  273. # fb_icon_url = requests.get('https://newuniverse.io/dashboardv2/uploads/fb_icon/{}'.format(fb_icon[i]))
  274. # with open(img_path, "wb") as f:
  275. # f.write(fb_icon_url.content)
  276. # with open(img_path, "rb") as f:
  277. # l = Image.open(f)
  278. # l = l.resize((150, 150))
  279. # l.save(img_path, "PNG")
  280. # except:
  281. try:
  282. fb_icon_path = os.path.join(app.asset_folder, "fb_icon", "{}".format(fb_icon[i]))
  283. with open(fb_icon_path, "rb") as f:
  284. l = Image.open(f)
  285. l = l.resize((150, 150))
  286. l.save(img_path, "PNG")
  287. except:
  288. print("error tab icon {}: {}".format(i,fb_icon[i]))
  289. else:
  290. logo = Image.open(fb_icon[i])
  291. logo = logo.resize((150, 150))
  292. logo.save(img_path, "PNG")
  293. def change_access(c_code_path, access_model):
  294. access = ["CPAAS_MODE_FLOATING", "CPAAS_MODE_DOCKED", "CPAAS_MODE_BURGER"]
  295. code_path = os.path.join(c_code_path, "PrefsUtil.swift")
  296. print(code_path)
  297. with open(code_path, "r") as f:
  298. file_source = f.read()
  299. acc = "CPAAS_MODE_MIX" if access_model > 2 else access[access_model]
  300. replaced = file_source.replace("= CPAAS_MODE_DOCKED", "= {}".format(acc))
  301. with open(code_path, "w") as f:
  302. f.write(replaced)
  303. pass
  304. def change_tab(c_code_path, tabs, tab_icon, tab3_mode):
  305. default_tab_icon = ["tab_1", "tab_2", "tab_3", "tab_4"]
  306. for i in range(4):
  307. if not tab_icon[i]:
  308. continue
  309. img_path = os.path.join(c_code_path, "Assets.xcassets",
  310. "{}_icon.imageset".format(default_tab_icon[i]),
  311. "{}_nexilis.png".format(default_tab_icon[i]))
  312. if isinstance(tab_icon[i], str):
  313. # try:
  314. # tab_icon_url = requests.get('https://newuniverse.io/dashboardv2/uploads/tab_icon/{}'.format(tab_icon[i]))
  315. # with open(img_path, "wb") as f:
  316. # f.write(tab_icon_url.content)
  317. # with open(img_path, "rb") as f:
  318. # l = Image.open(f)
  319. # l = l.resize((150, 150))
  320. # l.save(img_path, "PNG")
  321. # except:
  322. try:
  323. tab_icon_path = os.path.join(app.asset_folder, "tab_icon", "{}".format(tab_icon[i]))
  324. with open(tab_icon_path, "rb") as f:
  325. l = Image.open(f)
  326. l = l.resize((150, 150))
  327. l.save(img_path, "PNG")
  328. except:
  329. print("error tab_icon {}: {}".format(i,tab_icon[i]))
  330. return
  331. else:
  332. logo = Image.open(tab_icon[i])
  333. logo = logo.resize((150, 150))
  334. logo.save(img_path, "PNG")
  335. prefs_util = os.path.join(c_code_path, "PrefsUtil.swift")
  336. with open(prefs_util, "r") as f:
  337. file_source = f.read()
  338. replaced = file_source.replace("1,2,3,4", ",".join(tabs))
  339. with open(prefs_util, "w") as f:
  340. f.write(replaced)
  341. main_code_path = os.path.join(c_code_path, "ViewController.swift")
  342. with open(main_code_path, "r") as f:
  343. file_source = f.read()
  344. replaced = file_source.replace('tab3 = "0"', 'tab3 = "{}"'.format(tab3_mode))
  345. with open(main_code_path, "w") as f:
  346. f.write(replaced)
  347. def run_build(path_dest, app_name):
  348. workspace = os.path.join(path_dest, "{}.xcworkspace".format(app_name))
  349. build_args = ["xcodebuild", "clean", "build", "-scheme", app_name, "-workspace", workspace]
  350. install_args = ["xcodebuild", "clean", "install", "-scheme", app_name, "-workspace", workspace]
  351. ret = -1
  352. if(len(app.ios_platform_ids) > 0):
  353. for id in app.ios_platform_ids:
  354. build_args_run = install_args
  355. build_args_run.append("-destination")
  356. build_args_run.append('platform=iOS,id={}'.format(id))
  357. print(build_args_run)
  358. ret = subprocess.run(build_args_run)
  359. if ret.returncode != 0:
  360. break
  361. return ret.returncode
  362. else:
  363. ret = subprocess.run(build_args)
  364. if ret.returncode == 0:
  365. # ret = subprocess.run(["xcodebuild", "-workspace", workspace, "-scheme", app_name,
  366. # "-archivePath", os.path.join(path_dest, "out", "{}.xcarchive".format(app_name)),
  367. # "archive"])
  368. return ret.returncode
  369. return ret.returncode
  370. def deliver_app(path_dest, app_name, package_id, key, key_exists):
  371. archive_dir = os.path.join(path_dest, 'out', "{}.archive".format(app_name))
  372. timenow = time.time()
  373. archive_name = "{}{}.xarchive".format(package_id, timenow)
  374. zip_name = "{}{}.zip".format(package_id, timenow)
  375. new_arc_dir = os.path.join(app.app_folder, archive_name)
  376. new_dir = os.path.join(app.app_folder, zip_name)
  377. vprint(archive_dir)
  378. try:
  379. shutil.move(archive_dir, new_arc_dir)
  380. with ZipFile(new_dir, 'w') as zip_file:
  381. zip_file.write(new_arc_dir, os.path.basename(new_arc_dir))
  382. # os.remove(new_arc_dir)
  383. project_path = os.path.join(app.temp_folder, package_id)
  384. # shutil.rmtree(project_path)
  385. return {"name": zip_name}
  386. except Exception as e:
  387. return str(e)
  388. @app.route('/', methods=["GET", "POST"])
  389. def build_apk():
  390. vprint('==============================================================')
  391. if request.method == 'POST':
  392. logo = None
  393. logo_float = None
  394. app_name = app.app_name
  395. package_id = app.package_id
  396. acc = None
  397. url = None
  398. keystore = None
  399. key_exists = False
  400. # tabs = ["1", "2", "3", "4"]
  401. tabs = []
  402. tab3_mode = "0"
  403. tab_icon = [None, None, None, None]
  404. fb_icon = [None, None, None, None, None]
  405. background = None
  406. version_code = app.version_code
  407. version_name = app.version_name
  408. font = 0
  409. key = {"alias": "nexilislite", "store_password": "allyourbase", "key_password": "arebelongto", "common_name": "all", "organization_unit": "your",
  410. "organization_name": "base", "locality_name": "are", "state_name": "belong", "country": "to"}
  411. if 'logo' in request.files:
  412. logo = request.files['logo']
  413. vprint(type(logo))
  414. elif 'logo' in request.form:
  415. logo = request.form['logo']
  416. vprint(type(logo))
  417. if 'logofloat' in request.files:
  418. logo_float = request.files['logofloat']
  419. vprint(type(logo_float))
  420. elif 'logofloat' in request.form:
  421. logo_float = request.form['logofloat']
  422. vprint(type(logo_float))
  423. if 'app_name' in request.files:
  424. app_name = request.files['app_name']
  425. vprint(app_name)
  426. elif 'app_name' in request.form:
  427. app_name = request.form['app_name']
  428. vprint(app_name)
  429. if 'package_id' in request.files:
  430. package_id = request.files['package_id']
  431. vprint(package_id)
  432. elif 'package_id' in request.form:
  433. package_id = request.form['package_id']
  434. vprint(package_id)
  435. if 'acc' in request.files:
  436. acc = request.files['acc']
  437. vprint(acc)
  438. elif 'acc' in request.form:
  439. acc = request.form['acc']
  440. vprint(acc)
  441. if 'url' in request.files:
  442. url = request.files['url']
  443. vprint(url)
  444. elif 'url' in request.form:
  445. url = request.form['url']
  446. vprint(url)
  447. if 'keystore' in request.files:
  448. keystore = request.files['keystore']
  449. key_exists = True
  450. elif 'keystore' in request.form:
  451. keystore = request.form['keystore']
  452. key_exists = True
  453. if 'alias' in request.form:
  454. if request.form['alias']:
  455. key["alias"] = request.form['alias']
  456. if 'store_password' in request.form:
  457. if request.form['store_password']:
  458. key["store_password"] = request.form['store_password']
  459. if 'key_password' in request.form:
  460. if request.form['key_password']:
  461. key["key_password"] = request.form['key_password']
  462. if keystore:
  463. if 'common_name' in request.form:
  464. if request.form['common_name']:
  465. key["common_name"] = request.form['common_name']
  466. if 'organization_unit' in request.form:
  467. if request.form['organization_unit']:
  468. key["organization_unit"] = request.form['organization_unit']
  469. if 'organization_name' in request.form:
  470. if request.form['organization_name']:
  471. key["organization_name"] = request.form['organization_name']
  472. if 'locality_name' in request.form:
  473. if request.form['locality_name']:
  474. key["locality_name"] = request.form['locality_name']
  475. if 'state_name' in request.form:
  476. if request.form['state_name']:
  477. key["state_name"] = request.form['state_name']
  478. if 'country' in request.form:
  479. if request.form['country']:
  480. key["country"] = request.form['country']
  481. tabs.append(request.form["tab1"])
  482. tabs.append(request.form["tab2"])
  483. if request.form['tab3']:
  484. tabs.append(request.form["tab3"])
  485. if request.form['tab4']:
  486. tabs.append(request.form["tab4"])
  487. if 'tab1_icon' in request.files:
  488. tab_icon[0] = request.files['tab1_icon']
  489. elif 'tab1_icon' in request.form:
  490. tab_icon[0] = request.form['tab1_icon']
  491. if 'tab2_icon' in request.files:
  492. tab_icon[1] = request.files['tab2_icon']
  493. elif 'tab2_icon' in request.form:
  494. tab_icon[1] = request.form['tab2_icon']
  495. if 'tab3_icon' in request.files:
  496. tab_icon[2] = request.files['tab3_icon']
  497. elif 'tab3_icon' in request.form:
  498. tab_icon[2] = request.form['tab3_icon']
  499. if 'tab4_icon' in request.files:
  500. tab_icon[3] = request.files['tab4_icon']
  501. elif 'tab4_icon' in request.form:
  502. tab_icon[3] = request.form['tab4_icon']
  503. if 'fb1_icon' in request.files:
  504. fb_icon[0] = request.files['fb1_icon']
  505. elif 'fb1_icon' in request.form:
  506. fb_icon[0] = request.form['fb1_icon']
  507. if 'fb2_icon' in request.files:
  508. fb_icon[1] = request.files['fb2_icon']
  509. elif 'fb2_icon' in request.form:
  510. fb_icon[1] = request.form['fb2_icon']
  511. if 'fb3_icon' in request.files:
  512. fb_icon[2] = request.files['fb3_icon']
  513. elif 'fb3_icon' in request.form:
  514. fb_icon[2] = request.form['fb3_icon']
  515. if 'fb4_icon' in request.files:
  516. fb_icon[3] = request.files['fb4_icon']
  517. elif 'fb4_icon' in request.form:
  518. fb_icon[3] = request.form['fb4_icon']
  519. if 'fb5_icon' in request.files:
  520. fb_icon[4] = request.files['fb5_icon']
  521. elif 'fb5_icon' in request.form:
  522. fb_icon[4] = request.form['fb5_icon']
  523. vprint("fb_icon: {}".format(fb_icon))
  524. access_model = int(request.form['access_model'])
  525. if 'tab3_mode' in request.form:
  526. tab3_mode = request.form['tab3_mode']
  527. if 'tab_amount' in request.form:
  528. tab_amount = int(request.form['tab_amount'])
  529. if 'font' in request.form:
  530. font = int(request.form['font'])
  531. if 'background' in request.files:
  532. background = request.files['background']
  533. elif 'background' in request.form:
  534. background = request.form['background']
  535. if 'version_code' in request.form:
  536. version_code = request.form['version_code']
  537. if 'version_name' in request.form:
  538. version_name = request.form['version_name']
  539. else:
  540. version_name = "1.0.{}".format(version_code)
  541. derived_data = os.path.join(app.app_folder, 'Library/Developer/Xcode/DerivedData')
  542. if os.path.exists(derived_data):
  543. shutil.rmtree(derived_data,ignore_errors=True)
  544. path_dest, c_code_path, lib_dest = create_folder(package_id, app_name)
  545. vprint("path_dest: " + path_dest)
  546. vprint("c_code_path: " + c_code_path)
  547. if app_name != "AppBuilder":
  548. change_name(path_dest, app_name, package_id)
  549. if acc:
  550. change_acc(c_code_path, acc)
  551. if url:
  552. change_url(c_code_path, url)
  553. # change_certificate(path_dest, key, keystore, app.keytool)
  554. # change_package(path_dest, package_id)
  555. change_version(path_dest, app_name, version_code, version_name)
  556. change_font(c_code_path, font)
  557. if logo:
  558. change_logo(c_code_path, lib_dest, logo, logo_float)
  559. if background:
  560. change_background(c_code_path, background)
  561. change_fb(lib_dest, fb_icon)
  562. change_access(c_code_path, access_model)
  563. change_tab(c_code_path, tabs, tab_icon, tab3_mode)
  564. os.chdir(path_dest)
  565. return_code = run_build(path_dest,app_name)
  566. # if (return_code == 0):
  567. # return deliver_app(path_dest, app_name, package_id, key, key_exists)
  568. return {'return_code': return_code}
  569. else:
  570. if 'e' in request.args:
  571. return request.args['e']
  572. return "Hello World!"
  573. if __name__ == '__main__':
  574. app.run(host='0.0.0.0', port=8093, debug=app.verbose, ssl_context=app.ssl)