Commit e9b6c1b3 authored by shadMod's avatar shadMod 💬

added check if py3 version is > 3.8 else use try OSError to copytree

parent feb5086b
Pipeline #347 passed with stage
in 0 seconds
......@@ -16,6 +16,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import sys
import flask
import shutil
......@@ -96,7 +98,18 @@ def init_data_directory(data_path: str):
# Copy news tree dirs and file
ROOT_NEWS = os.path.join(BASE_DIR, "assets/news")
NEWS_PATH = os.path.join(data_path, "news")
shutil.copytree(ROOT_NEWS, NEWS_PATH, dirs_exist_ok=True)
if sys.version_info[:2] > (3, 8):
shutil.copytree(ROOT_NEWS, NEWS_PATH, dirs_exist_ok=True)
else:
try:
# if path already exists, remove it before copying with copytree()
if os.path.exists(NEWS_PATH):
shutil.rmtree(NEWS_PATH)
shutil.copytree(ROOT_NEWS, NEWS_PATH)
except OSError:
shutil.copy(ROOT_NEWS, NEWS_PATH)
except Exception as ex:
print(ex)
# Initialize the cache
static_dirs = {"static": "+assets"}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment