Skip to content

Adding audit-search.py to the utilities directory.#1117

Open
Eising wants to merge 3 commits intoSpriteLink:masterfrom
Eising:master
Open

Adding audit-search.py to the utilities directory.#1117
Eising wants to merge 3 commits intoSpriteLink:masterfrom
Eising:master

Conversation

@Eising
Copy link
Copy Markdown

@Eising Eising commented Dec 19, 2016

I've written a little script to work with the audit log. It's nothing fancy or anything, but it works.

The audit-search.py allows you to search through the audit log to see each change performed.

audit-search.py allows you to search through the audit log to see each change.
Comment thread utilities/audit-search.py
a = AuditLog()

if len(sys.argv) == 1:
print "Use with prefix to search in audit log"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SyntaxError: invalid syntax

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to use py3 syntax so that print would be print(). If you still want to use py2 then you can do from __future__ import print_function to just get the new print function.

Comment thread utilities/audit-search.py



a = AuditLog()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many blank lines (3)

Comment thread utilities/audit-search.py
return output


def search_log_prefix(self, prefix):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many blank lines (2)

Comment thread utilities/audit-search.py Outdated
parsed = eval(dataset)
output += "New data:\n"
for k,v in parsed.items():
output += "{:<16}{:<20}: {:<32}\n".format("",k, v)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing whitespace after ','

Comment thread utilities/audit-search.py Outdated
output += "{:<15} {}\n".format("Description:", description)
parsed = eval(dataset)
output += "New data:\n"
for k,v in parsed.items():
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing whitespace after ','

Comment thread utilities/audit-search.py Outdated
raise
output = "{:<15} {}\n".format("Log id", data['id'])
output += "{:<15} {}\n".format("Author:", data['username'])
output += "{:<15} {}\n".format("Date:", data['timestamp'].strftime('%c'))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (81 > 79 characters)

Comment thread utilities/audit-search.py
return _ext.INET


def _format_log_prefix(self, data):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many blank lines (2)

Comment thread utilities/audit-search.py Outdated
if not oid:
oid = 869
_ext.INET = _ext.new_type((oid, ), "INET",
lambda data, cursor: data and Inet(data) or None)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuation line under-indented for visual indent

Comment thread utilities/audit-search.py
break


def _register_inet(self, oid=None, conn_or_curs=None):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many blank lines (2)

Comment thread utilities/audit-search.py Outdated
self._con_pg = psycopg2.connect(**db_args)
self._curs_pg = self._con_pg.cursor(cursor_factory=psycopg2.extras.DictCursor)
self._register_inet()
psycopg2.extras.register_hstore(self._con_pg, globally=True, unicode=True)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (90 > 79 characters)

Comment thread utilities/audit-search.py Outdated
while True:
try:
self._con_pg = psycopg2.connect(**db_args)
self._curs_pg = self._con_pg.cursor(cursor_factory=psycopg2.extras.DictCursor)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (94 > 79 characters)

Comment thread utilities/audit-search.py



def _connect_db(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many blank lines (3)

Comment thread utilities/audit-search.py



def _get_afi(self, ip):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many blank lines (3)

Comment thread utilities/audit-search.py



def _is_ipv6(self, ip):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many blank lines (3)

Comment thread utilities/audit-search.py
self._connect_db()


def _is_ipv4(self, ip):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many blank lines (2)

Comment thread utilities/audit-search.py
import datetime
import sys

class AuditLog:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected 2 blank lines, found 1

Comment thread utilities/audit-search.py

return output

a = AuditLog()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected 2 blank lines after class or function definition, found 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants