Upload: Clean up output. #283

Merged
merged 1 commit into from Feb 1, 2016

Conversation

Projects
None yet
3 participants
Member

kyrofa commented Jan 29, 2016

This PR fixes LP: #1538692 by change the OTP prompt to be more clear, and adding progress indicators. The upload output now looks something like this:

$ snapcraft upload

Uploading foo_1.7_amd64.snap [==============================================================] 100%
Checking package status... | # <-- this is an animated pinwheel indicator

Application uploaded successfully (as revision 6)
Please check out the application at: https://myapps.developer.ubuntu.com/dev/click-apps/1337/

Note that the test logger output is not cleaned here-- I bisected it back to 2329098 but I can't figure out what's causing it.

Collaborator

sergiusens commented Jan 30, 2016

Nice work! I'll try and review soon; don't worry about the unit test dilemma; I have it covered

@@ -47,7 +47,8 @@ def main(argv=None):
print('Enter your Ubuntu One SSO credentials.')
email = input('Email: ')
password = getpass.getpass('Password: ')
- otp = input('OTP: ')
+ otp = input('One-time password (just press enter if you don\'t use '
+ 'two-factor authentication): ')
@elopio

elopio Jan 30, 2016

Member

I like this!

@kyrofa

kyrofa Feb 1, 2016

Member

It's a bit verbose as we discussed, but I think it's a good intermediate solution until the uploader is smart enough to know whether or not it's actually required.

snapcraft/storeapi/_upload.py
@@ -33,6 +38,7 @@
)
+logging.getLogger("requests").setLevel(logging.WARNING)
@elopio

elopio Jan 30, 2016

Member

we generally call the logger file. Any special reason for using "requests" here instead?

@kyrofa

kyrofa Feb 1, 2016

Member

Ah, yeah notice I don't save the logger off here-- this line was for shutting up the requests lib. But perhaps this isn't the best place to put such a line?

@elopio

elopio Feb 1, 2016

Member

We have log.py, with a configure method.

snapcraft/storeapi/_upload.py
@@ -48,7 +54,8 @@ def upload(binary_filename, metadata_filename='', metadata=None, config=None):
return
name = match.groupdict()['name']
- logger.info('Uploading files...')
+ logger.info('')
@elopio

elopio Jan 30, 2016

Member

Why did you keep this one? I might be missing something, but I fail to see a reason for logging nothing :)

@kyrofa

kyrofa Feb 1, 2016

Member

This is only here to print a newline before the progress bar (it can't be contained within the progress bar or it keeps printing newlines). I just thought it looked a little nicer with some spacing.

@sergiusens

sergiusens Feb 1, 2016

Collaborator

I say do a print instead

@elopio

elopio Feb 1, 2016

Member

Yes, the progress goes to stdout, not to the log. Thanks for the change.

if revision:
- logger.info('Uploaded as revision %s.', revision)
+ message += ' (as revision {})'.format(revision)
snapcraft/storeapi/_upload.py
+ # progresses.
+ def upload_progress_callback(monitor):
+ if monitor.bytes_read <= binary_file_size:
+ progress_bar.update(monitor.bytes_read)
@elopio

elopio Jan 30, 2016

Member

Could you extract a function for this block? maybe call it get_upload_progress_callback, that receives the binary_filename and returns the callback func.

@kyrofa

kyrofa Feb 1, 2016

Member

I extracted it, but used functools.partial instead.

- for fd in files.values():
- fd.close()
+ # Close the open file
+ binary_file.close()
@elopio

elopio Jan 30, 2016

Member

@sergiusens copied the same block in #285. I prefer your removal of the confusing dictionary of 1 element, so I think this one should land first.

@sergiusens

sergiusens Feb 1, 2016

Collaborator

Right, this may need to be refactored to support multiple snap uploads when library snaps come (hope we can have something for next week).

@kyrofa

kyrofa Feb 1, 2016

Member

Ah, yeah we'll have to discuss how we want to do the progress bar in that case.

Member

elopio commented Jan 30, 2016

Nice work indeed.

Member

elopio commented Feb 1, 2016

lgtm

Upload: Clean up output.
Change the OTP prompt to be more clear, and add progress indicators.

LP: #1538692
LP: #1539814

Signed-off-by: Kyle Fazzari <kyle@canonical.com>
Collaborator

sergiusens commented Feb 1, 2016

👍

sergiusens added a commit that referenced this pull request Feb 1, 2016

@sergiusens sergiusens merged commit 0c37853 into snapcore:master Feb 1, 2016

1 of 2 checks passed

coverage/coveralls Coverage decreased (-0.04%) to 93.307%
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@kyrofa kyrofa deleted the kyrofa:bugfix/1538692/cleanup_upload_messages branch Feb 1, 2016

kalikiana pushed a commit to kalikiana/snapcraft that referenced this pull request Apr 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment