summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergiusz Bazański <q3k@q3k.org>2012-11-11 13:14:50 +0100
committerSergiusz Bazański <q3k@q3k.org>2012-11-11 13:14:50 +0100
commit213b8f01eb41c4e402df158b8d85eb3ce74aff50 (patch)
treecd45256b7b27528933a1b43b7435c4dbbbe112b2
parenta562781ab72d5db5a32e367994ceb58cb43d4726 (diff)
downloadlaserz_und_stuff-213b8f01eb41c4e402df158b8d85eb3ce74aff50.tar.gz
laserz_und_stuff-213b8f01eb41c4e402df158b8d85eb3ce74aff50.tar.bz2
laserz_und_stuff-213b8f01eb41c4e402df158b8d85eb3ce74aff50.tar.xz
laserz_und_stuff-213b8f01eb41c4e402df158b8d85eb3ce74aff50.zip
added flask
-rw-r--r--Lasers_und_stuff/Cannon.py9
-rw-r--r--Lasers_und_stuff/Cannon.pycbin5244 -> 4919 bytes
-rw-r--r--Lasers_und_stuff/main.py14
3 files changed, 19 insertions, 4 deletions
diff --git a/Lasers_und_stuff/Cannon.py b/Lasers_und_stuff/Cannon.py
index 8b009bd..b997284 100644
--- a/Lasers_und_stuff/Cannon.py
+++ b/Lasers_und_stuff/Cannon.py
@@ -16,15 +16,18 @@ class CannonController :
ports = glob.glob("/dev/ttyACM*")
if(len(ports) == 1):
- self.ser = serial.Serial(ports[0], 115200, timeout=1)
+ try:
+ self.ser = serial.Serial(ports[0], 115200, timeout=1)
+ except serial.SerialException:
+ raise Exception("Could not open serial connction (busy?)")
self.connected_to_serial = True
else:
self.ser = False
self.connected_to_serial = False
if len(ports) > 1 :
- raise "To many devices to handle"
+ raise Exception("To many devices to handle")
elif len(ports) == 0 :
- print "No device is connected"
+ print Exception("No device is connected")
def set_position(self, point):
self.position = point
diff --git a/Lasers_und_stuff/Cannon.pyc b/Lasers_und_stuff/Cannon.pyc
index ada5c7d..3ce4fbc 100644
--- a/Lasers_und_stuff/Cannon.pyc
+++ b/Lasers_und_stuff/Cannon.pyc
Binary files differ
diff --git a/Lasers_und_stuff/main.py b/Lasers_und_stuff/main.py
index a878156..b296528 100644
--- a/Lasers_und_stuff/main.py
+++ b/Lasers_und_stuff/main.py
@@ -6,10 +6,14 @@ Created on Nov 10, 2012
import random, pygame, sys
+import flask
+import threading
from pygame.locals import *
from Cannon import CannonController
from Cannon import Gunpoint
+app = flask.Flask(__name__)
+app.debug = True
pygame.init()
def main():
@@ -174,4 +178,12 @@ class Screen:
if __name__ == '__main__':
- main() \ No newline at end of file
+ t = threading.Thread(target=main)
+ def flask_runner():
+ app.run(use_reloader=False)
+ t2 = threading.Thread(target=flask_runner)
+
+ print "Starting pygame..."
+ t.start()
+ print "Starting flask..."
+ t2.start() \ No newline at end of file