Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.

0 downloads

Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-server.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-server.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-server.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 signup: the person chooses the password and name on the confirm page 83c7aa6 2 weeks, 5 days ago History
mail_sync_attention.py · 1.7 KB · 47 lines
1"""system_mail_sync_attention -- how many mail accounts keep failing to sync.
2
3COUNT only (docs/package-authoring.md, the attention contract). An account
4counts when it is enabled and its last object_mail.ATTENTION_AFTER passes in
5a row all failed: one failure is a network blip, three is a changed
6password or a server that has gone away, and nobody will find out from the
7inbox itself, because a mailbox that stopped syncing looks exactly like a
8quiet one. That look-alike is the failure the predecessor's silent
9``except: pass`` produced, and this count is what ends it.
10
11The count is deployment-wide, as every attention count is, so the detail
12names no person and no address. The owner reads which account and why on
13/mail/accounts, where sync_error is shown in full.
14
15A box without app-mail-sync installed reads zero rather than raising.
16"""
17
18import os
19
20import object_mail
21import object_records
22
23
24def _text(value):
25 return str(value if value is not None else "").strip()
26
27
28def _int(value):
29 try:
30 return int(_text(value) or 0)
31 except ValueError:
32 return 0
33
34
35def COUNT(request):
36 base = os.environ.get("DBBASIC_DATA_DIR", "data")
37 try:
38 accounts = object_records.read_collection_records("mail_accounts", base_dir=base)
39 except (LookupError, OSError, ValueError):
40 return {"count": 0}
41 failing = [row for row in accounts
42 if _text(row.get("enabled")).lower() not in {"false", "0", "no", "off"}
43 and _int(row.get("sync_attempts")) >= object_mail.ATTENTION_AFTER]
44 if not failing:
45 return {"count": 0}
46 return {"count": len(failing),
47 "detail": f"failed {object_mail.ATTENTION_AFTER} or more syncs in a row"}