Ejemplo n.º 1
0
    def do_create_page_instance(self, arg):
        """
        Create a PyLucid page instance.
        Needs two arguments:
            - destination: filesystem point to create a new instance
            - name: The project name (Should be ASCII without spaces)

        Direct start with:
            $ pylucid_admin create_page_instance [destination] [name]

        tbd.
        """
        try:
            destination, name = arg.split(" ")
        except ValueError as err:
            print("ERROR: %s" % err)
            print("There are two arguments needed: [destination] [name]")
            return

        destination = destination.strip()
        name = name.strip()

        if not destination:
            print("ERROR: destination is needed!")
            return

        if not name:
            print("ERROR: name not given!")
            return

        create_instance(dest=destination,
                        name=name,
                        remove=False,
                        exist_ok=False)
Ejemplo n.º 2
0
    def do_create_page_instance(self, arg):
        """
        Create a PyLucid page instance.
        Needs two arguments:
            - destination: filesystem point to create a new instance
            - name: The project name (Should be ASCII without spaces)

        Direct start with:
            $ pylucid_admin create_page_instance [destination] [name]

        tbd.
        """
        try:
            destination, name = arg.split(" ")
        except ValueError as err:
            print("ERROR: %s" % err)
            print("There are two arguments needed: [destination] [name]")
            return

        destination = destination.strip()
        name = name.strip()

        if not destination:
            print("ERROR: destination is needed!")
            return

        if not name:
            print("ERROR: name not given!")
            return

        create_instance(dest=destination, name=name, remove=False, exist_ok=False)
Ejemplo n.º 3
0
    def setUp(self):
        super().setUp()

        self.temp_path = Path().cwd()  # isolated_filesystem does made a chdir to /tmp/...

        # We can't use the created temp path directly,
        # because the installer will only use a not existing directory
        self.instance_root = Path(self.temp_path, "instance")             # /tmp/TestClassNameXXX/instance

        self.project_name = clean_string(self._testMethodName)            # "test_func_name"
        self.instance_path = Path(self.instance_root, self.project_name)  # /tmp/TestClassNameXXX/instance/test_func_name

        with StdoutStderrBuffer() as buffer:
            create_instance(
                dest = self.instance_root,
                name = self.project_name,
                remove = False,
                exist_ok = False,
            )

        output = buffer.get_output()
        try:
            self.assertIn(
                "Create instance with name '%s' at: %s..." % (
                    self.project_name, self.instance_root
                ),
                output
            )

            self.manage_file_path = Path(self.instance_root, "manage.py")
            shebang=get_python3_shebang()
            self.assertIn("Update shebang in '%s' to '%s'" % (self.manage_file_path, shebang), output)
            self.assertIn("Update filecontent '%s/settings.py'" % self.instance_path, output)
            self.assertIn("Page instance created here: '%s'" % self.instance_root, output)

            self.assertNotIn("ERROR", output)
            self.assertTrue(self.instance_path.is_dir(), "Not a directory: '%s'" % self.instance_path)

            self.assertTrue(self.manage_file_path.is_file(), "File not found: '%s'" % self.manage_file_path)
            self.assertTrue(os.access(self.manage_file_path, os.X_OK), "File '%s' not executeable!" % self.manage_file_path)

            with self.manage_file_path.open("r") as f:
                manage_content=f.read()
        except Exception:
            print(output)
            raise

        try:
            self.assertIn(shebang, manage_content)
            self.assertIn("%s.settings" % self.project_name, manage_content)
        except Exception:
            print(manage_content)
            raise

        # Needed until https://github.com/divio/django-cms/issues/5079 is fixed:
        self.createcachetable()