ammarnasr commited on
Commit
d595659
·
verified ·
1 Parent(s): b0fa5f9

Show data usage for current user

Browse files
Files changed (1) hide show
  1. authentication.py +18 -0
authentication.py CHANGED
@@ -6,11 +6,29 @@ import time
6
  import re
7
  import hashlib
8
  import hmac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
 
11
  def greeting(msg="Welcome"):
12
  current_user = st.session_state['current_user']
13
  st.write(f"{msg} {current_user}!")
 
14
  return current_user
15
 
16
 
 
6
  import re
7
  import hashlib
8
  import hmac
9
+ import os
10
+ import shutil
11
+
12
+ def get_size(start_path = '.'):
13
+ total_size = 0
14
+ for dirpath, dirnames, filenames in os.walk(start_path):
15
+ for f in filenames:
16
+ fp = os.path.join(dirpath, f)
17
+ # skip if it is symbolic link
18
+ if not os.path.islink(fp):
19
+ total_size += os.path.getsize(fp)
20
+ ds = total_size/10**6
21
+ total, used, free = shutil.disk_usage("/")
22
+ total = total/ (2**30)
23
+ free = free/ (2**30)
24
+ st.write(f'Your Data size is {ds :.2f}MB; Space left {free :.2f}GB out of {total :.2f}GB')
25
+ return ds
26
 
27
 
28
  def greeting(msg="Welcome"):
29
  current_user = st.session_state['current_user']
30
  st.write(f"{msg} {current_user}!")
31
+ get_size(start_path=f'./{current_user}')
32
  return current_user
33
 
34