Mercurial > libervia-backend
comparison sat_frontends/jp/cmd_pubsub.py @ 3521:62f490eff51c
jp (pubsub, blog): `rename` commands implementation
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 01 May 2021 18:39:34 +0200 |
parents | be6d91572633 |
children | 04283582966f |
comparison
equal
deleted
inserted
replaced
3520:8acaf857cd0a | 3521:62f490eff51c |
---|---|
956 self.pubsub_item, | 956 self.pubsub_item, |
957 content_file_path, | 957 content_file_path, |
958 content_file_obj) = await self.getItemPath() | 958 content_file_obj) = await self.getItemPath() |
959 await self.runEditor("pubsub_editor_args", content_file_path, content_file_obj) | 959 await self.runEditor("pubsub_editor_args", content_file_path, content_file_obj) |
960 self.host.quit() | 960 self.host.quit() |
961 | |
962 | |
963 class Rename(base.CommandBase): | |
964 | |
965 def __init__(self, host): | |
966 base.CommandBase.__init__( | |
967 self, | |
968 host, | |
969 "rename", | |
970 use_pubsub=True, | |
971 pubsub_flags={C.NODE, C.SINGLE_ITEM}, | |
972 help=_("rename a pubsub item"), | |
973 ) | |
974 | |
975 def add_parser_options(self): | |
976 self.parser.add_argument( | |
977 "new_id", | |
978 help=_("new item id to use") | |
979 ) | |
980 | |
981 async def start(self): | |
982 try: | |
983 await self.host.bridge.psItemRename( | |
984 self.args.service, | |
985 self.args.node, | |
986 self.args.item, | |
987 self.args.new_id, | |
988 self.profile, | |
989 ) | |
990 except Exception as e: | |
991 self.disp( | |
992 f"can't rename item: {e}", error=True | |
993 ) | |
994 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
995 else: | |
996 self.disp("Item renamed") | |
997 self.host.quit(C.EXIT_OK) | |
961 | 998 |
962 | 999 |
963 class Subscribe(base.CommandBase): | 1000 class Subscribe(base.CommandBase): |
964 def __init__(self, host): | 1001 def __init__(self, host): |
965 base.CommandBase.__init__( | 1002 base.CommandBase.__init__( |
1980 subcommands = ( | 2017 subcommands = ( |
1981 Set, | 2018 Set, |
1982 Get, | 2019 Get, |
1983 Delete, | 2020 Delete, |
1984 Edit, | 2021 Edit, |
2022 Rename, | |
1985 Subscribe, | 2023 Subscribe, |
1986 Unsubscribe, | 2024 Unsubscribe, |
1987 Subscriptions, | 2025 Subscriptions, |
1988 Node, | 2026 Node, |
1989 Affiliations, | 2027 Affiliations, |