Browse Source

cat->random

rorist 3 months ago
parent
commit
b945a3e831
3 changed files with 12 additions and 9 deletions
  1. 1 0
      .gitignore
  2. 5 5
      node.lua
  3. 6 4
      screend.py

+ 1 - 0
.gitignore

@@ -3,5 +3,6 @@ power.txt
 events.json
 spaceapi.json
 cat.jpg
+random_image.jpg
 __pycache__/
 *.swp

+ 5 - 5
node.lua

@@ -75,8 +75,8 @@ util.file_watch("bus.txt", function(content)
     bus = content
 end)
 
-util.file_watch("cat.jpg", function(content)
-    cat = resource.load_image("cat.jpg")
+util.file_watch("random_image.jpg", function(content)
+    random_image = resource.load_image("random_image.jpg")
 end)
 
 --
@@ -218,10 +218,10 @@ function panel_clock()
 
 end;
 
-function panel_cat()
+function panel_image()
 
     function draw()
-        util.draw_correct(cat, WIDTH/2-1000, 300, WIDTH, HEIGHT-150)
+        util.draw_correct(random_image, WIDTH/2-1000, 300, WIDTH, HEIGHT-150)
     end;
 
     return {
@@ -240,7 +240,7 @@ local cycling = cycler(util.generator(function()
         return {
             panel_spaceapi(),
             panel_events(),
-            panel_cat(),
+            panel_image(),
         }
     end), 8)
 

+ 6 - 4
screend.py

@@ -100,11 +100,13 @@ def clock():
         send_data('screen/analogclock/clock/set', str(since_midnight))
         time.sleep(1)
 
-def cat():
+def random_image():
+    #URL='http://aws.random.cat/meow'
+    URL='https://picsum.photos/id/10/640/480'
     while True:
-        j = requests.get('http://aws.random.cat/meow').json()
+        j = requests.get(URL).json()
         response = requests.get(j['file'], stream=True)
-        handle = open('./cat.jpg', "wb")
+        handle = open('./random_image.jpg', "wb")
         for chunk in response.iter_content(chunk_size=512):
             if chunk:
                 handle.write(chunk)
@@ -197,7 +199,7 @@ if __name__ == '__main__':
         clock,
         snmp,
         spaceapi,
-        cat,
+        random_image,
     ]
     processes = {f: Process(target=f) for f in functions}
     [p.start() for p in processes.values()] # start the processes