#!/usr/bin/python3 import os import sqlite3 import sys from pathlib import Path def qmailstore_default_path(): return ( Path(os.getenv("XDG_DATA_HOME", Path.home() / ".local" / "share")) / "qmf" / "database" / "qmailstore.db" ) def qmf_have_account(qmailstore_path): try: con = sqlite3.connect(qmailstore_path) except sqlite3.OperationalError as e: return False cur = con.cursor() try: res = cur.execute("SELECT * FROM mailaccounts") except sqlite3.OperationalError as e: return False account_row = res.fetchone() con.close() return account_row is not None if __name__ == "__main__": if not qmf_have_account(qmailstore_default_path()): sys.exit(1)