Repository: djangopackages/djangopackages

Issue:
🐛  Issue in pypi_updater
Tonight, while testing I started seeing: 

```
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.8/site-packages/djclick/adapter.py", line 68, in run_from_argv
    exit_code = self.main(
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/djclick/adapter.py", line 50, in invoke
    return super(DjangoCommandMixin, self).invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/workspace/package/management/commands/pypi_updater.py", line 18, in command
    updated = package.fetch_pypi_data()
  File "/workspace/package/models.py", line 208, in fetch_pypi_data
    licenses = list(info['license'])
TypeError: 'NoneType' object is not iterable
```


Discussion:
@ShreehariVaasishta I'll take a quick look, but this came up tonight after merging and testing. 

Resolving patch:
diff --git a/package/models.py b/package/models.py
--- a/package/models.py
+++ b/package/models.py
@@ -185,7 +185,7 @@ def fetch_pypi_data(self, *args, **kwargs):
                     print((self, response.status_code))
             if response.status_code == 404:
                 if settings.DEBUG:
-                    print("BOOM!")
+                    print("BOOM! this package probably does not exist on pypi")
                     print((self, response.status_code))
                 return False
             release = json.loads(response.content)
@@ -205,18 +205,19 @@ def fetch_pypi_data(self, *args, **kwargs):
                     self.supports_python3 = True
 
             # add to versions
-            licenses = list(info['license'])
-            for index, license in enumerate(licenses):
-                if license or "UNKNOWN" == license.upper():
-                    for classifier in info['classifiers']:
-                        if classifier.startswith("License"):
-                            licenses[index] = classifier.strip().replace('License ::', '')
-                            licenses[index] = licenses[index].replace('OSI Approved :: ', '')
-                            break
-
-            version.licenses = licenses
-
-            #version stuff
+            if 'license' in info and info['license']:
+                licenses = list(info['license'])
+                for index, license in enumerate(licenses):
+                    if license or "UNKNOWN" == license.upper():
+                        for classifier in info['classifiers']:
+                            if classifier.startswith("License"):
+                                licenses[index] = classifier.strip().replace('License ::', '')
+                                licenses[index] = licenses[index].replace('OSI Approved :: ', '')
+                                break
+
+                version.licenses = licenses
+
+            # version stuff
             try:
                 url_data = release['urls'][0]
                 version.downloads = url_data['downloads']


Test patch: