• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python text.printout函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: do_import

 def do_import(db):
     cursor = db.cursor()
     # Make sure we don't insert the exact same page twice
     cursor.execute("SELECT text FROM wiki WHERE name=%s "
                    "ORDER BY version DESC LIMIT 1",
                    (title,))
     old = list(cursor)
     if old and title in create_only:
         printout(_('  %(title)s already exists', title=title))
         result[0] = False
         return
     if old and data == old[0][0]:
         printout(_('  %(title)s is already up to date', title=title))
         result[0] = False
         return
 
     if replace and old:
         cursor.execute("UPDATE wiki SET text=%s WHERE name=%s "
                        "  AND version=(SELECT max(version) FROM wiki "
                        "               WHERE name=%s)",
                        (data, title, title))
     else:
         cursor.execute("INSERT INTO wiki(version,name,time,author,"
                        "                 ipnr,text) "
                        "SELECT 1+COALESCE(max(version),0),%s,%s,"
                        "       'trac','127.0.0.1',%s FROM wiki "
                        "WHERE name=%s",
                        (title, to_utimestamp(datetime.now(utc)), data,
                         title))
     if not old:
         del WikiSystem(self.env).pages
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:31,代码来源:admin.py


示例2: main

def main():
    options, args = parse_args()
    names = sorted(name for name in resource_listdir('trac.wiki',
                                                     'default-pages')
                        if not name.startswith('.'))
    if args:
        args = sorted(set(names) & set(map(os.path.basename, args)))
    else:
        args = names

    if options.download:
        download_default_pages(args, options.prefix)

    env = EnvironmentStub()
    load_components(env)
    with env.db_transaction:
        for name in names:
            wiki = WikiPage(env, name)
            wiki.text = resource_string('trac.wiki', 'default-pages/' +
                                        name).decode('utf-8')
            if wiki.text:
                wiki.save('trac', '')
            else:
                printout('%s: Skipped empty page' % name)

    req = Mock(href=Href('/'), abs_href=Href('http://localhost/'),
               perm=MockPerm())
    for name in args:
        wiki = WikiPage(env, name)
        if not wiki.exists:
            continue
        context = web_context(req, wiki.resource)
        out = DummyIO()
        DefaultWikiChecker(env, context, name).format(wiki.text, out)
开发者ID:exocad,项目名称:exotrac,代码行数:34,代码来源:checkwiki.py


示例3: _do_changeset_modified

 def _do_changeset_modified(self, reponame, *revs):
     if is_default(reponame):
         reponame = ''
     rm = RepositoryManager(self.env)
     errors = rm.notify('changeset_modified', reponame, revs)
     for error in errors:
         printout(error)
开发者ID:exocad,项目名称:exotrac,代码行数:7,代码来源:admin.py


示例4: _do_changeset_added

 def _do_changeset_added(self, reponame, *revs):
     if is_default(reponame):
         reponame = ""
     rm = RepositoryManager(self.env)
     errors = rm.notify("changeset_added", reponame, revs)
     for error in errors:
         printout(error)
开发者ID:pkdevbox,项目名称:trac,代码行数:7,代码来源:admin.py


示例5: _do_wiki_upgrade

 def _do_wiki_upgrade(self):
     """Move all wiki pages starting with Trac prefix to unbranded user
     guide pages.
     """
     wiki_admin = WikiAdmin(self.env)
     pages = wiki_admin.get_wiki_list()
     for old_name in pages:
         if old_name.startswith('Trac'):
             new_name = wiki.new_name(old_name)
             if not new_name:
                 continue
             if new_name in pages:
                 printout(_('Ignoring %(page)s : '
                            'The page %(new_page)s already exists',
                            page=old_name, new_page=new_name))
                 continue
             try:
                 wiki_admin._do_rename(old_name, new_name)
             except AdminCommandError, exc:
                 printout(_('Error moving %(page)s : %(message)s',
                            page=old_name, message=unicode(exc)))
             else:
                 # On success, rename links in other pages
                 self._do_wiki_rename_links(old_name, new_name)
                 # On success, insert redirection page
                 redirection = WikiPage(self.env, old_name)
                 redirection.text = _('See [wiki:"%(name)s"].', name=new_name)
                 comment = 'Bloodhound guide update'
                 redirection.save('bloodhound', comment, '0.0.0.0')
开发者ID:Stackato-Apps,项目名称:bloodhound,代码行数:29,代码来源:admin.py


示例6: get_repository_id

    def get_repository_id(self, repository):
        """
        Returns the repository id inside Trac. This is needed to support
        multi-repository since v0.12. However, in lower versions of Trac, by simply
        using 'default' as repository name, it should work just fine :)
        """
        # The default repository is the one that has no "name" value in repository table
        if (repository == "default"):
            sql_string = """
                SELECT id
                 FROM repository 
                 WHERE name = 'name' AND value = '';
            """
            self.cursor.execute(sql_string)
            row = self.cursor.fetchone()
            # Default is an special situation, we need to handle different
            # Default dir could be specified in repository table or in trac.ini
            self.default = True
            return row[0]

        # The repository can be a path to the root of the repository
        if os.path.isdir(repository):
            # The default repository is not in the repository table
            # We need to check it apart, against the Trac's config file
            default_repository_path = self.config.get("trac", "repository_dir", "") 
            contains = re.compile(repository)
            if contains.match(default_repository_path):
                self.default = True
                return 1

            sql_string = """
                SELECT id
                 FROM repository
                 WHERE name = 'dir' AND value LIKE %s
            """
            self.cursor.execute(sql_string, ("%%%s%%" % repository,))
            row = self.cursor.fetchone()
            
            # If the repository is not controlled by Trac
            # We exit with successful execution. This way we can make a generic 
            # Mercurial hook that will work with all repositories in the machine
            if not row:
                printout("[E] Path",repository,"was not found in repository table, neither in Trac's config. Sync will not be executed")
                sys.exit(0)

        # Otherwise it should be the name of the repository
        else:
            sql_string = """
                SELECT id
                 FROM repository
                 WHERE name = 'name' AND value LIKE %s
            """
            self.cursor.execute(sql_string, (repository,))
            row = self.cursor.fetchone()
        
            if not row:
                printout("[E] Sorry, repository name not found")
                sys.exit(1)
        
        return row[0]
开发者ID:bkocherov,项目名称:TracMercurialChangesetPlugin,代码行数:60,代码来源:admin.py


示例7: main

def main():
    names = sorted(name for name in resource_listdir('trac.wiki',
                                                     'default-pages')
                        if not name.startswith('.'))

    env = EnvironmentStub()
    load_components(env)
    with env.db_transaction:
        for name in names:
            wiki = WikiPage(env, name)
            wiki.text = resource_string('trac.wiki', 'default-pages/' +
                                        name).decode('utf-8')
            if wiki.text:
                wiki.save('trac', '')
            else:
                printout('%s: Skipped empty page' % name)

    req = Mock(href=Href('/'), abs_href=Href('http://trac.edgewall.org/'),
               perm=MockPerm(), chrome={})
    for name in sys.argv[1:]:
        name = os.path.basename(name)
        wiki = WikiPage(env, name)
        if not wiki.exists:
            continue
        context = web_context(req, wiki.resource, absurls=True)
        rst = wiki2rest(env, context, wiki)
        sys.stdout.write(rst)
开发者ID:pkdevbox,项目名称:trac,代码行数:27,代码来源:wiki2rst.py


示例8: run

def run(args=None):
    """Main entry point."""
    if args is None:
        args = sys.argv[1:]
    if has_babel:
        translation.activate(get_console_locale())
    warn_setuptools_issue()
    admin = TracAdmin()
    if len(args) > 0:
        if args[0] in ('-h', '--help', 'help'):
            return admin.onecmd(' '.join(['help'] + args[1:]))
        elif args[0] in ('-v','--version'):
            printout(os.path.basename(sys.argv[0]), TRAC_VERSION)
        else:
            env_path = os.path.abspath(args[0])
            try:
                unicode(env_path, 'ascii')
            except UnicodeDecodeError:
                printerr(_("Non-ascii environment path '%(path)s' not "
                           "supported.", path=to_unicode(env_path)))
                sys.exit(2)
            admin.env_set(env_path)
            if len(args) > 1:
                s_args = ' '.join(["'%s'" % c for c in args[2:]])
                command = args[1] + ' ' + s_args
                return admin.onecmd(command)
            else:
                while True:
                    try:
                        admin.run()
                    except KeyboardInterrupt:
                        admin.do_quit('')
    else:
        return admin.onecmd("help")
开发者ID:pkdevbox,项目名称:trac,代码行数:34,代码来源:console.py


示例9: globally_get_command_help

    def globally_get_command_help(self, *args):
        sys_home_project_name = self.config.get('multiproject', 'sys_home_project_name')
        for env_name, in self.projects_iterator(['env_name'], batch_size=1):
            if env_name == sys_home_project_name:
                continue
            env = None

            try:
                env_path = safe_path(self.config.get('multiproject', 'sys_projects_root'),
                    env_name)
                env = open_environment(env_path, True)
            except TracError as e:
                printout(_('ERROR: Opening environment %(env_name)s failed', env_name=env_name))
                continue

            try:
                command_manager = AdminCommandManager(env)
                helps = command_manager.get_command_help(list(args))
                if not args:
                    TracAdmin.print_doc(helps, short=True)
                elif len(helps) == 1:
                    TracAdmin.print_doc(helps, long=True)
                else:
                    TracAdmin.print_doc(helps)

            except AdminCommandError as e:
                printout(_('ERROR: Getting command help in environment %(env_name)s failed: ',
                    env_name=env_name) + e)
            break
开发者ID:alvabai,项目名称:trac-multiproject,代码行数:29,代码来源:console.py


示例10: _load_fixture_from_file

 def _load_fixture_from_file(self, fname):
     """Calls _load_fixture with an open file"""
     try:
         fp = open(fname, mode='r')
         self._load_fixture(fp)
         fp.close()
     except IOError:
         printout(_("The file '%(fname)s' does not exist", fname=fname))
开发者ID:Stackato-Apps,项目名称:bloodhound,代码行数:8,代码来源:admin.py


示例11: _do_remove

 def _do_remove(self, number):
     try:
         number = int(number)
     except ValueError:
         raise AdminCommandError(_('<number> must be a number'))
     with self.env.db_transaction:
         model.Ticket(self.env, number).delete()
     printout(_('Ticket #%(num)s and all associated data removed.',
                num=number))
开发者ID:Stackato-Apps,项目名称:bloodhound,代码行数:9,代码来源:admin.py


示例12: do_load

 def do_load(db):
     for page in os.listdir(dir):
         if page in ignore:
             continue
         filename = os.path.join(dir, page)
         page = unicode_unquote(page.encode('utf-8'))
         if os.path.isfile(filename):
             if self.import_page(filename, page, create_only, replace):
                 printout(_("  %(page)s imported from %(filename)s",
                            filename=filename, page=page))
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:10,代码来源:admin.py


示例13: _add_comment

    def _add_comment(self, ticket_id, user, comment):
        """Add a comment to a ticket"""

        try:
            ticket = Ticket(self.env, ticket_id)
            self._save_ticket(ticket, user, comment)
            printout('Added comment to ticket %s' % ticket_id)
        except:
            # if no such ticket then add comment.
            printout('Unable to add comment.')
开发者ID:leihog,项目名称:TracTicketAdmin,代码行数:10,代码来源:api.py


示例14: do_transaction

 def do_transaction(db):
     for path in paths:
         if os.path.isdir(path):
             self.load_pages(path, replace=replace)
         else:
             page = os.path.basename(path)
             page = unicode_unquote(page.encode('utf-8'))
             if self.import_page(path, page, replace=replace):
                 printout(_("  %(page)s imported from %(filename)s",
                            filename=path, page=page))
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:10,代码来源:admin.py


示例15: _do_remove

 def _do_remove(self, number):
     try:
         number = int(number)
     except ValueError:
         raise AdminCommandError(_('<number> must be a number'))
     @self.env.with_transaction()
     def do_remove(db):
         ticket = model.Ticket(self.env, number, db=db)
         ticket.delete()
     printout(_('Ticket #%(num)s and all associated data removed.',
                num=number))
开发者ID:zjj,项目名称:trac_hack,代码行数:11,代码来源:admin.py


示例16: _do_add

 def _do_add(self, user, *actions):
     permsys = PermissionSystem(self.env)
     if user.isupper():
         raise AdminCommandError(_('All upper-cased tokens are reserved '
                                   'for permission names'))
     for action in actions:
         try:
             permsys.grant_permission(user, action)
         except self.env.db_exc.IntegrityError:
             printout(_("The user %(user)s already has permission "
                        "%(action)s.", user=user, action=action))
开发者ID:exocad,项目名称:exotrac,代码行数:11,代码来源:perm.py


示例17: _do_upgrade

    def _do_upgrade(self, no_backup=None):
        if no_backup not in (None, "-b", "--no-backup"):
            raise AdminCommandError(_("Invalid arguments"), show_usage=True)

        if not self.env.needs_upgrade():
            printout(_("Database is up to date, no upgrade necessary."))
            return

        try:
            self.env.upgrade(backup=no_backup is None)
        except BackupError as e:
            printerr(_("The pre-upgrade backup failed.\nUse '--no-backup' to " "upgrade without doing a backup.\n"))
            raise e.args[0]
        except Exception:
            printerr(_("The upgrade failed. Please fix the issue and try " "again.\n"))
            raise

        # Remove wiki-macros if it is empty and warn if it isn't
        wiki_macros = os.path.join(self.env.path, "wiki-macros")
        try:
            entries = os.listdir(wiki_macros)
        except OSError:
            pass
        else:
            if entries:
                printerr(
                    _(
                        "Warning: the wiki-macros directory in the "
                        "environment is non-empty, but Trac\n"
                        "doesn't load plugins from there anymore. "
                        "Please remove it by hand."
                    )
                )
            else:
                try:
                    os.rmdir(wiki_macros)
                except OSError as e:
                    printerr(
                        _(
                            "Error while removing wiki-macros: %(err)s\n"
                            "Trac doesn't load plugins from wiki-macros "
                            "anymore. Please remove it by hand.",
                            err=exception_to_unicode(e),
                        )
                    )

        printout(
            _(
                "Upgrade done.\n\n"
                "You may want to upgrade the Trac documentation now by "
                "running:\n\n  trac-admin %(path)s wiki upgrade",
                path=path_to_unicode(self.env.path),
            )
        )
开发者ID:spsoft-RockWang,项目名称:project-_trac,代码行数:54,代码来源:env.py


示例18: _load_or_replace

 def _load_or_replace(self, paths, replace):
     with self.env.db_transaction:
         for path in paths:
             if os.path.isdir(path):
                 self.load_pages(path, replace=replace)
             else:
                 page = os.path.basename(path)
                 page = unicode_unquote(page.encode('utf-8'))
                 if self.import_page(path, page, replace=replace):
                     printout(_("  %(page)s imported from %(filename)s",
                                filename=path_to_unicode(path), page=page))
开发者ID:pkdevbox,项目名称:trac,代码行数:11,代码来源:admin.py


示例19: load_pages

 def load_pages(self, dir, ignore=[], create_only=[], replace=False):
     with self.env.db_transaction:
         for page in os.listdir(dir):
             if page in ignore:
                 continue
             filename = os.path.join(dir, page)
             page = unicode_unquote(page.encode('utf-8'))
             if os.path.isfile(filename):
                 if self.import_page(filename, page, create_only, replace):
                     printout(_("  %(page)s imported from %(filename)s",
                                filename=path_to_unicode(filename),
                                page=page))
开发者ID:pkdevbox,项目名称:trac,代码行数:12,代码来源:admin.py


示例20: upgrade_environment

    def upgrade_environment(self, db):
        printout("Upgrading SimpleMultiProject database schema")
        cursor = db.cursor()

        db_installed_version = 0
        sqlGetInstalledVersion = """SELECT value FROM system WHERE name = %s"""
        cursor.execute(sqlGetInstalledVersion, [db_version_key])
        for row in cursor:
            db_installed_version = int(row[0])
        printout("SimpleMultiProject database schema version is %s, should be %s" %
                 (db_installed_version, db_version))

        db_connector, _ = DatabaseManager(self.env)._get_connector()

        if db_installed_version < 1:
            # Create tables
            for table in tables:
                for statement in db_connector.to_sql(table):
                    cursor.execute(statement)
                    
            sqlInsertVersion = """INSERT INTO system (name, value) VALUES (%s,%s)"""
            cursor.execute(sqlInsertVersion, [db_version_key, db_version])
            db_installed_version = 1
            
        if db_installed_version < 2:
            # Create tables
            for table in tables_v2:
                for statement in db_connector.to_sql(table):
                    cursor.execute(statement)
                    
            sqlInsertVersion = """UPDATE system SET value=%s WHERE name=%s"""
            cursor.execute(sqlInsertVersion, [db_version, db_version_key])
            db_installed_version = 2

        if db_installed_version < 3:
            # Create tables
            for table in tables_v3:
                for statement in db_connector.to_sql(table):
                    cursor.execute(statement)
                    
            sqlInsertVersion = """UPDATE system SET value=%s WHERE name=%s"""
            cursor.execute(sqlInsertVersion, [db_version, db_version_key])
            db_installed_version = 3

        if db_installed_version < 4:
            # Insert new column
            cursor.execute("""ALTER TABLE smp_project ADD summary varchar(255)""")
            
            sqlInsertVersion = """UPDATE system SET value=%s WHERE name=%s"""
            cursor.execute(sqlInsertVersion, [db_version, db_version_key])
            db_installed_version = 4
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:51,代码来源:environmentSetup.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python text.shorten_line函数代码示例发布时间:2022-05-27
下一篇:
Python text.print_table函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap