Skip to content

Commit 946a9d2

Browse files
committed
Update satdata generators to python3
1 parent 9a109eb commit 946a9d2

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

data/satdata/scripts/add-amsat.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
#
55
import os
66
import string
7-
import urllib
7+
import urllib.request
88

99

1010
webfile = 'https://www.amsat.org/amsat/ftp/keps/current/nasabare.txt'
1111
localfile = './in/amsat.txt'
12-
print 'Fetching ' + webfile + ' => ' + localfile
13-
urllib.urlretrieve (webfile, localfile)
12+
print('Fetching ' + webfile + ' => ' + localfile)
13+
urllib.request.urlretrieve (webfile, localfile)
1414

1515
tlefile = open(localfile, 'r')
1616
catfile = open('./out/amateur.cat', 'a')
@@ -29,7 +29,7 @@
2929
satfilename = './tmp/' + catnum + '.sat'
3030
if os.path.isfile(satfilename): continue
3131

32-
print " Adding " + catnum + " ..."
32+
print(" Adding " + catnum + " ...")
3333

3434
catfile.write(catnum+'\n')
3535

data/satdata/scripts/convert-celestrak.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
#
1414
import os
1515
import string
16-
import urllib
16+
import time
17+
import urllib.request
1718

1819
# Satellite groups
1920
groups = {
@@ -22,7 +23,6 @@
2223
"galileo" : "Galileo Nav.",
2324
"glo-ops" : "Glonass Operational",
2425
"gps-ops" : "GPS Operational",
25-
"iridium" : "Iridium",
2626
"iridium-NEXT" : "Iridium NEXT",
2727
"molniya" : "Molniya",
2828
"noaa" : "NOAA",
@@ -89,21 +89,22 @@
8989
"43017" : "AO-91"
9090
}
9191

92-
urlprefix = "http://celestrak.com/NORAD/elements/"
92+
urlprefix = "https://celestrak.org/NORAD/elements/gp.php?GROUP="
93+
urlsuffix = "&FORMAT=tle"
9394

94-
95-
for group, name in groups.iteritems():
96-
webfile = urlprefix + group + ".txt"
95+
for group, name in groups.items():
96+
webfile = urlprefix + group + urlsuffix
9797
localfile = "./in/" + group + ".txt"
98-
print "Fetching " + webfile + " => " + localfile
99-
urllib.urlretrieve (webfile, localfile)
98+
print("Fetching " + webfile + " => " + localfile)
99+
urllib.request.urlretrieve (webfile, localfile)
100+
time.sleep(30)
100101

101102
### CHK ###
102103

103104
# For each input file
104-
for group, name in groups.iteritems():
105+
for group, name in groups.items():
105106

106-
print name+':'
107+
print(name+':')
107108

108109
# open TLE file for reading
109110
tlefile = open('./in/'+group+'.txt', 'r')
@@ -124,7 +125,7 @@
124125

125126
# catalog number; strip leading zeroes
126127
catnum = line2[2:7].lstrip('0')
127-
print " ... "+catnum
128+
print(" ... " + catnum)
128129

129130
# add satellite to category
130131
catfile.write(catnum+'\n')

0 commit comments

Comments
 (0)