Skip to content

Commit

Permalink
rather than using variable, will use function
Browse files Browse the repository at this point in the history
  • Loading branch information
nasilc committed Feb 20, 2024
1 parent c0dfb74 commit 9cf9a0c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
import subprocess
from config import Config

DEFAULT_DATA = {"exports": {}}

logging.basicConfig(
format="%(asctime)s %(funcName)s %(levelname)s: %(message)s", level=logging.INFO
)


def _default_data():
return {"exports": {}}

def create_fake_data():
"""
Create fake data in root folder
Expand Down Expand Up @@ -56,7 +57,7 @@ def disk_usage():
Loop through folders get their disk usage grouped by export and folder as a dict
"""
c = Config()
usage = DEFAULT_DATA
usage = _default_data()
for dir in traverse_level(c.get("ROOT_FOLDER"), c.get("FOLDER_REPORTING_DEPTH")):
parent = dir[len(c.get("ROOT_FOLDER")) + len(os.path.sep) :].split(os.path.sep)[
c.get("EXPORT_REPORTING_DEPTH")
Expand Down Expand Up @@ -130,7 +131,7 @@ def get_usage_from_usage_file():
if usage_file and os.path.isfile(usage_file):
with open(usage_file) as uf:
return json.load(uf)
return DEFAULT_DATA
return _default_data()


def read_usage():
Expand All @@ -157,7 +158,7 @@ def read_usage():
c.set("LAST_READ_TIME", datetime.datetime.now())
c.set("CACHED_USAGE", usage)
return usage
return DEFAULT_DATA
return _default_data()


def write_disk_usage():
Expand Down

0 comments on commit 9cf9a0c

Please sign in to comment.