def is_satisfied_by(self, *args, **kwargs): user_data = kwargs.get("user_data", None) action_cache = kwargs.get("action_cache", None) if user_data is None or action_cache is None: return False # Make sure they've been a member for at least X years if user_data.joined is None or util.seconds_since(user_data.joined) < self.seconds_required: return False # Make sure they've seen recent activity of any sort in the past 30 days c_problem_logs = len(action_cache.problem_logs) c_video_logs = len(action_cache.video_logs) if c_problem_logs > 0: problem_log = action_cache.get_problem_log(c_problem_logs - 1) if util.seconds_since(problem_log.time_done) < 60 * 60 * 24 * 30: return True if c_video_logs > 0: video_log = action_cache.get_video_log(c_video_logs - 1) if util.seconds_since(video_log.time_watched) < 60 * 60 * 24 * 30: return True return False
def is_satisfied_by(self, *args, **kwargs): user_data = kwargs.get("user_data", None) action_cache = kwargs.get("action_cache", None) if user_data is None or action_cache is None: return False # Make sure they've been a member for at least X years if user_data.joined is None or util.seconds_since( user_data.joined) < self.seconds_required: return False # Make sure they've seen recent activity of any sort in the past 30 days c_problem_logs = len(action_cache.problem_logs) c_video_logs = len(action_cache.video_logs) if c_problem_logs > 0: problem_log = action_cache.get_problem_log(c_problem_logs - 1) if util.seconds_since(problem_log.time_done) < 60 * 60 * 24 * 30: return True if c_video_logs > 0: video_log = action_cache.get_video_log(c_video_logs - 1) if util.seconds_since(video_log.time_watched) < 60 * 60 * 24 * 30: return True return False
def is_satisfied_by(self, *args, **kwargs): user_data = kwargs.get("user_data", None) if user_data is None: return False # Make sure they've been a member for at least X years if user_data.joined is None or util.seconds_since(user_data.joined) < self.seconds_required: return False return True
def is_satisfied_by(self, *args, **kwargs): user_data = kwargs.get("user_data", None) if user_data is None: return False # Make sure they've been a member for at least X years if user_data.joined is None or (util.seconds_since(user_data.joined) < self.seconds_required): return False return True
def timesince_ago(content): if not content: return "" return append_ago(seconds_to_time_string(util.seconds_since(content)))
def timesince_ago_short(content): if not content: return "" return append_ago(util.seconds_to_time_string(util.seconds_since(content)))
def timesince_ago_en(content): if not content: return "" return _seconds_to_time_string(util.seconds_since(content), ago=True, english=True)
def _callfailed(self, reason, status=None): """If answered=True, it answered, but returned an invalid response.""" session = meta.Session() data = {} # FIXME: pass as a parameter entry = Domain.getone() if not entry.contact_failures: entry.contact_failures = 1 else: entry.contact_failures += 1 if status == 404: # The license was not found. # Set the expiration to now. entry.expiration_time = func.now() session.commit() return if not entry.contact_time: # Never connected successfully to the license server. # Could happen on initial installation. # Give them 72 hours to get this sorted out by pretending # they contacted the server on initial attempt. entry.contact_time = func.now() session.commit() return max_silence_time = self.server.system[SystemKeys.MAX_SILENCE_TIME] silence_time = seconds_since(entry.contact_time) # print "contact_time:", entry.contact_time # print "timestamp thing:", datetime.datetime.utcnow() # print "silence_time:", silence_time, "max:", max_silence_time if silence_time <= max_silence_time and max_silence_time != -1: # It failed to phone home, but we have more time to try, logging.debug("silence_time: %d <= max: %d", silence_time, max_silence_time) # If they had no expiration time (like on initial install) # then expire it now. if not entry.expiration_time: entry.expiration_time = func.now() session.commit() return data['failure_hours'] = int((datetime.datetime.utcnow() - \ entry.contact_time).total_seconds() / 3600) logging.debug("failure hours was longer than %d: %d", max_silence_time, data['failure_hours']) notification = self.server.notifications.get("phonehome") notification.description = reason if not status is None: notification.description += ', status: ' + str(status) data['contact_failures'] = entry.contact_failures data['last_contact_time'] = entry.contact_time if max_silence_time != -1: data['max_silence_hours'] = max_silence_time / (60 * 60) else: data['max_silence_hours'] = 96 # just to be different if notification.color != 'red': self.server.event_control.gen(EventControl.PHONE_HOME_FAILED, data) notification.color = 'red' notification.notified_color = 'red' # Remember when we sent the notification notification.modification_time = func.now() session.commit()