Debian Codegraph @

debian/bin/qmf-have-account

raw symbols SCIP
1 #!/usr/bin/python3
2
3 import os
4 import sqlite3
5 import sys
6 from pathlib import Path
7
8
9 def qmailstore_default_path():
10 return (
11 Path(os.getenv("XDG_DATA_HOME", Path.home() / ".local" / "share")) /
12 "qmf" / "database" / "qmailstore.db"
13 )
14
15
16 def qmf_have_account(qmailstore_path):
17 try:
18 con = sqlite3.connect(qmailstore_path)
19 except sqlite3.OperationalError as e:
20 return False
21 cur = con.cursor()
22 try:
23 res = cur.execute("SELECT * FROM mailaccounts")
24 except sqlite3.OperationalError as e:
25 return False
26 account_row = res.fetchone()
27 con.close()
28 return account_row is not None
29
30
31 if __name__ == "__main__":
32 if not qmf_have_account(qmailstore_default_path()):
33 sys.exit(1)