コード例 #1
0
ファイル: sqlite.py プロジェクト: k0lter/pwman3
 def getnodes(self, ids):
     """
     object should always be: (ipwman.data.nodes
     """
     nodes = []
     for i in ids:
             sql = "SELECT DATA FROM NODES WHERE ID = ?"
             self._cur.execute(sql, [i])
             row = self._cur.fetchone()
             if row is not None:
                 nodestring = str(row[0])
                 nodeargs, tags = self.parse_node_string(nodestring)
                 node = NewNode(**nodeargs)
                 node.set_tags(tags)
                 node.set_id(i)
                 nodes.append(node)
     return nodes
コード例 #2
0
ファイル: win.py プロジェクト: k0lter/pwman3
 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(username, password, url, notes)
         tags = self.get_tags()
         node.set_tags(tags)
         self._db.addnodes([node])
         print "Password ID: %d" % (node.get_id())
         # when done with node erase it
         zerome(password)
     except Exception, e:
         self.error(e)