Quisiera consultar si es posible usar pdb en trytond-console. Si introduzco un breakpoint() o import pdb; pdb.set_strace() me sale una excepción:
[3] > (19)()
(Pdb++)
Traceback (most recent call last):
File “”, line 19, in
File “”, line 19, in
File “/usr/lib/python3.7/bdb.py”, line 88, in trace_dispatch
return self.dispatch_line(frame)
File “/usr/lib/python3.7/bdb.py”, line 113, in dispatch_line
if self.quitting: raise BdbQuit
bdb.BdbQuit
Si necesito correr scripts en el servidor en combinación con el cron de Linux, suelo usar Proteus, me pregunto para que se debería usar o en qué casos trytond-console?
En caso de elegir trytond-console ¿ hay alguna manera de hacer debug que no sea usar prints?
Hi!
I assume this patch is for a more recent version of Tryton, and I’m using 6.0. Based on the code you shared, I manually adapted it to version 6.0. I also made some modifications so that pdbpp (a drop-in replacement for pdb) doesn’t throw errors when using the “sticky” and “ll” features.
--- commandline.py.orig 2025-09-16 16:13:29.335776000 -0300
+++ commandline.py.modified 2025-09-17 15:37:53.379989097 -0300
@@ -113,6 +113,13 @@
required=True, metavar='DATABASE', help="specify the database name")
parser.add_argument("--histsize", dest="histsize", type=int, default=500,
help="The number of commands to remember in the command history")
+ parser.add_argument(
+ "-f", "--file",
+ dest="script",
+ metavar='FILE',
+ nargs='+',
+ help="Python script(s) to execute"
+ )
parser.epilog = "To store changes, `transaction.commit()` must be called."
return parser
--- console.py.orig 2025-09-16 16:13:29.339776000 -0300
+++ console.py.modified 2025-09-17 15:42:33.054114243 -0300
@@ -50,14 +50,21 @@
'pool': pool,
'transaction': transaction,
}
- if sys.stdin.isatty():
+ if sys.stdin.isatty() and not options.script:
console = Console(local, histsize=options.histsize)
- banner = "Tryton %s, Python %s on %s" % (
- __version__, sys.version, sys.platform)
+ banner = "Tryton %s, Python %s on %s" % (__version__, sys.version, sys.platform)
kwargs = {}
if sys.version_info >= (3, 6):
kwargs['exitmsg'] = ''
console.interact(banner=banner, **kwargs)
+ elif options.script:
+ console = Console(local, histsize=options.histsize)
+ for script_path in options.script:
+ if not script_path:
+ continue
+ with open(script_path, 'r') as f:
+ code = compile(f.read(), script_path, 'exec')
+ console.runcode(code)
else:
console = InteractiveConsole(local)
console.runcode(sys.stdin.read())