Skip to content
Snippets Groups Projects
Commit 95b418a3 authored by Pavel Kácha's avatar Pavel Kácha
Browse files

Syntax compatibility with Python 3 (thx to Radko Krkos)

parent 35826c86
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@ from os import path
from operator import itemgetter
from sys import version_info
fix_logging_filename = str if version_info<(2, 7) else lambda(x): x
fix_logging_filename = str if version_info<(2, 7) else lambda x: x
VERSION = "3.0-beta2"
......
......@@ -106,7 +106,7 @@ def gen_random_idea(client_name="cz.example.warden.test"):
"Size": 46,
"Ref": ["cve:CVE-%s-%s" % (randstr(string.digits, 4), randstr())],
"ContentEncoding": "base64",
"Content": b64encode(randstr())
"Content": b64encode(randstr(maxlen=128*1024))
}
],
"Node": [
......@@ -139,7 +139,7 @@ def main():
# idstore="MyClient.id",
# name="cz.example.warden.test")
print "=== Debug ==="
print("=== Debug ===")
info = wclient.getDebug()
pprint(info)
......@@ -150,18 +150,18 @@ def main():
# If you want just to be informed, this is not necessary, just
# configure logging correctly and check logs.
if isinstance(info, Error):
print info
print(info)
print "=== Server info ==="
print("=== Server info ===")
info = wclient.getInfo()
print "=== Sending 10 event(s) ==="
print("=== Sending 10 event(s) ===")
start = time()
ret = wclient.sendEvents([gen_random_idea(client_name=wclient.name) for i in range(10)])
print ret
print "Time: %f" % (time()-start)
print(ret)
print("Time: %f" % (time()-start))
print "=== Getting 10 events ==="
print("=== Getting 10 events ===")
start = time()
# cat = ['Availability', 'Abusive.Spam','Attempt.Login']
......@@ -181,11 +181,12 @@ def main():
group = []
nogroup = []
ret = wclient.getEvents(count=0, id=0, cat=cat, nocat=nocat, tag=tag, notag=notag, group=group, nogroup=nogroup)
ret = wclient.getEvents(count=10, cat=cat, nocat=nocat, tag=tag, notag=notag, group=group, nogroup=nogroup)
print "Time: %f" % (time()-start)
print "Got %i events" % len(ret)
print("Time: %f" % (time()-start))
print("Got %i events" % len(ret))
for e in ret:
print e.get("Category"), e.get("Node")[0].get("Type"), e.get("Node")[0].get("Name")
print(e.get("Category"), e.get("Node")[0].get("Type"), e.get("Node")[0].get("Name"))
if __name__ == "__main__":
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment