Exemplo n.º 1
0
Arquivo: cli.py Projeto: k0lter/pwman3
    def get_tags(self, default=None):
        defaultstr = ""

        if default:
            for t in default:
                defaultstr += "%s " % (t)
        else:
            tags = self._db.currenttags()
            for t in tags:
                defaultstr += "%s " % (t)

        strings = []
        tags = self._db.listtags(True)
        for t in tags:
            # strings.append(t.get_name())
            strings.append(t)

        def complete(text, state):
            count = 0
            for s in strings:
                if s.startswith(text):
                    if count == state:
                        return s
                    else:
                        count += 1

        taglist = tools.getinput("Tags: ", defaultstr, complete)
        tagstrings = taglist.split()
        tags = []
        for tn in tagstrings:
            _Tag = Tag(tn)
            tags.append(_Tag)
        return tags
Exemplo n.º 2
0
    def get_tags(self, default=None, reader=raw_input):
        """read tags from user"""
        defaultstr = ''
        if default:
            for t in default:
                defaultstr += "%s " % (t)
        else:
            # tags = self._db.currenttags()
            tags = self._db._filtertags
            for t in tags:
                defaultstr += "%s " % (t)

        # strings = []
        tags = self._db.listtags(True)
        # for t in tags:
        #    strings.append(t.get_name())
        #    strings.append(t)

        strings = [t for t in tags]

        def complete(text, state):
            count = 0
            for s in strings:
                if s.startswith(text):
                    if count == state:
                        return s
                    else:
                        count += 1

        taglist = tools.getinput("Tags: ", defaultstr, completer=complete,
                                 reader=reader)
        tagstrings = taglist.split()
        tags = [TagNew(tn) for tn in tagstrings]

        return tags
Exemplo n.º 3
0
Arquivo: cli.py Projeto: k0lter/pwman3
    def do_export(self, arg):
        try:
            nodes = self.get_ids(arg)

            types = exporter.Exporter.types()
            ftype = tools.select("Select filetype:", types)
            exp = exporter.Exporter.get(ftype)
            out_file = tools.getinput("Select output file:")
            if len(nodes) > 0:
                b = tools.getyesno("Export nodes %s?" % (nodes), True)
                if not b:
                    return
                exp.export_data(self._db, out_file, nodes)
            else:
                nodes = self._db.listnodes()
                tags = self._db.currenttags()
                tagstr = ""
                if len(tags) > 0:
                    tagstr = " for "
                    for t in tags:
                        tagstr += "'%s' " % (t.get_name())
                b = tools.getyesno("Export all nodes%s?" % (tagstr), True)
                if not b:
                    return
                exp.export_data(self._db, out_file, nodes)
            print "Data exported."
        except Exception, e:
            self.error(e)
Exemplo n.º 4
0
 def do_delete(self, args):
     ids = self._get_ids(args)
     ans = tools.getinput("Are you sure you want to delete node{} {}"
                          " [y/N]?".format("s" if len(ids) > 1 else "",
                                           ",".join(ids) if len(ids) > 1 else ids[0]))  # noqa
     if ans.lower() == 'y':
         self._do_rm(args)
Exemplo n.º 5
0
    def _do_rm(self, args):
        for i in args.split():
            if not i.isdigit():
                print("%s is not a node ID" % i)
                return None

        for i in args.split():
            ans = tools.getinput(("Are you sure you want to delete node {}"
                                  " [y/N]?".format(i)))
            if ans.lower() == 'y':
                self._db.removenodes([i])
Exemplo n.º 6
0
Arquivo: cli.py Projeto: k0lter/pwman3
    def get_password(self, argsgiven, numerics=False, leetify=False, symbols=False, special_signs=False):
        """
        in the config file:
        numerics -> numerics
        leetify -> symbols
        special_chars -> special_signs
        """
        if argsgiven == 1:
            length = tools.getinput("Password length (default 7): ", "7")
            length = int(length)
            password, dumpme = generator.generate_password(length, length, True, leetify, numerics, special_signs)
            print "New password: %s" % (password)
            return password
        # no args given
        password = tools.getpassword("Password (Blank to generate): ", tools._defaultwidth, False)
        if len(password) == 0:
            length = tools.getinput("Password length (default 7): ", "7")
            length = int(length)

            (password, dumpme) = generator.generate_password(length, length, True, leetify, numerics, special_signs)
            print "New password: %s" % (password)
        return password
Exemplo n.º 7
0
    def do_delete(self, args):

        ce = CryptoEngine.get()
        ce.encrypt("")

        ids = self._get_ids(args)
        if not ids:
            return
        ans = tools.getinput("Are you sure you want to delete node{} {}"
                             " [y/N]?".format("s" if len(ids) > 1 else "",
                                              ",".join(ids) if len(ids) > 1 else ids[0]))  # noqa
        if ans.lower() == 'y':
            self._do_rm(ids)
Exemplo n.º 8
0
    def do_delete(self, args):

        ce = CryptoEngine.get()
        ce.encrypt("")

        ids = self._get_ids(args)
        if not ids:
            return
        ans = tools.getinput("Are you sure you want to delete node{} {}"
                             " [y/N]?".format("s" if len(ids) > 1 else "",
                                              ",".join(ids) if len(ids) > 1 else ids[0]))  # noqa
        if ans.lower() == 'y':
            self._do_rm(ids)
Exemplo n.º 9
0
 def do_delete(self, arg):
     ids = self.get_ids(arg)
     try:
         nodes = self._db.getnodes(ids)
         for n in nodes:
             ans = ''
             while True:
                 ans = tools.getinput(("Are you sure you want to"
                                      " delete '%s@%s' ([y/N])?"
                                       ) % (n.username, n.url)).lower().strip('\n')
                 if ans == '' or ans == 'y' or ans == 'n':
                     break
         if ans == 'y':
             self._db.removenodes([n])
             print ("%s@%s deleted" % (n.username, n.url))
     except Exception as e:
         self.error(e)
Exemplo n.º 10
0
Arquivo: cli.py Projeto: k0lter/pwman3
 def do_import(self, arg):
     try:
         args = arg.split()
         if len(args) == 0:
             types = importer.Importer.types()
             intype = tools.select("Select filetype:", types)
             imp = importer.Importer.get(intype)
             infile = tools.getinput("Select file:")
             imp.import_data(self._db, infile)
         else:
             for i in args:
                 types = importer.Importer.types()
                 intype = tools.select("Select filetype:", types)
                 imp = importer.Importer.get(intype)
                 imp.import_data(self._db, i)
     except Exception, e:
         self.error(e)
Exemplo n.º 11
0
Arquivo: cli.py Projeto: k0lter/pwman3
 def get_filesystem_path(self, default=""):
     return tools.getinput("Enter filename: ", default)
Exemplo n.º 12
0
Arquivo: cli.py Projeto: k0lter/pwman3
 def get_url(self, default=""):
     return tools.getinput("Url: ", default)
Exemplo n.º 13
0
 def get_notes(self, default="", reader=raw_input):
     return tools.getinput("Notes: ", default, reader)
Exemplo n.º 14
0
 def get_url(self, default="", reader=raw_input):
     return tools.getinput("Url: ", default, reader)
Exemplo n.º 15
0
 def get_username(self, default="", reader=raw_input):
     return tools.getinput("Username: ", default, reader)
Exemplo n.º 16
0
Arquivo: cli.py Projeto: k0lter/pwman3
 def get_notes(self, default=""):
     return tools.getinput("Notes: ", default)
Exemplo n.º 17
0
Arquivo: cli.py Projeto: k0lter/pwman3
 def get_username(self, default=""):
     return tools.getinput("Username: ", default)