def generate_cgi(self): common.create_dir(self.env, Path('cgi-bin')) fname = self.env + "cgi-bin" + "submin.cgi" fp = open(str(fname), "w+") suggestion = '/path/to/submin' if 'PYTHONPATH' in os.environ: suggestion = os.path.abspath(os.environ["PYTHONPATH"].split(":")[0]) fp.write("""#!/usr/bin/env python2 # If you installed submin in a non-standard path, uncomment the two lines below # and insert your submin path. #import sys #sys.path.append("%s") from submin.dispatch.cgirunner import run run() """ % suggestion) fp.close() os.chmod(str(fname), 0o755)
def create_dir(self, directory): """Create a relative or absulute directory, if it doesn't exist already""" common.create_dir(self.env, directory)