-
Notifications
You must be signed in to change notification settings - Fork 120
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
Library layer - first part #11
Conversation
@bwbeach please review to confirm that our views are still aligned. Console version should not be affected. Example usage of library: >>> import b2
>>> api = b2.B2Api(b2.StoredAccountInfo())
>>> for b in api.list_buckets():
... print b.name
...
test234
>>> b = api.get_bucket_by_name('foobar')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "b2.py", line 305, in get_bucket_by_name
raise NonExistentBucket(bucket_name)
b2.NonExistentBucket: No such bucket: foobar
>>> |
@bwbeach this is blocking for me: I don't want to put a few dozen hours into it without first making sure that my way of doing it is fine for you (and will get merged). Could you please take a quick look at it by tomorrow EOD? |
Pawel, Sorry for the delay. Just got back traveling this weekend. Your changes look good, and I like the direction you're taking. Just a few comments: What's the reason for mapping bucket types to 1001 and 1002? It might be easier when debugging just to use the strings names internally.
|
The thing with bucket types is a generic pattern for enum in python. You might be right, it may not be very useful here, I'll make a note to look at it again at the end and remove it if it is still not useful. Bucket types is a defense against user having to check if fields of bucket are None everywhere, so that any operation on bucket is contained in the class rather than splattered in every place someone needs to use it... However it is clear that you are working with b2 much longer than me - I can not think of any operations that would need to be extracted like that. I added a note to review and simplify that as well. Than you very much for the review, now I can proceed. |
* origin/master: Add retry logic for uploads, to upload to a different storage pod if the chosen one was busy. Bump version number. Add comment about version number conventions. Conflicts: b2
* origin/master: Bump version number. Check that file is not too big before trying to upload. Compute sha1 of uploaded file only once, even when retrying upload. Support external SHA1 sum Conflicts: b2
api = b2.B2Api()
bucket = api.get_bucket_by_name('foobar')
api.delete_bucket(bucket) or api = b2.B2Api()
bucket = api.get_bucket_by_name('foobar')
bucket.delete() ? I think the first version is better, because |
This makes it easier to use the api, for example: api = B2Api()
fd38c4f
to
0bb4430
Compare
|
@bwbeach why does |
This is needed for bucket methods which need to call the API
* origin/master: Rename class stream_with_progress to StreamWithProgress, following PEP 8 conventions. Update shebang line to work with default OSX Python installation. Remove the option to disable progress bar during uploads Add a progress bar for downloads Add a progress bar for uploads Sort imports Conflicts: b2
Passing the file name into |
Each command will now print helpful info if you get its arguments wrong, without spewing out info about all commands.
* master: Add --quiet option to upload_file. More complete tests. Add tests for all options to "b2 ls". Add tester for b2: test_b2_command_line.py. Conflicts: b2
@bwbeach I am removing |
Sounds good.
|
How close are you on #11? If you're close, I could wait on #20. I'll go ahead an pull in #20 later today if I don't hear from you.
|
I am close. I will finish tonight. It is my fault that #20 will have conflicts and I can see that you intend to merge it in, so in order to avoid putting additional burden on @cederberg, I will try to use git magic to merge it and resolve the conflicts myself. It has to be in the right order with my commits or otherwise the conflict will be massive. |
@bwbeach there is code to cope with the fact that the API has returned a dictionary after uploading a file, but the dictionary did not contain the |
I think that was an unclear way of checking whether an error was returned, but there are better checks for it now. Feel free to remove it and clean up the code.
|
2c636c6
to
c3050f0
Compare
I'll wait until you're done.
|
I started work on IMO it is not a good idea to merge those new changes with the previous changes. Therefore lets execute plan B: merge it as it currently is and do the remaining items in other pull requests. I will coordinate the merging and testing of #20 in its pull request. |
just a moment, test failure |
It was a bad git add, I fixed it. Ready for merge. |
This PR is WIP (created for easy early review). Please do not merge it before it is ready.
This will eventually implement #4.
Task list:
Unfinished items will be done in another PR