2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-27 19:16:44 +00:00

Small tweak to tasks.py (#9544)

This commit is contained in:
Oliver 2025-04-20 16:03:48 +10:00 committed by GitHub
parent 13412adeb3
commit 88102ad9aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,7 +31,7 @@ def is_rtd_environment():
return is_true(os.environ.get('READTHEDOCS', 'False')) return is_true(os.environ.get('READTHEDOCS', 'False'))
def is_deb_environment(): def is_debug_environment():
"""Check if the InvenTree environment is running in a debug environment.""" """Check if the InvenTree environment is running in a debug environment."""
from src.backend.InvenTree.InvenTree.config import is_true from src.backend.InvenTree.InvenTree.config import is_true
@ -101,7 +101,7 @@ def state_logger(fn=None, method_name=None):
@wraps(func) @wraps(func)
def wrapped(c, *args, **kwargs): def wrapped(c, *args, **kwargs):
do_log = is_deb_environment() do_log = is_debug_environment()
if do_log: if do_log:
info(f'# {func.method_name}| start') info(f'# {func.method_name}| start')
func(c, *args, **kwargs) func(c, *args, **kwargs)
@ -381,7 +381,7 @@ def check_file_existence(filename: Path, overwrite: bool = False):
# Install tasks # Install tasks
# region tasks # region tasks
@task(help={'uv': 'Use UV (experimental package manager)'}) @task(help={'uv': 'Use UV (experimental package manager)'})
@state_logger('TSK01') @state_logger('TASK01')
def plugins(c, uv=False): def plugins(c, uv=False):
"""Installs all plugins as specified in 'plugins.txt'.""" """Installs all plugins as specified in 'plugins.txt'."""
from src.backend.InvenTree.InvenTree.config import get_plugin_file from src.backend.InvenTree.InvenTree.config import get_plugin_file
@ -407,7 +407,7 @@ def plugins(c, uv=False):
'skip_plugins': 'Skip plugin installation', 'skip_plugins': 'Skip plugin installation',
} }
) )
@state_logger('TSK02') @state_logger('TASK02')
def install(c, uv=False, skip_plugins=False): def install(c, uv=False, skip_plugins=False):
"""Installs required python packages.""" """Installs required python packages."""
# Ensure path is relative to *this* directory # Ensure path is relative to *this* directory
@ -495,7 +495,7 @@ def rebuild_thumbnails(c):
@task @task
@state_logger('TSK09') @state_logger('TASK09')
def clean_settings(c): def clean_settings(c):
"""Clean the setting tables of old settings.""" """Clean the setting tables of old settings."""
info('Cleaning old settings from the database') info('Cleaning old settings from the database')
@ -520,7 +520,7 @@ def remove_mfa(c, mail=''):
'skip_plugins': 'Ignore collection of plugin static files', 'skip_plugins': 'Ignore collection of plugin static files',
} }
) )
@state_logger('TSK08') @state_logger('TASK08')
def static(c, frontend=False, clear=True, skip_plugins=False): def static(c, frontend=False, clear=True, skip_plugins=False):
"""Copies required static files to the STATIC_ROOT directory, as per Django requirements.""" """Copies required static files to the STATIC_ROOT directory, as per Django requirements."""
if frontend and node_available(): if frontend and node_available():
@ -571,7 +571,7 @@ def translate(c, ignore_static=False, no_frontend=False):
'path': 'Specify path for generated backup files (leave blank for default path)', 'path': 'Specify path for generated backup files (leave blank for default path)',
} }
) )
@state_logger('TSK04') @state_logger('TASK04')
def backup(c, clean=False, path=None): def backup(c, clean=False, path=None):
"""Backup the database and media files.""" """Backup the database and media files."""
info('Backing up InvenTree database...') info('Backing up InvenTree database...')
@ -648,7 +648,7 @@ def restore(
@task(post=[rebuild_models, rebuild_thumbnails]) @task(post=[rebuild_models, rebuild_thumbnails])
@state_logger('TSK05') @state_logger('TASK05')
def migrate(c): def migrate(c):
"""Performs database migrations. """Performs database migrations.
@ -681,7 +681,7 @@ def showmigrations(c, app=''):
'uv': 'Use UV (experimental package manager)', 'uv': 'Use UV (experimental package manager)',
}, },
) )
@state_logger('TSK03') @state_logger('TASK03')
def update( def update(
c, c,
skip_backup: bool = False, skip_backup: bool = False,
@ -988,7 +988,7 @@ def import_fixtures(c):
# Execution tasks # Execution tasks
@task @task
@state_logger('TSK10') @state_logger('TASK10')
def wait(c): def wait(c):
"""Wait until the database connection is ready.""" """Wait until the database connection is ready."""
info('Waiting for database connection...') info('Waiting for database connection...')
@ -1276,7 +1276,7 @@ def setup_test(
'no_default': 'Do not use default settings for schema (default = off/False)', 'no_default': 'Do not use default settings for schema (default = off/False)',
} }
) )
@state_logger('TSK11') @state_logger('TASK11')
def schema( def schema(
c, filename='schema.yml', overwrite=False, ignore_warnings=False, no_default=False c, filename='schema.yml', overwrite=False, ignore_warnings=False, no_default=False
): ):
@ -1419,7 +1419,7 @@ def frontend_check(c):
@task @task
@state_logger('TSK06') @state_logger('TASK06')
def frontend_compile(c): def frontend_compile(c):
"""Generate react frontend. """Generate react frontend.
@ -1491,7 +1491,7 @@ def frontend_server(c):
'clean': 'Delete old files from InvenTree/web/static/web first, default: True', 'clean': 'Delete old files from InvenTree/web/static/web first, default: True',
} }
) )
@state_logger('TSK07') @state_logger('TASK07')
def frontend_download( def frontend_download(
c, c,
ref=None, ref=None,