diff --git a/app/app.py b/app/app.py index 1986333..5895cb9 100644 --- a/app/app.py +++ b/app/app.py @@ -1,7 +1,6 @@ import os import sys import os.path -sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__)))) import logging import shutil from typing import Optional @@ -12,6 +11,8 @@ import html import glob +sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__)))) + # Initialise flask app app = Flask(__name__, static_url_path='/static', static_folder='static') # Current video @@ -274,10 +275,10 @@ def update_tesseract_path(): message = 'Could not find tesseract executable. Please enter the path manually.' return render_template('settings.html', current_settings=current_settings, message=message) -if __name__ == "__main__": +if __name__ == "__main__": host = "localhost" port = 5000 - if utils.update_port() == True: + if utils.update_port(): port = 5002 else: port = port diff --git a/app/utils.py b/app/utils.py index aec5915..e58f176 100644 --- a/app/utils.py +++ b/app/utils.py @@ -1,5 +1,5 @@ -import sys, os.path -sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__)))) +import sys +import os.path import hashlib import json import os.path @@ -16,6 +16,7 @@ from pytube.exceptions import RegexMatchError from configparser import ConfigParser +sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__)))) def config(section: str = None, option: str = None) -> Union[ConfigParser, str]: """ @@ -533,7 +534,13 @@ def extract_form_values(request): } } -def update_port() -> bool : - if sys.platform.lower() in ['darwin', 'linux']: +def update_port()->bool: + """ + Checks if the current platform is a Unix-based system (like Darwin or Linux). If so, returns True. + + Returns: + bool - True if running on a Unix-based system, False otherwise + """ + if sys.platform.lower() in ['darwin', 'linux']: return True return False \ No newline at end of file diff --git a/tests/test_utils.py b/tests/test_utils.py index fb950e7..52cf0e0 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -142,7 +142,7 @@ def test_file_already_exists_no_user_data(mocker): assert not utils.file_already_exists("4aj3sdl5a4k2sjd091u091j") -def test_set_port_for_macos(): +def test_set_port_for_macos(): port = 5000 if sys.platform.lower() in ["darwin", 'linux']: port = 5002