Skip to content

Commit bf6430f

Browse files
committed
Add paper-genmon
1 parent 7c6925d commit bf6430f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

bin/paper-genmon

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python3
2+
import sys
3+
4+
from ocflib.account.search import user_exists, user_is_group
5+
from ocflib.misc.whoami import current_user
6+
from ocflib.printing.quota import get_connection, get_quota
7+
8+
IMAGE_PATH = '/opt/share/xsession/icons/paper-stack.png'
9+
10+
11+
def main(argv=None):
12+
user = None
13+
daily_quota = 'N/A'
14+
semester_quota = 'N/A'
15+
user = current_user()
16+
17+
if user_exists(user) and not user_is_group(user):
18+
conn = get_connection()
19+
with conn.cursor() as c:
20+
quota = get_quota(c, user)
21+
daily_quota = quota.daily
22+
semester_quota = quota.semesterly
23+
conn.commit()
24+
conn.close()
25+
26+
PANEL_TEXT = '{} {} left today | {} left this semester'
27+
print(PANEL_TEXT.format(daily_quota, 'side of paper' if daily_quota == 1 else 'sides of paper',
28+
semester_quota
29+
))
30+
31+
32+
if __name__ == '__main__':
33+
sys.exit(main())

0 commit comments

Comments
 (0)