[IMP] cli first command testjs
authorAntony Lesuisse <al@openerp.com>
Sun, 9 Dec 2012 02:46:18 +0000 (03:46 +0100)
committerAntony Lesuisse <al@openerp.com>
Sun, 9 Dec 2012 02:46:18 +0000 (03:46 +0100)
bzr revid: al@openerp.com-20121209024618-cae0ux1vmo38ccwr

debian/control
openerp/cli/__init__.py
openerp/modules/module.py
setup.py

index 7a1bfb6..2017c34 100644 (file)
@@ -23,6 +23,7 @@ Depends:
  python-libxslt1,
  python-lxml,
  python-mako,
+ python-mock,
  python-openid,
  python-psutil,
  python-psycopg2,
index a48d20e..7111112 100644 (file)
@@ -2,6 +2,8 @@ import logging
 import sys
 
 import openerp
+from openerp import tools
+from openerp.modules import module
 
 _logger = logging.getLogger(__name__)
 
@@ -32,8 +34,25 @@ import server
 
 def main():
     args = sys.argv[1:]
+
+    # The only shared option is '--addons-path=' needed to discover additional
+    # commands from modules
+    if len(args) > 1 and args[0].startswith('--addons-path=') and not args[1].startswith("-"):
+        tools.config.parse_config([args[0]])
+        args = args[1:]
+
+    # Default legacy command
     command = "server"
+
+    # Subcommand discovery
     if len(args) and not args[0].startswith("-"):
+        for m in module.get_modules():
+            m = 'openerp.addons.' + m
+            __import__(m)
+            #try:
+            #except Exception, e:
+            #    raise
+            #    print e
         command = args[0]
         args = args[1:]
 
index ca654b9..bb4ff48 100644 (file)
@@ -433,8 +433,9 @@ def get_modules():
             return name
 
         def is_really_module(name):
-            name = opj(dir, name)
-            return os.path.isdir(name) or zipfile.is_zipfile(name)
+            manifest_name = opj(dir, name, '__openerp__.py')
+            zipfile_name = opj(dir, name)
+            return os.path.isfile(manifest_name) or zipfile.is_zipfile(zipfile_name)
         return map(clean, filter(is_really_module, os.listdir(dir)))
 
     plist = []
index 7d41e4d..5b1b2f4 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -108,6 +108,7 @@ setuptools.setup(
           'gdata',
           'lxml < 3', # windows binary http://www.lfd.uci.edu/~gohlke/pythonlibs/
           'mako',
+          'mock',
           'PIL', # windows binary http://www.lfd.uci.edu/~gohlke/pythonlibs/
           'psutil', # windows binary code.google.com/p/psutil/downloads/list
           'psycopg2',