rt3x.de NoPaste

Testing pickledb for mfingerd

This is a nopaste service, powered by Flying Paste.

Author: Malte Bublitz
Language/File type: Python Console Session

Description

Some tests with pickledb to use it as a storage backend of mfingerd

Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Python 2.7.17 (default, Sep 30 2020, 13:38:04) 
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickledb
>>> pickledb.get("ip")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'get'
>>> db = pickledb.load("fingerinfo.db", False)
>>> db.get("ip")
u'%%IP%%'
>>> UserInfo = {
... "malte70": """Full name: Malte Bublitz
... Twitter: @malte70
... EMail:   malte@rolltreppe3.de
... Web:     https://malte70.de
... Work:    https://rolltreppe3.de
... GnuPG:   B214 8955 F6A6 6A8B 8FA3  F59B 605D A5C7 29F9 C184""",
... "myip": """Your IP: %%IP%%
... Your Hostname: %%FQDN%%""",
... "bofh": "%%BOFH%%"
... }
>>> UserInfo.keys()
['malte70', 'bofh', 'myip']
>>> for k in UserInfo.keys():
...     print (k, UserInfo[k])
... 
('malte70', 'Full name: Malte Bublitz\nTwitter: @malte70\nEMail:   malte@rolltreppe3.de\nWeb:     https://malte70.de\nWork:    https://rolltreppe3.de\nGnuPG:   B214 8955 F6A6 6A8B 8FA3  F59B 605D A5C7 29F9 C184')
('bofh', '%%BOFH%%')
('myip', 'Your IP: %%IP%%\nYour Hostname: %%FQDN%%')
>>> for k in UserInfo.keys():
...     db.set(k, UserInfo[k])
... 
True
True
True
>>> db.get("bofh")
'%%BOFH%%'
>>> db.exists("bofh")
True
>>> db.exists("bofh_")
False
>>>