diff --git a/src/oebuild/app/plugins/bitbake/bitbake.py b/src/oebuild/app/plugins/bitbake/bitbake.py index a92ad408db3c98b2a3132b5cb8b7e88d1631f075..e9fc70703e217a92171d12ac37ccd9a427c1873c 100644 --- a/src/oebuild/app/plugins/bitbake/bitbake.py +++ b/src/oebuild/app/plugins/bitbake/bitbake.py @@ -68,7 +68,7 @@ class Bitbake(OebuildCommand): and the fourth step to enter the build environment ''' if '-h' in unknown or '--help' in unknown: - args.parse_args(unknown) + self.print_help_msg() return command = self._get_command(unknow=unknown) diff --git a/src/oebuild/app/plugins/clear/clear.py b/src/oebuild/app/plugins/clear/clear.py index 80bc4138884d0f11ed0659ead2cfc9e3948f477c..8b6733c72a065dd67a83e8f77c42bdf10af088d4 100644 --- a/src/oebuild/app/plugins/clear/clear.py +++ b/src/oebuild/app/plugins/clear/clear.py @@ -51,8 +51,12 @@ class Clear(OebuildCommand): return parser def do_run(self, args: argparse.Namespace, unknown = None): + # perpare parse help command + if self.pre_parse_help(args, unknown): + return + args = args.parse_args(unknown) - + if args.item == "docker": self.clear_docker() @@ -68,7 +72,7 @@ class Clear(OebuildCommand): build_dir = os.path.join(self.configure.build_dir(), build_dir) if os.path.exists(os.path.join(build_dir,".env")): env_list.append(os.path.join(build_dir,".env")) - + # traversal every env file and get container_id, and then try to stop it and rm it for env in env_list: env_conf = oebuild_util.read_yaml(pathlib.Path(env)) @@ -77,10 +81,10 @@ class Clear(OebuildCommand): container = self.client.get_container(container_id=container_id) DockerProxy().stop_container(container=container) DockerProxy().delete_container(container=container) - logger.info(f"delete container: {container.short_id} successful") + logger.info("delete container: %s successful",container.short_id) except: continue - + # get all container which name start with oebuild and delete it, # in case when user rm build directory then legacy container # containers = self.client.get_all_container() diff --git a/src/oebuild/app/plugins/generate/generate.py b/src/oebuild/app/plugins/generate/generate.py index 62bcf8c6b63192357286842d4f9c7e41a34b1ac7..bea902b65be10b86746405e994d299c1cacf7e69 100644 --- a/src/oebuild/app/plugins/generate/generate.py +++ b/src/oebuild/app/plugins/generate/generate.py @@ -139,6 +139,10 @@ class Generate(OebuildCommand): return parser def do_run(self, args: argparse.Namespace, unknown = None): + # perpare parse help command + if self.pre_parse_help(args, unknown): + return + args = args.parse_args(unknown) if not self.configure.is_oebuild_dir(): diff --git a/src/oebuild/app/plugins/init/init.py b/src/oebuild/app/plugins/init/init.py index 02ae4400acbe56d96b896b8bbe801ffb2159f340..c71bb79bae5ef6a03b43bb2c49cc3864db1d05ef 100644 --- a/src/oebuild/app/plugins/init/init.py +++ b/src/oebuild/app/plugins/init/init.py @@ -66,7 +66,11 @@ class Init(OebuildCommand): ''' detach target dicrectory if finished init, if inited, just put out err msg and exit ''' - iargs = args + + # perpare parse help command + if self.pre_parse_help(args, unknown): + return + args = args.parse_args(unknown) if self.configure.is_oebuild_dir(): @@ -78,7 +82,7 @@ class Init(OebuildCommand): if args.directory is None: logger.error("'oebuild init' need param directory") logger.info("\noebuild init help:") - self.print_help(iargs) + self.print_help_msg() return if not self.init_workspace(args.directory): @@ -120,6 +124,7 @@ please execute the follow commands next self.oebuild_dir = self.create_oebuild_directory(directory) self.copy_config_file(self.oebuild_dir) + self.copy_compile_file(self.oebuild_dir) self.src_dir = self.create_src_directory(directory) return True @@ -159,14 +164,14 @@ please execute the follow commands next shutil.copyfile(config, os.path.join(updir, CONFIG)) except FileNotFoundError: logger.error("mkdir config faild") - + @staticmethod def copy_compile_file(updir : str): ''' copy oebuild compile.yaml.sample to some directory ''' try: - compile = oebuild_util.get_compile_yaml_dir() - shutil.copyfile(compile, os.path.join(updir, COMPILE_YAML)) + compil = oebuild_util.get_compile_yaml_dir() + shutil.copyfile(compil, os.path.join(updir, COMPILE_YAML)) except FileNotFoundError: logger.error("mkdir compile.yaml.sample faild") diff --git a/src/oebuild/app/plugins/manifest/manifest.py b/src/oebuild/app/plugins/manifest/manifest.py index e5502329e6e3941d61a3101fb23ec37efa0cf3d1..f20b9e9cea1bed758b246d7ca2f8e6315a18e720 100644 --- a/src/oebuild/app/plugins/manifest/manifest.py +++ b/src/oebuild/app/plugins/manifest/manifest.py @@ -83,6 +83,10 @@ class Manifest(OebuildCommand): return parser def do_run(self, args: argparse.Namespace, unknown = None): + # perpare parse help command + if self.pre_parse_help(args, unknown): + return + args = args.parse_args(unknown) if not self.configure.is_oebuild_dir(): @@ -101,7 +105,7 @@ class Manifest(OebuildCommand): local_dir = os.path.join(self.configure.source_dir(), repo_dir) try: repo = Repo(local_dir) - remote_url = repo.remote().url + remote_url = repo.remote("upstream").url version = repo.head.commit.hexsha except git.GitError: continue @@ -179,7 +183,7 @@ class Manifest(OebuildCommand): else: continue if remote is None: - remote_name = "manifest" + remote_name = "upstream" remote = git.Remote.add(repo = repo, name = remote_name, url = value['remote_url']) try: repo.git.checkout(value['version']) diff --git a/src/oebuild/app/plugins/update/update.py b/src/oebuild/app/plugins/update/update.py index e90010a259ced946814ffc89fe228ae79754f1d1..82eae1d8e5f59df5be567e618648c331cf2837c7 100644 --- a/src/oebuild/app/plugins/update/update.py +++ b/src/oebuild/app/plugins/update/update.py @@ -68,6 +68,10 @@ class Update(OebuildCommand): ''' update action rely on directory which has initd, so check it first ''' + # perpare parse help command + if self.pre_parse_help(args, unknown): + return + args = args.parse_args(unknown) if not self.configure.is_oebuild_dir(): diff --git a/src/oebuild/command.py b/src/oebuild/command.py index 8af8072d26180cc0af62de7bcef08959606376b4..07d22bf86c44def214ecc9f0b1f2f56163794fe2 100644 --- a/src/oebuild/command.py +++ b/src/oebuild/command.py @@ -35,11 +35,21 @@ class OebuildCommand(ABC): The executing body, each inherited class will register the executor with the executor body for execution ''' + self.do_run(args=args, unknown=unknown) + + def pre_parse_help(self, args: argparse.ArgumentParser, unknown: List[str]): + ''' + Whether to parse the help command in advance, designed to adapt to some extended + scenarios that do not require command resolution, generally the function is placed + in the front of the do_run to execute, if it returns true, it means that it is a + help command, then there is no need to continue to execute, otherwise the specific + function content is executed + ''' pars = args.parse_args(unknown) if pars.help: self.print_help_msg() - return - self.do_run(args=args, unknown=unknown) + return True + return False def add_parser(self, parser_adder: argparse.ArgumentParser): ''' diff --git a/src/oebuild/version.py b/src/oebuild/version.py index bc4863654885ab18a294a4af43a8a19ed54af74b..d705e18486ec6c342aa62aa5c142fe5ff79bc4c7 100644 --- a/src/oebuild/version.py +++ b/src/oebuild/version.py @@ -10,4 +10,4 @@ MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v2 for more details. ''' -__version__ = '0.0.25' +__version__ = '0.0.26'