Example #1
0
    def do_edit(self, arg, menu=None):
        ids = self.get_ids(arg)
        for i in ids:
            try:
                i = int(i)
                node = self._db.getnodes([i])[0]
                if not menu:
                    menu = CMDLoop()
                    print ("Editing node %d." % (i))

                    menu.add(CliMenuItem("Username", self.get_username,
                                         node.username,
                                         node.username))
                    menu.add(CliMenuItem("Password", self.get_password,
                                         node.password,
                                         node.password))
                    menu.add(CliMenuItem("Url", self.get_url,
                                         node.url,
                                         node.url))
                    menunotes = CliMenuItem("Notes", self.get_notes,
                                            node.notes,
                                            node.notes)
                    menu.add(menunotes)
                    menu.add(CliMenuItem("Tags", self.get_tags,
                                         node.tags,
                                         node.tags))
                menu.run(node)
                self._db.editnode(i, node)
                # when done with node erase it
                zerome(node._password)
            except Exception as e:
                self.error(e)
Example #2
0
 def do_print(self, arg):
     for i in self.get_ids(arg):
         try:
             node = self._db.getnodes([i])
             self.print_node(node[0])
             # when done with node erase it
             zerome(node[0]._password)
         except Exception as e:
             self.error(e)
Example #3
0
 def do_new(self, args):
     """
     can override default config settings the following way:
     Pwman3 0.2.1 (c) visit: http://github.com/pwman3/pwman3
     pwman> n {'leetify':False, 'numerics':True, 'special_chars':True}
     Password (Blank to generate):
     """
     errmsg = """could not parse config override, please input some"""\
              + """ kind of dictionary, e.g.: n {'leetify':False, """\
              + """'numerics':True, 'special_chars':True}"""
     try:
         username = self.get_username()
         if args:
             try:
                 args = ast.literal_eval(args)
             except Exception:
                 raise Exception(errmsg)
             if not isinstance(args, dict):
                 raise Exception(errmsg)
             password = self.get_password(1, **args)
         else:
             numerics = config.get_value(
                 "Generator", "numerics").lower() == 'true'
             # TODO: allow custom leetifying through the config
             leetify = config.get_value(
                 "Generator", "leetify").lower() == 'true'
             special_chars = config.get_value(
                 "Generator", "special_chars").lower() == 'true'
             password = self.get_password(0,
                                          numerics=numerics,
                                          symbols=leetify,
                                          special_signs=special_chars)
         url = self.get_url()
         notes = self.get_notes()
         node = NewNode()
         node.username = username
         node.password = password
         node.url = url
         node.notes = notes
         tags = self.get_tags()
         node.tags = tags
         self._db.addnodes([node])
         print("Password ID: %d" % (node._id))
         # when done with node erase it
         zerome(password)
     except Exception as e:
         self.error(e)
Example #4
0
File: cli.py Project: k0lter/pwman3
 def do_edit(self, arg):
     ids = self.get_ids(arg)
     for i in ids:
         try:
             i = int(i)
             node = self._db.getnodes([i])[0]
             menu = CliMenu()
             print "Editing node %d." % (i)
             menu.add(CliMenuItem("Username", self.get_username, node.get_username, node.set_username))
             menu.add(CliMenuItem("Password", self.get_password, node.get_password, node.set_password))
             menu.add(CliMenuItem("Url", self.get_url, node.get_url, node.set_url))
             menu.add(CliMenuItem("Notes", self.get_notes, node.get_notes, node.set_notes))
             menu.add(CliMenuItem("Tags", self.get_tags, node.get_tags, node.set_tags))
             menu.run()
             self._db.editnode(i, node)
             # when done with node erase it
             zerome(node._password)
         except Exception, e:
             self.error(e)
Example #5
0
 def do_new(self, args):
     """
     can override default config settings the following way:
     Pwman3 0.2.1 (c) visit: http://github.com/pwman3/pwman3
     pwman> n {'leetify':False, 'numerics':True, 'special_chars':True}
     Password (Blank to generate):
     """
     errmsg = ("could not parse config override, please input some"
               " kind of dictionary, e.g.: n {'leetify':False, "
               " numerics':True, 'special_chars':True}")
     try:
         username = self.get_username()
         if args:
             try:
                 args = ast.literal_eval(args)
             except Exception:
                 raise Exception(errmsg)
             if not isinstance(args, dict):
                 raise Exception(errmsg)
             password = self.get_password(argsgiven=1, **args)
         else:
             numerics, leet, s_chars = get_pass_conf()
             password = self.get_password(argsgiven=0,
                                          numerics=numerics,
                                          leetify=leet,
                                          special_signs=s_chars)
         url = self.get_url()
         notes = self.get_notes()
         node = NewNode()
         node.username = username
         node.password = password
         node.url = url
         node.notes = notes
         # node = NewNode(username, password, url, notes)
         node.tags = self.get_tags()
         self._db.addnodes([node])
         print ("Password ID: %d" % (node._id))
         # when done with node erase it
         zerome(password)
     except Exception as e:
         self.error(e)