Release WiFiTrip format v2.0.0
This commit is contained in:
+100
-33
@@ -58,8 +58,10 @@ from reports.hashcat import (
|
||||
)
|
||||
from reports.trips_page import render_trips_page
|
||||
from reports.wifitrip import (
|
||||
WifitripError,
|
||||
export_wifitrip,
|
||||
import_wifitrip,
|
||||
select_wifitrip_session_ids,
|
||||
validate_wifitrip,
|
||||
)
|
||||
from reports.session_page import render_session_page
|
||||
@@ -2039,7 +2041,8 @@ def reports_dashboard():
|
||||
def reports_capture_sessions():
|
||||
|
||||
return render_report(
|
||||
generate_capture_sessions
|
||||
generate_capture_sessions,
|
||||
sessions_page_limit=request.args.get("limit"),
|
||||
)
|
||||
|
||||
@app.route("/reports/trips/")
|
||||
@@ -2050,50 +2053,114 @@ def reports_trips():
|
||||
)
|
||||
|
||||
|
||||
@app.route("/reports/trips/export")
|
||||
def reports_trips_export():
|
||||
|
||||
filename = (
|
||||
"wifi-gps-mapper-"
|
||||
f"{datetime.now(timezone.utc).strftime('%Y%m%d-%H%M%S')}.wifitrip"
|
||||
)
|
||||
|
||||
temp_file = tempfile.NamedTemporaryFile(
|
||||
prefix="wifitrip-",
|
||||
suffix=".tmp",
|
||||
delete=False,
|
||||
)
|
||||
|
||||
temp_path = Path(
|
||||
temp_file.name
|
||||
)
|
||||
|
||||
temp_file.close()
|
||||
|
||||
output_path = (
|
||||
temp_path.with_name(
|
||||
filename
|
||||
)
|
||||
)
|
||||
|
||||
temp_path.unlink(
|
||||
missing_ok=True
|
||||
)
|
||||
@app.route("/reports/trips/preview")
|
||||
def reports_trips_preview():
|
||||
|
||||
conn = connect_database()
|
||||
|
||||
try:
|
||||
session_ids = select_wifitrip_session_ids(
|
||||
conn,
|
||||
mode=request.args.get("mode", "all"),
|
||||
limit=request.args.get("limit", "1"),
|
||||
date_from=request.args.get("date_from"),
|
||||
date_to=request.args.get("date_to"),
|
||||
)
|
||||
|
||||
available_count = conn.execute(
|
||||
"SELECT COUNT(*) FROM capture_sessions"
|
||||
).fetchone()[0]
|
||||
|
||||
except WifitripError as exc:
|
||||
return jsonify(
|
||||
{
|
||||
"error": str(exc),
|
||||
}
|
||||
), 400
|
||||
|
||||
finally:
|
||||
close_database(conn)
|
||||
|
||||
return jsonify(
|
||||
{
|
||||
"count": len(session_ids),
|
||||
"available_count": available_count,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@app.route("/reports/trips/export")
|
||||
def reports_trips_export():
|
||||
|
||||
conn = connect_database()
|
||||
output_path = None
|
||||
|
||||
try:
|
||||
session_ids = select_wifitrip_session_ids(
|
||||
conn,
|
||||
mode=request.args.get("mode", "all"),
|
||||
limit=request.args.get("limit", "1"),
|
||||
date_from=request.args.get("date_from"),
|
||||
date_to=request.args.get("date_to"),
|
||||
)
|
||||
|
||||
if not session_ids:
|
||||
return jsonify(
|
||||
{
|
||||
"error": "No capture sessions match the selected criteria.",
|
||||
}
|
||||
), 400
|
||||
|
||||
filename = (
|
||||
"wifi-gps-mapper-"
|
||||
f"{datetime.now(timezone.utc).strftime('%Y%m%d-%H%M%S')}.wifitrip"
|
||||
)
|
||||
|
||||
temp_file = tempfile.NamedTemporaryFile(
|
||||
prefix="wifitrip-",
|
||||
suffix=".tmp",
|
||||
delete=False,
|
||||
)
|
||||
|
||||
temp_path = Path(
|
||||
temp_file.name
|
||||
)
|
||||
|
||||
temp_file.close()
|
||||
|
||||
output_path = temp_path.with_name(
|
||||
filename
|
||||
)
|
||||
|
||||
temp_path.unlink(
|
||||
missing_ok=True
|
||||
)
|
||||
|
||||
result = export_wifitrip(
|
||||
conn,
|
||||
output_path=output_path,
|
||||
session_ids=session_ids,
|
||||
)
|
||||
|
||||
except WifitripError as exc:
|
||||
|
||||
if output_path is not None:
|
||||
output_path.unlink(
|
||||
missing_ok=True
|
||||
)
|
||||
|
||||
return jsonify(
|
||||
{
|
||||
"error": str(exc),
|
||||
}
|
||||
), 400
|
||||
|
||||
except Exception:
|
||||
|
||||
output_path.unlink(
|
||||
missing_ok=True
|
||||
)
|
||||
if output_path is not None:
|
||||
output_path.unlink(
|
||||
missing_ok=True
|
||||
)
|
||||
|
||||
raise
|
||||
|
||||
|
||||
Reference in New Issue
Block a user