Merge branch 'release/0.1rc2'
This commit is contained in:
commit
a6f9d75a21
|
@ -16,16 +16,17 @@ the unix console or toolbars like polybar
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
usage: SpaceApiCli.py [-h] [-n NAME] [-v] [-w]
|
usage: SpaceApiCli.py [-h] [-n NAME] [-l] [-v] [-w]
|
||||||
|
|
||||||
Show Space Status
|
Show Space Status
|
||||||
|
|
||||||
optional arguments:
|
optional arguments:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
-n NAME, --name NAME Name of Hackerspace
|
-n NAME, --name NAME Name of Hackerspace
|
||||||
-v Show more Infos of Hackerspace
|
-l, --list List all Hackspaces on Spaceapi
|
||||||
-w get homepage url
|
-v, --verbose Show more Infos of Hackspace
|
||||||
|
-w, --web get homepage url
|
||||||
|
|
||||||
|
|
||||||
Defaults: without option -n it will get the state of the hackspace
|
Defaults: without option -n it will get the state of the hackspace
|
||||||
LeineLab in Hannover, Germany <https://leinelab.org>.
|
LeineLab in Hannover, Germany <https://leinelab.org>.
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -1,7 +1,7 @@
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
setup(
|
setup(
|
||||||
name="SpaceApiCli",
|
name="SpaceApiCli",
|
||||||
version="0.1rc1",
|
version="0.1rc2",
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
scripts=["src/SpaceApiCli.py"],
|
scripts=["src/SpaceApiCli.py"],
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
#
|
#
|
||||||
# Reiko Kaps 2015 <r31k@k4p5.de>
|
# Reiko Kaps 2015-2020 <r31k@k4p5.de>
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import sys, os, argparse
|
import sys, os, argparse
|
||||||
|
@ -16,9 +16,9 @@ except ImportError as e:
|
||||||
|
|
||||||
DIR_URL='https://directory.spaceapi.io/'
|
DIR_URL='https://directory.spaceapi.io/'
|
||||||
|
|
||||||
|
|
||||||
def download(url):
|
def download(url):
|
||||||
"""Download a file to local filesystem
|
"""
|
||||||
|
Download json endpoint
|
||||||
Parameter url: URL
|
Parameter url: URL
|
||||||
returns string (json)
|
returns string (json)
|
||||||
"""
|
"""
|
||||||
|
@ -30,11 +30,18 @@ def download(url):
|
||||||
return file.json()
|
return file.json()
|
||||||
|
|
||||||
|
|
||||||
def save(json):
|
def list_spaces():
|
||||||
status(json)
|
"""
|
||||||
file = open("./spaceapi.json", 'w')
|
list all directory entries
|
||||||
file.write(str(json))
|
"""
|
||||||
file.close()
|
try:
|
||||||
|
directory = download(DIR_URL)
|
||||||
|
except ConnectionError:
|
||||||
|
raise
|
||||||
|
# print all entries
|
||||||
|
for name in directory:
|
||||||
|
print('{}'.format(name))
|
||||||
|
|
||||||
|
|
||||||
def status(json, verbose):
|
def status(json, verbose):
|
||||||
"""Ermittelt aus dem Json den Status des Hackerspace"""
|
"""Ermittelt aus dem Json den Status des Hackerspace"""
|
||||||
|
@ -77,18 +84,24 @@ def getspaceurl(name, debug=False):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
if args.v:
|
if args.verbose:
|
||||||
debug = args.v
|
debug = args.v
|
||||||
else:
|
else:
|
||||||
debug = False
|
debug = False
|
||||||
|
|
||||||
|
# get the full hackspace list and exit
|
||||||
|
if args.list:
|
||||||
|
list_spaces()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
json = download(getspaceurl(args.name, debug))
|
json = download(getspaceurl(args.name, debug))
|
||||||
except ConnectionError as e:
|
except ConnectionError as e:
|
||||||
print('not connected')
|
print('not connected')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if args.w:
|
if args.web:
|
||||||
getHomepage(json, debug)
|
getHomepage(json, debug)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
@ -99,8 +112,9 @@ def main(args):
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser(description='Show Space Status')
|
parser = argparse.ArgumentParser(description='Show Space Status')
|
||||||
parser.add_argument('-n', '--name', help='Name of Hackerspace', default='LeineLab')
|
parser.add_argument('-n', '--name', help='Name of Hackerspace', default='LeineLab')
|
||||||
parser.add_argument('-v', action='store_true', help='Show more Infos of Hackerspace')
|
parser.add_argument('-l', '--list', action='store_true', help='List all Hackspaces on Spaceapi')
|
||||||
parser.add_argument('-w', action='store_true', help='get homepage url')
|
parser.add_argument('-v', '--verbose', action='store_true', help='Show more Infos of Hackspace')
|
||||||
|
parser.add_argument('-w', '--web', action='store_true', help='get homepage url')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
main(args)
|
main(args)
|
||||||
|
|
Loading…
Reference in New Issue