Search code examples
pythonbitbucketbitbucket-api

How to download zip from Bitbucket by using Bitbucket-api and Python on Windows10


I have searched some code about bitbucket-api (here)

How to download "zip" by using Bitbucket-api and Python on Windows10 ?

I use :

Python 3.5.0

Bitbucket-api 0.5.0 (from pip install bitbucket-api )

Windows 10

-----update
Do I miss parameter in bb.repository.archive() ?

>>>from bitbucket.bitbucket import Bitbucket
>>>USERNAME = 'CCC'
>>>PASSWORD = 'BBB'    
>>>bb = Bitbucket(USERNAME, PASSWORD, repo_name_or_slug="Py-Bitbucket-api")
>>>success, result = bb.repository.get()
>>>print (bb.repository.get())
True{......}
>>>success, archive_path = bb.repository.archive()
>>> print (success, archive_path)
True C:\....\Temp\tmp_zxpa_14

It download some tmp files.(tmp_zxpa_14....)

But it not a zip .

Do I miss some parameter?

BTW

I wandt to download one of file in my repo.

Can Bitbucket-api specify the file to download? How to modify my code?


Solution

  • you can do it like

    # Access a public repository
    bb = Bitbucket(USERNAME, repo_name_or_slug="public_repository")
    # Access a private repository
    bb = Bitbucket(USERNAME, PASSWORD, repo_name_or_slug="private_repository")
    
    # Download a repository as an archive
    success, archive_path = bb.repository.archive()
    

    Let me know if you need any clarification.