2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-04-15 07:48:51 +00:00

Invoke verbosity (#11706)

* Reduce verbosity of invoke tasks

- Suppress some django messages which are not useful to most users
- Verbosity can be added with --verbose flag

* Further improvements

* Better messaging

* Extra options

* No!
This commit is contained in:
Oliver
2026-04-10 07:58:53 +10:00
committed by GitHub
parent 8d24abcb2a
commit 4b3b03ed4b
3 changed files with 170 additions and 72 deletions

View File

@@ -13,25 +13,39 @@ class Command(BaseCommand):
def handle(self, *args, **kwargs):
"""Wait till the database is ready."""
self.stdout.write('Waiting for database...')
connected = False
verbose = int(kwargs.get('verbosity', 0)) > 0
attempts = kwargs.get('attempts', 10)
while not connected:
time.sleep(2)
if verbose:
self.stdout.write('Waiting for database connection...')
self.stdout.flush()
while not connected and attempts > 0:
attempts -= 1
try:
connection.ensure_connection()
connected = True
except OperationalError as e:
self.stdout.write(f'Could not connect to database: {e}')
except ImproperlyConfigured as e:
self.stdout.write(f'Improperly configured: {e}')
except (OperationalError, ImproperlyConfigured):
if verbose:
self.stdout.write('Database connection failed, retrying ...')
self.stdout.flush()
else:
if not connection.is_usable():
self.stdout.write('Database configuration is not usable')
if verbose:
self.stdout.write('Database configuration is not usable')
self.stdout.flush()
if connected:
self.stdout.write('Database connection successful!')
if verbose:
self.stdout.write('Database connection successful!')
self.stdout.flush()
else:
time.sleep(1)
if not connected:
self.stderr.write('Failed to connect to database after multiple attempts')
self.stderr.flush()

View File

@@ -13,7 +13,7 @@ import { __INVENTREE_VERSION_INFO__ } from './version-info';
const IS_IN_WSL = platform().includes('WSL') || release().includes('WSL');
if (IS_IN_WSL) {
console.log('WSL detected: using polling for file system events');
console.debug('WSL detected: using polling for file system events');
}
// Output directory for the built files