diff options
| author | Samus CTO <cto@openerp.com> | 2014-12-25 23:28:05 +0100 |
|---|---|---|
| committer | Samus CTO <cto@openerp.com> | 2014-12-25 23:28:05 +0100 |
| commit | a5dad001726ef469e1ec0e4d7bf7d795164a4d91 (patch) | |
| tree | 1d50a26303b8fe6f0c73277deea77f7e54952e64 /openerp/cli/shell.py | |
| parent | 0451f197712b251bae4241b4a60c906c5a711306 (diff) | |
[IMP] stream code from stdin through Odoo's shell
Now I have a machine gun. Ho-ho-ho.
Diffstat (limited to 'openerp/cli/shell.py')
| -rw-r--r-- | openerp/cli/shell.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/openerp/cli/shell.py b/openerp/cli/shell.py index 6b251284e6d..3639615a2e8 100644 --- a/openerp/cli/shell.py +++ b/openerp/cli/shell.py @@ -18,6 +18,8 @@ import code import signal +from os import isatty +from sys import stdin import openerp from . import Command @@ -58,10 +60,13 @@ class Shell(Command): env = openerp.api.Environment(cr, uid, ctx) self.locals['env'] = env self.locals['self'] = env.user - print 'Connected to %s,' % dbname - print ' env: Environement(cr, openerp.SUPERUSER_ID, %s).' % ctx - print ' self: %s.' % env.user - Console(locals=self.locals).interact() + if not isatty(stdin.fileno()): + exec stdin in self.locals + else: + print 'Connected to %s,' % dbname + print ' env: Environement(cr, openerp.SUPERUSER_ID, %s).' % ctx + print ' self: %s.' % env.user + Console(locals=self.locals).interact() else: print 'No evironement set, use `odoo.py shell -d dbname` to get one.' Console(locals=self.locals).interact() |
