Load collection filter from file
This commit is contained in:
parent
7a42938523
commit
a1f4a8207e
|
@ -29,7 +29,7 @@ def main():
|
||||||
)
|
)
|
||||||
|
|
||||||
client.check_logged_in()
|
client.check_logged_in()
|
||||||
start_favro_fuse(client)
|
start_favro_fuse(client, secrets.favro_collection_filter())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -215,7 +215,7 @@ class FavroClient:
|
||||||
def _invalidate_cache(self, card_id: CardId) -> None:
|
def _invalidate_cache(self, card_id: CardId) -> None:
|
||||||
card = self.card_cache.remove(card_id)
|
card = self.card_cache.remove(card_id)
|
||||||
if card:
|
if card:
|
||||||
self.session.card_cache.delete(
|
self.session.cache.delete(
|
||||||
requests=[self._get_cards_prepared_request(seq_id=card.seq_id)],
|
requests=[self._get_cards_prepared_request(seq_id=card.seq_id)],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -213,6 +213,8 @@ class FavroFuse(fuse.Fuse):
|
||||||
return st
|
return st
|
||||||
|
|
||||||
def _is_allowed_collection(self, item: CollectionFileSystemItem) -> bool:
|
def _is_allowed_collection(self, item: CollectionFileSystemItem) -> bool:
|
||||||
|
if self.collection_filter is None:
|
||||||
|
return True
|
||||||
return item.collection_name in self.collection_filter
|
return item.collection_name in self.collection_filter
|
||||||
|
|
||||||
def readdir(self, path: str, offset: int) -> Iterator[fuse.Direntry]:
|
def readdir(self, path: str, offset: int) -> Iterator[fuse.Direntry]:
|
||||||
|
@ -347,10 +349,8 @@ Userspace hello example
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def start_favro_fuse(favro_client: FavroClient):
|
def start_favro_fuse(favro_client: FavroClient, collection_filter: frozenset[str]):
|
||||||
logger.info('Starting favro FUSE')
|
logger.info('Starting favro FUSE with collection filter: %s', collection_filter)
|
||||||
collection_filter = frozenset(['Platform'])
|
|
||||||
# TODO:
|
|
||||||
server = FavroFuse(
|
server = FavroFuse(
|
||||||
favro_client=favro_client,
|
favro_client=favro_client,
|
||||||
formatter=CardFileFormatter(),
|
formatter=CardFileFormatter(),
|
||||||
|
|
|
@ -17,3 +17,13 @@ def favro_username():
|
||||||
|
|
||||||
def favro_password():
|
def favro_password():
|
||||||
return secrets.load_or_fail('FAVRO_PASSWORD')
|
return secrets.load_or_fail('FAVRO_PASSWORD')
|
||||||
|
|
||||||
|
|
||||||
|
def favro_collection_filter() -> frozenset[str]:
|
||||||
|
loaded = secrets.load('FAVRO_COLLECTION_FILTER')
|
||||||
|
if loaded is None:
|
||||||
|
return None
|
||||||
|
values = loaded.strip().split('\n')
|
||||||
|
values = [v.strip() for v in values]
|
||||||
|
values = [v for v in values if v]
|
||||||
|
return frozenset(values)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user