Skip to content

Commit

Permalink
Updated SATNOGs db fetch script to work with Python 3
Browse files Browse the repository at this point in the history
Fixes la1k#98.  Changes include using correct urllib,
updating sorted function call, and ensuring
temp files are opened in text mode.
  • Loading branch information
dalenkruse committed Dec 1, 2021
1 parent e548037 commit 5076654
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions utils/fetch_satnogs_db.py.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env python

#This is a script that fetches transponder data from db.satnogs.org and parses it to flyby transponder data.
import urllib2
import json
import sys
import tempfile
from urllib.request import urlopen
from distutils import spawn
from subprocess import call
from operator import itemgetter
Expand All @@ -21,16 +21,16 @@ else:
sys.exit();

#Step 1: Fetch JSON transponder information from SatNOGS db.
request = urllib2.urlopen("https://db.satnogs.org/api/transmitters")
request = urlopen("https://db.satnogs.org/api/transmitters")
data = json.load(request)

# Order data by norad_cat_id entry
sorteddata = sorted(data, key=itemgetter('norad_cat_id'))
sorteddata = sorted(data, key=lambda x: x['norad_cat_id'] or 0)

# Open output file
db = None;
if not named_file:
db = tempfile.NamedTemporaryFile();
db = tempfile.NamedTemporaryFile(mode='w+t')
else:
db = open(named_file, "w");

Expand Down

0 comments on commit 5076654

Please sign in to comment.