diff --git a/FakeGPIO/__init__.py b/FakeGPIO/__init__.py new file mode 100644 index 0000000..da5db8b --- /dev/null +++ b/FakeGPIO/__init__.py @@ -0,0 +1,27 @@ +BOARD = 1 +HIGH = 1 +LOW = 0 +OUT = 1 +IN = 0 +FALLING = 0 +RISING = 1 + + +def setmode(x): + pass + + +def setwarnings(x): + pass + + +def setup(gpio, mode, initial=None): + pass + + +def output(gpio, state): + pass + + +def add_event_detect(gpio, edge, callback, bouncetime=None): + pass diff --git a/FakeGPIO/__init__.pyc b/FakeGPIO/__init__.pyc new file mode 100644 index 0000000..c770557 Binary files /dev/null and b/FakeGPIO/__init__.pyc differ diff --git a/FakePicamera/__init__.py b/FakePicamera/__init__.py new file mode 100644 index 0000000..fe52923 --- /dev/null +++ b/FakePicamera/__init__.py @@ -0,0 +1,28 @@ +from PIL import Image + + +class Overlay(object): + def __init__(self): + self.alpha = 0 + + +class PiCamera(object): + def __init__(self): + self.resolution = None + + def start_preview(self, *args, **kwargs): + pass + + def add_overlay(self, *args, **kwargs): + return Overlay() + + def remove_overlay(self, *args, **kwargs): + pass + + def capture(self, filename, format, *args, **kwargs): + print("FAKE: capture(%s, %s)" % (filename, format)) + img = Image.new("RGB", self.resolution, (255, 255, 255)) + img.save(filename, format) + + def close(self, *args, **kwargs): + pass diff --git a/FakePicamera/__init__.pyc b/FakePicamera/__init__.pyc new file mode 100644 index 0000000..3e6ac8c Binary files /dev/null and b/FakePicamera/__init__.pyc differ diff --git a/photobox.py b/photobox.py index 03a10a0..c2bd3d5 100755 --- a/photobox.py +++ b/photobox.py @@ -1,6 +1,7 @@ #!/usr/bin/python import datetime +import imp import inspect import os import sys @@ -8,13 +9,20 @@ from math import floor from shutil import copyfile from time import sleep -import RPi.GPIO as GPIO -import picamera import pygame from PIL import Image -# ~ import server +try: + imp.find_module('RPi') + import RPi.GPIO as GPIO +except ImportError: + import FakeGPIO as GPIO +try: + imp.find_module('picamera') + import picamera +except ImportError: + import FakePicamera as picamera __all__ = ["monotonic_time"] @@ -222,7 +230,7 @@ def waitForBegin(): def countdown(camera, pad, img): sleep(PIC_INTERVAL) - o = camera.add_overlay(pad.tostring(), size=img.size) + o = camera.add_overlay(pad.tobytes(), size=img.size) o.alpha = OVERLAY_ALPHA o.layer = 3 sleep(TEXT_INTERVAL)