#!/usr/bin/env python3importos.pathimportasabimportasab.libraryimportasab.zookeeperasab.Config.add_defaults({"zookeeper":{# "servers": "zookeeper-1:2181,zookeeper-2:2181,zookeeper-3:2181","servers":"zookeeper-1:2181"},"library":{"azure_cache":"true",}})classMyApplication(asab.Application):def__init__(self):super().__init__(modules=[asab.zookeeper.Module])# Specify a locations of the default libraryasab.Config["library"]["providers"]='\n'.join([os.path.join(os.path.dirname(__file__),"library"),# "zk:///library",# "git+https://github.com/TeskaLabs/asab.git""azure+https://lmio.blob.core.windows.net/library"])self.LibraryService=asab.library.LibraryService(self,"LibraryService",)# Continue only if the library is ready# We need to wait till eg. Zookeeper is connectedself.PubSub.subscribe("Library.ready!",self.on_library_ready)asyncdefon_library_ready(self,event_name,library):items=awaitself.LibraryService.list("",recursive=True)print("# Library\n")foriteminitems:print(" *",item)ifitem.type=='item':itemio=awaitself.LibraryService.read(item.name)ifitemioisnotNone:withitemio:content=itemio.read()print(" - content: {} bytes".format(len(content)))else:print(" - N/A")# Item is likely disabledprint("\n===")self.stop()if__name__=='__main__':app=MyApplication()app.run()