コード例 #1
0
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') == '???'
コード例 #2
0
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') == '???'
コード例 #3
0
 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)
コード例 #4
0
ファイル: __init__.py プロジェクト: rmoorman/pyramid-phoenix
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
コード例 #5
0
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
コード例 #6
0
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
コード例 #7
0
ファイル: grid.py プロジェクト: TeriForey/fawkes
 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))
コード例 #8
0
ファイル: start.py プロジェクト: Ouranosinc/pyramid-phoenix
 def gentitle(job):
     return "{0} - {1} - {2}".format(
         job.get('title'), job.get('caption', '???'),
         time_ago_in_words(job.get('finished')))
コード例 #9
0
ファイル: __init__.py プロジェクト: KatiRG/pyramid-phoenix
 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))
コード例 #10
0
ファイル: grid.py プロジェクト: bird-house/pyramid-phoenix
 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))