Skip to content

Commit

Permalink
Don't crash script when some controller configs don't have URLs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr_Goldberg committed Aug 16, 2022
1 parent 3c1fc7f commit 7e14095
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions scripts/generate_emu_config.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,17 @@ def download_published_file(client, published_file_id, backup_directory):
with open(os.path.join(backup_directory, "info.txt"), "w") as f:
f.write(str(ugc_info.body))

with urllib.request.urlopen(file_details.file_url) as response:
data = response.read()
with open(os.path.join(backup_directory, file_details.filename.replace("/", "_").replace("\\", "_")), "wb") as f:
f.write(data)
return data
return None
if len(file_details.file_url) > 0:
with urllib.request.urlopen(file_details.file_url) as response:
data = response.read()
with open(os.path.join(backup_directory, file_details.filename.replace("/", "_").replace("\\", "_")), "wb") as f:
f.write(data)
return data
return None
else:
print("Could not download file", published_file_id, "no url (you can ignore this if the game doesn't need a controller config)")
return None


def get_inventory_info(client, game_id):
return client.send_um_and_wait('Inventory.GetItemDefMeta#1', {
Expand Down

0 comments on commit 7e14095

Please sign in to comment.