Exemplo n.º 1
0
 def run_lookup(self, files=None):
     """
   Create a new sqlite db filled with a lookup table, useful for client applications
   to not overload the API server and to provide a better UX.
   """
     task = LookupTableTask()
     task.perform_update()
Exemplo n.º 2
0
def api_get_lookup_table():
   """
      <h3>/client-lookup-table/?local_update=date</h3>
      <p>Rooms lookup table</p>
      <p><em>date[string]</em> : a date with format yyy/mm/dd</p>
      <p>Return an object with a boolean <em>update</em> attribute and the URL of the sqlite database.</p>
      <p>If the <em>update</em> attribute is true, the client should update its local db.</p>
   """
   date = request.args.get('local_update') or ""
   print(date)

   try:
      date_obj = datetime.strptime(date,"%Y/%m/%d")
   except ValueError:
      abort(400)

   task              = LookupTableTask()
   to_update         = task.client_should_update_db(date_obj.timestamp())

   return jsonify({ 'update': to_update , 'url':lookup_table_url(task.db_name()) })
Exemplo n.º 3
0
 def setUp(self):
     self.ltt = LookupTableTask()