Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print-summary: New script to dump a summary file #11

Merged
merged 1 commit into from
Mar 2, 2017

Conversation

cgwalters
Copy link
Member

@miabbott
Copy link
Contributor

miabbott commented Mar 2, 2017

Example output:

$ ./print-summary summary 
rhel-atomic-host/7/x86_64/standard → bfc591ba1a4395c6b8e54d34964b5df4a61e0d82d20cc1a2fd817855c7e2da5 (size=230)
delta: 69a74a4ed6954492a7c82279f6efe59bffb8952e95577f8359a6717d57a36774-bfc591ba1a4395c6b8e54d34964b05df4a61e0d82d20cc1a2fd817855c7e2da5
delta: 96826a0d917d7ff10f9fd0289581649f2ffbddd76f3b80efd3d95cc11915cacb-69a74a4ed6954492a7c82279f6efe59bffb8952e95577f8359a6717d57a36774
delta: 347c3f5eb641e69fc602878c646cf42c4bcd5d9f36847a1f24ff8f3ec80f17b1-90c9735becfff1c55c8586ae0f2c904bc0928f042cd4d016e9e0e2edd16e5e97
delta: 90c9735becfff1c55c8586ae0f2c904bc0928f042cd4d016e9e0e2edd16e5e97-42cfe1ca3305defb16dfd59cd0be5c539f19ea720dba861ed11e13941423ae86
delta: 42cfe1ca3305defb16dfd59cd0be5c539f19ea720dba861ed11e13941423ae86-96826a0d917d7ff10f9fd0289581649f2ffbddd76f3b80efd3d95cc11915cacb
delta: 96826a0d917d7ff10f9fd0289581649f2ffbddd76f3b80efd3d95cc11915cacb-bfc591ba1a4395c6b8e54d34964b05df4a61e0d82d20cc1a2fd817855c7e2da5

@miabbott
Copy link
Contributor

miabbott commented Mar 2, 2017

Works for me. Very useful! Thanks!

Copy link
Member

@dbnicholson dbnicholson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I left some python nitpicks, but this is good as is.

print-summary Outdated
action='store')
args = parser.parse_args()

bytedata = GLib.Bytes.new(open(args.path).read())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more python-y way to do this would be with a context manager:

with open(args.path) as f:
    bytedata = GLib.Bytes.new(f.read())

Then the file is closed immediately whether there's an error or not.

print-summary Outdated
d = GLib.Variant.new_from_bytes(typestr, bytedata, False)

refs = d[0]
other = d[1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more python-y way to write this is like:

refs, other = GLib.Variant.new_from_bytes(typestr, bytedata, False)

print-summary Outdated
refs = d[0]
other = d[1]

for (refname, refdata) in refs:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No parentheses needed here.

print-summary Outdated
continue
csum = ''
for v in csumarray:
csum += '%x' % v
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

csum = ''.join(['%x' % v for v in csumarray]) for a one liner.

print-summary Outdated
print("{} → {} (size={})".format(refname, csum, size))

deltas = other.get('ostree.static-deltas')
if deltas is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you pass an empty dict as the default to get, then you don't need to check for None and can just loop way:

deltas = others.get('ostree.static-deltas', {})

@cgwalters
Copy link
Member Author

Thanks @dbnicholson ! I've merged in all your changes.

@cgwalters cgwalters merged commit cc38e16 into ostreedev:master Mar 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants