Difference between revisions of "SpaceAPI"

From Fixme.ch
Jump to: navigation, search
Line 36: Line 36:
 
else:
 
else:
 
print("The hackerspace is closed")
 
print("The hackerspace is closed")
<\syntaxhighlight>
+
</syntaxhighlight>
 +
 
 
== Participant ==
 
== Participant ==
 
* [[User:Nemen]]
 
* [[User:Nemen]]
 
* [[User:Gcmalloc]]
 
* [[User:Gcmalloc]]
 
* [[User:Rorist]]
 
* [[User:Rorist]]

Revision as of 19:52, 2 May 2012

Description

Components

  • Sources on Github
  • Python script on fixme.ch that serves the API
  • Perl script that put the status in a Mysql DB (from the RFID_Doorlock or from a computer)
  • A Drupal module to show the status on the main website

Dummy script to lookup the status

#!/usr/bin/env python2
import urllib
try:
	import json
except ImportError:
	import simplejson as json
 
URL = "https://fixme.ch/cgi-bin/spaceapi.py"
try:
	con = urllib.urlopen(URL)
	hs_json = json.load(con)
except IOError:
	print("An error occured sorry")
	exit(1)
if hs_json['open']:
	print("OPENENENENEN")
	print("status is : %(status)s" %hs_json)
	print("the changes happens at %(lastchange)s" % hs_json)
	print("The duration is %(duration)s hours" % hs_json)
else:
	print("The hackerspace is closed")

Participant