]> git.aero2k.de Git - sirius.git/commitdiff
updating requirements, giving time for renders to take place
authorMatt Webb <matt@interconnected.org>
Sat, 27 Sep 2014 12:04:19 +0000 (13:04 +0100)
committerMatt Webb <matt@interconnected.org>
Sat, 27 Sep 2014 12:04:19 +0000 (13:04 +0100)
app/image_encoding.py
app/queues.py
requirements.txt

index 3bc1e49739efe061c5dc9c1d62d7de3451e62e86..374e2b28aabf5a478657392379656e17f0dcdabf 100644 (file)
@@ -2,6 +2,7 @@ from PIL import Image
 from itertools import groupby
 import struct
 import io
+import time
 
 WHITE = 0
 BLACK = 1
@@ -85,15 +86,27 @@ def _rle_image(im):
     return len(pixels), output
 
 def rle_html(html):
+       """ This works:
+       <html><body style="width: 384px; margin: 0;">
+       <img src="https://dl.dropboxusercontent.com/u/165957/Escher.gif">
+       </body></html>
+       """
        from selenium import webdriver
        driver = webdriver.PhantomJS('phantomjs')
-       driver.set_window_size(384, 800)
+       driver.set_window_size(384, 5)
        #driver.get("http://www.google.com")
        
-       driver.get("about:black")
+       driver.get("about:blank")
        html = html.replace('"', '\\"')
        driver.execute_script("""document.write("%s")""" % html)
+       # @TODO good grief, I can't just go putting sleeps around the place.
+       # how else to tell when the document.write has finished rendering, and
+       # all the images have loaded?
+       # maybe I need to inject something like this and look for an alert?
+       # http://imagesloaded.desandro.com
+       time.sleep(2)
        
+       #p = driver.get_screenshot_as_file("/Users/matt/Desktop/test5.png")
        p = driver.get_screenshot_as_png()
        im = Image.open(io.BytesIO(p))
        return _rle_image(im)
index 38c179ee5d6be25fe1fecee6718b74cec3c74d39..3e33a352802579207c9b778f4fb12594a08df68f 100644 (file)
@@ -84,7 +84,7 @@ class _CommandQueue(object):
                self.device_queue = {} # device_address: [DeviceCommand]
                self.bridge_pending = None
                self.device_pending = {} # device_address: None|DeviceCommand
-           
+
        def add_device(self, device):
                da = device.device_address
                if da not in self.devices:
index a7d3eb827072cc21cedddf5c22258545f8e05706..a5502ba5209bd7f6f2ba21847f9dde17d10c4f89 100755 (executable)
@@ -4,11 +4,13 @@ Flask-Migrate==1.2.0
 Flask-SQLAlchemy==2.0
 Flask-Script==2.0.5
 Flask-Sockets==0.1
+Flask-WTF==0.10.2
 Jinja2==2.7.3
 Mako==1.0.0
 MarkupSafe==0.23
 Pillow==2.5.3
 SQLAlchemy==0.9.7
+WTForms==2.0.1
 Werkzeug==0.9.6
 alembic==0.6.7
 gevent==1.0.1
@@ -17,4 +19,6 @@ greenlet==0.4.4
 gunicorn==19.1.1
 itsdangerous==0.24
 pycrypto==2.6.1
+redis==2.10.3
+selenium==2.43.0
 wsgiref==0.1.2