Skip to content

Commit

Permalink
fixed bug in csv input type when a line had no image link
Browse files Browse the repository at this point in the history
  • Loading branch information
Greenwolf committed Jun 14, 2019
1 parent 34bdcc8 commit 9f427ba
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions social_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,15 +916,18 @@ def loadPage(client, url, data=None):
os.makedirs('temp-targets')
filereader = csv.reader(open('temp.csv', 'rb'), delimiter=",")
for full_name, person_image in filereader:
full_name = encoding.smart_str(full_name, encoding='ascii', errors='ignore')
person_image = encoding.smart_str(person_image, encoding='ascii', errors='ignore')
#print person_image
urllib.urlretrieve(person_image, "temp-targets/" + full_name + ".jpg")
first_name = full_name.split(" ")[0]
last_name = full_name.split(" ",1)[1]
person = Person(first_name, last_name, full_name, "temp-targets/" + full_name + ".jpg")
person.person_imagelink = person_image
peoplelist.append(person)
try:
full_name = encoding.smart_str(full_name, encoding='ascii', errors='ignore')
person_image = encoding.smart_str(person_image, encoding='ascii', errors='ignore')
#print person_image
urllib.urlretrieve(person_image, "temp-targets/" + full_name + ".jpg")
first_name = full_name.split(" ")[0]
last_name = full_name.split(" ",1)[1]
person = Person(first_name, last_name, full_name, "temp-targets/" + full_name + ".jpg")
person.person_imagelink = person_image
peoplelist.append(person)
except Exception as e:
print("Error getting image or creating person structure, skipping:" + full_name)

#remove this when fixed downloading
#sys.exit(1)
Expand Down

0 comments on commit 9f427ba

Please sign in to comment.