def call(self): # Track time it took to get response start = util.get_time() call = requests.get(self.url) end = util.get_time() # When endpoint responds successfully... if call.status_code == requests.codes.ok: print(GREEN + 'GET {0}: {1} {2}'.format( self.endpoint, call.status_code, call.reason) + END) # TODO add logging integration here # Get status from statuses.json and notify if there is a change if status.get_status(self.endpoint) == 'down': status.set_status(self.endpoint, 'up') # TODO add Slack notification integration here # When endpoint responds with a failure... else: print(RED + 'GET {0}: {1} {2}'.format( self.endpoint, call.status_code, call.reason) + END) # TODO add logging integration here # Get status from statuses.json and notify if there is a change if status.get_status(self.endpoint) == 'up': status.set_status(self.endpoint, 'down') # TODO add Slack notification integration here print('Call to {0} took {1}ms\n'.format(self.endpoint, end - start))
def _cleanup_friends_list(self): current_time = get_time() period = self._settings['maximum_friend_inactivity_period'] friend_last_time_online_min_time = current_time - period * 24 * 60 * 60 for friend_number in self._get_friends_list(): last_time_online = self._tox.friend_get_last_online() if last_time_online < friend_last_time_online_min_time: self._delete_friend(friend_number)
def __init__(self, tox, settings, profile_manager, permission_checker, stop_action, reconnect_action): self._tox = tox self._settings = settings self._profile_manager = profile_manager self._permission_checker = permission_checker self._stop_action = stop_action self._reconnect_action = reconnect_action self._start_time = get_time()
def create_info(self): current_time = get_time() online_time = time_from_seconds(current_time - self._start_time) friends_list = self._tox.self_get_friend_list() friends_count = len(friends_list) online_friends_count = sum([ self._tox.friend_get_connection_status(friend) != TOX_CONNECTION['NONE'] for friend in friends_list ]) messages = [ 'Uptime: ' + online_time, 'Friends: {} ({} online)'.format(friends_count, online_friends_count) ] return messages
def __init__(self, tox, settings, profile_manager, permission_checker, file_transfer_handler, group_service, stop_action, reconnect_action): super().__init__(tox) self._settings = settings self._profile_manager = profile_manager self._permission_checker = permission_checker self._file_transfer_handler = file_transfer_handler self._group_service = group_service self._stop_action = stop_action self._reconnect_action = reconnect_action self._start_time = get_time() self._timer = None self._waiting_for_reconnection = False self._print_info()