def main(directory, force=False):
    WebServiceApplication.cached_wadl = None  # do not use cached file version
    execute_zcml_for_scripts()
    config = getUtility(IWebServiceConfiguration)

    # First, create an index.html with links to all the HTML
    # documentation files we're about to generate.
    template_file = "apidoc-index.pt"
    template = PageTemplateFile(template_file)
    index_filename = os.path.join(directory, "index.html")
    print "Writing index:", index_filename
    f = open(index_filename, "w")
    f.write(template(config=config))

    # Get the time of the last commit.  We will use this as the mtime for the
    # generated files so that we can safely use it as part of Apache's etag
    # generation in the face of multiple servers/filesystems.
    with bzrlib.initialize():
        branch = Branch.open(os.path.dirname(os.path.dirname(__file__)))
        timestamp = branch.repository.get_revision(branch.last_revision()).timestamp

    # Start a process to build each set of WADL and HTML files.
    processes = []
    for version in config.active_versions:
        p = Process(target=make_files, args=(directory, version, timestamp, force))
        p.start()
        processes.append(p)

    # Wait for all the subprocesses to finish.
    for p in processes:
        p.join()

    return 0
Beispiel #2
0
def main(directory, force=False):
    WebServiceApplication.cached_wadl = None  # do not use cached file version
    execute_zcml_for_scripts()
    config = getUtility(IWebServiceConfiguration)

    # First, create an index.html with links to all the HTML
    # documentation files we're about to generate.
    template_file = 'apidoc-index.pt'
    template = PageTemplateFile(template_file)
    index_filename = os.path.join(directory, "index.html")
    print "Writing index:", index_filename
    f = open(index_filename, 'w')
    f.write(template(config=config))

    # Get the time of the last commit.  We will use this as the mtime for the
    # generated files so that we can safely use it as part of Apache's etag
    # generation in the face of multiple servers/filesystems.
    with bzrlib.initialize():
        branch = Branch.open(os.path.dirname(os.path.dirname(__file__)))
        timestamp = branch.repository.get_revision(
            branch.last_revision()).timestamp

    # Start a process to build each set of WADL and HTML files.
    processes = []
    for version in config.active_versions:
        p = Process(target=make_files,
            args=(directory, version, timestamp, force))
        p.start()
        processes.append(p)

    # Wait for all the subprocesses to finish.
    for p in processes:
        p.join()

    return 0
Beispiel #3
0
 def from_source_tree(cls, source_tree):
     """
     Initialize :class:`~versiontools.bzr_support.BzrIntegration` by
     pointing at the source tree.  Any file or directory inside the
     source tree may be used.
     """
     branch = None
     try:
         import bzrlib
         if bzrlib.__version__ >= (2, 2, 1):
             # Python 2.4 the with keyword is not supported
             # and so you need to use the context manager manually, sigh.
             library_state = bzrlib.initialize()
             library_state.__enter__()
             try:
                 from bzrlib.branch import Branch
                 branch = Branch.open_containing(source_tree)[0]
             finally:
                 library_state.__exit__(None, None, None)
         else:
             from bzrlib.branch import Branch
             branch = Branch.open_containing(source_tree)[0]
     except Exception:
         from versiontools import get_exception_message
         message = get_exception_message(*sys.exc_info())
         logging.debug("Unable to get branch revision because "
                       "directory %r is not a bzr branch. Erorr: %s",
                       (source_tree, message))
     if branch:
         return cls(branch)
Beispiel #4
0
 def from_source_tree(cls, source_tree):
     """
     Initialize :class:`~versiontools.bzr_support.BzrIntegration` by
     pointing at the source tree.  Any file or directory inside the
     source tree may be used.
     """
     branch = None
     try:
         import bzrlib
         if bzrlib.__version__ >= (2, 2, 1):
             # Python 2.4 the with keyword is not supported
             # and so you need to use the context manager manually, sigh.
             library_state = bzrlib.initialize()
             library_state.__enter__()
             try:
                 from bzrlib.branch import Branch
                 branch = Branch.open_containing(source_tree)[0]
             finally:
                 library_state.__exit__(None, None, None)
         else:
             from bzrlib.branch import Branch
             branch = Branch.open_containing(source_tree)[0]
     except Exception:
         from versiontools import get_exception_message
         message = get_exception_message(*sys.exc_info())
         logging.debug(
             "Unable to get branch revision because "
             "directory %r is not a bzr branch. Erorr: %s",
             (source_tree, message))
     if branch:
         return cls(branch)
 def run(self):
     os.chdir(self._work_dir)
     import bzrlib
     library_state = bzrlib.initialize()
     library_state.__enter__()
     try:
         exit_val = bzrlib.commands.main()
     finally:
         library_state.__exit__(None, None, None)
def main(argv):
    parser = OptionParser(usage="""%prog [options] OUTPUT_FORMAT

Available OUTPUT_FORMAT:

    man              man page
    rstx             man page in ReStructuredText format
    bash_completion  bash completion script""")

    parser.add_option("-s",
                      "--show-filename",
                      action="store_true",
                      dest="show_filename",
                      default=False,
                      help="print default filename on stdout")

    parser.add_option("-o",
                      "--output",
                      dest="filename",
                      metavar="FILE",
                      help="write output to FILE")

    parser.add_option("-b",
                      "--bzr-name",
                      dest="bzr_name",
                      default="bzr",
                      metavar="EXEC_NAME",
                      help="name of bzr executable")

    parser.add_option("-e",
                      "--examples",
                      action="callback",
                      callback=print_extended_help,
                      help="Examples of ways to call generate_doc")

    (options, args) = parser.parse_args(argv)

    if len(args) != 2:
        parser.print_help()
        sys.exit(1)

    with bzrlib.initialize():
        commands.install_bzr_command_hooks()
        infogen_type = args[1]
        infogen_mod = doc_generate.get_module(infogen_type)
        if options.filename:
            outfilename = options.filename
        else:
            outfilename = infogen_mod.get_filename(options)
        if outfilename == "-":
            outfile = sys.stdout
        else:
            outfile = open(outfilename, "w")
        if options.show_filename and (outfilename != "-"):
            sys.stdout.write(outfilename)
            sys.stdout.write('\n')
        infogen_mod.infogen(options, outfile)
Beispiel #7
0
def bzr_initialize():
    _logger.debug('Importing and initializing bzrlib')
    from bzrlib.branch import Branch
    from bzrlib.trace import set_verbosity_level
    from bzrlib.plugin import load_plugins
    from bzrlib import initialize
    library_state = initialize()
    library_state.__enter__()
    set_verbosity_level(1000)

    import odootools.lib.logger
    odootools.lib.logger.set_levels()

    load_plugins()
Beispiel #8
0
def main(argv):
    parser = OptionParser(usage="""%prog [options] OUTPUT_FORMAT

Available OUTPUT_FORMAT:

    man              man page
    rstx             man page in ReStructuredText format
    bash_completion  bash completion script""")

    parser.add_option("-s", "--show-filename",
                      action="store_true", dest="show_filename", default=False,
                      help="print default filename on stdout")

    parser.add_option("-o", "--output", dest="filename", metavar="FILE",
                      help="write output to FILE")

    parser.add_option("-b", "--bzr-name",
                      dest="bzr_name", default="bzr", metavar="EXEC_NAME",
                      help="name of bzr executable")

    parser.add_option("-e", "--examples",
                      action="callback", callback=print_extended_help,
                      help="Examples of ways to call generate_doc")


    (options, args) = parser.parse_args(argv)

    if len(args) != 2:
        parser.print_help()
        sys.exit(1)

    with bzrlib.initialize():
        commands.install_bzr_command_hooks()
        infogen_type = args[1]
        infogen_mod = doc_generate.get_module(infogen_type)
        if options.filename:
            outfilename = options.filename
        else:
            outfilename = infogen_mod.get_filename(options)
        if outfilename == "-":
            outfile = sys.stdout
        else:
            outfile = open(outfilename,"w")
        if options.show_filename and (outfilename != "-"):
            sys.stdout.write(outfilename)
            sys.stdout.write('\n')
        infogen_mod.infogen(options, outfile)
Beispiel #9
0
# % git clone bzr::$HOME/myrepo
# or
# % git clone bzr::lp:myrepo
#
# If you want to specify which branches you want to track (per repo):
# % git config remote.origin.bzr-branches 'trunk, devel, test'
#
# Where 'origin' is the name of the repository you want to specify the
# branches.
#

import sys

import bzrlib
if hasattr(bzrlib, "initialize"):
    bzrlib.initialize()

import bzrlib.plugin
bzrlib.plugin.load_plugins()

import bzrlib.generate_ids
import bzrlib.transport
import bzrlib.errors
import bzrlib.ui
import bzrlib.urlutils
import bzrlib.branch

import sys
import os
import json
import re
Beispiel #10
0
 def f(*args, **kwargs):
     with(bzrlib.initialize()):
         return func(*args, **kwargs)
Beispiel #11
0
# % git clone bzr::$HOME/myrepo
# or
# % git clone bzr::lp:myrepo
#
# If you want to specify which branches you want to track (per repo):
# % git config remote.origin.bzr-branches 'trunk, devel, test'
#
# Where 'origin' is the name of the repository you want to specify the
# branches.
#

import sys

import bzrlib
if hasattr(bzrlib, "initialize"):
    bzrlib.initialize()

import bzrlib.plugin
bzrlib.plugin.load_plugins()

import bzrlib.generate_ids
import bzrlib.transport
import bzrlib.errors
import bzrlib.ui
import bzrlib.urlutils
import bzrlib.branch

import sys
import os
import json
import re
Beispiel #12
0
 def f(*args, **kwargs):
     with (bzrlib.initialize()):
         return func(*args, **kwargs)