Spaces:
Running
Running
Compute disk usage
Browse files
app.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
import base64
|
|
|
|
| 2 |
import json5
|
|
|
|
| 3 |
import time
|
| 4 |
import streamlit as st
|
| 5 |
import streamlit.runtime.scriptrunner as st_sr
|
|
@@ -9,7 +11,9 @@ import llm_helper
|
|
| 9 |
import pptx_helper
|
| 10 |
from global_config import GlobalConfig
|
| 11 |
|
|
|
|
| 12 |
APP_TEXT = json5.loads(open(GlobalConfig.APP_STRINGS_FILE, 'r').read())
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
@st.cache_data
|
|
@@ -66,16 +70,39 @@ def get_ai_image_wrapper(text: str) -> str:
|
|
| 66 |
return llm_helper.get_ai_image(text)
|
| 67 |
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
def build_ui():
|
| 70 |
"""
|
| 71 |
Display the input elements for content generation. Only covers the first step.
|
| 72 |
"""
|
| 73 |
|
|
|
|
|
|
|
| 74 |
st.title(APP_TEXT['app_name'])
|
| 75 |
st.subheader(APP_TEXT['caption'])
|
| 76 |
-
st.markdown(
|
| 77 |
-
|
| 78 |
-
)
|
| 79 |
st.divider()
|
| 80 |
|
| 81 |
st.header(APP_TEXT['section_headers'][0])
|
|
|
|
| 1 |
import base64
|
| 2 |
+
import os
|
| 3 |
import json5
|
| 4 |
+
import shutil
|
| 5 |
import time
|
| 6 |
import streamlit as st
|
| 7 |
import streamlit.runtime.scriptrunner as st_sr
|
|
|
|
| 11 |
import pptx_helper
|
| 12 |
from global_config import GlobalConfig
|
| 13 |
|
| 14 |
+
|
| 15 |
APP_TEXT = json5.loads(open(GlobalConfig.APP_STRINGS_FILE, 'r').read())
|
| 16 |
+
GB_CONVERTER = 2 ** 30
|
| 17 |
|
| 18 |
|
| 19 |
@st.cache_data
|
|
|
|
| 70 |
return llm_helper.get_ai_image(text)
|
| 71 |
|
| 72 |
|
| 73 |
+
def get_disk_used_percentage() -> float:
|
| 74 |
+
"""
|
| 75 |
+
Compute the disk usage.
|
| 76 |
+
|
| 77 |
+
:return: Percentage of the disk space currently used
|
| 78 |
+
"""
|
| 79 |
+
|
| 80 |
+
total, used, free = shutil.disk_usage('/')
|
| 81 |
+
total = total // GB_CONVERTER
|
| 82 |
+
used = used // GB_CONVERTER
|
| 83 |
+
free = free // GB_CONVERTER
|
| 84 |
+
used_perc = 100.0 * used / total
|
| 85 |
+
print(f'Total: {total} GB\n'
|
| 86 |
+
f'Used: {used} GB\n'
|
| 87 |
+
f'Free: {free} GB')
|
| 88 |
+
|
| 89 |
+
print('\n'.join(os.listdir()))
|
| 90 |
+
|
| 91 |
+
return used_perc
|
| 92 |
+
|
| 93 |
+
|
| 94 |
def build_ui():
|
| 95 |
"""
|
| 96 |
Display the input elements for content generation. Only covers the first step.
|
| 97 |
"""
|
| 98 |
|
| 99 |
+
get_disk_used_percentage()
|
| 100 |
+
|
| 101 |
st.title(APP_TEXT['app_name'])
|
| 102 |
st.subheader(APP_TEXT['caption'])
|
| 103 |
+
# st.markdown(
|
| 104 |
+
# ''
|
| 105 |
+
# )
|
| 106 |
st.divider()
|
| 107 |
|
| 108 |
st.header(APP_TEXT['section_headers'][0])
|