Repository: openstates/openstates-scrapers

Issue:
AZ failing since at least 2018-04-26
AZ has been failing since 2018-04-26

Based on automated runs it appears that AZ has not run successfully in 2 days (2018-04-26).


```
  02:48:26 INFO scrapelib: GET - https://apps.azleg.gov/api/Keyword/?billStatusId=70889
02:48:27 INFO pupa: save bill HCR2041 in 53rd-2nd-regular as bill_5d68f44a-49ef-11e8-90dc-02a421fbb6ce.json
02:48:27 INFO scrapelib: GET - https://apps.azleg.gov/api/Bill/?billNumber=HCR2042&sessionId=119&legislativeBody=H
02:48:28 INFO scrapelib: GET - https://apps.azleg.gov/api/DocType/?billStatusId=70890
02:48:29 INFO scrapelib: GET - https://apps.azleg.gov/api/BillSponsor/?id=70890
02:48:30 INFO scrapelib: GET - https://apps.azleg.gov/api/Keyword/?billStatusId=70890
02:48:31 INFO pupa: save bill HCR2042 in 53rd-2nd-regular as bill_5fcd61a8-49ef-11e8-90dc-02a421fbb6ce.json
02:48:31 INFO scrapelib: GET - https://apps.azleg.gov/api/Bill/?billNumber=HCR2043&sessionId=119&legislativeBody=H
02:48:32 INFO scrapelib: GET - https://apps.azleg.gov/api/DocType/?billStatusId=70896
02:48:33 INFO scrapelib: GET - https://apps.azleg.gov/api/BillSponsor/?id=70896
02:48:34 INFO scrapelib: GET - https://apps.azleg.gov/api/Keyword/?billStatusId=70896
02:48:35 INFO pupa: save bill HCR2043 in 53rd-2nd-regular as bill_622e455c-49ef-11e8-90dc-02a421fbb6ce.json
02:48:35 INFO scrapelib: GET - https://apps.azleg.gov/api/Bill/?billNumber=HCR2044&sessionId=119&legislativeBody=H
02:48:36 INFO scrapelib: GET - https://apps.azleg.gov/api/DocType/?billStatusId=70904
02:48:37 INFO scrapelib: GET - https://apps.azleg.gov/api/BillSponsor/?id=70904
02:48:38 INFO scrapelib: GET - https://apps.azleg.gov/api/Keyword/?billStatusId=70904
02:48:39 INFO pupa: save bill HCR2044 in 53rd-2nd-regular as bill_64915ec4-49ef-11e8-90dc-02a421fbb6ce.json
02:48:39 INFO scrapelib: GET - https://apps.azleg.gov/api/Bill/?billNumber=HCR2045&sessionId=119&legislativeBody=H
02:48:40 INFO scrapelib: GET - https://apps.azleg.gov/api/DocType/?billStatusId=70908
02:48:41 INFO scrapelib: GET - https://apps.azleg.gov/api/BillSponsor/?id=70908
02:48:42 INFO scrapelib: GET - https://apps.azleg.gov/api/Keyword/?billStatusId=70908
02:48:43 INFO pupa: save bill HCR2045 in 53rd-2nd-regular as bill_66f384da-49ef-11e8-90dc-02a421fbb6ce.json
02:48:43 INFO scrapelib: GET - https://apps.azleg.gov/api/Bill/?billNumber=HCR2046&sessionId=119&legislativeBody=H
02:48:44 INFO scrapelib: GET - https://apps.azleg.gov/api/DocType/?billStatusId=70907
02:48:45 INFO scrapelib: GET - https://apps.azleg.gov/api/BillSponsor/?id=70907
Traceback (most recent call last):
  File "/opt/openstates/venv-pupa//bin/pupa", line 11, in <module>
    load_entry_point('pupa', 'console_scripts', 'pupa')()
  File "/opt/openstates/venv-pupa/src/pupa/pupa/cli/__main__.py", line 68, in main
    subcommands[args.subcommand].handle(args, other)
  File "/opt/openstates/venv-pupa/src/pupa/pupa/cli/commands/update.py", line 260, in handle
    return self.do_handle(args, other, juris)
  File "/opt/openstates/venv-pupa/src/pupa/pupa/cli/commands/update.py", line 305, in do_handle
    report['scrape'] = self.do_scrape(juris, args, scrapers)
  File "/opt/openstates/venv-pupa/src/pupa/pupa/cli/commands/update.py", line 173, in do_scrape
    report[scraper_name] = scraper.do_scrape(**scrape_args)
  File "/opt/openstates/venv-pupa/src/pupa/pupa/scrape/base.py", line 111, in do_scrape
    for obj in self.scrape(**kwargs) or []:
  File "/opt/openstates/openstates/openstates/az/bills.py", line 248, in scrape
    yield from self.scrape_bill(chamber, session, bill_id, session_id)
  File "/opt/openstates/openstates/openstates/az/bills.py", line 44, in scrape_bill
    self.scrape_sponsors(bill, internal_id)
  File "/opt/openstates/openstates/openstates/az/bills.py", line 96, in scrape_sponsors
    if 'FullName' in sponsor['Legislator']:
UnboundLocalError: local variable 'sponsor' referenced before assignment
loaded Open States pupa settings...
az (scrape, import)
  people: {}
  bills: {}
  committees: {}
```

Visit http://bobsled.openstates.org for more info.



Discussion:
On it.

Resolving patch:
diff --git a/openstates/az/bills.py b/openstates/az/bills.py
--- a/openstates/az/bills.py
+++ b/openstates/az/bills.py
@@ -92,20 +92,20 @@ def scrape_sponsors(self, bill, internal_id):
             else:
                 sponsor_type = 'cosponsor'
 
-        # Some older bills don't have the FullName key
-        if 'FullName' in sponsor['Legislator']:
-            sponsor_name = sponsor['Legislator']['FullName']
-        else:
-            sponsor_name = "{} {}".format(
-                sponsor['Legislator']['FirstName'],
-                sponsor['Legislator']['LastName'],
+            # Some older bills don't have the FullName key
+            if 'FullName' in sponsor['Legislator']:
+                sponsor_name = sponsor['Legislator']['FullName']
+            else:
+                sponsor_name = "{} {}".format(
+                    sponsor['Legislator']['FirstName'],
+                    sponsor['Legislator']['LastName'],
+                )
+            bill.add_sponsorship(
+                classification=str(sponsor_type),
+                name=sponsor_name,
+                entity_type='person',
+                primary=sponsor_type == 'primary'
             )
-        bill.add_sponsorship(
-            classification=str(sponsor_type),
-            name=sponsor_name,
-            entity_type='person',
-            primary=sponsor_type == 'primary'
-        )
 
     def scrape_subjects(self, bill, internal_id):
         # https://apps.azleg.gov/api/Keyword/?billStatusId=68149


Test patch: