def get(self): """This method is called with a GET. Without parameter return a list of ongoin call of the User-Agent. With the token_call parameter set, this method return the specific call information. """ duration = 0 token_call = self.get_argument("token_call",None) call_info = Call() if token_call is not None: try: infos = call_info.getCallInfo(token_call,self._grant_token) if infos['stop'] is not None: stop = datetime.datetime.fromtimestamp(int(infos['stop'])).strftime('%d/%m/%Y %H:%M:%S') else: stop = "Call Ongoing" if infos['duration'] is None: #we need to calculate the duration netween the satrt to now duration = call_info.getDuration(infos['start']) else: duration = infos['duration'] user_info = dict( info= dict(duration=str(datetime.timedelta(seconds=duration)), number=infos['number'], token=infos['token'], start=datetime.datetime.fromtimestamp(int(infos['start'])).strftime('%d/%m/%Y %H:%M:%S'), end=stop), user = dict(username=infos['username']) ) self.set_status(200) self.write_result(user_info,"call") except ObjectDoesNotExist, e: raise tornado.web.HTTPError(409,"the token send is not correct")