Commit a5c7f56abd77418ce5cd146080a376221670a204

Authored by Erickson Silva
1 parent c1f81c19
Exists in devel

[TranslationServer] Corrige rota para regionalismo

Showing 1 changed file with 13 additions and 7 deletions   Show diff stats
src/TranslationServer.py
@@ -256,22 +256,28 @@ def update_list_bundles(): @@ -256,22 +256,28 @@ def update_list_bundles():
256 256
257 @app.route("/<platform>/<sign>", methods=['GET']) 257 @app.route("/<platform>/<sign>", methods=['GET'])
258 @check_run_mode 258 @check_run_mode
259 -def get_sign(platform, sign, state=None): 259 +def get_sign(platform, sign):
260 platform = platform.encode("UTF-8") 260 platform = platform.encode("UTF-8")
261 sign = sign.encode("UTF-8") 261 sign = sign.encode("UTF-8")
262 if " " in sign or platform not in BUNDLES_PATH: abort(400) 262 if " " in sign or platform not in BUNDLES_PATH: abort(400)
263 - file_exists = sign in BUNDLES_LIST["DEFAULT"] if state == None else sign in BUNDLES_LIST[state] 263 + file_exists = sign in BUNDLES_LIST["DEFAULT"]
264 thread.start_new_thread(update_database_statistic, (sign, platform, file_exists)) 264 thread.start_new_thread(update_database_statistic, (sign, platform, file_exists))
265 - if file_exists and state is not None:  
266 - return send_from_directory(os.path.join(BUNDLES_PATH[platform], state), sign)  
267 - elif file_exists or (sign in BUNDLES_LIST["DEFAULT"] and state is not None): 265 + if file_exists:
268 return send_from_directory(BUNDLES_PATH[platform], sign) 266 return send_from_directory(BUNDLES_PATH[platform], sign)
269 abort(404) 267 abort(404)
270 268
271 @app.route("/<platform>/<state>/<sign>", methods=['GET']) 269 @app.route("/<platform>/<state>/<sign>", methods=['GET'])
272 @check_run_mode 270 @check_run_mode
273 -def get_sign_localism(platform, state, sign):  
274 - return get_sign(platform, sign, state) 271 +def get_sign_state(platform, state, sign):
  272 + platform = platform.encode("UTF-8")
  273 + sign = sign.encode("UTF-8")
  274 + state = state.encode("UTF-8")
  275 + if " " in sign or platform not in BUNDLES_PATH: abort(400)
  276 + file_exists = sign in BUNDLES_LIST[state]
  277 + thread.start_new_thread(update_database_statistic, (sign, platform, file_exists))
  278 + if file_exists:
  279 + return send_from_directory(os.path.join(BUNDLES_PATH[platform], state), sign)
  280 + return get_sign(platform.decode("UTF-8"), sign.decode("UTF-8"))
275 281
276 if __name__ == "__main__": 282 if __name__ == "__main__":
277 parser = argparse.ArgumentParser(description='Translation server and signs download for VLibras.') 283 parser = argparse.ArgumentParser(description='Translation server and signs download for VLibras.')