diff --git a/bin/trytond b/bin/trytond index 5519f342cb..d97e7d9a5a 100755 --- a/bin/trytond +++ b/bin/trytond @@ -21,23 +21,26 @@ def parse_commandline(): parser.add_argument('--version', action='version', version='%(prog)s ' + VERSION) - parser.add_argument("-c", "--config", dest="configfile", + parser.add_argument("-c", "--config", dest="configfile", metavar='FILE', help="specify config file") - parser.add_argument('--debug', dest='debug', action='store_true', - help='enable debug mode') + parser.add_argument('--dev', dest='dev', action='store_true', + help='enable development mode') parser.add_argument("-v", "--verbose", action="store_true", dest="verbose", help="enable verbose mode") parser.add_argument("-d", "--database", dest="database_names", nargs='+', - default=[], help="specify the database name") - parser.add_argument("-i", "--init", dest="init", nargs='+', default=[], - help="init a module (use \"all\" for all modules)") + default=[], metavar='DATABASE', help="specify the database name") parser.add_argument("-u", "--update", dest="update", nargs='+', default=[], - help="update a module (use \"all\" for all modules)") + metavar='MODULE', help="update a module") + parser.add_argument("-i", "--init", dest="update", nargs='+', + action="append", metavar='MODULE', + help="init a module (deprecated use --update)") + parser.add_argument("--all", dest="update", action="append_const", + const="ir", help="update all installed modules") - parser.add_argument("--pidfile", dest="pidfile", + parser.add_argument("--pidfile", dest="pidfile", metavar='FILE', help="file where the server pid will be stored") - parser.add_argument("--logconf", dest="logconf", + parser.add_argument("--logconf", dest="logconf", metavar='FILE', help="logging configuration file (ConfigParser format)") parser.add_argument("--cron", dest="cron", action="store_true", help="enable cron") @@ -52,7 +55,7 @@ def parse_commandline(): options = parser.parse_args() - if not options.database_names and bool(options.init or options.update): + if not options.database_names and options.update: parser.error('Missing database option') return options diff --git a/trytond/modules/__init__.py b/trytond/modules/__init__.py index 2a5cbd7dba..8034784a14 100644 --- a/trytond/modules/__init__.py +++ b/trytond/modules/__init__.py @@ -152,11 +152,7 @@ def create_graph(module_list): packages = [] for module in module_list: - try: - info = get_module_info(module) - except IOError: - if module != 'all': - raise Exception('Module %s not found' % module) + info = get_module_info(module) packages.append((module, info.get('depends', []), info.get('extras_depend', []), info)) @@ -194,7 +190,7 @@ def create_graph(module_list): def is_module_to_install(module, update): - if 'all' in update and module != 'tests': + if module != 'tests': return True elif module in update: return True @@ -373,13 +369,9 @@ def load_modules(database_name, pool, update=None, lang=None): # Migration from 2.2: workflow module removed cursor.execute(*ir_module.delete( where=(ir_module.name == 'workflow'))) - if 'all' in update: - cursor.execute(*ir_module.select(ir_module.name, - where=(ir_module.name != 'tests'))) - else: - cursor.execute(*ir_module.select(ir_module.name, - where=ir_module.state.in_(('installed', 'to install', - 'to upgrade', 'to remove')))) + cursor.execute(*ir_module.select(ir_module.name, + where=ir_module.state.in_(('installed', 'to install', + 'to upgrade', 'to remove')))) else: cursor.execute(*ir_module.select(ir_module.name, where=ir_module.state.in_(('installed', 'to upgrade', diff --git a/trytond/server.py b/trytond/server.py index 992e08a25f..a22e4f0068 100644 --- a/trytond/server.py +++ b/trytond/server.py @@ -51,7 +51,6 @@ class TrytonServer(object): def run(self): "Run the server and never return" - update = self.options.init + self.options.update init = {} signal.signal(signal.SIGINT, lambda *a: self.stop()) @@ -65,14 +64,14 @@ class TrytonServer(object): with open(self.options.pidfile, 'w') as fd_pid: fd_pid.write("%d" % (os.getpid())) - if not update: + if not self.options.update: self.start_servers() for db_name in self.options.database_names: init[db_name] = False with Transaction().start(db_name, 0) as transaction: cursor = transaction.cursor - if self.options.init: + if self.options.update: if not cursor.test(): self.logger.info("init db") backend.get('Database').init(cursor) @@ -82,7 +81,7 @@ class TrytonServer(object): raise Exception("'%s' is not a Tryton database!" % db_name) for db_name in self.options.database_names: - if update: + if self.options.update: with Transaction().start(db_name, 0) as transaction: cursor = transaction.cursor if not cursor.test(): @@ -93,7 +92,7 @@ class TrytonServer(object): lang = [x[0] for x in cursor.fetchall()] else: lang = None - Pool(db_name).init(update=update, lang=lang) + Pool(db_name).init(update=self.options.update, lang=lang) for db_name in self.options.database_names: if init[db_name]: @@ -131,7 +130,7 @@ class TrytonServer(object): }) transaction.cursor.commit() - if update: + if self.options.update: self.logger.info('Update/Init succeed!') logging.shutdown() sys.exit(0) @@ -157,7 +156,7 @@ class TrytonServer(object): args=(dbname,), kwargs={}) thread.start() threads[dbname] = thread - if self.options.debug: + if self.options.dev: for _ in range(60): if monitor(): self.restart()