本文整理汇总了Python中trac.versioncontrol.api.RepositoryManager.sync方法的典型用法代码示例。如果您正苦于以下问题:Python RepositoryManager.sync方法的具体用法?Python RepositoryManager.sync怎么用?Python RepositoryManager.sync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.versioncontrol.api.RepositoryManager
的用法示例。
在下文中一共展示了RepositoryManager.sync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_initenv
# 需要导入模块: from trac.versioncontrol.api import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.api.RepositoryManager import sync [as 别名]
#.........这里部分代码省略.........
project_name, db_str = self.get_initenv_args()
elif len(arg) == 2:
project_name, db_str = arg
elif len(arg) == 4:
project_name, db_str, repository_type, repository_dir = arg
else:
initenv_error('Wrong number of arguments: %d' % len(arg))
return 2
try:
printout(_("Creating and Initializing Project"))
options = []
if config:
for section in config.sections(defaults=False):
options.extend((section, option, value)
for option, value
in config.options(section))
options.extend([
('project', 'name', project_name),
('trac', 'database', db_str),
])
def add_nav_order_options(section, default):
for i, name in enumerate(default, 1):
options.append((section, name + '.order', float(i)))
add_nav_order_options('mainnav', default_mainnav_order)
add_nav_order_options('metanav', default_metanav_order)
if repository_dir:
options.extend([
('repositories', '.type', repository_type),
('repositories', '.dir', repository_dir),
])
if inherit_paths:
options.append(('inherit', 'file',
",\n ".join(inherit_paths)))
try:
self.__env = Environment(self.envname, create=True,
options=options)
except Exception as e:
initenv_error(_('Failed to create environment.'))
printerr(e)
traceback.print_exc()
sys.exit(1)
# Add a few default wiki pages
printout(_(" Installing default wiki pages"))
pages_dir = pkg_resources.resource_filename('trac.wiki',
'default-pages')
WikiAdmin(self.__env).load_pages(pages_dir)
if repository_dir:
try:
repos = RepositoryManager(self.__env).get_repository('')
if repos:
printout(_(" Indexing default repository"))
repos.sync(self._resync_feedback)
except TracError as e:
printerr(_("""
---------------------------------------------------------------------
Warning: couldn't index the default repository.
This can happen for a variety of reasons: wrong repository type,
no appropriate third party library for this repository type,
no actual repository at the specified repository path...
You can nevertheless start using your Trac environment, but
you'll need to check again your trac.ini file and the [trac]
repository_type and repository_path settings.
"""))
except Exception as e:
initenv_error(to_unicode(e))
traceback.print_exc()
return 2
printout(_("""
---------------------------------------------------------------------
Project environment for '%(project_name)s' created.
You may now configure the environment by editing the file:
%(config_path)s
If you'd like to take this new project environment for a test drive,
try running the Trac standalone web server `tracd`:
tracd --port 8000 %(project_path)s
Then point your browser to http://localhost:8000/%(project_dir)s.
There you can also browse the documentation for your installed
version of Trac, including information on further setup (such as
deploying Trac to a real web server).
The latest documentation can also always be found on the project
website:
http://trac.edgewall.org/
Congratulations!
""", project_name=project_name, project_path=self.envname,
project_dir=os.path.basename(self.envname),
config_path=os.path.join(self.envname, 'conf', 'trac.ini')))