Skip to content

UnboundLocalError: cannot access local variable 'url' where it is not associated with a value #245

@mohsen-mahmoodi

Description

@mohsen-mahmoodi

Checklist

  • [ V] I have verified that I am using a GIS-enabled database, such as PostGIS or Spatialite.
  • [ V] I have verified that that issue exists against the master branch of django-cities.
  • [ V] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • [ V] I have reduced the issue to the simplest possible case.
  • [ X] I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)

Steps to reproduce

Configure CITIES_FILES for a pre-downloaded file without URL:

CITIES_FILES = {
        'country': {
            'filename': 'not-existing',
            'urls': []
        },
}

Run the import command:

python manage.py cities --import=country

Expected behavior

Exception: File not found and download failed: citiesxx500.zip [[]]

Actual behavior

UnboundLocalError: cannot access local variable 'url' where it is not associated with a value

Reason

In the file cities/management/commands/citities.py method def download(self, filekey):, we have a line to raise an exception like this:

raise Exception("File not found and download failed: {} [{}]".format(filename, url))

It should be changed to:

raise Exception("File not found and download failed: {} [{}]".format(filename, urls))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions