-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
289 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
__pycache__ | ||
passhportd/config.pyc | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# -*-coding:Utf-8 -*- | ||
|
||
# Compatibility 2.7-3.4 | ||
from __future__ import absolute_import | ||
from __future__ import unicode_literals | ||
|
||
from app import app, db | ||
from app.models_mod import target,usergroup,targetgroup,user | ||
|
||
class Logentry(db.Model): | ||
"""Logentry store connexion history for furture reference""" | ||
__tablename__ = "logentry" | ||
id = db.Column(db.Integer, primary_key=True) | ||
connexiondate = db.Column(db.String(20), index=True, nullable=False) | ||
connexioncmd = db.Column(db.String(200), index=True, nullable=False) | ||
logfilepath = db.Column(db.String(200)) # Empty if archived or logrotated | ||
logfilename = db.Column(db.String(200), nullable=False) | ||
|
||
# Relations | ||
target = db.relationship("Target", secondary="target_log") | ||
user = db.relationship("User", secondary="user_log") | ||
|
||
def __repr__(self): | ||
"""Return main data of the Log entry as a string""" | ||
output = [] | ||
|
||
output.append("Date : {}".format(self.connexiondate)) | ||
output.append("Command: {}".format(self.connexioncmd)) | ||
output.append("Logfile:" + self.logfilepath + self.logfilename) | ||
output.append("User : {}".format(self.user[0].show_name())) | ||
output.append("Target : {}".format(self.target[0].show_name())) | ||
return "\n".join(output) | ||
|
||
|
||
def simplejson(self): | ||
"""Return a json of logentry infos""" | ||
output = "{" | ||
output = output + "\"Date\": \"" + format(self.connexiondate) + "\",\n" | ||
output = output + "\"Command\": \"" + \ | ||
format(self.connexioncmd) + "\",\n" | ||
output = output + "\"Logfile\": \"" + self.logfilepath + \ | ||
self.logfilename + "\",\n" | ||
output = output + "\"User\": \"" + format(self.user[0].show_name()) + "\",\n" | ||
output = output + "\"Target\": \"" + format(self.target[0].show_name()) + "\"" | ||
output = output + "}" | ||
|
||
return output | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import logentry |
Oops, something went wrong.