Skip to content

Commit

Permalink
Modified how product data is stored to be able to pull in more meanin…
Browse files Browse the repository at this point in the history
…gful data from the FCC
  • Loading branch information
grvvy committed Jun 14, 2017
1 parent d7fba53 commit 8328647
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
6 changes: 2 additions & 4 deletions pyFCC/archive.py
Expand Up @@ -56,7 +56,7 @@ def lookup_fcc_id(app_id, product_id, FromRec = 1):
"FromRec" : FromRec
}
r = s.post(fcc_url + product_search_url, data=payload)
print("FCC id lookup complete")
print("FCC ID lookup complete")
return r.text

# format app_id and product_id correctly
Expand Down Expand Up @@ -84,7 +84,7 @@ def parse_search_results(html, tupIDdict):
if len(rs_tables) != 1:
raise Exception("Error, found %d results tables" % len(rs_tables))

rows = rs_tables[0].find_all("tr") # get all of the rows in the table
rows = rs_tables[0].find_all("tr")

for row in rows:
links = row.find_all("a", href=re.compile("/oetcf/eas/reports/ViewExhibitReport.cfm\?mode=Exhibits"))
Expand All @@ -94,8 +94,6 @@ def parse_search_results(html, tupIDdict):
cols = row.find_all("td")
ID = cols[11].get_text().strip()
grantee_code, product_code = parse_fcc_id(ID)
print("grantee_code:", grantee_code)
print("product_code:", product_code)

#links[0] = url, cols[11] = full ID, cols[14] = low_freq, cols[15] = high_freq
product_info = {
Expand Down
2 changes: 1 addition & 1 deletion pyFCC/fccDB.py
Expand Up @@ -54,7 +54,7 @@ def populate_products(product_test):
product_list = []
for key, value in product_test.items():
for row in value:
dbValues = (row['grantee_code'], row['product_code'], row['url'], row['high_freq'], row['low_freq'], row['version'])
dbValues = (row['grantee_code'], row['product_code'], row['url'], row['low_freq'], row['high_freq'], row['version'])
product_list.append(dbValues)

conn = sqlite3.connect('FCC.db')
Expand Down
9 changes: 4 additions & 5 deletions update_archive.py
Expand Up @@ -10,18 +10,17 @@
sys.exit(1)
for fcc_id in sys.argv[1:]:
print("Looking up FCC id: %s" % fcc_id)
productData = load_next(fcc_id)
product_data = load_next(fcc_id)

for key, value in productData.items():
for key, value in product_data.items():
for row in value:
print("Fetching result %d" % row['version'])
attachments = get_attachment_urls(row['url'])

# we don't want to create empty directories when there are no attachments
# no attachments happens when a company has stuff that is permanently confidential
if attachments:
dir_name = "%s/%s/%d" % (row['grantee_code'], row['product_code'], row['version'])
fetch_and_pack(attachments, dir_name, row['url'])

create_product_table()
populate_products(productData)
populate_products(product_data)

2 changes: 1 addition & 1 deletion update_grantees.py
Expand Up @@ -15,7 +15,7 @@
try:
grantees = parse_grantees()
except FileNotFoundError:
print("No local xml file found.")
print("No local xml file found")
print("Use '--help' for help")
print("Downloading grantee data...")
fetch_grantees_xml()
Expand Down

0 comments on commit 8328647

Please sign in to comment.