PEP8 Fixes
This commit is contained in:
parent
23d2adba3c
commit
829fb05801
11
barbican.py
11
barbican.py
@ -33,7 +33,7 @@ admin.add_view(ModelView(Tenant, db_session))
|
|||||||
admin.add_view(ModelView(Key, db_session))
|
admin.add_view(ModelView(Key, db_session))
|
||||||
admin.add_view(ModelView(Policy, db_session))
|
admin.add_view(ModelView(Policy, db_session))
|
||||||
admin.add_view(ModelView(Event, db_session))
|
admin.add_view(ModelView(Event, db_session))
|
||||||
admin.add_view(ModelView(Agent,db_session))
|
admin.add_view(ModelView(Agent, db_session))
|
||||||
admin.add_view(ModelView(Tag, db_session))
|
admin.add_view(ModelView(Tag, db_session))
|
||||||
|
|
||||||
login_manager = login.LoginManager()
|
login_manager = login.LoginManager()
|
||||||
@ -46,11 +46,13 @@ login_manager.login_view = 'login'
|
|||||||
def hello():
|
def hello():
|
||||||
return render_template("index.html")
|
return render_template("index.html")
|
||||||
|
|
||||||
|
|
||||||
@app.route("/events")
|
@app.route("/events")
|
||||||
@login.login_required
|
@login.login_required
|
||||||
def events():
|
def events():
|
||||||
return render_template("events.html")
|
return render_template("events.html")
|
||||||
|
|
||||||
|
|
||||||
@app.route("/agents", methods=["GET", "POST"])
|
@app.route("/agents", methods=["GET", "POST"])
|
||||||
@login.login_required
|
@login.login_required
|
||||||
def agents():
|
def agents():
|
||||||
@ -58,14 +60,14 @@ def agents():
|
|||||||
# need to update all agents since it is possible to disable pairing for them all
|
# need to update all agents since it is possible to disable pairing for them all
|
||||||
all_data = request.form
|
all_data = request.form
|
||||||
length = int(all_data["example_length"])
|
length = int(all_data["example_length"])
|
||||||
ids=[]
|
ids = []
|
||||||
for k in all_data:
|
for k in all_data:
|
||||||
m = re.match('check(\d+)', k)
|
m = re.match('check(\d+)', k)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
id = m.group(1)
|
id = m.group(1)
|
||||||
ids.append(int(id))
|
ids.append(int(id))
|
||||||
min_id = min(ids)/length * length +1
|
min_id = min(ids) / length * length + 1
|
||||||
id_range = range(min_id, min_id+length)
|
id_range = range(min_id, min_id + length)
|
||||||
agents = Agent.query.order_by(Agent.id)
|
agents = Agent.query.order_by(Agent.id)
|
||||||
for agent in agents.all():
|
for agent in agents.all():
|
||||||
if agent.id not in id_range:
|
if agent.id not in id_range:
|
||||||
@ -82,6 +84,7 @@ def agents():
|
|||||||
else:
|
else:
|
||||||
return render_template("agents.html")
|
return render_template("agents.html")
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Login forms
|
# Login forms
|
||||||
#
|
#
|
||||||
|
@ -26,6 +26,7 @@ api = Blueprint('api', __name__, url_prefix="/api")
|
|||||||
def root():
|
def root():
|
||||||
return jsonify(hello='World')
|
return jsonify(hello='World')
|
||||||
|
|
||||||
|
|
||||||
@api.route('/<int:tenant_id>/', methods=['GET', 'POST'])
|
@api.route('/<int:tenant_id>/', methods=['GET', 'POST'])
|
||||||
def tenant(tenant_id):
|
def tenant(tenant_id):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
@ -37,8 +38,6 @@ def tenant(tenant_id):
|
|||||||
return jsonify(tenant.as_dict()), 201
|
return jsonify(tenant.as_dict()), 201
|
||||||
else:
|
else:
|
||||||
return jsonify(tenant.as_dict())
|
return jsonify(tenant.as_dict())
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
tenant = Tenant.query.filter_by(id=tenant_id).first()
|
tenant = Tenant.query.filter_by(id=tenant_id).first()
|
||||||
if tenant is None:
|
if tenant is None:
|
||||||
@ -46,6 +45,7 @@ def tenant(tenant_id):
|
|||||||
else:
|
else:
|
||||||
return jsonify(tenant.as_dict())
|
return jsonify(tenant.as_dict())
|
||||||
|
|
||||||
|
|
||||||
@api.route('/<int:tenant_id>/policies/', methods=['GET', 'POST'])
|
@api.route('/<int:tenant_id>/policies/', methods=['GET', 'POST'])
|
||||||
def policies(tenant_id):
|
def policies(tenant_id):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
@ -96,7 +96,6 @@ def agents(tenant_id):
|
|||||||
return Response(json.dumps(agents_dicts, cls=DateTimeJsonEncoder), mimetype='application/json')
|
return Response(json.dumps(agents_dicts, cls=DateTimeJsonEncoder), mimetype='application/json')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@api.route('/<int:tenant_id>/logs/', methods=['GET', 'POST'])
|
@api.route('/<int:tenant_id>/logs/', methods=['GET', 'POST'])
|
||||||
def logs(tenant_id):
|
def logs(tenant_id):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
@ -124,6 +123,7 @@ def logs(tenant_id):
|
|||||||
events_dicts = map(Event.as_dict, events.all())
|
events_dicts = map(Event.as_dict, events.all())
|
||||||
return Response(json.dumps(events_dicts, cls=DateTimeJsonEncoder), mimetype='application/json')
|
return Response(json.dumps(events_dicts, cls=DateTimeJsonEncoder), mimetype='application/json')
|
||||||
|
|
||||||
|
|
||||||
@api.route('/alllogs/', methods=['GET'])
|
@api.route('/alllogs/', methods=['GET'])
|
||||||
def alllogs(timestamp=None):
|
def alllogs(timestamp=None):
|
||||||
events = Event.query.order_by(Event.received_on)
|
events = Event.query.order_by(Event.received_on)
|
||||||
@ -138,6 +138,7 @@ def alllogs(timestamp=None):
|
|||||||
}'''
|
}'''
|
||||||
return Response(json_str, mimetype='application/json')
|
return Response(json_str, mimetype='application/json')
|
||||||
|
|
||||||
|
|
||||||
@api.route('/allagents/', methods=['GET'])
|
@api.route('/allagents/', methods=['GET'])
|
||||||
def allagents(timestamp=None):
|
def allagents(timestamp=None):
|
||||||
agents = Agent.query.order_by(Agent.id)
|
agents = Agent.query.order_by(Agent.id)
|
||||||
|
@ -141,7 +141,6 @@ class Agent(Base):
|
|||||||
self.hostname = hostname
|
self.hostname = hostname
|
||||||
self.os_version = os_version
|
self.os_version = os_version
|
||||||
self.agent_version = agent_version
|
self.agent_version = agent_version
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<Agent %s>' % self.uuid
|
return '<Agent %s>' % self.uuid
|
||||||
|
Loading…
x
Reference in New Issue
Block a user