Skip to content

Instantly share code, notes, and snippets.

@tuxmartin
Created April 2, 2020 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxmartin/700d33548156269712e6d9de63b5d6ad to your computer and use it in GitHub Desktop.
Save tuxmartin/700d33548156269712e6d9de63b5d6ad to your computer and use it in GitHub Desktop.
Vypsani stavu IMAP kvoty
import imaplib, re
import os
p = re.compile('d+')
# ---------------------------------
login="user@example.net"
password="password123"
imap_server="example.net"
imap_port=993
# ---------------------------------
M = imaplib.IMAP4_SSL(imap_server, imap_port)
M.login(login, password)
quotaStr = M.getquotaroot("INBOX")[1][1][0]
r = re.compile('\d+').findall(quotaStr.decode('utf-8'))
if r == []:
r.append(0)
r.append(0)
total = float(r[1])/1000
used = float(r[0])/1000
print('Quota = %d MB'%( int(total) ))
print('Used = %d MB'%( int(used) ))
M.logout()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment