Exemplo n.º 1
0
 def testAllCreate(self):
     package = PackagePages(self.request.rootpage.page_name, self.request)
     temp = tempfile.NamedTemporaryFile(suffix='.zip')
     package.collectpackage(self.request.rootpage.getPageList(
                             include_underlay=False,
                             filter=lambda name: not wikiutil.isSystemPage(self.request, name)),
                             temp)
     if not package:
         py.test.skip("No user created pages in wiki!")
     assert zipfile.is_zipfile(temp.name)
Exemplo n.º 2
0
    def mainloop(self):
        """ moin-package's main code. """

        # Initalize request
        self.init_request()
        request = self.request
        _ = self.request.getText

        # Check our command line args
        if self.options.pages and self.options.search:
            script.fatal(_("Options --pages and --search are mutually exclusive!"))
        elif not self.options.output:
            script.fatal(_("You must specify an output file!"))
        elif not self.options.pages and not self.options.search:
            script.log(_("No pages specified using --pages or --search, assuming full package."))

        include_attachments = self.options.attachment or False
        if include_attachments:
            script.log(_("All attachments included into the package."))

        # Sanity checks
        if os.path.exists(self.options.output):
            script.fatal(_("Output file already exists! Cowardly refusing to continue!"))

        # Check for user
        if self.options.package_user:
            request.user = user.User(request, name=self.options.package_user)

        # Import PackagePages here, as we now have an initalized request.
        from MoinMoin.action.PackagePages import PackagePages

        # Perform actual packaging.
        package = PackagePages(request.rootpage.page_name, request)
        packageoutput = open(self.options.output, "wb")
        if self.options.search:
            packagedata = package.collectpackage(
                package.searchpackage(request, self.options.search),
                packageoutput,
                include_attachments=include_attachments,
            )
        elif self.options.pages:
            packagedata = package.collectpackage(
                self.options.pages.split(","), packageoutput, include_attachments=include_attachments
            )
        else:
            packagedata = package.collectpackage(
                request.rootpage.getPageList(
                    include_underlay=False, filter=lambda name: not wikiutil.isSystemPage(request, name)
                ),
                packageoutput,
                include_attachments=include_attachments,
            )
        if packagedata:
            script.fatal(packagedata)
Exemplo n.º 3
0
 def testAllCreate(self):
     package = PackagePages(self.request.rootpage.page_name, self.request)
     temp = tempfile.NamedTemporaryFile(suffix='.zip')
     package.collectpackage(
         self.request.rootpage.getPageList(
             include_underlay=False,
             filter=lambda name: not wikiutil.isSystemPage(
                 self.request, name)), temp)
     if not package:
         py.test.skip("No user created pages in wiki!")
     assert zipfile.is_zipfile(temp.name)
Exemplo n.º 4
0
    def mainloop(self):
        """ moin-package's main code. """

        # Initalize request
        self.init_request()
        request = self.request
        _ = self.request.getText

        # Check our command line args
        if self.options.pages and self.options.search:
            script.fatal(_("Options --pages and --search are mutually exclusive!"))
        elif not self.options.output:
            script.fatal(_("You must specify an output file!"))
        elif not self.options.pages and not self.options.search:
            script.log(_("No pages specified using --pages or --search, assuming full package."))

        include_attachments = self.options.attachment or False
        if include_attachments:
            script.log(_("All attachments included into the package."))

        # Sanity checks
        if os.path.exists(self.options.output):
            script.fatal(_("Output file already exists! Cowardly refusing to continue!"))

        # Check for user
        if self.options.package_user:
            request.user = user.User(request, name=self.options.package_user)

        # Import PackagePages here, as we now have an initalized request.
        from MoinMoin.action.PackagePages import PackagePages

        # Perform actual packaging.
        package = PackagePages(request.rootpage.page_name, request)
        packageoutput = open(self.options.output, "wb")
        if self.options.search:
            packagedata = package.collectpackage(package.searchpackage(request,
                                                                       self.options.search), packageoutput,
                                                                       include_attachments=include_attachments)
        elif self.options.pages:
            packagedata = package.collectpackage(self.options.pages.split(","), packageoutput, include_attachments=include_attachments)
        else:
            packagedata = package.collectpackage(request.rootpage.getPageList(
                                include_underlay=False,
                                filter=lambda name: not wikiutil.isSystemPage(request, name)),
                                packageoutput, include_attachments=include_attachments)
        if packagedata:
            script.fatal(packagedata)
Exemplo n.º 5
0
 def testListCreate(self):
     package = PackagePages(self.request.rootpage.page_name, self.request)
     temp = tempfile.NamedTemporaryFile(suffix='.zip')
     package.collectpackage(['FrontPage'], temp)
     assert zipfile.is_zipfile(temp.name)
Exemplo n.º 6
0
 def testInvalidCreate(self):
     package = PackagePages(self.request.rootpage.page_name, self.request)
     temp = tempfile.NamedTemporaryFile(suffix='.zip')
     package.collectpackage(['___//THIS PAGE SHOULD NOT EXIST\\___'], temp)
     assert not zipfile.is_zipfile(temp.name)
Exemplo n.º 7
0
 def testListCreate(self):
     package = PackagePages(self.request.rootpage.page_name, self.request)
     temp = tempfile.NamedTemporaryFile(suffix='.zip')
     package.collectpackage(['FrontPage'], temp)
     assert zipfile.is_zipfile(temp.name)
Exemplo n.º 8
0
 def testInvalidCreate(self):
     package = PackagePages(self.request.rootpage.page_name, self.request)
     temp = tempfile.NamedTemporaryFile(suffix='.zip')
     package.collectpackage(['___//THIS PAGE SHOULD NOT EXIST\\___'], temp)
     assert not zipfile.is_zipfile(temp.name)