示例#1
0
def site(request, tmp_path_factory):
    from pelican import settings

    # this will pass the test configuration down to the pelicanconf.py
    settings.DEFAULT_CONFIG["PCONF"] = Pconf(*request.param)

    # renders a simple site with three pages
    output = tmp_path_factory.mktemp("site")
    datadir = pathlib.Path(__file__).parent / "data"
    args = [
        datadir / "content",
        "-o",
        output,
        "-s",
        datadir / "pelicanconf.py",
        "--relative-urls",
        "--debug",
    ]
    pelican.main([str(a) for a in args])

    # write a file with a name like (for troubleshooting):
    #  AUTOEXT=0-ALL_POSTS=1-ON_SIDEBAR=0-IN_SECTION=1
    (
        output
        / "-".join(f"{k[12:]}={int(v)}" for k, v in zip(Pconf._fields, request.param))
    ).touch()
    yield output
示例#2
0
    def do_POST(self):
        try:
            #Hard reset both repos so they match the remote (origin) master branches
            self.hard_reset_source_repos()

            if not self.server.deploy_repo.is_local_dir:
                self.hard_reset_deploy_repos()

                # Git Remove all deploy_repo files (except those whitelisted) and then rebuild with pelican
                self.nuke_git_cwd(self.server.deploy_repo)
                main()

                # Add all files newly created by pelican, then commit and push everything
                self.server.deploy_repo.add(['.'])

                commit_message = self.server.source_repo.log(['-n1', '--pretty=format:"%h %B"'])
                self.server.deploy_repo.commit(commit_message, ['-a'])
                self.server.deploy_repo.push([self.server.deploy_repo.origin, self.server.deploy_repo.master])
            else:
                try:
                    main()
                except:
                    pass

            self.do_response(POST_RESPONSE_BODY.encode())

        except Exception as e:
            print(e)

            #In the event of an excepion, hard reset both repos so they match the remote (origin) master branches
            self.hard_reset_source_repos()
            if not self.server.deploy_repo.is_local_dir:
                self.hard_reset_deploy_repos()

            self.do_response(ERROR_RESPONSE_BODY.encode())
示例#3
0
def rebuild ():
  output = []
  os.chdir (WC_FILEPATH)
  with open ("stdout.log", "w") as stdout:
    subprocess.check_call (["git", "pull"], stdout=stdout, shell=True)
  output.append ("Git pulled")
  sys.argv[1:] = ['-s', 'settings.py', 'site']
  pelican.main ()
  output.append ("Pelican rebuild complete")
  return "\n".join (output)
示例#4
0
def pelican_generate(dir_: str, fatal: str):
    """Generate the (sub) blog/site using Pelican.

    :param dir_: The name of sub blog directories (en, cn, etc.).
    :param fatal: Pass values to the --fatal option of pelican.
        If empty the --fatal option is disabled,
        which means the compiling will ingore warnings and errors.
    """
    blog_dir = BASE_DIR / dir_
    os.chdir(blog_dir)
    #config = blog_dir / "pconf.py"
    #settings = pelican.settings.read_settings(path=str(config))
    #pelican.Pelican(settings).run()
    args = ["-s", str(blog_dir / "pconf.py")]
    if fatal:
        args.extend(["--fatal", fatal])
    pelican.main(args)
示例#5
0
    def do_POST(self):
        try:
            #Hard reset both repos so they match the remote (origin) master branches
            self.hard_reset_repos()
            
            # Git Remove all deploy_repo files (except those whitelisted) and then rebuild with pelican
            self.nuke_git_cwd(self.server.deploy_repo) 
            main()

            # Add all files newly created by pelican, then commit and push everything
            self.server.deploy_repo.add(['.'])

            commit_message = self.server.source_repo.log(['-n1', '--pretty=format:"%h %B"'])
            self.server.deploy_repo.commit(commit_message, ['-a'])
            self.server.deploy_repo.push([self.server.deploy_repo.origin, self.server.deploy_repo.master])

            self.do_response(POST_RESPONSE_BODY)
        except Exception as e:
            print e
            
            #In the event of an excepion, hard reset both repos so they match the remote (origin) master branches
#            self.hard_reset_repos()
            self.do_response(ERROR_RESPONSE_BODY)
示例#6
0
from pelicansage.sagecell import main

if __name__ == '__main__':
    import pelican

    pelican.main()
示例#7
0
def main():
    """
    for debugging
    """
    pelican.main()
示例#8
0
import sys
sys.path.append(
    '/Users/dg/projects/codecachet/pelhub/ve/lib/python3.7/site-packages/pelican'
)
from pelican import main

import os
os.chdir('/Users/dg/projects/codecachet/pelhub/site')

main()