mirror of
https://github.com/DarkflameUniverse/NexusDashboard.git
synced 2024-11-21 21:17:23 +00:00
fix edge cases in report generation
with xml parsing error > system disable email by default
This commit is contained in:
parent
9452e8c801
commit
039b45c824
@ -50,7 +50,7 @@ def init_accounts():
|
||||
@click.argument('player')
|
||||
@with_appcontext
|
||||
def load_property(zone, player):
|
||||
|
||||
"""shoves property data into db"""
|
||||
char = CharacterInfo.query.filter(CharacterInfo.name == player).first()
|
||||
if not char:
|
||||
print("Character not Found")
|
||||
@ -97,6 +97,7 @@ def load_property(zone, player):
|
||||
|
||||
@click.command("gen_image_cache")
|
||||
def gen_image_cache():
|
||||
"""generates image cache"""
|
||||
luclient = pathlib.Path('app/luclient/res')
|
||||
files = [path for path in luclient.rglob("*.dds") if path.is_file()]
|
||||
|
||||
@ -114,6 +115,7 @@ def gen_image_cache():
|
||||
|
||||
@click.command("gen_model_cache")
|
||||
def gen_model_cache():
|
||||
"""generate model obj cache"""
|
||||
luclient = pathlib.Path('app/luclient/res')
|
||||
files = [path for path in luclient.rglob("*.lxfml") if path.is_file()]
|
||||
pool = Pool(processes=4)
|
||||
@ -135,6 +137,7 @@ def convert_lxfml_to_obj(file, lod):
|
||||
return
|
||||
|
||||
def get_cache_file(path):
|
||||
"""helper"""
|
||||
# convert to list so that we can change elements
|
||||
parts = list(path.parts)
|
||||
|
||||
|
@ -21,12 +21,12 @@ def command():
|
||||
return render_template('logs/command.html.j2')
|
||||
|
||||
|
||||
@log_blueprint.route('/errors')
|
||||
@log_blueprint.route('/system')
|
||||
@gm_level(8)
|
||||
def error():
|
||||
def system():
|
||||
with open('nexus_dashboard.log', 'r') as file:
|
||||
logs = '</br>'.join(file.read().split('\n')[-100:])
|
||||
return render_template('logs/error.html.j2', logs=logs)
|
||||
return render_template('logs/system.html.j2', logs=logs)
|
||||
|
||||
|
||||
@log_blueprint.route('/audits')
|
||||
|
@ -1,4 +1,4 @@
|
||||
from flask import render_template, Blueprint, redirect, url_for, request, abort, flash, current_app
|
||||
from flask import render_template, Blueprint, redirect, url_for, request, flash, current_app
|
||||
from flask_user import login_required
|
||||
from app.models import PetNames, db, CharacterXML, CharacterInfo
|
||||
from datatables import ColumnDT, DataTables
|
||||
@ -126,7 +126,7 @@ def get_pets(status="all"):
|
||||
return data
|
||||
|
||||
|
||||
@scheduler.task("cron", id="pet_name_maintenance", second="*", timezone="UTC")
|
||||
@scheduler.task("cron", id="pet_name_maintenance", hour="*", timezone="UTC")
|
||||
def pet_name_maintenance():
|
||||
with scheduler.app.app_context():
|
||||
# associate pet names to characters
|
||||
|
@ -60,17 +60,21 @@ def gen_item_report():
|
||||
report_data={}
|
||||
|
||||
for char_xml in char_xmls:
|
||||
character_json = xmltodict.parse(
|
||||
char_xml.xml_data,
|
||||
attr_prefix="attr_"
|
||||
)
|
||||
for inv in character_json["obj"]["inv"]["items"]["in"]:
|
||||
if "i" in inv.keys() and type(inv["i"]) == list and (int(inv["attr_t"])==0 or int(inv["attr_t"])==0):
|
||||
for item in inv["i"]:
|
||||
if item["attr_l"] in report_data:
|
||||
report_data[item["attr_l"]] = report_data[item["attr_l"]] + int(item["attr_c"])
|
||||
else:
|
||||
report_data[item["attr_l"]] = int(item["attr_c"])
|
||||
try:
|
||||
character_json = xmltodict.parse(
|
||||
char_xml.xml_data,
|
||||
attr_prefix="attr_"
|
||||
)
|
||||
for inv in character_json["obj"]["inv"]["items"]["in"]:
|
||||
if "i" in inv.keys() and type(inv["i"]) == list and (int(inv["attr_t"])==0 or int(inv["attr_t"])==0):
|
||||
for item in inv["i"]:
|
||||
if item["attr_l"] in report_data:
|
||||
report_data[item["attr_l"]] = report_data[item["attr_l"]] + int(item["attr_c"])
|
||||
else:
|
||||
report_data[item["attr_l"]] = int(item["attr_c"])
|
||||
except Exception as e:
|
||||
current_app.logger.error(f"REPORT::ITEMS - ERROR PARSING CHARACTER {char_xml.id}")
|
||||
current_app.logger.error(f"REPORT::ITEMS - {e}")
|
||||
|
||||
new_report = Reports(
|
||||
data=report_data,
|
||||
@ -110,11 +114,15 @@ def gen_currency_report():
|
||||
report_data={}
|
||||
|
||||
for character in characters:
|
||||
character_json = xmltodict.parse(
|
||||
character.xml_data,
|
||||
attr_prefix="attr_"
|
||||
)
|
||||
report_data[CharacterInfo.query.filter(CharacterInfo.id==character.id).first().name] = int(character_json["obj"]["char"]["attr_cc"])
|
||||
try:
|
||||
character_json = xmltodict.parse(
|
||||
character.xml_data,
|
||||
attr_prefix="attr_"
|
||||
)
|
||||
report_data[CharacterInfo.query.filter(CharacterInfo.id==character.id).first().name] = int(character_json["obj"]["char"]["attr_cc"])
|
||||
except Exception as e:
|
||||
current_app.logger.error(f"REPORT::CURRENCY - ERROR PARSING CHARACTER {char_xml.id}")
|
||||
current_app.logger.error(f"REPORT::CURRENCY - {e}")
|
||||
|
||||
new_report = Reports(
|
||||
data=report_data,
|
||||
@ -154,11 +162,15 @@ def gen_uscore_report():
|
||||
report_data={}
|
||||
|
||||
for character in characters:
|
||||
character_json = xmltodict.parse(
|
||||
character.xml_data,
|
||||
attr_prefix="attr_"
|
||||
)
|
||||
report_data[CharacterInfo.query.filter(CharacterInfo.id==character.id).first().name] = int(character_json["obj"]["char"]["attr_ls"])
|
||||
try:
|
||||
character_json = xmltodict.parse(
|
||||
character.xml_data,
|
||||
attr_prefix="attr_"
|
||||
)
|
||||
report_data[CharacterInfo.query.filter(CharacterInfo.id==character.id).first().name] = int(character_json["obj"]["char"]["attr_ls"])
|
||||
except Exception as e:
|
||||
current_app.logger.error(f"REPORT::U-SCORE - ERROR PARSING CHARACTER {char_xml.id}")
|
||||
current_app.logger.error(f"REPORT::U-SCORE - {e}")
|
||||
|
||||
new_report = Reports(
|
||||
data=report_data,
|
||||
|
@ -25,7 +25,7 @@ USER_REQUIRE_RETYPE_PASSWORD = True # Prompt for `retype password`
|
||||
USER_ENABLE_USERNAME = True # Register and Login with username
|
||||
|
||||
# Email Related Settings
|
||||
USER_ENABLE_EMAIL = True # Register with Email WILL - DISABLE OTHER THINGS TOO
|
||||
USER_ENABLE_EMAIL = False # Register with Email WILL - DISABLE OTHER THINGS TOO
|
||||
USER_ENABLE_CONFIRM_EMAIL = True # Force users to confirm their email
|
||||
USER_ENABLE_INVITE_USER = False # Allow users to be invited
|
||||
USER_REQUIRE_INVITATION = False # Only invited users may - WILL DISABLE REGISTRATION
|
||||
|
@ -69,14 +69,12 @@
|
||||
<a class="dropdown-item text-center" href='{{ url_for('log.activity') }}'>Command Log</a>
|
||||
<a class="dropdown-item text-center" href='{{ url_for('log.command') }}'>Activity Log</a>
|
||||
<a class="dropdown-item text-center" href='{{ url_for('log.audit') }}'>Audit Log</a>
|
||||
<a class="dropdown-item text-center" href='{{ url_for('log.error') }}'>Error Log</a>
|
||||
<a class="dropdown-item text-center" href='{{ url_for('log.system') }}'>System Log</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
{% if current_user.is_authenticated and current_user.gm_level == 9 and config.REQUIRE_PLAY_KEY %}
|
||||
{# Play Keys #}
|
||||
<a id='play_keys-index' class='nav-link' href='{{ url_for('play_keys.index') }}'>Play Keys</a>
|
||||
|
Loading…
Reference in New Issue
Block a user