<syntaxhighlight lang="python">
#!/usr/bin/env python2python3import urllib.request
try:
import json
except ImportError:
import simplejson as json
URL = "https://fixme.ch/cgi-bin/spaceapi.py"
trydef get_json(): try: con = urllib.request.urlopen(URL) content = con.read() hs_json = json.loadloads(concontent.decode('utf8')) return hs_json except IOError: print("An A network error occured sorry") exit(1) except ValueError: print("Malformatted json") def print_info(hs_json): if hs_json['open']: print("OPENENENENEN") print("status is : %({status)s}" %.format(**hs_json)) print("the changes happens at %({lastchange)s}" % .format(**hs_json)) print("The duration is %({duration)s } hours" % .format(**hs_json)) else: print("The hackerspace is closed") print_info(get_json())
</syntaxhighlight>