Skip to content

Commit

Permalink
Merge pull request #62 from tinyerp/skip-interact
Browse files Browse the repository at this point in the history
return the interactive namespace for use in third-party libraries
  • Loading branch information
florentx committed Sep 23, 2014
2 parents 602e277 + 7e00be0 commit 277d93b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Changelog
* Use blocking RPC call in ``Client.create_database``. Asynchronous
method is removed in Odoo.

* Return the interactive namespace with ``main(interact=False)``.
It helps to integrate with third-party libraries, such as IPython.

* Remove a duplicate ``Logged in as ...`` line in interactive mode.

* Remove the ``search+name_get`` undocumented feature which has
Expand Down
4 changes: 2 additions & 2 deletions erppeek.py
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,7 @@ def runcode(self, code):
Console().interact('\033[A')


def main():
def main(interact=_interact):
description = ('Inspect data on Odoo objects. Use interactively '
'or query a model (-m) and pass search terms or '
'ids as positional parameters after the options.')
Expand Down Expand Up @@ -1631,7 +1631,7 @@ def main():
if not client.user:
client.connect()
# Enter interactive mode
_interact(global_vars)
return interact(global_vars) if interact else global_vars

if __name__ == '__main__':
main()
1 change: 1 addition & 0 deletions tests/test_interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def setUp(self):
mock.patch('erppeek.Client._set_interactive', wraps=erppeek.Client._set_interactive).start()
self.interact = mock.patch('erppeek._interact', wraps=erppeek._interact).start()
self.infunc = mock.patch('code.InteractiveConsole.raw_input').start()
mock.patch('erppeek.main.__defaults__', (self.interact,)).start()

def test_main(self):
env_tuple = ('http://127.0.0.1:8069', 'database', 'usr', None)
Expand Down

0 comments on commit 277d93b

Please sign in to comment.