poprawki w naglowkach w trybie lokalnym, poprawka progressbaru
This commit is contained in:
48
app.py
48
app.py
@@ -56,6 +56,16 @@ from collections import Counter
|
||||
import pytesseract
|
||||
from pytesseract import Output
|
||||
|
||||
if os.environ.get("FLASK_RUN_FROM_CLI") == "true":
|
||||
print("""
|
||||
NIE URUCHAMIAJ aplikacji przez `flask run`!
|
||||
|
||||
Socket.IO wymaga uruchamiania przez `python app.py`, bo `flask run`
|
||||
nie obsługuje WebSocketów poprawnie (działa tylko z Werkzeugem).
|
||||
|
||||
Użyj: `python app.py`
|
||||
""")
|
||||
sys.exit(1)
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(Config)
|
||||
@@ -2571,8 +2581,42 @@ def handle_unmark_not_purchased(data):
|
||||
|
||||
@app.cli.command("create_db")
|
||||
def create_db():
|
||||
db.create_all()
|
||||
print("Database created.")
|
||||
inspector = inspect(db.engine)
|
||||
expected_tables = set(db.Model.metadata.tables.keys())
|
||||
actual_tables = set(inspector.get_table_names())
|
||||
missing_tables = expected_tables - actual_tables
|
||||
extra_tables = actual_tables - expected_tables
|
||||
|
||||
if missing_tables:
|
||||
print(f"Brakuje tabel: {', '.join(sorted(missing_tables))}")
|
||||
|
||||
if extra_tables:
|
||||
print(f"Dodatkowe tabele w bazie: {', '.join(sorted(extra_tables))}")
|
||||
|
||||
critical_error = False
|
||||
|
||||
for table in expected_tables & actual_tables:
|
||||
expected_columns = set(c.name for c in db.Model.metadata.tables[table].columns)
|
||||
actual_columns = set(c["name"] for c in inspector.get_columns(table))
|
||||
missing_cols = expected_columns - actual_columns
|
||||
extra_cols = actual_columns - expected_columns
|
||||
|
||||
if missing_cols:
|
||||
print(f"Brakuje kolumn w tabeli '{table}': {', '.join(sorted(missing_cols))}")
|
||||
critical_error = True
|
||||
|
||||
if extra_cols:
|
||||
print(f"ℹDodatkowe kolumny w tabeli '{table}': {', '.join(sorted(extra_cols))}")
|
||||
|
||||
if missing_tables or critical_error:
|
||||
print("Struktura bazy jest niekompletna lub niezgodna. Przerwano.")
|
||||
return
|
||||
|
||||
if not actual_tables:
|
||||
db.create_all()
|
||||
print("Utworzono strukturę bazy danych.")
|
||||
else:
|
||||
print("Struktura bazy danych jest poprawna.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Reference in New Issue
Block a user