def move(self, **kwargs):
     from_globs = glob(os.path.join(self.old_artifact_path, "*.epub"))
     if not os.path.exists(self.target):
         os.makedirs(self.target)
     if from_globs:
         from_file = from_globs[0]
         to_file = os.path.join(self.target, "%s.epub" % self.state.project)
         run('mv -f %s %s' % (from_file, to_file))
 def move(self, **kwargs):
     from_globs = glob(os.path.join(self.old_artifact_path, "*.epub"))
     if not os.path.exists(self.target):
         os.makedirs(self.target)
     if from_globs:
         from_file = from_globs[0]
         to_file = os.path.join(self.target, "%s.epub" % self.state.project)
         run('mv -f %s %s' % (from_file, to_file))
Example #3
0
 def fetch(self):
     code, out, err = run('git fetch --prune')
     if code != 0:
         raise BuildException(
             "Failed to get code from '%s' (git fetch): %s\n\nStderr:\n\n%s\n\n" % (
                 self.repo_url, code, err)
         )
Example #4
0
 def branches(self):
     # Only show remote branches
     retcode, stdout, err = run('git branch -r')
     # error (or no tags found)
     if retcode != 0:
         return []
     return self.parse_branches(stdout)
Example #5
0
 def clone(self):
     code, out, err = run('git clone --recursive --quiet %s .' %
                          self.repo_url)
     if code != 0:
         raise BuildException(
             "Failed to get code from '%s' (git clone): %s" %
             (self.repo_url, code))
Example #6
0
 def branches(self):
     # Only show remote branches
     retcode, stdout, err = run('git branch -r')
     # error (or no tags found)
     if retcode != 0:
         return []
     return self.parse_branches(stdout)
Example #7
0
 def clone(self):
     code, out, err = run('git clone --recursive --quiet %s .' % self.repo_url)
     if code != 0:
         raise BuildException(
             "Failed to get code from '%s' (git clone): %s" % (
                 self.repo_url, code)
         )
Example #8
0
 def build(self, **kwargs):
     project = self.version.project
     os.chdir(project.checkout_path(self.version.slug))
     results = {}
     build_command = "%s build " % (
         project.venv_bin(version=self.version.slug,
                          bin='asciidoctor')
     )
     results['html'] = run(build_command, shell=True)
     return results
Example #9
0
    def checkout_revision(self, revision=None):
        if not revision:
            branch = self.default_branch or self.fallback_branch
            revision = 'origin/%s' % branch

        code, out, err = run('git checkout --force --quiet %s' % revision)
        if code != 0:
            log.warning("Failed to checkout revision '%s': %s" % (
                revision, code))
        return [code, out, err]
Example #10
0
    def checkout_revision(self, revision=None):
        if not revision:
            branch = self.default_branch or self.fallback_branch
            revision = 'origin/%s' % branch

        code, out, err = run('git checkout --force --quiet %s' % revision)
        if code != 0:
            log.warning("Failed to checkout revision '%s': %s" %
                        (revision, code))
        return [code, out, err]
 def build(self, **kwargs):
     checkout_path = self.version.project.checkout_path(self.version.slug)
     #site_path = os.path.join(checkout_path, 'site')
     os.chdir(checkout_path)
     # Actual build
     build_command = "{command} {builder} --site-dir={build_dir} --theme=readthedocs".format(
         command=self.version.project.venv_bin(version=self.version.slug, bin='mkdocs'),
         builder=self.builder,
         build_dir=self.build_dir,
     )
     results = run(build_command, shell=True)
     return results
Example #12
0
    def checkout(self, identifier=None):
        self.check_working_dir()

        # Clone or update repository
        if self.repo_exists():
            self.set_remote_url(self.repo_url)
            self.fetch()
        else:
            self.make_clean_working_dir()
            self.clone()

        # Find proper identifier
        if not identifier:
            identifier = self.default_branch or self.fallback_branch

        identifier = self.find_ref(identifier)

        #Checkout the correct identifier for this branch.
        code, out, err = self.checkout_revision(identifier)
        if code != 0:
            return code, out, err

        # Clean any remains of previous checkouts
        run('git clean -d -f -f')

        # Update submodules
        run('git submodule sync')
        run('git submodule update --init --recursive --force')

        return code, out, err
    def build(self, **kwargs):
        self.clean()
        os.chdir(self.state.conf_dir)
        # Default to this so we can return it always.
        results = {}
        latex_results = run(
            '%s -b latex -D language=%s -d _build/doctrees . _build/latex' %
            ('sphinx-build', self.state.language))

        if latex_results[0] == 0:
            os.chdir(self.sphinx_build_dir)
            tex_files = glob('*.tex')

            if tex_files:
                # Run LaTeX -> PDF conversions
                pdflatex_cmds = [
                    ('pdflatex -interaction=nonstopmode %s' % tex_file)
                    for tex_file in tex_files
                ]
                makeindex_cmds = [('makeindex -s python.ist %s.idx' %
                                   os.path.splitext(tex_file)[0])
                                  for tex_file in tex_files]
                pdf_results = run(*pdflatex_cmds)
                ind_results = run(*makeindex_cmds)
                pdf_results = run(*pdflatex_cmds)
            else:
                pdf_results = (0, "No tex files found", "No tex files found")
                ind_results = (0, "No tex files found", "No tex files found")

            results = [
                latex_results[0] + ind_results[0] + pdf_results[0],
                latex_results[1] + ind_results[1] + pdf_results[1],
                latex_results[2] + ind_results[2] + pdf_results[2],
            ]
            pdf_match = PDF_RE.search(results[1])
            if pdf_match:
                self.pdf_file_name = pdf_match.group(1).strip()
        else:
            results = latex_results
        return results
Example #14
0
    def checkout(self, identifier=None):
        self.check_working_dir()

        # Clone or update repository
        if self.repo_exists():
            self.set_remote_url(self.repo_url)
            self.fetch()
        else:
            self.make_clean_working_dir()
            self.clone()

        # Find proper identifier
        if not identifier:
            identifier = self.default_branch or self.fallback_branch

        identifier = self.find_ref(identifier)

        #Checkout the correct identifier for this branch.
        code, out, err = self.checkout_revision(identifier)
        if code != 0:
            return code, out, err

        # Clean any remains of previous checkouts
        run('git clean -d -f -f')

        # Update submodules
        run('git submodule sync')
        run('git submodule update --init --recursive --force')

        return code, out, err
    def move(self, **kwargs):
        if not os.path.exists(self.target):
            os.makedirs(self.target)

        exact = os.path.join(self.old_artifact_path, "%s.pdf" % self.state.project)
        exact_upper = os.path.join(self.old_artifact_path, "%s.pdf" % self.state.project.capitalize())

        if self.pdf_file_name and os.path.exists(self.pdf_file_name):
            from_file = self.pdf_file_name
        if os.path.exists(exact):
            from_file = exact
        elif os.path.exists(exact_upper):
            from_file = exact_upper
        else:
            from_globs = glob(os.path.join(self.old_artifact_path, "*.pdf"))
            if from_globs:
                from_file = from_globs[0]
            else:
                from_file = None
        if from_file:
            to_file = os.path.join(self.target, "%s.pdf" % self.state.project)
            run('mv -f %s %s' % (from_file, to_file))
Example #16
0
 def build(self, **kwargs):
     checkout_path = self.version.project.checkout_path(self.version.slug)
     #site_path = os.path.join(checkout_path, 'site')
     os.chdir(checkout_path)
     # Actual build
     build_command = "{command} {builder} --site-dir={build_dir} --theme=readthedocs".format(
         command=self.version.project.venv_bin(version=self.version.slug,
                                               bin='mkdocs'),
         builder=self.builder,
         build_dir=self.build_dir,
     )
     results = run(build_command, shell=True)
     return results
    def move(self, **kwargs):
        if not os.path.exists(self.target):
            os.makedirs(self.target)

        exact = os.path.join(self.old_artifact_path,
                             "%s.pdf" % self.state.project)
        exact_upper = os.path.join(self.old_artifact_path,
                                   "%s.pdf" % self.state.project.capitalize())

        if self.pdf_file_name and os.path.exists(self.pdf_file_name):
            from_file = self.pdf_file_name
        if os.path.exists(exact):
            from_file = exact
        elif os.path.exists(exact_upper):
            from_file = exact_upper
        else:
            from_globs = glob(os.path.join(self.old_artifact_path, "*.pdf"))
            if from_globs:
                from_file = from_globs[0]
            else:
                from_file = None
        if from_file:
            to_file = os.path.join(self.target, "%s.pdf" % self.state.project)
            run('mv -f %s %s' % (from_file, to_file))
    def build(self, **kwargs):
        self.clean()
        os.chdir(self.state.conf_dir)
        # Default to this so we can return it always.
        results = {}
        latex_results = run('%s -b latex -D language=%s -d _build/doctrees . _build/latex'
                            % ('sphinx-build', self.state.language))

        if latex_results[0] == 0:
            os.chdir(self.sphinx_build_dir)
            tex_files = glob('*.tex')

            if tex_files:
                # Run LaTeX -> PDF conversions
                pdflatex_cmds = [('pdflatex -interaction=nonstopmode %s'
                                  % tex_file) for tex_file in tex_files]
                makeindex_cmds = [('makeindex -s python.ist %s.idx'
                                   % os.path.splitext(tex_file)[0]) for tex_file in tex_files]
                pdf_results = run(*pdflatex_cmds)
                ind_results = run(*makeindex_cmds)
                pdf_results = run(*pdflatex_cmds)
            else:
                pdf_results = (0, "No tex files found", "No tex files found")
                ind_results = (0, "No tex files found", "No tex files found")

            results = [
                latex_results[0] + ind_results[0] + pdf_results[0],
                latex_results[1] + ind_results[1] + pdf_results[1],
                latex_results[2] + ind_results[2] + pdf_results[2],
            ]
            pdf_match = PDF_RE.search(results[1])
            if pdf_match:
                self.pdf_file_name = pdf_match.group(1).strip()
        else:
            results = latex_results
        return results
Example #19
0
    def setup_environment(self):
        """
        Build the virtualenv and install the project into it.
        """
        ret_dict = {}

        # Clean up from possible old builds
        build_dir = os.path.join(self.state.env_path, 'build')
        if os.path.exists(build_dir):
            log.info(
                LOG_TEMPLATE.format(project=self.state.project,
                                    version=self.state.version,
                                    msg='Removing existing build dir'))
            shutil.rmtree(build_dir)

        ret_dict['env'] = run(
            '{cmd} {path}'.format(cmd='virtualenv -p %s' %
                                  self.state.interpreter,
                                  path=self.state.env_path),
            stdout=sys.stdout,
            stderr=sys.stderr,
        )

        # Other code expects sphinx-build to be installed inside the
        # virtualenv.  Using the -I option makes sure it gets installed
        # even if it is already installed system-wide (and
        # --system-site-packages is used)
        if self.state.use_system_packages:
            ignore_option = '-I'
        else:
            ignore_option = ''

        ret_dict['sphinx'] = run(
            ('{cmd} install -U {ignore_option} '
             'sphinx_rtd_theme sphinx==1.2.2 '
             'virtualenv==1.9.1 docutils==0.11 '
             'git+git://github.com/ericholscher/readthedocs-sphinx-ext#egg=readthedocs_ext'
             ).format(ignore_option=ignore_option,
                      cmd=self.state.env_bin('pip')),
            stdout=sys.stdout,
            stderr=sys.stderr,
        )

        requirements_file_path = self.state.requirements_file
        if not requirements_file_path:
            for path in [self.docs_dir(), '']:
                for req_file in ['pip_requirements.txt', 'requirements.txt']:
                    test_path = os.path.join(self.state.root, path, req_file)
                    if os.path.exists(test_path):
                        requirements_file_path = test_path
                        break

        if requirements_file_path:
            os.chdir(self.state.root)
            ret_dict['requirements'] = run(
                '{cmd} install --exists-action=w -r {requirements}'.format(
                    cmd=self.state.env_bin('pip'),
                    requirements=requirements_file_path),
                stdout=sys.stdout,
                stderr=sys.stderr,
            )

        os.chdir(self.state.root)
        if os.path.isfile("setup.py"):
            ret_dict['install'] = run(
                '{cmd} setup.py install --force'.format(
                    cmd=self.state.env_bin('python')),
                stdout=sys.stdout,
                stderr=sys.stderr,
            )
        return ret_dict
Example #20
0
 def tags(self):
     retcode, stdout, err = run('git show-ref --tags')
     # error (or no tags found)
     if retcode != 0:
         return []
     return self.parse_tags(stdout)
Example #21
0
 def ref_exists(self, ref):
     code, out, err = run('git show-ref %s' % ref)
     return code == 0
Example #22
0
 def fetch(self):
     code, out, err = run('git fetch --prune')
     if code != 0:
         raise BuildException(
             "Failed to get code from '%s' (git fetch): %s\n\nStderr:\n\n%s\n\n"
             % (self.repo_url, code, err))
Example #23
0
 def repo_exists(self):
     code, out, err = run('git status')
     return code == 0
Example #24
0
 def ref_exists(self, ref):
     code, out, err = run('git show-ref %s' % ref)
     return code == 0
Example #25
0
 def commit(self):
     retcode, stdout, err = run('git rev-parse HEAD')
     return stdout.strip()
Example #26
0
 def tags(self):
     retcode, stdout, err = run('git show-ref --tags')
     # error (or no tags found)
     if retcode != 0:
         return []
     return self.parse_tags(stdout)
Example #27
0
 def set_remote_url(self, url):
     return run('git remote set-url origin %s' % url)
Example #28
0
 def set_remote_url(self, url):
     return run('git remote set-url origin %s' % url)
Example #29
0
 def commit(self):
     retcode, stdout, err = run('git rev-parse HEAD')
     return stdout.strip()
Example #30
0
 def repo_exists(self):
     code, out, err = run('git status')
     return code == 0