mirror of https://github.com/CIRCL/lookyloo
new: Simple tool to check if a file exists on s3fs
parent
050ece57c8
commit
9f293c70c6
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
|
||||||
|
import s3fs
|
||||||
|
|
||||||
|
from lookyloo.default import get_config
|
||||||
|
|
||||||
|
|
||||||
|
def check_path(path: str):
|
||||||
|
s3fs_config = get_config('generic', 's3fs')
|
||||||
|
s3fs_client = s3fs.S3FileSystem(key=s3fs_config['config']['key'],
|
||||||
|
secret=s3fs_config['config']['secret'],
|
||||||
|
endpoint_url=s3fs_config['config']['endpoint_url'])
|
||||||
|
|
||||||
|
s3fs_bucket = s3fs_config['config']['bucket_name']
|
||||||
|
return s3fs_client.info(f'{s3fs_bucket}/{path}')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
logger = logging.getLogger('Lookyloo - S3FS checker')
|
||||||
|
parser = argparse.ArgumentParser(description='Check the status of a file/directory on s3fs.')
|
||||||
|
parser.add_argument('--path', help='The path to check on s3fs. Should always start with Year/Month.')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
path_info = check_path(args.path)
|
||||||
|
print(json.dumps(path_info, indent=2))
|
Loading…
Reference in New Issue