Add an option to trytond-console to run a script file
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -172,6 +172,9 @@ def get_parser_console():
|
||||
"-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',
|
||||
|
||||
@@ -53,7 +53,12 @@ def run(options):
|
||||
'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)
|
||||
|
||||
Reference in New Issue
Block a user