Example #1
0
    def pre(self, command, output_dir, vars):
        """ Overrides :meth:`pyramid.scaffold.template.Template.pre`, adding
        several variables to the default variables list (including
        ``random_string``, and ``package_logger``).  It also prevents common
        misnamings (such as naming a package "site" or naming a package
        logger "root".
        """
        # configuration
        
        vars['root'] = raw_input("Root directory for files (default './files'): ")
        if not vars['root']:
            vars['root'] = "files"

        vars['files'] = raw_input("File server url prefix. Use * for all (default '*'): ")
        if not vars['files'] or vars['files'] == "*":
            vars['files'] = ""

        vars['host'] = raw_input("Proxy requests to the following host/domain e.g. 'mydomain.nive.io' (default empty): ")

        vars['proxy'] = raw_input("Proxy url prefix. Use * for all (default '__proxy'): ")
        if not vars['proxy']:
            vars['proxy'] = "__proxy"
        elif vars['proxy'] == "*":
            vars['proxy'] = ""

        #vars['host'] = raw_input("Server host (default '127.0.0.1'): ")
        #if not vars['host']:
        #    vars['host'] = "127.0.0.1"

        #vars['port'] = raw_input("Server port (default 5556): ")
        #if not vars['port']:
        #    vars['port'] = "5556"

        return PyramidTemplate.pre(self, command, output_dir, vars)
Example #2
0
    def pre(self, command, output_dir, vars):
        the_args = command.args

        module_name = the_args[1] if len(the_args) >= 2 else ''
        self._setup_module(vars, module_name)

        return PyramidTemplate.pre(self, command, output_dir, vars)
Example #3
0
 def pre(self, command, output_dir, vars):  # pragma: no cover
     """Create example extension package."""
     size = 10
     chars = string.ascii_letters + string.digits
     vars['random_password'] = ''.join(
         random.choice(chars) for x in range(size))
     return PyramidTemplate.pre(self, command, output_dir, vars)
Example #4
0
    def pre(self, command, output_dir, vars):
        the_args = command.args

        module_name = the_args[1] if len(the_args) >= 2 else ''
        self._setup_module(vars, module_name)

        return PyramidTemplate.pre(self, command, output_dir, vars)
Example #5
0
 def pre(self, command, output_dir, vars): #pragma: no cover
     size = 10
     chars = string.ascii_letters + string.digits
     vars['random_password'] = ''.join(
         random.choice(chars) for x in range(size)
         )
     return PyramidTemplate.pre(self, command, output_dir, vars)
Example #6
0
    def pre(self, command, output_dir, vars):

        check_valid_package_name(vars['project'])

        vars['authentication_random'] = binascii.hexlify(os.urandom(20)).decode("utf-8")
        vars['authomatic_random'] = binascii.hexlify(os.urandom(20)).decode("utf-8")
        vars['session_random'] = binascii.hexlify(os.urandom(20)).decode("utf-8")
        return PyramidTemplate.pre(self, command, output_dir, vars)
    def pre(self, command, output_dir, vars):
        the_args = command.args

        module_name = '' if not isinstance(the_args, list) or len(the_args) < 2 else the_args[1]

        logging.warning('command: %s output_dir: %s vars: %s args: %s module_name: %s', command, output_dir, vars, command.args, module_name)

        self._setup_module(vars, module_name)

        return PyramidTemplate.pre(self, command, output_dir, vars)
Example #8
0
    def pre(self, command, output_dir, vars):
        the_args = command.args

        module_name = '' if not isinstance(the_args, list) or len(the_args) < 2 else the_args[1]

        logging.warning('command: %s output_dir: %s vars: %s args: %s module_name: %s', command, output_dir, vars, command.args, module_name)

        self._setup_module(vars, module_name)

        return PyramidTemplate.pre(self, command, output_dir, vars)
Example #9
0
    def pre(self, command, output_dir, vars):

        check_valid_package_name(vars['project'])

        vars['authentication_random'] = binascii.hexlify(
            os.urandom(20)).decode("utf-8")
        vars['authomatic_random'] = binascii.hexlify(
            os.urandom(20)).decode("utf-8")
        vars['session_random'] = binascii.hexlify(
            os.urandom(20)).decode("utf-8")
        return PyramidTemplate.pre(self, command, output_dir, vars)
Example #10
0
    def pre(self, command, output_dir, vars):
        """ Overrides :meth:`pyramid.scaffold.template.Template.pre`, adding
        several variables to the default variables list (including
        ``random_string``, and ``package_logger``).  It also prevents common
        misnamings (such as naming a package "site" or naming a package
        logger "root".
        """
        # configuration
        user = None
        while not user:
            user = raw_input("Admin username: "******"Admin email: ")
        vars['adminemail'] = str(mail)

        vars['root'] = raw_input("Root directory for files (default data): ")
        if not vars['root']:
            vars['root'] = "data"

        vars['comment'] = "# SQLite"
        vars[
            'param_website'] = """context="Sqlite3", dbName="%(root)s/website.db" """ % vars
        vars[
            'param_user'] = """context="Sqlite3", dbName="%(root)s/userdb.db" """ % vars
        vars['dbPackage'] = ''

        vars['language'] = raw_input(
            "Locale name. Please choose english-> en (default), german-> de or french-> fr: "
        )

        vars['authsecret'] = str(uuid.uuid4())
        vars['cookiesecret'] = str(uuid.uuid4())

        return PyramidTemplate.pre(self, command, output_dir, vars)
Example #11
0
    def pre(self, command, output_dir, vars):

        check_valid_package_name(vars['project'])

        if vars['package'] == 'site':
            raise ValueError('Sorry, you may not name your package "site". '
                             'The package name "site" has a special meaning in '
                             'Python.  Please name it anything except "site".')

        vars['authentication_random'] = binascii.hexlify(os.urandom(20)).decode("utf-8")
        vars['authomatic_random'] = binascii.hexlify(os.urandom(20)).decode("utf-8")
        vars['session_random'] = binascii.hexlify(os.urandom(20)).decode("utf-8")

        package_logger = vars['package']
        if package_logger == 'root':
            # Rename the app logger in the rare case a project is named 'root'
            package_logger = 'app'
        vars['package_logger'] = package_logger
        return PyramidTemplate.pre(self, command, output_dir, vars)
Example #12
0
    def pre(self, command, output_dir, vars):
        """ Overrides :meth:`pyramid.scaffold.template.Template.pre`, adding
        several variables to the default variables list (including
        ``random_string``, and ``package_logger``).  It also prevents common
        misnamings (such as naming a package "site" or naming a package
        logger "root".
        """
        # configuration
        user = None
        while not user:
            user = raw_input("Admin username: "******"Admin email: ")
        vars['adminemail'] = str(mail)
        
        vars['root'] = raw_input("Root directory for files (default data): ")
        if not vars['root']:
            vars['root'] = "data"

        vars['comment'] = "# SQLite"
        vars['param_datastore'] = """context="Sqlite3", dbName="%(root)s/data.db" """ % vars
        vars['param_user'] = """context="Sqlite3", dbName="%(root)s/userdb.db" """ % vars
        vars['dbPackage'] = ''
        
        vars['language'] = raw_input("Locale name. Please choose english-> en or german-> de: ")
        
        vars['authsecret'] = str(uuid.uuid4())
        vars['cookiesecret'] = str(uuid.uuid4())

        return PyramidTemplate.pre(self, command, output_dir, vars)
Example #13
0
    def pre(self, command, output_dir, vars):  # pragma: no cover
        """ Overrides :meth:`pyramid.scaffolds.PyramidTemplate.pre`, adding
        several variables to the default variables list.

        :param command: Command that invoked the template
        :type command: :class:`pyramid.scripts.pcreate.PCreateCommand`

        :param output_dir: Full filesystem path where the created package will
                           be created
        :type output_dir: str

        :param vars: Dictionary of vars passed to the templates for rendering
        :type vars: dict
        """

        vars['project_line'] = '*' * len(vars['project'])
        vars['date'] = datetime.date.today().strftime('%Y-%m-%d')

        vars['author'] = self._get('author', 'Author name')
        vars['email'] = self._get('email', 'Author email')
        vars['gh_user'] = self._get('gh_user', 'Github username')

        return PyramidTemplate.pre(self, command, output_dir, vars)
Example #14
0
    def pre(self, command, output_dir, vars):

        check_valid_package_name(vars['project'])

        if vars['package'] == 'site':
            raise ValueError(
                'Sorry, you may not name your package "site". '
                'The package name "site" has a special meaning in '
                'Python.  Please name it anything except "site".')

        vars['authentication_random'] = binascii.hexlify(
            os.urandom(20)).decode("utf-8")
        vars['authomatic_random'] = binascii.hexlify(
            os.urandom(20)).decode("utf-8")
        vars['session_random'] = binascii.hexlify(
            os.urandom(20)).decode("utf-8")

        package_logger = vars['package']
        if package_logger == 'root':
            # Rename the app logger in the rare case a project is named 'root'
            package_logger = 'app'
        vars['package_logger'] = package_logger
        return PyramidTemplate.pre(self, command, output_dir, vars)
Example #15
0
    def pre(self, command, output_dir, vars):  # pragma: no cover
        """ Overrides :meth:`pyramid.scaffolds.PyramidTemplate.pre`, adding
        several variables to the default variables list.

        :param command: Command that invoked the template
        :type command: :class:`pyramid.scripts.pcreate.PCreateCommand`

        :param output_dir: Full filesystem path where the created package will
                           be created
        :type output_dir: str

        :param vars: Dictionary of vars passed to the templates for rendering
        :type vars: dict
        """

        vars['project_line'] = '*' * len(vars['project'])
        vars['date'] = datetime.date.today().strftime('%Y-%m-%d')

        vars['author'] = self._get('author', 'Author name')
        vars['email'] = self._get('email', 'Author email')
        vars['gh_user'] = self._get('gh_user', 'Github username')

        return PyramidTemplate.pre(self, command, output_dir, vars)
Example #16
0
    def pre(self, command, output_dir, vars):
        """ Overrides :meth:`pyramid.scaffold.template.Template.pre`, adding
        several variables to the default variables list (including
        ``random_string``, and ``package_logger``).  It also prevents common
        misnamings (such as naming a package "site" or naming a package
        logger "root".
        """
        # configuration
        user = None
        while not user:
            user = raw_input("Admin username: "******"Admin email: ")
        vars['adminemail'] = str(mail)

        print "Please enter MySql database settings for the datastore. Two databases will be used, one for collections ",
        print "and one to store userdata. Host, port, user and password are used for both databases."
        print ""
        print "The datastore will create all required database tables and columns automatically when starting the webserver."
        print "These manual administrator actions are required after running this installation script:"
        print "- Create the two databases"
        print "- Assign create and alter table rights to the database user"
        
        vars['root'] = raw_input("Root directory for files (default data): ")
        if not vars['root']:
            vars['root'] = "data"
            
        vars['dbcontentname'] = raw_input("Datastore database name (default %s): " % vars["project"])
        if not vars['dbcontentname']:
            vars['dbcontentname'] = vars["project"]
        vars['dbusername'] = raw_input("User database name (default %s_user): "% vars["project"])
        if not vars['dbusername']:
            vars['dbusername'] = vars["project"]+"_user"
        vars['dbhost'] = raw_input("MySql database host (default localhost): ")
        vars['dbport'] = raw_input("MySql database port (leave empty to use default): ")
        vars['dbuser'] = raw_input("MySql database user: "******"Locale name. Please choose english-> en or german-> de: ")

        vars['comment'] = "# MySql "
        vars['param_datastore'] = """context="MySql",
            dbName="%(dbcontentname)s",
            host="%(dbhost)s",
            port="%(dbport)s",
            user="******",
            password=base64.decodestring("%(dbpass)s") """ % vars

        vars['param_user'] = """context="MySql",
            dbName="%(dbusername)s",
            host="%(dbhost)s",
            port="%(dbport)s",
            user="******",
            password=base64.decodestring("%(dbpass)s") """ % vars
        vars['dbPackage'] = "'MySQL-python'"

        vars['authsecret'] = str(uuid.uuid4())
        vars['cookiesecret'] = str(uuid.uuid4())

        return PyramidTemplate.pre(self, command, output_dir, vars)
Example #17
0
    def pre(self, command, output_dir, vars):
        """ Overrides :meth:`pyramid.scaffold.template.Template.pre`, adding
        several variables to the default variables list (including
        ``random_string``, and ``package_logger``).  It also prevents common
        misnamings (such as naming a package "site" or naming a package
        logger "root".
        """
        # configuration
        user = None
        while not user:
            user = raw_input("Admin username: "******"Admin email: ")
        vars['adminemail'] = str(mail)

        print "Please enter MySql database settings for the datastore. Two databases will be used, one for collections ",
        print "and one to store userdata. Host, port, user and password are used for both databases."
        print ""
        print "The datastore will create all required database tables and columns automatically when starting the webserver."
        print "These manual administrator actions are required after running this installation script:"
        print "- Create the two databases"
        print "- Assign create and alter table rights to the database user"

        vars['root'] = raw_input("Root directory for files (default data): ")
        if not vars['root']:
            vars['root'] = "data"

        vars['dbcontentname'] = raw_input(
            "Datastore database name (default %s): " % vars["project"])
        if not vars['dbcontentname']:
            vars['dbcontentname'] = vars["project"]
        vars['dbusername'] = raw_input(
            "User database name (default %s_user): " % vars["project"])
        if not vars['dbusername']:
            vars['dbusername'] = vars["project"] + "_user"
        vars['dbhost'] = raw_input("MySql database host (default localhost): ")
        vars['dbport'] = raw_input(
            "MySql database port (leave empty to use default): ")
        vars['dbuser'] = raw_input("MySql database user: "******"Locale name. Please choose english-> en or german-> de: ")

        vars['comment'] = "# MySql "
        vars['param_datastore'] = """context="MySql",
            dbName="%(dbcontentname)s",
            host="%(dbhost)s",
            port="%(dbport)s",
            user="******",
            password=base64.decodestring("%(dbpass)s") """ % vars

        vars['param_user'] = """context="MySql",
            dbName="%(dbusername)s",
            host="%(dbhost)s",
            port="%(dbport)s",
            user="******",
            password=base64.decodestring("%(dbpass)s") """ % vars
        vars['dbPackage'] = "'MySQL-python'"

        vars['authsecret'] = str(uuid.uuid4())
        vars['cookiesecret'] = str(uuid.uuid4())

        return PyramidTemplate.pre(self, command, output_dir, vars)
Example #18
0
 def pre(self, command, output_dir, vars):
     vars['Package'] = vars['package'].capitalize()
     return PyramidTemplate.pre(self, command, output_dir, vars)
Example #19
0
 def pre(self, command, output_dir, vars):
     vars['capitalized_package'] = self._smart_capitalize(vars['package'])
     return PyramidTemplate.pre(self, command, output_dir, vars)
Example #20
0
 def _makeOne(self):
     from pyramid.scaffolds import PyramidTemplate
     return PyramidTemplate('name')
Example #21
0
 def pre(self, command, output_dir, vars):
     vars['capitalized_package'] = self._smart_capitalize(vars['package'])
     return PyramidTemplate.pre(self, command, output_dir, vars)
Example #22
0
 def post(self, command, output_dir, vars):
     val = PyramidTemplate.post(self, command, output_dir, vars)
     self.out('')
     self.out('Now check README_FANSTATIC.txt to finalize installation')
     return val