~openerp-dev/openobject-server/7.0-opw-586924-dhs

« back to all changes in this revision

Viewing changes to openerp/cli/__init__.py

  • Committer: Antony Lesuisse
  • Date: 2012-11-27 00:55:13 UTC
  • mto: This revision was merged to the branch mainline in revision 4600.
  • Revision ID: al@openerp.com-20121127005513-vi9viu4oafbrze6y
openerp apps main moved to cli ready for new commands

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import logging
 
2
import sys
 
3
 
 
4
import openerp
 
5
 
 
6
_logger = logging.getLogger(__name__)
 
7
 
 
8
commands = {}
 
9
 
 
10
class CommandType(type):
 
11
    def __init__(cls, name, bases, attrs):
 
12
        super(CommandType, cls).__init__(name, bases, attrs)
 
13
        name = cls.__name__.lower()
 
14
        commands[name] = cls
 
15
 
 
16
class Command(object):
 
17
    __metaclass__ = CommandType
 
18
 
 
19
    def run():
 
20
        pass
 
21
 
 
22
import server
 
23
 
 
24
def main():
 
25
    args = sys.argv[1:]
 
26
    command = "server"
 
27
    if len(args) and not args[0].startswith("-"):
 
28
        command = args[0]
 
29
        args = args[1:]
 
30
 
 
31
    if command in commands:
 
32
        o = commands[command]()
 
33
        o.run(args)
 
34
 
 
35
# vim:et:ts=4:sw=4: