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