Spaces:
Build error
Build error
Download pages/utils/util.py from FriendlyUser/openbb_analyzer: direct link, hf CLI and curl.
- Browser
- Download file 792 Bytes
-
https://huggingface.co/spaces/FriendlyUser/openbb_analyzer/resolve/main/pages/utils/util.py
- Command line
-
hf download hf://spaces/FriendlyUser/openbb_analyzer/pages/utils/util.py
-
curl -L -o util.py https://huggingface.co/spaces/FriendlyUser/openbb_analyzer/resolve/main/pages/utils/util.py
792 Bytes
| import os | |
| import sys | |
| from PIL import Image | |
| from io import StringIO | |
| def remove_existing_file(func): | |
| def wrapper(*args, **kwargs): | |
| old_stdin = sys.stdin | |
| sys.stdin = StringIO("y") | |
| stream = os.popen('cd ~ && pwd') | |
| root_dir = stream.read() | |
| sample_dir = root_dir.strip() | |
| # remove /home/codespace/OpenBBUserData/exports/bbands.png already | |
| # get last arg as export | |
| export = args[-1] | |
| temp_image = os.path.join(sample_dir, "OpenBBUserData", "exports", export) | |
| # if exists erase | |
| if os.path.exists(temp_image): | |
| os.remove(temp_image) | |
| func(*args, **kwargs) | |
| sys.stdin = old_stdin | |
| if os.path.exists(temp_image): | |
| return temp_image | |
| return None | |
| return wrapper |