From fd1a36e8cc74ad55f98c106eca21ba04988c26ba Mon Sep 17 00:00:00 2001 From: Andrew Bolster Date: Tue, 22 Sep 2015 17:01:03 +0000 Subject: [PATCH] that should do it, little messy in the imports but its working --- Doorbot.apache.conf | 2 +- README.md | 4 ++-- doorbot/doorbot.py | 6 +----- doorbot/interfaces.py | 4 ++++ 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Doorbot.apache.conf b/Doorbot.apache.conf index 2641e34..88cb979 100644 --- a/Doorbot.apache.conf +++ b/Doorbot.apache.conf @@ -3,7 +3,7 @@ ServerName doorbot.farsetlabs.org.uk ServerAlias * ServerAdmin admin@farsetlabs.org.uk - WSGIDaemonProcess doorbot user=doorbot group=doorbot + WSGIDaemonProcess doorbot user=doorbot group=doorbot processes=1 home=/home/doorbot WSGIScriptAlias / /opt/doorbot/doorbot.wsgi WSGIPassAuthorization On diff --git a/README.md b/README.md index 7ffa769..4157a8d 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Then, enable the site with `sudo a2ensite Doorbot.apache.conf; sudo service apac ## Configuration -Doorbot is configured using two JSON dotfiles in the operating-users home directory (`/home/username`, depending on usecase) +Doorbot is configured using two JSON dotfiles in the operating-users home directory (`/var/www/` for default apache config) ### `.doorbot_users` @@ -94,7 +94,7 @@ Currently Authenticated but doesn't need to be; returns a list of the doorids Inside the enclosure above the network rack in the co-working space, the piface as as wired up as it needs to be for the foreseeable. -**IF ANYONE WANTS TO INTERFACE WITH OR EVEN CONSIDER OPENING THE ENCLOSURE, WRITTEN DIRECTOR CONFIRMATION IS REQUIRED IN ADVANCE AND THE ENCLOSURE MUST BE RESEALED BY A DIRECTOR OR NEM AFTERWARDS** +**IF ANYONE WANTS TO INTERFACE WITH OR EVEN CONSIDER OPENING THE ENCLOSURE, RECORDED DIRECTOR CONFIRMATION IS REQUIRED IN ADVANCE AND THE ENCLOSURE MUST BE RESEALED BY A DIRECTOR OR DI NEM AFTERWARDS** There are 12 interface lines wired up to the terminal strip in the top lid of the enclosure; they are split into two 'sectors' of 6, which represent the two proposed 'door' controls, with the front door on the 'left' and the currently unpopulated back door on the right. diff --git a/doorbot/doorbot.py b/doorbot/doorbot.py index 489ae93..5eaaf1b 100644 --- a/doorbot/doorbot.py +++ b/doorbot/doorbot.py @@ -21,12 +21,8 @@ def get_pw(username): return user_db.get(username) return None - - - - import interfaces -app.doors = { +app.doors = { door_config['doorid']:interfaces.pick( door_config['interface'] )(**door_config) for door_config in config_settings['doors'] diff --git a/doorbot/interfaces.py b/doorbot/interfaces.py index 6c13057..d30dcf4 100644 --- a/doorbot/interfaces.py +++ b/doorbot/interfaces.py @@ -154,6 +154,10 @@ def __init__(self, *args, **kwargs): super(PiFace, self).__init__(*args, **kwargs) self.open_time = "Never" + try: + import pifacedigitalio + except ImportError: + raise ImportWarning("No PiFaceDigitalIO Module, Cannot instantiate PiFace") self.pfd = pifacedigitalio.PiFaceDigital() self.relay = kwargs.get('interfaceopt',0) self.log.warn("Got Config {}".format(kwargs))