Last active
December 1, 2017 15:05
-
-
Save dleehr/fc073a8977ef813f3c1afb1d6ff8aeb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Displays the file size of a DDS Project by ID | |
Loads config/credentials from ~/.ddsclient | |
Usage: python3 get_project_size.py c8f46e4d-635a-441a-b309-375818f1f7c1 | |
""" | |
import sys | |
from ddsc.config import create_config | |
from ddsc.core.remotestore import RemoteStore | |
def main(args=None): | |
config = create_config() | |
remote_store = RemoteStore(config) | |
ds = remote_store.data_service | |
project_id = args[1] | |
children = ds.get_project_children(project_id, '').json().get('results') | |
files = [child for child in children if child['kind'] == 'dds-file'] | |
total = 0 | |
for file in files: | |
file_size = file['current_version']['upload']['size'] | |
print('{}\t{}'.format(file_size, file['name'])) | |
total += file_size | |
print() | |
print('Project {}: {} bytes ({} gigabytes)'.format(project_id, total, total / (1024 * 1024 * 1024))) | |
if __name__ == '__main__': | |
main(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment