def getWCS(key):
logon = requests.post('http://nova.astrometry.net/api/login', data={'request-json': json.dumps({"apikey": key})})
session = logon.json()['session'] # Session number
#MODIFIED CLIENT.PY CODE
import random
boundary_key = ''.join([random.choice('0123456789') for i in range(19)])
boundary = '===============%s==' % boundary_key
headers = {'Content-Type':
'multipart/form-data; boundary="%s"' % boundary}
data_pre = (
'--' + boundary + '\n' +
'Content-Type: text/plain\r\n' +
'MIME-Version: 1.0\r\n' + # TypeError: can only concatenate str (not "module") to str
'Content-disposition: form-data; name="request-json"\r\n' +
'\r\n' +
json + '\n' +
'--' + boundary + '\n' +
'Content-Type: application/octet-stream\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-disposition: form-data; name="file"; filename="files/DW Cnc V-20200215at080749_-25-1X1-300-V.fts"\r\n\r\n')
data_post = (
'\n' + '--' + boundary + '--\n')
data = data_pre.encode() + data_post.encode()
request = requests.get(url='http://nova.astrometry.net/api/upload', headers=headers, data=data)
print(request.json())
subid = request.json()['subid']
joburl = 'http://nova.astrometry.net/new_fits_file/' + subid
#print(joburl)
results = requests.get(joburl, allow_redirects=True)
#print(results.headers.get('content-type'))
open('file.fits', 'wb').write(results.content)
json + '\n' +
'--' + boundary + '\n' +
"
--
You received this message because you are subscribed to the Google Groups "astrometry" group.
To unsubscribe from this group and stop receiving emails from it, send an email to astrometry+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/astrometry/c66e9fa3-f810-417b-af29-421246b1346co%40googlegroups.com.
def getWCS(key):
logon = requests.post('http://nova.astrometry.net/api/login', data={'request-json': json.dumps({"apikey": key})})
session = logon.json()['session'] # Session number
#MODIFIED CLIENT.PY CODE
python2json = json.dumps
args = {}
if session is not None:
args.update({'session': session})
print('Python:', args)
j = python2json(args)
print('Sending json:', j)
url = 'http://nova.astrometry.net/api/upload'
print('Sending to URL:', url)
import random
boundary_key = ''.join([random.choice('0123456789') for i in range(19)])
boundary = '===============%s==' % boundary_key
headers = {'Content-Type':
'multipart/form-data; boundary="%s"' % boundary}
data_pre = (
'--' + boundary + '\n' +
'Content-Type: text/plain\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-disposition: form-data; name="request-json"\r\n' +
'\r\n' +
j + '\n' +
'--' + boundary + '\n' +
'Content-Type: application/octet-stream\r\n' +
'MIME-Version: 1.0\r\n' +
'Content-disposition: form-data; name="file"; filename="files/DW Cnc V-20200215at080749_-25-1X1-300-V.fts"\r\n\r\n')
data_post = (
'\n' + '--' + boundary + '--\n')
data = data_pre.encode() + data_post.encode()
request = requests.get(url=url, headers=headers, data=data)
print(request.json()) #Prints "{'status': 'error', 'errormessage': 'no json'}
subid = request.json()['subid'] #KeyError: 'subid'
joburl = 'http://nova.astrometry.net/new_fits_file/' + subid
#print(joburl)
results = requests.get(joburl, allow_redirects=True)
#print(results.headers.get('content-type'))
open('file.fits', 'wb').write(results.content)
To unsubscribe from this group and stop receiving emails from it, send an email to astro...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to astrometry+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/astrometry/017fc0e4-d5e9-4a32-9f21-ee9b9e674008o%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/astrometry/017fc0e4-d5e9-4a32-9f21-ee9b9e674008o%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to astrometry+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/astrometry/df75b61f-2539-4156-a462-9bdab29b7b4fo%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/astrometry/df75b61f-2539-4156-a462-9bdab29b7b4fo%40googlegroups.com.