sbg / sevenbridges-python

SevenBridges Python Api bindings
Apache License 2.0
46 stars 27 forks source link

Exception when downloading empty files #86

Closed Gig77 closed 7 years ago

Gig77 commented 7 years ago

It is not unusual for apps to output files that have no content, i.e. have length zero. Currently, the API throws the following exception when trying to download empty files:

File size is 0. Refusing to download.

While it is not difficult to work around this problem like shown below, it would be more convenient if the API tolerated downloading empty files.

def download_file(f, path):
    print("Downloading '%s' to '%s'" % (f.name, path))
    try:
        f.download(path, wait=True)
    except SbgError as e:
        if e.message == "File size is 0. Refusing to download.":
            open(path, 'a').close()
        else:
            raise e
SenadI commented 7 years ago

Fixed in 0.8.0