Esempio n. 1
0
    def do_enable(self, arguments):
        """enable a previously disabled Module repository"""

        if len(arguments.options) == 1:
            path = arguments.options[0]

            try:
                Repository.enable(path)

                print "Enabled repository at %s.\n" % path
            except UnknownRepository:
                print "The target (%s) is not a drozer module repository.\n" % path
        else:
            print "usage: drozer module repository enable /path/to/repository\n"
Esempio n. 2
0
    def do_delete(self, arguments):
        """remove a drozer module repository"""

        if len(arguments.options) == 1:
            path = arguments.options[0]

            try:
                Repository.delete(path)

                print "Removed repository at %s.\n" % path
            except UnknownRepository:
                print "The target (%s) is not a drozer module repository.\n" % path
        else:
            print "usage: drozer module repository delete /path/to/repository\n"
Esempio n. 3
0
    def do_disable(self, arguments):
        """hide a Module repository, without deleting its contents"""

        if len(arguments.options) == 1:
            path = arguments.options[0]

            try:
                Repository.disable(path)

                print "Hidden repository at %s.\n" % path
            except UnknownRepository:
                print "The target (%s) is not a drozer module repository.\n" % path
        else:
            print "usage: drozer module repository disable /path/to/repository\n"
Esempio n. 4
0
 def do_enable(self, arguments):
     """enable a previously disabled Module repository"""
     
     if len(arguments.options) == 1:
         path = arguments.options[0]
         
         try:
             Repository.enable(path)
             
             print "Enabled repository at %s.\n" % path
         except UnknownRepository:
             print "The target (%s) is not a drozer module repository.\n" % path
     else:
         print "usage: drozer module repository enable /path/to/repository\n"
Esempio n. 5
0
    def do_create(self, arguments):
        """create a new drozer module repository"""

        if len(arguments.options) == 1:
            path = arguments.options[0]

            try:
                Repository.create(path)

                print "Initialised repository at %s.\n" % path
            except NotEmptyException:
                print "The target (%s) already exists.\n" % path
        else:
            print "usage: drozer module repository create /path/to/repository\n"
Esempio n. 6
0
 def do_disable(self, arguments):
     """hide a Module repository, without deleting its contents"""
     
     if len(arguments.options) == 1:
         path = arguments.options[0]
         
         try:
             Repository.disable(path)
             
             print "Hidden repository at %s.\n" % path
         except UnknownRepository:
             print "The target (%s) is not a drozer module repository.\n" % path
     else:
         print "usage: drozer module repository disable /path/to/repository\n"
Esempio n. 7
0
 def do_delete(self, arguments):
     """remove a drozer module repository"""
     
     if len(arguments.options) == 1:
         path = arguments.options[0]
         
         try:
             Repository.delete(path)
             
             print "Removed repository at %s.\n" % path
         except UnknownRepository:
             print "The target (%s) is not a drozer module repository.\n" % path
     else:
         print "usage: drozer module repository delete /path/to/repository\n"
Esempio n. 8
0
 def do_create(self, arguments):
     """create a new drozer module repository"""
     
     if len(arguments.options) == 1:
         path = arguments.options[0]
         
         try:
             Repository.create(path)
             
             print "Initialised repository at %s.\n" % path
         except NotEmptyException:
             print "The target (%s) already exists.\n" % path
     else:
         print "usage: drozer module repository create /path/to/repository\n"
Esempio n. 9
0
    def __choose_repo(self):
        """
        Return the path of a repository, either the only repo or presenting the user
        with a choice.
        """

        repositories = Repository.all()

        if len(repositories) == 1:
            return repositories[0]
        elif len(repositories) == 0:
            print "You do not have a drozer Module Repository."
            if self.confirm("Would you like to create one?") == "y":
                while True:
                    path = self.ask("Path to new repository: ")

                    try:
                        Repository.create(path)

                        print "Initialised repository at %s.\n" % path

                        return Repository.all()[0]
                    except NotEmptyException:
                        print "The target (%s) already exists.\n" % path

                return None
            else:
                return None
        else:
            print "You have %d drozer Module Repositories. Which would you like to install into?\n" % len(
                repositories)
            for i in xrange(len(repositories)):
                print "  %5d  %s" % (i + 1, repositories[i])
            print

            while (True):
                print "repo>",
                try:
                    idx = int(raw_input().strip())

                    if idx >= 1 and idx <= len(repositories):
                        print

                        return repositories[idx - 1]
                    else:
                        raise ValueError(idx)
                except ValueError:
                    print "Not a valid selection. Please enter a number between 1 and %d." % len(
                        repositories)
Esempio n. 10
0
 def __choose_repo(self):
     """
     Return the path of a repository, either the only repo or presenting the user
     with a choice.
     """
     
     repositories = Repository.all()
     
     if len(repositories) == 1:
         return repositories[0]
     elif len(repositories) == 0:
         print "You do not have a drozer Module Repository."
         if self.confirm("Would you like to create one?") == "y":
             while True:
                 path = self.ask("Path to new repository: ")
                 
                 try:
                     Repository.create(path)
                     
                     print "Initialised repository at %s.\n" % path
                     
                     return Repository.all()[0]
                 except NotEmptyException:
                     print "The target (%s) already exists.\n" % path
             
             return None
         else:
             return None
     else:
         print "You have %d drozer Module Repositories. Which would you like to install into?\n" % len(repositories)
         for i in xrange(len(repositories)):
             print "  %5d  %s" % (i+1, repositories[i])
         print
         
         while(True):
             print "repo>",
             try:
                 idx = int(raw_input().strip())
             
                 if idx >= 1 and idx <= len(repositories):
                     print
                     
                     return repositories[idx-1]
                 else:
                     raise ValueError(idx)
             except ValueError:
                 print "Not a valid selection. Please enter a number between 1 and %d." % len(repositories)
Esempio n. 11
0
    def __list_repositories(self):
        """
        Print a list of drozer Repositories (a) on the local system, and
        (b) registered as remotes.
        """

        print "Local repositories:"
        for repo in Repository.all():
            print "  %s" % repo
        print
Esempio n. 12
0
 def __list_repositories(self):
     """
     Print a list of drozer Repositories (a) on the local system, and
     (b) registered as remotes.
     """
     
     print "Local repositories:"
     for repo in Repository.all():
         print "  %s" % repo
     print
Esempio n. 13
0
 def setUp(self):
     Configuration._Configuration__config = configparser.SafeConfigParser()
     
     shutil.rmtree("./tmp", True)
     
     Repository.create("./tmp")