-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
76 lines (61 loc) · 2.61 KB
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
# -*- coding: utf-8 -*-
# Copyright (c) 2019-2024 Ramon van der Winkel.
# All rights reserved.
# Licensed under BSD-3-Clause-Clear. See LICENSE file for details.
# this line + shebang ensures python is taken from the user's PATH
# python sees this as a string and ignores it
# note: -u = unbuffered stdout/stderr
"exec" "python3" "-u" "$0" "$@" # noqa
from django.core.management import execute_from_command_line
from TestHelpers.template_status import end_of_run
from traceback import StackSummary
import sys
import os
"""
Django's command-line utility for administrative tasks.
"""
def my_format(self): # pragma: no cover
""" variant of StackSummary.format that skips all django site-package files in the output
so focus is on the application source files. This saves ~75% of the output.
"""
suppress = ' ...\n'
result = []
for frame in self:
if '/site-packages/django/' not in frame.filename:
row = list()
row.append(' File "{}", line {}, in {}\n'.format(
frame.filename, frame.lineno, frame.name))
if frame.line:
row.append(' {}\n'.format(frame.line.strip()))
if frame.locals:
for name, value in sorted(frame.locals.items()):
row.append(' {name} = {value}\n'.format(name=name, value=value))
result.append(''.join(row))
else:
if len(result) == 0 or result[-1] != suppress:
result.append(suppress)
# for
return result
def main():
# eigen formatteer functie voor de stack trace, zodat we alleen nuttige regels kunnen tonen
StackSummary.format = my_format
try:
# # print a clear separator on the terminal when using runserver or test
# stars = None
# if "runserver" in sys.argv or ("test" in sys.argv and "--noinput" not in sys.argv):
# # avoid double line when runserver starts a child process
# if "DJANGO_SETTINGS_MODULE" not in os.environ: # pragma: no branch
# stars = "*" * 30
# print("\n%s START OF RUN %s\n" % (stars, stars))
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Site.settings')
execute_from_command_line(sys.argv)
end_of_run()
# if stars: # pragma: no cover
# print("\nDone!")
except (KeyboardInterrupt, SystemExit): # pragma: no cover
print('\nInterrupted!')
sys.exit(3) # allows test suite to detect test abort
if __name__ == '__main__': # pragma: no branch
main()
# end of file