Пример #1
0
    def prepare(self):
        self.temp_dir_root = tempfile.mkdtemp(prefix='sphinx_docs_',
                                              dir=get_tmpdir())
        if self.config['checkout_root']:
            tree_hash = _tree_hash(self.project_id, '')
        else:
            tree_hash = _tree_hash(self.project_id, self.dir)
        if not tree_hash or not self.has_content():
            warn("No docs directory in project repo at HEAD for builder %s" %
                 self.builder)
            return False, 'no_doc_dir_found'
        mc.set(LAST_TREE_HASH_MC_KEY % (self.project_id, self.builder),
               tree_hash)

        if os.path.exists(self.docs_dir):
            shutil.rmtree(self.docs_dir, ignore_errors=True)
        try:
            os.makedirs(self.docs_dir)
        except OSError:
            pass
        ret, msg = _export_docs_tree(self.project_id, tree_hash,
                                     self.temp_dir_root)
        if not ret:
            return False, msg
        if self.config['checkout_root']:
            self.temp_dir = os.path.join(self.temp_dir_root, self.dir)
        else:
            self.temp_dir = self.temp_dir_root
        return True, 'success'
Пример #2
0
 def prepare(self):
     self.temp_dir_root = tempfile.mkdtemp(
         prefix='sphinx_docs_', dir=get_tmpdir())
     if self.config['checkout_root']:
         tree_hash = _tree_hash(self.project_id, '')
     else:
         tree_hash = _tree_hash(self.project_id, self.dir)
     if not tree_hash or not self.has_content():
         warn("No docs directory in project repo at HEAD for builder %s" %
              self.builder)
         return False, 'no_doc_dir_found'
     mc.set(LAST_TREE_HASH_MC_KEY % (self.project_id,
            self.builder), tree_hash)
     try:
         os.makedirs(self.docs_dir)
     except OSError:
         pass
     ret, msg = _export_docs_tree(
         self.project_id, tree_hash, self.temp_dir_root)
     if not ret:
         return False, msg
     if self.config['checkout_root']:
         self.temp_dir = os.path.join(self.temp_dir_root, self.dir)
     else:
         self.temp_dir = self.temp_dir_root
     return True, 'success'
Пример #3
0
 def __init__(self, *args, **kwargs):
     SessionPublisher.__init__(self, *args, **kwargs)
     self.configure(DISPLAY_EXCEPTIONS='plain',
                    SECURE_ERRORS=0,
                    DEBUG_PROPAGATE_EXCEPTIONS=DEVELOP_MODE,
                    UPLOAD_DIR=get_tmpdir() + '/upload/',
                    SESSION_COOKIE_NAME=SESSION_COOKIE_NAME,
                    SESSION_COOKIE_DOMAIN=SESSION_COOKIE_DOMAIN,
                    SESSION_COOKIE_PATH=SESSION_COOKIE_PATH)
Пример #4
0
    def temp_dir(self):
        if self._temp_dir:
            return self._temp_dir

        # TODO: move to Jagare
        pulltmp = os.path.join(get_tmpdir(), "pulltmp")
        if not os.path.exists(pulltmp):
            os.makedirs(pulltmp)
        worktree = tempfile.mkdtemp(dir=pulltmp)
        self._temp_dir = worktree
        return worktree
Пример #5
0
    def temp_dir(self):
        if self._temp_dir:
            return self._temp_dir

        # TODO: move to Jagare
        pulltmp = os.path.join(get_tmpdir(), "pulltmp")
        if not os.path.exists(pulltmp):
            os.makedirs(pulltmp)
        worktree = tempfile.mkdtemp(dir=pulltmp)
        self._temp_dir = worktree
        return worktree
Пример #6
0
 def test_removed_page_not_indexd(self):
     raise SkipTest("advanced index way doesn't exist now.")
     prj = self._prj()
     self._add(prj, 'docs/index.rst', base_index_rst)
     self._add(prj, 'docs/doc1.rst', 'aaa')
     _el.CodeSearch.index_a_project_docs(prj.id)
     res = _el.CodeSearch.search_a_phrase('aaa', from_=0, size=100)
     res = _el.CodeSearch.format_search_result(res)
     assert len(res) == 1
     prj.git.call('read-tree HEAD')
     temp_dir = get_tmpdir()
     env = make_git_env(is_anonymous=True)
     prj.git.call('--work-tree %s checkout-index --force -a' % temp_dir)
     prj.git.call(['--work-tree', temp_dir, 'rm', 'docs/doc1.rst'])
     prj.git.call(['--work-tree', temp_dir, 'commit', '-m', 'm'], _env=env)
     _el.CodeSearch.index_a_project_docs(prj.id)
     res = _el.CodeSearch.search_a_phrase('aaa', from_=0, size=100)
     res = _el.CodeSearch.format_search_result(res)
     assert len(res) == 0, \
         "Should find no results after removing and reindexing"
     _el.CodeSearch.delete_a_project_docs(prj.id)
     shutil.rmtree(temp_dir)
Пример #7
0
 def test_removed_page_not_indexd(self):
     raise SkipTest("advanced index way doesn't exist now.")
     prj = self._prj()
     self._add(prj, 'docs/index.rst', base_index_rst)
     self._add(prj, 'docs/doc1.rst', 'aaa')
     _el.CodeSearch.index_a_project_docs(prj.id)
     res = _el.CodeSearch.search_a_phrase('aaa', from_=0, size=100)
     res = _el.CodeSearch.format_search_result(res)
     assert len(res) == 1
     prj.git.call('read-tree HEAD')
     temp_dir = get_tmpdir()
     env = make_git_env(is_anonymous=True)
     prj.git.call('--work-tree %s checkout-index --force -a' % temp_dir)
     prj.git.call(['--work-tree', temp_dir, 'rm', 'docs/doc1.rst'])
     prj.git.call(['--work-tree', temp_dir, 'commit', '-m', 'm'], _env=env)
     _el.CodeSearch.index_a_project_docs(prj.id)
     res = _el.CodeSearch.search_a_phrase('aaa', from_=0, size=100)
     res = _el.CodeSearch.format_search_result(res)
     assert len(res) == 0, \
         "Should find no results after removing and reindexing"
     _el.CodeSearch.delete_a_project_docs(prj.id)
     shutil.rmtree(temp_dir)
Пример #8
0
def get_doc_builder_option(project, builder_name):
    option = ArminOption()

    repo_path = project.repo_path
    config = get_builder_conf(project.conf, builder_name)
    builder = config.get('builder')
    builder_dir = config.get('dir')

    temp_path = tempfile.mkdtemp(prefix='sphinx_docs_', dir=get_tmpdir())
    doc_path = os.path.join(get_repo_root(), project.name + DOC_EXT, builder)

    builder_doc_path = os.path.join(doc_path, '.build', builder)
    if config.get('checkout_root'):
        autodoc = True
        builder_temp_path = os.path.join(temp_path, builder_dir)
    else:
        autodoc = False
        builder_temp_path = temp_path
    builder_temp_doc_path = os.path.join(builder_temp_path, '.build', builder)

    option.builder = builder
    option.settings['master_doc'] = 'index'
    option.settings['source_suffix'] = '.rst'
    option.settings['html_short_title'] = project.name
    option.settings.update(config)
    option.settings['project'] = project.name  # noqa -- override a setting in configuration
    option.doctree_path = os.path.join(temp_path, SPHINX_BUILD_DOCTREES)
    option.temp_path = temp_path
    option.sourcedir = builder_temp_path
    option.outdir = builder_temp_doc_path
    option.doc_path = doc_path
    option.builder_doc_path = builder_doc_path
    option.builder_dir = builder_dir
    option.autodoc = autodoc
    option.repo_path = repo_path
    return option
Пример #9
0
import os
from os.path import join
import logging
logging.getLogger().setLevel(logging.DEBUG)

from mako import exceptions
from mako.lookup import TemplateLookup
from vilya.libs.permdir import get_tmpdir
from vilya.libs.import_obj import import_obj
from vilya.config import CODE_DIR, MAKO_FS_CHECK, DEVELOP_MODE

import vilya.libs.mako_cache  # noqa


MAKO_CACHE_DIR = join(get_tmpdir(), "tmp_mako_0606", "mako_cache")

c = import_obj("c")
request = import_obj("request")

code_templates = TemplateLookup(
    directories=CODE_DIR + '/templates',
    module_directory=MAKO_CACHE_DIR,
    input_encoding='utf8',
    output_encoding='utf8',
    encoding_errors='ignore',
    default_filters=['h'],
    filesystem_checks=MAKO_FS_CHECK,
    cache_enabled=True,
    cache_impl='mccache',
    imports=["from vilya.libs.tplhelpers import static"]
Пример #10
0
 def tearDown(self):
     new_nb_dirs_in_tmpdir = len(os.listdir(get_tmpdir()))
     assert self._nb_dirs_in_tempdir == new_nb_dirs_in_tmpdir, (
         "Builder process should not leave dirs in tmpdir")
     TestCase.tearDown(self)
Пример #11
0
 def setUp(self):
     self._nb_dirs_in_tempdir = len(os.listdir(get_tmpdir()))
     TestCase.setUp(self)
Пример #12
0
 def __init__(self, *args, **kwargs):
     SessionPublisher.__init__(self, *args, **kwargs)
     self.configure(DISPLAY_EXCEPTIONS='plain',
                    SECURE_ERRORS=0,
                    UPLOAD_DIR=get_tmpdir() + '/upload/')
Пример #13
0
 def __init__(self, *args, **kwargs):
     Publisher.__init__(self, *args, **kwargs)
     self.configure(DISPLAY_EXCEPTIONS='plain',
                    SECURE_ERRORS=0,
                    UPLOAD_DIR=get_tmpdir() + '/upload/')
Пример #14
0
 def tearDown(self):
     new_nb_dirs_in_tmpdir = len(os.listdir(get_tmpdir()))
     assert self._nb_dirs_in_tempdir == new_nb_dirs_in_tmpdir, (
         "Builder process should not leave dirs in tmpdir")
     TestCase.tearDown(self)
Пример #15
0
 def setUp(self):
     self._nb_dirs_in_tempdir = len(os.listdir(get_tmpdir()))
     TestCase.setUp(self)