Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for python3 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

An interactive browser of waterfall snapshots in the Bolidozor repository

# Launguage

Python3

## Dependencies

* bzpost
* pysdl2
* pyfits
* astropy.io.fits
* numpy
33 changes: 15 additions & 18 deletions bzbrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import sdl2.ext
import multiprocessing.dummy as mpdummy
import threading
import Queue
import queue
import bzpost
import pyfits
import StringIO
import urllib2
import astropy.io.fits as pyfits
import io
import urllib
import numpy as np

from httplib import BadStatusLine
from http.client import BadStatusLine

from sdl2 import *

Expand All @@ -27,7 +27,7 @@ def __init__(self, source, sink):
self.thread = threading.Thread(target=self.async)
self.thread.daemon = True
self.covered_range = None
self.cover_reqs = Queue.Queue()
self.cover_reqs = queue.Queue()

self.thread.start()

Expand All @@ -44,8 +44,8 @@ def _cover(self, a, b):
for ss in self.source.get_snapshots(a, b):
if b > ss.time >= a:
self.sink(ss)
except BadStatusLine, e:
print "oh no, a BadStatusLine!", e # TODO
except BadStatusLine as e:
print( "oh no, a BadStatusLine!", e) # TODO
self.source.close()
self.source.connect()

Expand Down Expand Up @@ -77,7 +77,7 @@ def main():
430, 600, SDL_WINDOW_SHOWN)
windowsurface = SDL_GetWindowSurface(window)

main_thread_queue = Queue.Queue()
main_thread_queue = queue.Queue()

def run_on_main_thread(func):
main_thread_queue.put(func)
Expand All @@ -94,11 +94,11 @@ def run_on_main_thread(func):
drawable_snapshots = []

def put_up_snapshot(snapshot):
print "downloading %s..." % snapshot.url
print( "downloading %s..." % snapshot.url)
x = urllib.request.urlopen(snapshot.url)

fits = pyfits.open(StringIO.StringIO(urllib2.urlopen(snapshot.url).read()))

print "downloading %s... done" % snapshot.url
fits = pyfits.open(io.BytesIO(x.read()))
print( "downloading %s... done" % snapshot.url)

imunit = None
for unit in fits:
Expand All @@ -113,9 +113,8 @@ def finish():
h, w = img.shape
surface = SDL_CreateRGBSurfaceFrom(rgbimg.ctypes.data, w, h, 24,
3 * w, 0, 0, 0, 0)

drawable_snapshots.append({'time': snapshot.time, 'surface': surface,
'imgdata': rgbimg})
'imgdata': rgbimg})
run_on_main_thread(finish)

collection = SnapshotCollection(connector,
Expand Down Expand Up @@ -162,6 +161,4 @@ def finish():


if __name__ == "__main__":
sys.exit(main())


sys.exit(main())