def test_time_ago_in_words(): assert utils.time_ago_in_words(datetime.now() - timedelta(minutes=1)) == '1 minute ago' assert utils.time_ago_in_words(datetime.now() - timedelta(hours=1, minutes=7)) == '1 hour ago' assert utils.time_ago_in_words(datetime.now() - timedelta(hours=1, minutes=1)) == '1 hour ago' assert utils.time_ago_in_words(datetime.now() - timedelta(days=1, hours=1)) == '1 day ago' assert utils.time_ago_in_words(datetime.now() - timedelta(days=31, hours=1)) == '1 month ago' assert utils.time_ago_in_words(datetime.now() - timedelta(days=366, hours=1)) == '1 year ago' assert utils.time_ago_in_words('nothing') == '???'
def deferred_favorite_widget(node, kw): jobs = kw.get('jobs', []) last = kw.get('last', False) gentitle = lambda job: "{0} - {1} - {2}".format( job.get('title'), job.get('caption', '???'), time_ago_in_words(job.get('finished'))) choices = [('', 'No Favorite')] if last: choices.append(('last', 'Last Run')) logger.debug('jobs %s', jobs) choices.extend([(job['identifier'], gentitle(job)) for job in jobs]) return SelectWidget(values=choices)
def job_details(request, job_id): job = request.db.jobs.find_one({'identifier': job_id}) details = {} if job is not None: details['identifier'] = job.get('identifier') details['title'] = job.get('title') details['abstract'] = job.get('abstract') details['status'] = job.get('status', 'unknown') details['finished'] = time_ago_in_words(job.get('finished')) details['progress'] = job.get('progress') details['duration'] = job.get('duration') details['status_message'] = job.get('status_message') details['status_location'] = job.get('status_location') return details
def job_details(request, job_id): job = request.db.jobs.find_one({'identifier': job_id}) details = {} if job is not None: details['identifier'] = job.get('identifier') details['title'] = job.get('title') details['abstract'] = job.get('abstract') details['status'] = job.get('status', 'unknown') details['finished'] = time_ago_in_words(job.get('finished')) details['progress'] = job.get('progress') details['duration'] = job.get('duration') details['status_message'] = job.get('status_message') or '' if len(details['status_message']) > 250: details['status_message'] = details['status_message'][:250] + " [..]" # not more the 250 chars if job.get('status_location'): details['status_location'] = job['status_location'] elif job.get('response'): details['response'] = job['response'] details['caption'] = job.get('caption', '???') details['tags'] = job.get('tags') return details
def job_details(request, job_id): job = request.db.jobs.find_one({'identifier': job_id}) details = {} if job is not None: details['identifier'] = job.get('identifier') details['title'] = job.get('title') details['abstract'] = job.get('abstract') details['status'] = job.get('status', 'unknown') details['finished'] = time_ago_in_words(job.get('finished')) details['progress'] = job.get('progress') details['duration'] = job.get('duration') details['status_message'] = job.get('status_message', '') if len(details['status_message']) > 250: details['status_message'] = details[ 'status_message'][:250] + " [..]" # not more the 250 chars if job.get('status_location'): details['status_location'] = job['status_location'] elif job.get('response'): details['response'] = job['response'] details['caption'] = job.get('caption', '???') details['tags'] = job.get('tags') return details
def _column_format(column_number, i, record): from phoenix.utils import time_ago_in_words timestamp = get_value(record, attribute) return HTML.td(time_ago_in_words(timestamp))
def gentitle(job): return "{0} - {1} - {2}".format( job.get('title'), job.get('caption', '???'), time_ago_in_words(job.get('finished')))
def render_time_ago_td(self, from_time): from phoenix.utils import time_ago_in_words return self.render_label_td(time_ago_in_words(from_time))