Ejemplo n.º 1
0
    def __search_remotes(self, term, include_descriptions=False):
        """
        Search for modules, on remote repositories.
        """

        installer = ModuleInstaller(None)

        try:
            modules = installer.search_index(term)

            if len(modules) > 0:
                for module in modules:
                    print module

                    if include_descriptions:
                        if module.description != None:
                            print "%s\n" % text.indent(
                                text.wrap(module.description,
                                          console.get_size()[0] - 4), "    ")
                        else:
                            print text.indent("No description given.\n",
                                              "    ")
                print
            else:
                print "No modules found.\n"
        except NetworkException:
            print "There was a problem accessing one-or-more of the remote repositories.\n\nMake sure that you have a working network connection.\n"
Ejemplo n.º 2
0
    def testItShouldNotInstallAnArchivedLocalModuleIfAlreadyPresent(self):

        ModuleInstaller("./tmp").install(["./test/mwr_test/mocks/a.local.zip"])
        
        assert os.path.exists("./tmp/a")
        assert os.path.exists("./tmp/a/__init__.py")
        assert os.path.exists("./tmp/a/local")
        assert os.path.exists("./tmp/a/local/__init__.py")
        assert os.path.exists("./tmp/a/local/module.py")

        ModuleInstaller("./tmp").install(["./test/mwr_test/mocks(reinstall)/a.local.zip"])
        
        assert fs.read("./tmp/a/local/module.py") != b"This is an edited local, archived module.\n"
Ejemplo n.º 3
0
    def testItShouldOverwriteAnArchivedLocalModuleIfForceIsSet(self):
        
        ModuleInstaller("./tmp").install(["./test/mwr_test/mocks/a.local.zip"])
        
        assert os.path.exists("./tmp/a")
        assert os.path.exists("./tmp/a/__init__.py")
        assert os.path.exists("./tmp/a/local")
        assert os.path.exists("./tmp/a/local/__init__.py")
        assert os.path.exists("./tmp/a/local/module.py")

        ModuleInstaller("./tmp").install(["./test/mwr_test/mocks/mocks(reinstall)/a.local.zip"], True)
        
        assert fs.read("./tmp/a/local/module.py") == b"This is an edited local, archived module.\n"
Ejemplo n.º 4
0
 def do_install(self, arguments):
     """install a new module"""
     
     repository = self.__choose_repo()
     
     if repository != None:
         installer = ModuleInstaller(repository)
         modules = installer.install(arguments.options, arguments.force)
                     
         print
         print "Successfully installed %d modules, %d already installed." % (len(modules['success']), len(modules['existing']))
         if len(modules['fail']) > 0:
             print "Failed to install %d modules:" % len(modules['fail'])
             for module in modules['fail']:
                 print "  %s" % module
                 print "    %s" % modules['fail'][module]
         print
Ejemplo n.º 5
0
    def do_install(self, arguments):
        """install a new module"""

        repository = self.__choose_repo()

        if repository != None:
            installer = ModuleInstaller(repository)
            modules = installer.install(arguments.options, arguments.force)

            print
            print "Successfully installed %d modules, %d already installed." % (
                len(modules['success']), len(modules['existing']))
            if len(modules['fail']) > 0:
                print "Failed to install %d modules:" % len(modules['fail'])
                for module in modules['fail']:
                    print "  %s" % module
                    print "    %s" % modules['fail'][module]
            print
Ejemplo n.º 6
0
    def testItShouldNotInstallARawLocalModuleIfAlreadyPresent(self):
        fs.write("./tmp/a.local.module", "This is a local, raw module.")

        ModuleInstaller("./tmp").install(["./tmp/a.local.module"])

        assert os.path.exists("./tmp/a")
        assert os.path.exists("./tmp/a/__init__.py")
        assert os.path.exists("./tmp/a/local")
        assert os.path.exists("./tmp/a/local/__init__.py")
        assert os.path.exists("./tmp/a/local/module.py")

        assert fs.read("./tmp/a/local/module.py") == b"This is a local, raw module."

        fs.write("./tmp/a.local.module", "This is an edited local, raw module.")

        ModuleInstaller("./tmp").install(["./tmp/a.local.module"])

        assert fs.read("./tmp/a/local/module.py") != b"This is an edited local, raw module."
Ejemplo n.º 7
0
    def testItShouldOverwriteARawLocalModuleIfForceIsSet(self):

        fs.write("./tmp/a.local.module", "This is a local, raw module.")

        ModuleInstaller("./tmp").install(["./tmp/a.local.module"])

        assert os.path.exists("./tmp/a")
        assert os.path.exists("./tmp/a/__init__.py")
        assert os.path.exists("./tmp/a/local")
        assert os.path.exists("./tmp/a/local/__init__.py")
        assert os.path.exists("./tmp/a/local/module.py")

        assert fs.read("./tmp/a/local/module.py") == b"This is a local, raw module."

        fs.write("./tmp/a.local.module", "This is an edited local, raw module.")

        ModuleInstaller("./tmp").install(["./tmp/a.local.module"], True)

        assert fs.read("./tmp/a/local/module.py") == b"This is an edited local, raw module."
Ejemplo n.º 8
0
 def testItShouldInstallAnArchiveModuleFromALocalSource(self):
     ModuleInstaller("./tmp").install(["./test/mwr_test/mocks/a.local.zip"])
     
     assert os.path.exists("./tmp/a")
     assert os.path.exists("./tmp/a/__init__.py")
     assert os.path.exists("./tmp/a/local")
     assert os.path.exists("./tmp/a/local/__init__.py")
     assert os.path.exists("./tmp/a/local/module.py")
     
     assert fs.read("./tmp/a/local/module.py") == b"This is a local, archived module.\n"
Ejemplo n.º 9
0
 def testItShouldInstallARawModuleFromALocalSource(self):
     fs.write("./tmp/a.local.module", "This is a local, raw module.")
     
     ModuleInstaller("./tmp").install(["./tmp/a.local.module"])
     
     assert os.path.exists("./tmp/a")
     assert os.path.exists("./tmp/a/__init__.py")
     assert os.path.exists("./tmp/a/local")
     assert os.path.exists("./tmp/a/local/__init__.py")
     assert os.path.exists("./tmp/a/local/module.py")
     
     assert fs.read("./tmp/a/local/module.py") == b"This is a local, raw module."
Ejemplo n.º 10
0
    def __search_remotes(self, term, include_descriptions=False):
        """
        Search for modules, on remote repositories.
        """
        
        installer = ModuleInstaller(None)

        try:
            modules = installer.search_index(term)
            
            if len(modules) > 0:
                for module in modules:
                    print module
                    
                    if include_descriptions:
                        if module.description != None:
                            print "%s\n" % text.indent(text.wrap(module.description, console.get_size()[0] - 4), "    ")
                        else:
                            print text.indent("No description given.\n", "    ")
                print
            else:
                print "No modules found.\n"
        except NetworkException:
            print "There was a problem accessing one-or-more of the remote repositories.\n\nMake sure that you have a working network connection.\n"