details: https://code.tryton.org/tryton/commit/9487ce20c3a5
branch: default
user: Cédric Krier <[email protected]>
date: Tue Oct 21 16:05:39 2025 +0200
description:
Add an option to trytond-console to run a script file
diffstat:
trytond/CHANGELOG | 1 +
trytond/trytond/commandline.py | 3 +++
trytond/trytond/console.py | 7 ++++++-
3 files changed, 10 insertions(+), 1 deletions(-)
diffs (38 lines):
diff -r 6084b9b0c2f0 -r 9487ce20c3a5 trytond/CHANGELOG
--- a/trytond/CHANGELOG Wed Nov 26 21:53:24 2025 +0100
+++ b/trytond/CHANGELOG Tue Oct 21 16:05:39 2025 +0200
@@ -1,3 +1,4 @@
+* Add an option to trytond-console to run a script file
* Store only immutable structure in MemoryCache
* Replace ``clean_days`` with ``log_size`` in the cron configuration
* Enforce access check in export_data (issue14366)
diff -r 6084b9b0c2f0 -r 9487ce20c3a5 trytond/trytond/commandline.py
--- a/trytond/trytond/commandline.py Wed Nov 26 21:53:24 2025 +0100
+++ b/trytond/trytond/commandline.py Tue Oct 21 16:05:39 2025 +0200
@@ -172,6 +172,9 @@
"-d", "--database", dest="database_name",
required=True, metavar='DATABASE',
help="specify the database name").completer = database_completer
+ parser.add_argument(
+ "-f", "--file", dest="file",
+ help="the Python script file to execute")
parser.add_argument("--histsize", dest="histsize", type=int, default=500,
help="set the number of commands to remember in the command history")
parser.add_argument("--readonly", dest="readonly", action='store_true',
diff -r 6084b9b0c2f0 -r 9487ce20c3a5 trytond/trytond/console.py
--- a/trytond/trytond/console.py Wed Nov 26 21:53:24 2025 +0100
+++ b/trytond/trytond/console.py Tue Oct 21 16:05:39 2025 +0200
@@ -53,7 +53,12 @@
'pool': pool,
'transaction': transaction,
}
- if sys.stdin.isatty():
+ if options.file:
+ console = InteractiveConsole(local)
+ with open(options.file, 'r') as f:
+ console.runsource(
+ f.read(), filename=options.file, symbol='exec')
+ elif sys.stdin.isatty():
console = Console(local, histsize=options.histsize)
banner = "Tryton %s, Python %s on %s" % (
__version__, sys.version, sys.platform)