summaryrefslogtreecommitdiff
path: root/openerp/cli/shell.py
diff options
context:
space:
mode:
authorSamus CTO <cto@openerp.com>2014-12-25 23:28:05 +0100
committerSamus CTO <cto@openerp.com>2014-12-25 23:28:05 +0100
commita5dad001726ef469e1ec0e4d7bf7d795164a4d91 (patch)
tree1d50a26303b8fe6f0c73277deea77f7e54952e64 /openerp/cli/shell.py
parent0451f197712b251bae4241b4a60c906c5a711306 (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.py13
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()