repackage this

this makes the python scripts available as commands
master
nathaniel smith 2017-04-21 21:29:55 -07:00
parent 1b7f68c631
commit b74fdc94e6
4 changed files with 24 additions and 13 deletions

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
# TODO just make this better once the new package is ready
# Feed JSON/tdp output from "stats" into mustache template to generate # Feed JSON/tdp output from "stats" into mustache template to generate
# tilde.town homepage. Invoke periodically from crontab. # tilde.town homepage. Invoke periodically from crontab.

View File

@ -4,19 +4,25 @@ from setuptools import setup
setup( setup(
name='tildetown', name='tildetown',
version='0.0.2', version='1.0.0',
description='python stuf for tilde.town', description='executable scripts used on tildetown',
url='https://github.com/tildetown/tildetown-scripts', url='https://github.com/tildetown/tildetown-scripts',
author='vilmibm shaksfrpease', author='vilmibm',
author_email='nks@lambdaphil.es', author_email='tildetown@protonmail.ch',
license='GPL', license='GPL',
classifiers=[ classifiers=[
'Development Status :: 3 - Alpha', 'Development Status :: 3 - Beta',
'Intended Audience :: Other Audience', 'Intended Audience :: Other Audience',
'Topic :: Artistic Software', 'Topic :: Artistic Software',
'License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)', 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
], ],
keywords='community', keywords='community',
packages=['tildetown'], packages=['tildetown'],
install_requires = ['pyhocon==0.3.10', 'sh==1.11', 'Flask==0.10.1', 'requests==2.7.0', 'pystache==0.5.4'], install_requires = ['pystache==0.5.4'],
entry_points = {
'console_scripts': [
'stats = tildetown.stats:main',
'mustache = tildetown.mustache:main'
]
},
) )

View File

@ -1,5 +1,6 @@
from json import loads #!/usr/bin/env python3
from sys import argv,stdin import json
import sys
from pystache import render from pystache import render
@ -14,9 +15,11 @@ def slurp(file_path):
pass pass
return contents return contents
def main(argv):
template = slurp(argv[1])
data = json.loads(sys.stdin.read())
sys.stdout.write(render(template, data))
if __name__ == '__main__': if __name__ == '__main__':
template = slurp(argv[1]) exit(main(sys.argv))
data = loads(stdin.read())
print(render(template, data))

View File

@ -1,4 +1,4 @@
#!/usr/local/bin/python3 #!/usr/bin/env python3
# stats.py - tilde data in tilde data protocol format. # stats.py - tilde data in tilde data protocol format.
# Copyright 2015 Michael F. Lamb <http://datagrok.org> # Copyright 2015 Michael F. Lamb <http://datagrok.org>