def execute(self, argv): try: opts, args = getopt.gnu_getopt( argv, 'v', ['with-maven-deps', 'force', 'verbose', 'debug', 'help']) except getopt.GetoptError as e: logger.error(e) self.print_help() sys.exit(1) instance_name = 'pki-tomcat' with_maven_deps = False force = False for o, _ in opts: if o == '--with-maven-deps': with_maven_deps = True elif o == '--force': force = True elif o in ('-v', '--verbose'): logging.getLogger().setLevel(logging.INFO) elif o == '--debug': logging.getLogger().setLevel(logging.DEBUG) elif o == '--help': self.print_help() sys.exit() else: logger.error('Unknown option: %s', o) self.print_help() sys.exit(1) if len(args) > 0: instance_name = args[0] instance = pki.server.instance.PKIServerFactory.create(instance_name) if not force and instance.is_valid(): logger.error('Instance already exists: %s', instance_name) sys.exit(1) logging.info('Creating instance: %s', instance_name) instance.with_maven_deps = with_maven_deps instance.create(force=force)
def execute(self, argv): try: opts, args = getopt.gnu_getopt( argv, 'v', ['force', 'verbose', 'debug', 'help']) except getopt.GetoptError as e: print('ERROR: %s' % e) self.print_help() sys.exit(1) instance_name = 'pki-tomcat' force = False for o, _ in opts: if o == '--force': force = True elif o in ('-v', '--verbose'): logging.getLogger().setLevel(logging.INFO) elif o == '--debug': logging.getLogger().setLevel(logging.DEBUG) elif o == '--help': self.print_help() sys.exit() else: print('ERROR: Unknown option: %s' % o) self.print_help() sys.exit(1) if len(args) > 0: instance_name = args[0] instance = pki.server.PKIServerFactory.create(instance_name) if not force and instance.is_valid(): print('ERROR: Instance already exists: %s' % instance_name) sys.exit(1) instance.create(force)