The web design and pages for my personal website.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.6 KiB

#!/usr/bin/env python3
"""Bootstrap script to set up a local dev instance of
This will `git clone` an instance of the Rophako CMS and configure it to run
this local website. When the dev Rophako instance already exists, running this
script again acts as a shortcut to running `python` from within
the Rophako git repo.
This script is only designed to work in Python 3 and requires the `git` and
`pyvenv` commands.
This performs the following tasks:
* Clones Rophako into ./rophako
* Sets up a Python 3 virtual environment via `pyvenv` at ./rophako/pyvenv
* Installs requirements via `pip` into its virtual environment
* Symlinks settings.yml and into the Rophako root
* Runs the server
import os
import os.path
import subprocess
import sys
def main():
# Make sure we have everything we need.
# Do we already have Rophako?
if os.path.isdir("./rophako"):
# Clone it.
must_run(["git", "clone", ""])
# Make the Python environment.
must_run(["pyvenv", "pyvenv"])
must_run(["pyvenv/bin/pip", "install", "-r", "requirements.txt"])
# Configure it.
os.symlink("../settings.yml", "settings.yml")
os.symlink("../", "")
print("=" * 80)
print("Success! Rophako has been cloned and configured! The server")
print("will now start. To quickly start the server again in the")
print("future, just run again.")
print("=" * 80)
# Run Rophako.
must_run(["pyvenv/bin/python", ""])
def check_depends():
# Make sure we have access to required commands.
errors = False
for command in [ "git", "pyvenv" ]:
subprocess.check_call(["which", command],
except subprocess.CalledProcessError:
print("You seem to be missing the command: {}".format(command))
errors = True
if errors:
print("Make sure the required commands are installed and try again.")
def must_run(args, **kwargs):
"""Calls subprocess to run a command which must succeed or die."""
result =, **kwargs)
if result != 0:
print("Errors were detected in the command I tried to run: {}".format(
" ".join(args),
if __name__ == "__main__":