当前位置: 首页>>代码示例>>Python>>正文


Python util.format_datetime函数代码示例

本文整理汇总了Python中trac.util.format_datetime函数的典型用法代码示例。如果您正苦于以下问题:Python format_datetime函数的具体用法?Python format_datetime怎么用?Python format_datetime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了format_datetime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_build_data

def _get_build_data(env, req, build):
    platform = TargetPlatform.fetch(env, build.platform)
    data = {'id': build.id, 'name': build.slave, 'rev': build.rev,
            'status': _status_label[build.status],
            'platform': getattr(platform, 'name', 'unknown'),
            'cls': _status_label[build.status].replace(' ', '-'),
            'href': req.href.build(build.config, build.id),
            'chgset_href': req.href.changeset(build.rev)}
    if build.started:
        data['started'] = format_datetime(build.started)
        data['started_delta'] = pretty_timedelta(build.started)
        data['duration'] = pretty_timedelta(build.started)
    if build.stopped:
        data['stopped'] = format_datetime(build.stopped)
        data['stopped_delta'] = pretty_timedelta(build.stopped)
        data['duration'] = pretty_timedelta(build.stopped, build.started)
    data['slave'] = {
        'name': build.slave,
        'ipnr': build.slave_info.get(Build.IP_ADDRESS),
        'os_name': build.slave_info.get(Build.OS_NAME),
        'os_family': build.slave_info.get(Build.OS_FAMILY),
        'os_version': build.slave_info.get(Build.OS_VERSION),
        'machine': build.slave_info.get(Build.MACHINE),
        'processor': build.slave_info.get(Build.PROCESSOR)
    }
    return data
开发者ID:kroman0,项目名称:bitten,代码行数:26,代码来源:web_ui.py

示例2: process_request

    def process_request(self, req):
        req.hdf['trac.href.blog'] = req.href.blog()

        entries = []
        for page_name in WikiSystem(self.env).get_pages(prefix='Blog'):
            page = WikiPage(self.env, page_name)
            title = page_name
            text = page.text

            match = title_split_match(page.text)
            if match:
                title = match.group(1)
                text = match.group(2)

            comments = text.count('[[SimpleBlogComment(')
            cutoff = text.find('[[SimpleBlogComment(')
            if cutoff >= 0:
                text = text[:cutoff].rstrip()
            description = wiki_to_html(text, self.env, req)

            original = self._get_original_post_info(page_name)
            event = {
                'href': self.env.href.wiki(page_name),
                'title': title,
                'description': description,
                'escaped': Markup.escape(unicode(description)),
                'date': format_datetime(original['time']),
                'rfcdate': http_date(original['time']),
                'author': original['author'],
                'comment': original['comment'],
                'comments': comments,
                }
            if page.version > 1:
                event['updated.version'] = page.version
                event['updated.date'] = format_datetime(page.time)
                event['updated.rfcdate'] = http_date(page.time)
                event['updated.author'] = page.author
                event['updated.comment'] = page.comment
            entries.append((original['time'], event))

        entries.sort()
        entries.reverse()
        max_count = 20
        if len(entries) > max_count:
            entries = entries[:max_count]

        events = []
        for date, event in entries:
            events.append(event)
        req.hdf['blog.events'] = events

        format = req.args.get('format')
        if format == 'rss':
            return 'blog_rss.cs', 'application/rss+xml'

        add_link(req, 'alternate', self.env.href.blog(format='rss'),
                 'RSS Feed', 'application/rss+xml', 'rss')
        return 'blog.cs', None
开发者ID:Adel-Magebinary,项目名称:browsershots,代码行数:58,代码来源:__init__.py

示例3: iTest_report

def iTest_report(env, test):
        import itest_mmi_data
        from trac.util import format_datetime
        
        testname = test.name        
        test_type = itest_mmi_data._test_type(env, test)          
        test_url=gl.url_log_testid_(test) #'http://itest-center/iTest/build/testresult/' + str(test.id)
        versionpath=test.versionpath
        version_num = test.version_num
        passratio=itest_mmi_data._test_passratio(env, test)
        total=itest_mmi_data._test_total_num(env, test)
        passed=test.passed
        failed=test.failed
        start_t=format_datetime(test.started)
        end=format_datetime(test.stopped)
        timecost=itest_mmi_data._test_timecost(env, test.started, test.stopped)
        result_path=itest_mmi_data._test_reportpath(env, test)
        caselist=itest_mmi_data._test_xmlfile_mmipath(env, test)        

        #if 1:
        #    comment_content = "---------------------------------------\n"
        #    comment_content += "---------------------------------------\n"

        js = ''
        js += "<br /><br /><br /><br />" 
        js += web_li('Test Name', testname)           
        js += "<br />"
        js += web_li('Version Num', version_num)           
        js += "<br />"        
        js += web_li('Type', test_type)           
        js += "<br />"          
        js += web_li('Total Cases Num', str(total))           
        js += "<br />"  
        js += web_li('Passed Cases Num', str(passed))           
        js += "<br />"  
        js += web_li('Failed Cases Num', str(failed))           
        js += "<br />"  
        js += web_li('Pass Ratio', passratio)           
        js += "<br />"  
        #js += web_li('Start Time', test.start)           
        #js += "<br />"  
        #js += web_li('End Time', test.end)           
        js += "<br />"  
        #js += web_li('Time Cost', test.timecost)           
        #js += "<br />"  
        #js += web_li('Status', test.status)           
        js += "<br />"  
        js += web_li('Result Path', result_path)           
        js += "<br />"          
        js += web_li('CaseList Path', caselist)           
        js += "<br />"  
        js += web_li('Version Path', versionpath )           
        js += "<br />"    
        js += web_li('Test URL', test_url )           
        js += "<br /><br />" 
        
        js += "<br />" 
        return js    
开发者ID:monadyn,项目名称:itest_cts,代码行数:58,代码来源:web_utils.py

示例4: process_projmanager_request

    def process_projmanager_request(self, req, cat, page, version):
        # Detail view?
        if version:
            ver = ticket.Version(self.env, version)
            if req.method == 'POST':
                if req.args.get('save'):
                    ver.name = req.args.get('name')
                    if req.args.get('time'):
                        try:
                            ver.time =  util.parse_date(req.args.get('time'))
                        except ValueError:
                            ver.time = ""
                    ver.description = req.args.get('description')
                    ver.update()
                    req.redirect(self.env.href.projmanager(cat, page))
                elif req.args.get('cancel'):
                    req.redirect(self.env.href.projmanager(cat, page))

            req.hdf['projmanager.version'] = {
                'name': ver.name,
                'time': ver.time and util.format_datetime(ver.time) or '',
                'description': ver.description
            }
        else:
            if req.method == 'POST':
                # Add Version
                if req.args.get('add') and req.args.get('name'):
                    ver = ticket.Version(self.env)
                    ver.name = req.args.get('name')
                    if req.args.get('time'):
                        ver.time = util.parse_date(req.args.get('time'))
                    if req.args.get('description'):
                        ver.description = req.args.get('description')
                    ver.insert()
                    req.redirect(self.env.href.projmanager(cat, page))
                         
                # Remove versions
                elif req.args.get('remove') and req.args.get('sel'):
                    sel = req.args.get('sel')
                    sel = isinstance(sel, list) and sel or [sel]
                    if not sel:
                        raise TracError, 'No version selected'
                    db = self.env.get_db_cnx()
                    for name in sel:
                        ver = ticket.Version(self.env, name, db=db)
                        ver.delete(db=db)
                    db.commit()
                    req.redirect(self.env.href.projmanager(cat, page))

            req.hdf['projmanager.versions'] = \
                [{'name': version.name,
                  'time': version.time and util.format_datetime(version.time) or '',
                  'href': self.env.href.projmanager(cat, page, version.name)
                 } for version in ticket.Version.select(self.env)]

        return 'projmanager_version.cs', None
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:56,代码来源:version.py

示例5: render_discussion

    def render_discussion(self, req, cursor):
        # Get request mode
        group, forum, topic, message = self._get_items(req, cursor)
        modes = self._get_modes(req, group, forum, topic, message)
        self.log.debug('modes: %s' % modes)

        # Determine moderator rights.
        if forum:
            is_moderator = (req.authname in forum['moderators']) or \
              req.perm.has_permission('DISCUSSION_ADMIN')
        else:
            is_moderator = req.perm.has_permission('DISCUSSION_ADMIN')

        # Perform mode actions
        self._do_action(req, cursor, modes, group, forum, topic, message,
          is_moderator)

        # Add CSS styles
        add_stylesheet(req, 'common/css/wiki.css')
        add_stylesheet(req, 'discussion/css/discussion.css')
        add_stylesheet(req, 'discussion/css/admin.css')

        # Fill up HDF structure and return template
        req.hdf['discussion.authname'] = req.authname
        req.hdf['discussion.is_moderator'] = is_moderator
        if group:
            group['name'] = wiki_to_oneliner(group['name'], self.env)
            group['description'] = wiki_to_oneliner(group['description'],
              self.env)
            req.hdf['discussion.group'] = group
        if forum:
            forum['name'] = wiki_to_oneliner(forum['name'], self.env)
            forum['description'] = wiki_to_oneliner(forum['description'],
              self.env)
            forum['subject'] = wiki_to_oneliner(forum['subject'], self.env)
            forum['time'] = format_datetime(forum['time'])
            req.hdf['discussion.forum'] = forum
        if topic:
            topic['subject'] = wiki_to_oneliner(topic['subject'], self.env)
            topic['author'] = wiki_to_oneliner(topic['author'], self.env)
            topic['body'] = wiki_to_html(topic['body'], self.env, req)
            topic['time'] = format_datetime(topic['time'])
            req.hdf['discussion.topic'] = topic
        if message:
            message['author'] = wiki_to_oneliner(message['author'], self.env)
            message['body'] = wiki_to_html(message['body'], self.env, req)
            message['time'] = format_datetime(message['time'])
            req.hdf['discussion.message'] = message
        req.hdf['discussion.mode'] = modes[-1]
        req.hdf['discussion.time'] = format_datetime(time.time())
        return modes[-1] + '.cs', None
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:51,代码来源:api.py

示例6: formattime

 def formattime(self,time):
     """Return formatted time for ListOfWikiPages table."""
     time = int(time)
     return [ tag.span( format_datetime  ( time ) ),
              tag.span(
                 " (", 
                 tag.a( pretty_timedelta ( time ),
                        href = self.href('timeline',
                               precision='seconds', from_=
                               quote_plus( format_datetime (time,'iso8601') )
                        ) ),
                 " ago)"
              )
            ]
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:14,代码来源:macro.py

示例7: expand_macro

    def expand_macro(self, formatter, name, content):
        req = formatter.req
        args, kwargs = parse_args(content)
        args += [None, None]
        path, limit, rev = args[:3]
        limit = kwargs.pop('limit', limit)
        rev = kwargs.pop('rev', rev)

        if 'CHANGESET_VIEW' not in req.perm:
            return Markup('<i>Changelog not available</i>')

        repo = self.env.get_repository(req.authname)

        if rev is None:
            rev = repo.get_youngest_rev()
        rev = repo.normalize_rev(rev)
        path = repo.normalize_path(path)
        if limit is None:
            limit = 5
        else:
            limit = int(limit)
        node = repo.get_node(path, rev)
        out = StringIO()
        out.write('<div class="changelog">\n')
        for npath, nrev, nlog in node.get_history(limit):
            change = repo.get_changeset(nrev)
            datetime = format_datetime(change.date, '%Y/%m/%d %H:%M:%S', req.tz)
            out.write(wiki_to_html("'''[%s] by %s on %s'''\n\n%s" %
                (nrev, change.author, datetime, change.message),
                                   self.env, req));
        out.write('</div>\n')
        return out.getvalue()
开发者ID:lkraav,项目名称:trachacks,代码行数:32,代码来源:ChangeLogMacro.py

示例8: get_timeline_events

    def get_timeline_events(self, req, start, stop, filters):
        if isinstance(start, datetime): # Trac>=0.11
                from trac.util.datefmt import to_timestamp
                start = to_timestamp(start)
                stop = to_timestamp(stop)

        if 'build' in filters:
            add_stylesheet(req, 'BambooTrac/bambootrac.css')

            feed = feedparser.parse(self.feed_url, handlers=[self.bAuth, self.dAuth])

            for entry in feed.entries:

                # check time range
                completed = calendar.timegm(entry.date_parsed)

                # create timeline entry
                if entry.title.find('SUCCESS') >= 0:
                    message = 'Build finished successfully'
                    kind = 'bamboo-successful'
                else:
                    message = 'Build failed'
                    kind = 'bamboo-failed'

                fulltitle = entry.title.split(":")
                newtitle = fulltitle[0]
				
                href = entry.link
                title = entry.title

                comment = message + ' at ' + format_datetime(completed)

                yield kind, href, newtitle, completed, None, comment
开发者ID:grimsy,项目名称:bamboo-trac-plugin,代码行数:33,代码来源:BambooTracPlugin.py

示例9: get_topics

 def get_topics(self, req, cursor, forum_id, order_by = 'time', desc = False):
     if not order_by in ('replies', 'lastreply',):
         order_by = 't.' + order_by
     columns = ('id', 'forum', 'time', 'subject', 'body', 'author',
       'replies', 'lastreply')
     sql = "SELECT t.id, t.forum, t.time, t.subject, t.body, t.author," \
       " m.replies, m.lastreply FROM topic t LEFT JOIN (SELECT COUNT(id)" \
       " AS replies, MAX(time) AS lastreply, topic FROM message GROUP BY" \
       " topic) m ON t.id = m.topic WHERE t.forum = %s ORDER BY " \
       + order_by + (" ASC", " DESC")[bool(desc)]
     self.log.debug(sql % (forum_id,))
     cursor.execute(sql, (forum_id,))
     topics = []
     for row in cursor:
         row = dict(zip(columns, row))
         row['author'] = wiki_to_oneliner(row['author'], self.env)
         row['body'] = wiki_to_html(row['body'], self.env, req)
         if row['lastreply']:
             row['lastreply'] = pretty_timedelta(float(row['lastreply']))
         else:
             row['lastreply'] = 'No replies'
         if not row['replies']:
             row['replies'] = 0
         row['time'] = format_datetime(row['time'])
         topics.append(row)
     return topics
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:26,代码来源:api.py

示例10: get_forums

 def get_forums(self, req, cursor, order_by = 'ORDER BY subject ASC'):
     columns = ('id', 'name', 'author', 'time', 'moderators', 'group',
       'subject', 'description', 'topics', 'replies', 'lastreply',
       'lasttopic')
     sql = "SELECT id, name, author, time, moderators, forum_group," \
       " subject, description, (SELECT COUNT(id) FROM topic t WHERE" \
       " t.forum = forum.id) AS topics, (SELECT COUNT(id) FROM message m" \
       " WHERE m.forum = forum.id) AS replies, (SELECT MAX(time) FROM" \
       " message m WHERE m.forum = forum.id) AS lasttopic, (SELECT" \
       " MAX(time) FROM topic t WHERE t.forum = forum.id) AS lastreply" \
       " FROM forum " + order_by
     self.log.debug(sql)
     cursor.execute(sql)
     forums = []
     for row in cursor:
         row = dict(zip(columns, row))
         row['moderators'] = wiki_to_oneliner(row['moderators'], self.env)
         row['description'] = wiki_to_oneliner(row['description'], self.env)
         if row['lastreply']:
             row['lastreply'] = pretty_timedelta(row['lastreply'])
         else:
             row['lastreply'] = 'No replies'
         if row['lasttopic']:
             row['lasttopic'] = pretty_timedelta(row['lasttopic'])
         else:
             row['lasttopic'] = 'No topics'
         row['time'] = format_datetime(row['time'])
         forums.append(row)
     return forums
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:29,代码来源:api.py

示例11: _render_stats_delete

    def _render_stats_delete(self, req, delete=False):
        href_back = self.env.href.admin(self.cat, self.page, req.args.get("page_part"), req.args.get("page"))
        if not req.args.get("get_4"):
            req.redirect(href_back)
        id = int(req.args.get("get_4"))
        try:
            dwnl = DownloadData(self.env, req, id=id)
        except TracError:
            req.redirect(href_back)
        try:
            file = File(self.env, dwnl.file_id)
        except TracError:
            file.name = "id=" + str(dwnl.file_id)

        if not delete:
            req.hdf["dwn_record.redir"] = href_back + self.get_method_string(req)
            req.hdf["dwn_record.id"] = dwnl.id
            req.hdf["dwn_record.file"] = file.name
            req.hdf["dwn_record.timest"] = util.format_datetime(dwnl.timestamp)

            req.hdf["dwn_record.items"] = dwnl.get_attr_list()

            return "admin_downloader_stats_really_delete.cs", None
        else:
            dwnl.delete()
            if req.args.has_key("redirect_back"):
                req.redirect(req.args.get("redirect_back"))
            else:
                req.redirect(href_back)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:29,代码来源:admin.py

示例12: get_messages

    def get_messages(self, req, cursor, topic, time, order_by = 'ORDER BY time ASC'):
        columns = ('id', 'replyto', 'time', 'author', 'body')
        sql = "SELECT id, replyto, time, author, body FROM message WHERE" \
          " topic = %s " + order_by
        self.log.debug(sql % (topic,))
        cursor.execute(sql, (topic,))
        messagemap = {}
        messages = []
        for row in cursor:
            row = dict(zip(columns, row))
            row['author'] = wiki_to_oneliner(row['author'], self.env)
            row['body'] = wiki_to_html(row['body'], self.env, req)
            if int(row['time']) > time:
                row['new'] = True
            row['time'] = format_datetime(row['time'])
            messagemap[row['id']] = row

            # Add top-level messages to the main list, in order of time
            if row['replyto'] == -1:
                messages.append(row)

        # Second pass, add replies
        for message in messagemap.values():
            if message['replyto'] != -1:
                parent = messagemap[message['replyto']]
                if 'replies' in parent:
                    parent['replies'].append(message)
                else:
                    parent['replies'] = [message]
        return messages;
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:30,代码来源:api.py

示例13: get_timeline_events

    def get_timeline_events(self, req, start, stop, filters):
        if "build" in filters:
            add_stylesheet(req, "HudsonTrac/hudsontrac.css")

            feed = feedparser.parse(self.feed_url)

            for entry in feed.entries:
                # Only look at top-level entries
                if not self.disp_sub and entry.title.find(u"»") >= 0:
                    continue

                # check time range
                completed = calendar.timegm(entry.updated_parsed)
                if completed > stop:
                    continue
                if completed < start:
                    break

                    # create timeline entry
                if entry.title.find("SUCCESS") >= 0:
                    message = "Build finished successfully"
                    kind = "build-successful"
                else:
                    message = "Build failed"
                    kind = "build-failed"

                href = entry.link
                title = entry.title
                comment = message + " at " + format_datetime(completed)

                yield kind, href, title, completed, None, comment
开发者ID:khots,项目名称:common-security-module,代码行数:31,代码来源:HudsonTracPlugin.py

示例14: post_process_request

 def post_process_request(self, req, template, content_type):
     # req.hdf['wiki.page_html'] = str(req.hdf)
     # return (template, content_type)
     if not (req.hdf and
             'wiki.action' in req.hdf and
             req.hdf['wiki.action'] == 'view'):
         return (template, content_type)
     if not ('wiki.page_name' in req.hdf and
             'wiki.page_html' in req.hdf):
         return (template, content_type)
     page_name = req.hdf['wiki.page_name']
     if not page_name.startswith('Blog'):
         return (template, content_type)
     match = h1_match(req.hdf['wiki.page_html'])
     if not match:
         return (template, content_type)
     original = self._get_original_post_info(page_name)
     title, body = match.groups()
     title = title.rstrip()
     body = body.lstrip()
     permalink = '<a href="%s" title="Permalink" style="%s">#</a>' % (
         '/'.join((req.hdf['base_url'], 'wiki', page_name)),
         'border-bottom-style: none;')
     post_info = '<p style="%s">%s | %s | %s</p>' % (
         'font-size: smaller; color: gray; margin: 0 0 0 -18px;',
         format_datetime(original['time']),
         original['author'],
         permalink)
     req.hdf['wiki.page_html'] = Markup('\n'.join(
         (title, post_info, body)))
     return (template, content_type)
开发者ID:Adel-Magebinary,项目名称:browsershots,代码行数:31,代码来源:__init__.py

示例15: _render_stats_delete

 def _render_stats_delete(self, req, delete=False):
     href_back = self.env.href.admin(
                                     self.cat, 
                                     self.page, 
                                     req.args['page_part'].value,
                                     req.args['page'].value
                                     )
     if not req.args['get_4'].value:
         req.redirect(href_back)
     id = int(req.args['get_4'].value)
     try:
         dwnl = DownloadData(self.env, req, id=id)
     except TracError:
         req.redirect(href_back)
     try:
         file = File(self.env, dwnl.file_id)
     except TracError:
         file.name = 'id=' + str(dwnl.file_id)
         
     if not delete:
         req.hdf['dwn_record.redir'] = \
                 href_back + self.get_method_string(req)
         req.hdf['dwn_record.id'] = dwnl.id
         req.hdf['dwn_record.file'] = file.name
         req.hdf['dwn_record.timest'] = util.format_datetime(dwnl.timestamp)
         
         req.hdf['dwn_record.items'] = dwnl.get_attr_list()
             
         return 'admin_downloader_stats_really_delete.cs', None
     else:
         dwnl.delete()
         if req.args.has_key('redirect_back'):
             req.redirect(req.args['redirect_back'].value)
         else:
             req.redirect(href_back)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:35,代码来源:admin.py


注:本文中的trac.util.format_datetime函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。