def init(self, delete_if_exists, python_path=""): if self.use_virtualenv: virtualenv_full_path = path(self.virtualenv_path).joinpath(self.virtualenv_name) if cuisine.dir_exists(virtualenv_full_path) and delete_if_exists: dir_delete(virtualenv_full_path) with cuisine_sudo(): pip_install(['virtualenv']) with cuisine_sudo(): dir_ensure(self.virtualenv_path, recursive=True, mode=777) dir_attribs(self.virtualenv_path, mode=777, recursive=True) # make lib synlinks to install PIL correctly with cuisine_sudo(): if not file_exists("/usr/lib/libfreetype.so"): run("ln -sf /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib/") if not file_exists("/usr/lib/libz.so"): run("ln -sf /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/") if not file_exists("/usr/lib/libjpeg.so"): run("ln -sf /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/") with cd(self.virtualenv_path): run('VIRTUALENV_EXTRA_SEARCH_DIR="%s" && virtualenv %s' % (python_path, self.virtualenv_name))
def setup(self): if not file_exists(self.lessc_path()): print("Installing Node and Less") cuisine.sudo("sudo apt-get --yes install python-software-properties") cuisine.sudo("sudo add-apt-repository ppa:chris-lea/node.js --yes") cuisine.sudo("sudo apt-get --yes update") cuisine.sudo("sudo apt-get --yes install nodejs") cuisine.run("curl http://npmjs.org/install.sh | sudo sh") with cd('~'): cuisine.run("npm install less") else: print ("Less is already installed")
def configure_webserver(self, name, config, delete_other_sites=False): if delete_other_sites: with cuisine_sudo(): clear_dir("/etc/apache2/sites-enabled") with cuisine_sudo(): cuisine.file_write("/etc/apache2/sites-enabled/%s" % name, config) run("ln -fs /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load") ssl_load = "/etc/apache2/mods-enabled/ssl.load" if not file_exists(ssl_load): run("ln -s /etc/apache2/mods-available/ssl.load /etc/apache2/mods-enabled/ssl.load") print("Apache configured\n%s" % config)
def file_delete(file, only_if_exists=True): if only_if_exists and not cuisine.file_exists(file): return cuisine.run("rm %s" % file)