コード例 #1
0
    def run(self):
        """Create a Bisque Service/Module template"""

        # Get to toplevel directory name i.e. the project
        while not self.name:
            self.name = raw_input("Enter bisque project [egg] name: ")

        # The package name to be used internally
        while not self.package:
            package = self.name.lower()
            package = beginning_letter.sub("", package)
            package = valid_only.sub("", package)
            self.package = raw_input("Enter [python] package name  [%s]: " % package)
            if not self.package:
                self.package = package

        while not self.mount:
            mount = self.package.lower()
            mount = beginning_letter.sub("", mount)
            mount = valid_only.sub("", mount)
            self.mount = raw_input("Enter mount point (url point) [%s]: " % mount)
            if not self.mount:
                self.mount = mount



        command = create_distro.CreateDistroCommand("create")
        for template in self.templates.split(" "):
            self.cmd_args.append("--template=%s" % template)
        self.cmd_args.append(self.name)
        # Variables
        self.cmd_args.append("package=%s" % self.package)
        self.cmd_args.append("mount=%s" % self.mount)

        command.run(self.cmd_args)
コード例 #2
0
    def command(self):
        if self.args:
            self.name = self.args[0]

        while not self.name:
            self.name = raw_input("Enter project name: ")

        if not self.package:
            package = self.name.lower()
            package = beginning_letter.sub("", package)
            package = valid_only.sub("", package)
            while not self.package:
                self.package = raw_input(
                    "Enter package name [%s]: " % package).strip() or package

        self.name = pkg_resources.safe_name(self.name)

        env = pkg_resources.Environment()
        if self.name.lower() in env:
            print 'The name "%s" is already in use by' % self.name,
            for dist in env[self.name]:
                print dist
                return

        import imp
        try:
            if imp.find_module(self.package):
                print 'The package name "%s" is already in use' % self.package
                return
        except ImportError:
            pass

        if os.path.exists(self.name):
            print 'A directory called "%s" already exists. Exiting.' % self.name
            return

        command = create_distro.CreateDistroCommand("create")
        cmd_args = []
        cmd_args.append("--template=quickstart-pluggable-template")
        cmd_args.append(self.name)
        cmd_args.append("package=%s" % self.package)

        command.run(cmd_args)

        os.chdir(self.name)
コード例 #3
0
ファイル: quickstart.py プロジェクト: decause/moksha
    def command(self):
        """Quickstarts the new project."""

        self.__dict__.update(self.options.__dict__)

        if self.args:
            self.name = self.args[0]

        while not self.name:
            self.name = raw_input("Enter project name: ")

        package = self.name.lower()
        package = beginning_letter.sub("", package)
        package = valid_only.sub("", package)
        if package:
            self.package = package
        else:
            self.package = None
            while not self.package:
                self.package = raw_input(
                    "Enter package name [%s]: " % package).strip() or package

        self.name = pkg_resources.safe_name(self.name).replace('-', '_')
        self.rpm_name = self.package.replace('.', '-')

        env = pkg_resources.Environment()
        if self.name.lower() in env:
            print 'The name "%s" is already in use by' % self.name,
            for dist in env[self.name]:
                print dist
                return

        try:
            if imp.find_module(self.package):
                print 'The package name "%s" is already in use' % self.package
                return
        except ImportError:
            pass

        if os.path.exists(self.name):
            print 'A directory called "%s" already exists. Exiting.' % self.name
            return

        command = create_distro.CreateDistroCommand("create")
        cmd_args = ['--template=moksha.master']
        if self.livewidget:
            cmd_args.append('--template=moksha.livewidget')
        if self.stream:
            cmd_args.append('--template=moksha.stream')
        if self.consumer:
            cmd_args.append('--template=moksha.consumer')
        if self.connector:
            cmd_args.append('--template=moksha.connector')
        if self.controller:
            cmd_args.append('--template=moksha.controller')

        #if self.dry_run:
        #    cmd_args.append("--simulate")
        #    cmd_args.append("-q")
        cmd_args.append(self.name)
        cmd_args.append("livewidget=%s" % self.livewidget)
        cmd_args.append("connector=%s" % self.connector)
        cmd_args.append("consumer=%s" % self.consumer)
        cmd_args.append("controller=%s" % self.controller)
        cmd_args.append("stream=%s" % self.stream)
        cmd_args.append("package=%s" % self.package)
        cmd_args.append("widget_name=%s" % self.package.title() + 'Widget')
        cmd_args.append("stream_name=%s" % self.package.title() + 'Stream')
        cmd_args.append("consumer_name=%s" % self.package.title() + 'Consumer')
        cmd_args.append("connector_name=%s" % self.package.title() +
                        'Connector')
        cmd_args.append("controller_name=%s" % self.package.title() +
                        'Controller')
        command.run(cmd_args)
コード例 #4
0
 def setUp(self):
     self.cmd = create_distro.CreateDistroCommand('create_distro')
コード例 #5
0
    def command(self):
        """LayCement for the new project."""

        self.__dict__.update(self.options.__dict__)

        if self.args:
            self.name = self.args[0]

        while not self.name:
            self.name = raw_input("Enter project name: ").strip()

        self.name = pkg_resources.safe_name(self.name)

        package = self.name.lower()
        package = beginning_letter.sub("", package)
        package = valid_only.sub("_", package)
        self.package = raw_input(
            "Enter module name [%s]: " % package).strip() or package

        self.description = raw_input("Project Description: ").strip()
        self.creator = raw_input("Project Creator: ").strip()
        self.creator_email = raw_input("Project Creator Email: ").strip()
        self.url = raw_input("Project URL: ").strip()
        self.license = raw_input("Project License: ").strip()

        env = pkg_resources.Environment()
        if self.name.lower() in env:
            print 'The name "%s" is already in use by ' % self.name,
            for dist in env[self.name]:
                print dist
                return

        import imp
        try:
            if imp.find_module(self.package):
                print 'The package name "%s" is already in use' % self.package
                return
        except ImportError:
            pass

        if os.path.exists(self.name):
            print 'A directory called "%s" already exists. Exiting.' % self.name
            return

        command = create_distro.CreateDistroCommand("create")
        cmd_args = []
        for template in self.templates.split():
            cmd_args.append("--template=%s" % template)

        cmd_args.append(self.name)
        cmd_args.append("package=%s" % self.package)
        cmd_args.append("cement_version=%s" % CEMENT_VERSION)
        cmd_args.append("cement_next_version=%s" % CEMENT_NEXT_VERSION)
        cmd_args.append("description=%s" % self.description)
        cmd_args.append("creator=%s" % self.creator)
        cmd_args.append("creator_email=%s" % self.creator_email)
        cmd_args.append("url=%s" % self.url)
        cmd_args.append("license=%s" % self.license)

        command.run(cmd_args)

        if not self.dry_run:
            sys.argv = ["setup.py", "egg_info"]

            # dirty hack to allow "empty" dirs
            for base, path, files in os.walk("./"):
                for file in files:
                    if file == "empty":
                        os.remove(os.path.join(base, file))
コード例 #6
0
    def command(self):
        """Quickstarts the new project."""

        self.__dict__.update(self.options.__dict__)
        if not True in [self.sqlalchemy, self.sqlobject]:
            self.sqlalchemy = True

        if self.args:
            self.name = self.args[0]

        while not self.name:
            self.name = raw_input("Enter project name: ")

        package = self.name.lower()
        package = beginning_letter.sub("", package)
        package = valid_only.sub("", package)
        if package and self.no_input:
            self.package = package
        else:
            self.package = None
            while not self.package:
                self.package = raw_input(
                    "Enter package name [%s]: " % package).strip() or package

        if not self.no_input:
            while self.auth is None:
                self.auth = raw_input(
                    "Do you need authentication and authorization"
                    " in this project? [yes] ")
                self.auth = dict(y=True,
                                 n=False).get(self.auth.lstrip()[:1].lower()
                                              or 'y')
                if self.auth is None:
                    print "Please enter y(es) or n(o)."

        if self.auth:
            if self.sqlalchemy:
                self.auth = "sqlalchemy"
            else:
                print(
                    'You can only use authentication and authorization'
                    ' in a new project if you use SQLAlchemy. Please check'
                    ' the repoze.what documentation to learn how to implement'
                    ' authentication/authorization with other sources.')
                return
                # TODO: As far as I know, SQLObject has never been supported in
                # TG2
                # self.auth = "sqlobject"
        else:
            self.auth = None

        self.name = pkg_resources.safe_name(self.name)

        env = pkg_resources.Environment()
        if self.name.lower() in env:
            print 'The name "%s" is already in use by' % self.name,
            for dist in env[self.name]:
                print dist
                return

        import imp
        try:
            if imp.find_module(self.package):
                print 'The package name "%s" is already in use' % self.package
                return
        except ImportError:
            pass

        if os.path.exists(self.name):
            print 'A directory called "%s" already exists. Exiting.' % self.name
            return

        command = create_distro.CreateDistroCommand("create")
        cmd_args = []
        for template in self.templates.split():
            cmd_args.append("--template=%s" % template)
        if self.svn_repository:
            cmd_args.append("--svn-repository=%s" % self.svn_repository)
        if self.dry_run:
            cmd_args.append("--simulate")
            cmd_args.append("-q")
        cmd_args.append(self.name)
        cmd_args.append("sqlalchemy=%s" % self.sqlalchemy)
        cmd_args.append("sqlobject=%s" % self.sqlobject)
        cmd_args.append("auth=%s" % self.auth)
        cmd_args.append("geo=%s" % self.geo)
        cmd_args.append("package=%s" % self.package)
        cmd_args.append("tgversion=%s" % self.version)
        # set the exact ORM-version for the proper requirements
        # it's extracted from our own requirements, so looking
        # them up must be in sync (there must be the extras_require named
        # sqlobject/sqlalchemy)
        """if self.sqlobject:
            sqlobjectversion = str(get_requirement('sqlobject'))
            cmd_args.append("sqlobjectversion=%s" % sqlobjectversion)
        if self.sqlalchemy:
            sqlalchemyversion = str(get_requirement('sqlalchemy'))
            cmd_args.append("sqlalchemyversion=%s" % sqlalchemyversion)
        """
        command.run(cmd_args)

        if not self.dry_run:
            os.chdir(self.name)
            if self.sqlobject:
                # Create the SQLObject history directory only when needed.
                # With paste.script it's only possible to skip files, but
                # not directories. So we are handling this manually.
                sodir = '%s/sqlobject-history' % self.package
                if not os.path.exists(sodir):
                    os.mkdir(sodir)
                try:
                    if not os.path.exists(
                            os.path.join(
                                os.path.dirname(os.path.abspath(sodir)),
                                '.svn')):
                        raise OSError
                    command.run_command('svn', 'add', sodir)
                except OSError:
                    pass

            startscript = "start-%s.py" % self.package
            if os.path.exists(startscript):
                oldmode = os.stat(startscript).st_mode
                os.chmod(startscript, oldmode | stat.S_IXUSR)
            sys.argv = ["setup.py", "egg_info"]
            import imp
            imp.load_module("setup", *imp.find_module("setup", ["."]))

            # dirty hack to allow "empty" dirs
            for base, path, files in os.walk("./"):
                for file in files:
                    if file == "empty":
                        os.remove(os.path.join(base, file))
コード例 #7
0
ファイル: quickstart.py プロジェクト: clsdaniel/tg2devtools
    def command(self):
        """Quickstarts the new project."""

        self.__dict__.update(self.options.__dict__)

        if self.no_sqlalchemy:
            self.sqlalchemy = False

        if self.ming:
            self.sqlalchemy = False
            self.migrations = False

        if self.no_auth:
            self.auth = False

        if self.args:
            self.name = self.args[0]

        while not self.name:
            self.name = raw_input("Enter project name: ")

        if not self.package:
            package = self.name.lower()
            package = beginning_letter.sub("", package)
            package = valid_only.sub("", package)
            if package and self.no_input:
                self.package = package
            else:
                self.package = None
                while not self.package:
                    self.package = raw_input("Enter package name [%s]: " %
                                             package).strip() or package

        if self.no_input:
            #defaults
            self.mako = False
            self.jinja = False
            self.kajiki = False
            self.auth = True

        if self.jinja is None and self.mako is None and self.kajiki is None:
            template = None
            while template is None:
                template = raw_input(
                    "Would you prefer to use an alternative template system? (m=mako, j=jinja, k=kajiki, n=no [default]): "
                )
                template = dict(m="mako", j="jinja", k='kajiki',
                                n="none").get(template.lstrip()[:1].lower()
                                              or 'n')
                if template == "mako":
                    self.mako = True
                elif template == "jinja":
                    self.jinja = True
                elif template == "kajiki":
                    self.kajiki = True
                elif template is None:
                    print "Please enter an option or n(o)."

        while self.auth is None:
            self.auth = raw_input(
                "Do you need authentication and authorization"
                " in this project? ([yes]/no): ")
            self.auth = dict(y=True,
                             n=False).get(self.auth.lstrip()[:1].lower()
                                          or 'y')
            if self.auth is None:
                print "Please enter y(es) or n(o)."

        if self.auth:
            if self.ming:
                self.auth = "ming"
                self.ming = True
            else:
                self.auth = "sqlalchemy"
                self.sqlalchemy = True
        else:
            self.auth = None

        self.name = pkg_resources.safe_name(self.name)

        env = pkg_resources.Environment()
        if self.name.lower() in env:
            print 'The name "%s" is already in use by' % self.name,
            for dist in env[self.name]:
                print dist
                return

        import imp
        try:
            if imp.find_module(self.package):
                print 'The package name "%s" is already in use' % self.package
                return
        except ImportError:
            pass

        if os.path.exists(self.name):
            print 'A directory called "%s" already exists. Exiting.' % self.name
            return

        self.cookiesecret = None
        try:
            import uuid
            self.cookiesecret = str(uuid.uuid4())
        except ImportError:
            import random
            import base64
            import struct
            self.cookiesecret = base64.b64encode("".join([
                struct.pack('i', random.randrange(2**31))
                for x in [1, 2, 3, 4, 5, 6]
            ])).strip()

        command = create_distro.CreateDistroCommand("create")
        cmd_args = []
        templates = self.templates.split()
        for template in templates:
            cmd_args.append("--template=%s" % template)
        if self.dry_run:
            cmd_args.append("--simulate")
            cmd_args.append("-q")
        cmd_args.append(self.name)
        cmd_args.append("sqlalchemy=%s" % self.sqlalchemy)
        cmd_args.append("ming=%s" % self.ming)
        cmd_args.append("auth=%s" % self.auth)
        cmd_args.append("geo=%s" % self.geo)
        cmd_args.append("tw1=%s" % self.tw1)
        cmd_args.append("package=%s" % self.package)
        cmd_args.append("tgversion=%s" % self.version)
        cmd_args.append("mako=%s" % self.mako)
        cmd_args.append("jinja=%s" % self.jinja)
        cmd_args.append("kajiki=%s" % self.kajiki)
        cmd_args.append("migrations=%s" % self.migrations)
        cmd_args.append("cookiesecret=%s" % self.cookiesecret)
        # set the exact ORM-version for the proper requirements
        # it's extracted from our own requirements, so looking
        # them up must be in sync (there must be the extras_require named
        # sqlalchemy)

        command.run(cmd_args)

        if self.dry_run:
            return

        os.chdir(self.name)

        sys.argv = ["setup.py", "egg_info"]
        import imp
        imp.load_module("setup", *imp.find_module("setup", ["."]))

        # dirty hack to allow "empty" dirs
        for base, path, files in os.walk("./"):
            for file in files:
                if file == "empty":
                    os.remove(os.path.join(base, file))

        #copy over the alternative templates if appropriate
        if self.mako or self.kajiki or self.jinja:

            def overwrite_templates(template_type):
                print 'Writing ' + template_type + ' template files to ./' + os.path.join(
                    self.package, 'templates')
                #remove existing template files
                package_template_dir = os.path.abspath(
                    os.path.join(self.package, 'templates'))
                shutil.rmtree(package_template_dir, ignore_errors=True)
                #replace template files with alternative ones
                alt_template_dir = os.path.abspath(
                    os.path.dirname(__file__)) + '/quickstart_' + template_type
                shutil.copytree(alt_template_dir, package_template_dir)

            if self.mako:
                overwrite_templates('mako')
            elif self.jinja:
                overwrite_templates('jinja')
            elif self.kajiki:
                overwrite_templates('kajiki')

        if self.ming:
            print 'Writing Ming model files to ./' + os.path.join(
                self.package, 'model')
            package_model_dir = os.path.abspath(
                os.path.join(self.package, 'model'))
            ming_model_dir = os.path.abspath(
                os.path.dirname(__file__)) + '/model_ming'
            shutil.copy(os.path.join(ming_model_dir, 'session.py'),
                        package_model_dir)

        if not self.migrations:
            print 'Disabling migrations support'

            #remove existing migrations directory
            package_migrations_dir = os.path.abspath('migration')
            shutil.rmtree(package_migrations_dir, ignore_errors=True)
コード例 #8
0
    def run(self):
        "Updates an existing project"

        if not paste_script_installed:
            print "Quickstart is dependent on PasteScript to be installed."
            print "Please install and try again."
            print "   easy_install PasteScript"
            return
        
        self.name = gearshift.util.get_project_name()
        self.package = gearshift.util.get_package_name()
        gearshift.command.base.load_project_config()

        if not self.sqlalchemy:
            if gearshift.config.get('sqlalchemy.dburi'):
                self.sqlalchemy = True

        if self.elixir:
            self.sqlalchemy = True
            self.sqlobject = False
        elif self.sqlalchemy:
            self.sqlobject = False
        else:
            self.sqlobject = True

        if not self.identity:
            if gearshift.config.get('tools.identity.on'):
                self.identity = True

        if self.identity:
            if self.sqlalchemy:
                self.identity = 'sqlalchemy'
            else:
                self.identity =  'sqlobject'
        else:
            self.identity = 'none'
        currentdir = os.path.basename(os.getcwd())
        if not currentdir == self.name:
            print 'It looks like your project dir "%s" is named wrongly.' % currentdir
            print 'Please rename it to "%s".' % self.name
            return

        command = create_distro.CreateDistroCommand("update")
        cmd_args = []
        cmd_args.append("-o../")
        for template in self.templates.split(" "):
            cmd_args.append("--template=%s" % template)
        cmd_args.append(self.name)
        cmd_args.append("sqlalchemy=%s" % self.sqlalchemy)
        cmd_args.append("elixir=%s" % self.elixir)
        cmd_args.append("sqlobject=%s" % self.sqlobject)
        cmd_args.append("identity=%s" % self.identity)
        cmd_args.append("package=%s" % self.package)
        # set the exact ORM-version for the proper requirements
        # it's extracted from our own requirements, so looking
        # them up must be in sync (there must be the extras_require named sqlobject/sqlalchemy)
        if self.sqlobject:
            sqlobjectversion = str(get_requirement('sqlobject'))
            cmd_args.append("sqlobjectversion=%s" % sqlobjectversion)

        if self.sqlalchemy:
            sqlalchemyversion = str(get_requirement('sqlalchemy'))
            cmd_args.append("sqlalchemyversion=%s" % sqlalchemyversion)

        command.run(cmd_args)

        startscript = "start-%s.py" % self.package
        if os.path.exists(startscript):
            oldmode = os.stat(startscript).st_mode
            os.chmod(startscript,
                    oldmode | stat.S_IXUSR)
        sys.argv = ["setup.py", "egg_info"]
        import imp
        imp.load_module("setup", *imp.find_module("setup", ["."]))

        # dirty hack to allow "empty" dirs
        for base, path, files in os.walk("./"):
            for file in files:
                if file == "empty":
                    os.remove(os.path.join(base, file))
コード例 #9
0
    def run(self):
        "Quickstarts the new project."

        while not self.name:
            self.name = raw_input("Enter project name: ")

        while not self.package:
            package = self.name.lower()
            package = beginning_letter.sub("", package)
            package = valid_only.sub("", package)
            self.package = raw_input("Enter package name [%s]: " % package)
            if not self.package:
                self.package = package

        doidentity = self.identity
        while self.prompt_identity and not doidentity:
            doidentity = raw_input("Do you need Identity "
                        "(usernames/passwords) in this project? [no] ")

            doidentity = doidentity.lower()

            if not doidentity or doidentity.startswith('n'):
                self.identity = "none"
                break

            if doidentity.startswith("y"):
                doidentity = True
                break

            print "Please enter y(es) or n(o)."
            doidentity = None

        if doidentity is True:
            if self.sqlalchemy or self.elixir:
                self.identity = "sqlalchemy"
            else:
                self.identity = "sqlobject"
        else:
            self.identity = "none"

        self.name = pkg_resources.safe_name(self.name)

        env = pkg_resources.Environment()
        if self.name.lower() in env:
            print 'The name "%s" is already in use by' % self.name,
            for dist in env[self.name]:
                print dist
                return

        import imp
        try:
            if imp.find_module(self.package):
                print 'The package name "%s" is already in use' % self.package
                return
        except ImportError:
            pass

        if os.path.exists(self.name):
            print 'A directory called "%s" already exists. Exiting.' % self.name
            return

        command = create_distro.CreateDistroCommand("quickstart")
        cmd_args = []
        for template in self.templates.split(" "):
            cmd_args.append("--template=%s" % template)
        if self.svn_repository:
            cmd_args.append("--svn-repository=%s" % self.svn_repository)
        if self.dry_run:
            cmd_args.append("--simulate")
            cmd_args.append("-q")
        cmd_args.append(self.name)
        cmd_args.append("sqlalchemy=%s" % self.sqlalchemy)
        cmd_args.append("elixir=%s" % self.elixir)
        cmd_args.append("sqlobject=%s" % self.sqlobject)
        cmd_args.append("identity=%s" % self.identity)
        cmd_args.append("package=%s" % self.package)
        # set the exact ORM-version for the proper requirements
        # it's extracted from our own requirements, so looking
        # them up must be in sync (there must be the extras_require named sqlobject/sqlalchemy)
        if self.sqlobject:
            sqlobjectversion = str(get_requirement('sqlobject'))
            cmd_args.append("sqlobjectversion=%s" % sqlobjectversion)
        if self.sqlalchemy:
            sqlalchemyversion = str(get_requirement('sqlalchemy'))
            cmd_args.append("sqlalchemyversion=%s" % sqlalchemyversion)
        if self.elixir:
            elixirversion = str(get_requirement('sqlalchemy', 'elixir'))
            cmd_args.append("elixirversion=%s" % elixirversion)

        command.run(cmd_args)

        if not self.dry_run:
            os.chdir(self.name)
            if self.sqlobject:
                # Create the SQLObject history directory only when needed.
                # With paste.script it's only possible to skip files, but
                # not directories. So we are handling this manually.
                sodir = '%s/sqlobject-history' % self.package
                if not os.path.exists(sodir):
                    os.mkdir(sodir)
                try:
                    if not os.path.exists(os.path.join(os.path.dirname(
                            os.path.abspath(sodir)), '.svn')):
                        raise OSError
                    command.run_command('svn', 'add', sodir)
                except OSError:
                    pass

            startscript = "start-%s.py" % self.package
            if os.path.exists(startscript):
                oldmode = os.stat(startscript).st_mode
                os.chmod(startscript,
                        oldmode | stat.S_IXUSR)
            sys.argv = ["setup.py", "egg_info"]
            import imp
            imp.load_module("setup", *imp.find_module("setup", ["."]))

        # dirty hack to allow "empty" dirs
        for base, path, files in os.walk("./"):
            for file in files:
                if file == "empty":
                    os.remove(os.path.join(base, file))