From 581fe15a04f1d2def3a7775f4a16a9d76a18c8d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edison=20Iba=C3=B1ez?= Date: Wed, 11 Nov 2015 16:01:26 -0500 Subject: [PATCH 1/6] start iptrhon if is installed --- erppeek.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erppeek.py b/erppeek.py index 712c232..0323315 100644 --- a/erppeek.py +++ b/erppeek.py @@ -1675,4 +1675,8 @@ def main(interact=_interact): return interact(global_vars) if interact else global_vars if __name__ == '__main__': - main() + try: + import IPython + IPython.start_ipython(user_ns=main(interact=False), argv=[]) + except ImportError: + main() From 225c259ebac4de915b02e98feb2ecf3cdf02a57f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edison=20Iba=C3=B1ez?= Date: Wed, 11 Nov 2015 16:25:14 -0500 Subject: [PATCH 2/6] start ipython if is installed --- erppeek.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/erppeek.py b/erppeek.py index 0323315..63d995d 100644 --- a/erppeek.py +++ b/erppeek.py @@ -1672,11 +1672,11 @@ def main(interact=_interact): if not client.user: client.connect() # Enter interactive mode - return interact(global_vars) if interact else global_vars + try: + import IPython + IPython.start_ipython(user_ns=global_vars, argv=[]) + except ImportError: + return interact(global_vars) if interact else global_vars if __name__ == '__main__': - try: - import IPython - IPython.start_ipython(user_ns=main(interact=False), argv=[]) - except ImportError: main() From 27772b1b78480dc92fa708ae5c99c1cfbe7edd04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edison=20Iba=C3=B1ez?= Date: Mon, 19 Mar 2018 10:42:31 -0500 Subject: [PATCH 3/6] WIP ptpython + ipython --- erppeek.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/erppeek.py b/erppeek.py index 44dae39..0cc6a49 100644 --- a/erppeek.py +++ b/erppeek.py @@ -5,7 +5,6 @@ Author: Florent Xicluna (derived from a script by Alan Bell) """ -import _ast import atexit import csv import functools @@ -16,6 +15,18 @@ import sys import time import traceback + +import _ast + +try: + from ptpython.ipython import embed + from ptpython.prompt_style import PromptStyle + from pygments.token import Token + PTPYTHON = True +except ImportError: + print('INstall ptpython') + PTPYTHON = False + try: # Python 3 import configparser from threading import current_thread @@ -155,7 +166,7 @@ def literal_eval(expression, _octal_digits=frozenset('01234567')): raise SyntaxError('unsupported octal notation') value = _convert(node.body) if isinstance(value, int_types) and not MININT <= value <= MAXINT: - raise ValueError('overflow, int exceeds XML-RPC limits') + raise ValueError('overflow, int exceeds XML-RPC limits') return value @@ -1356,6 +1367,7 @@ class Record(object): The attributes are evaluated lazily, and they are cached in the record. The Record's cache is invalidated if any attribute is changed. """ + def __init__(self, res_model, res_id, context=None): if isinstance(res_id, (list, tuple)): (res_id, res_name) = res_id @@ -1566,7 +1578,8 @@ def displayhook(value, _printer=pprint.pprint, _builtins=builtins): class Usage(object): def __call__(self): print(usage) - __repr__ = lambda s: usage + + def __repr__(s): return usage builtins.usage = Usage() try: @@ -1677,11 +1690,11 @@ def main(interact=_interact): if not client.user: client.connect() # Enter interactive mode - try: - import IPython - IPython.start_ipython(user_ns=global_vars, argv=[]) - except ImportError: + if PTPYTHON: + embed() + else: return interact(global_vars) if interact else global_vars + if __name__ == '__main__': - main() + main() From f7f593c401cb0cec732ff1ad4f1c6d58508fd10d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edison=20Iba=C3=B1ez?= Date: Tue, 20 Mar 2018 10:01:45 -0500 Subject: [PATCH 4/6] WIP --- erppeek.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/erppeek.py b/erppeek.py index b9bea61..5d792cc 100644 --- a/erppeek.py +++ b/erppeek.py @@ -19,12 +19,9 @@ import _ast try: - from ptpython.ipython import embed - from ptpython.prompt_style import PromptStyle - from pygments.token import Token + from ptpython.relp import embed PTPYTHON = True except ImportError: - print('INstall ptpython') PTPYTHON = False try: # Python 3 @@ -1702,7 +1699,7 @@ def main(interact=_interact): client.connect() # Enter interactive mode if PTPYTHON: - embed() + embed(global_vars, locals(), vi_mode=False) else: return interact(global_vars) if interact else global_vars From 3ca80199d387c7c7da5e860197f3fcfcbb88a4d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edison=20Iba=C3=B1ez?= Date: Tue, 20 Mar 2018 10:15:24 -0500 Subject: [PATCH 5/6] WIP --- erppeek.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erppeek.py b/erppeek.py index 5d792cc..d2f69e9 100644 --- a/erppeek.py +++ b/erppeek.py @@ -19,7 +19,7 @@ import _ast try: - from ptpython.relp import embed + from ptpython.repl import embed PTPYTHON = True except ImportError: PTPYTHON = False @@ -1698,6 +1698,8 @@ def main(interact=_interact): if not client.user: client.connect() # Enter interactive mode + import pudb + pudb.set_trace() if PTPYTHON: embed(global_vars, locals(), vi_mode=False) else: From 434e40cd9386f91aa14881b4779bc3043b19ac06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edison=20Iba=C3=B1ez?= Date: Tue, 20 Mar 2018 10:17:12 -0500 Subject: [PATCH 6/6] WIP --- erppeek.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/erppeek.py b/erppeek.py index d2f69e9..92917f9 100644 --- a/erppeek.py +++ b/erppeek.py @@ -1698,8 +1698,6 @@ def main(interact=_interact): if not client.user: client.connect() # Enter interactive mode - import pudb - pudb.set_trace() if PTPYTHON: embed(global_vars, locals(), vi_mode=False) else: