Finish platform app
Update Dockerfile to use platform template for supervisord. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.core import management
|
||||
|
||||
from ...classes import PlatformTemplate
|
||||
|
||||
|
||||
class Command(management.BaseCommand):
|
||||
help = 'Render a platform configuration template.'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('name', nargs='?', help='Template name')
|
||||
parser.add_argument(
|
||||
'--list', action='store_true', dest='list',
|
||||
help='Show a list of available templates.',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--context', action='store', default='', dest='context',
|
||||
help='Show a list of available templates.',
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
if options.get('list'):
|
||||
self.stdout.write('\nAvailable platform templates.')
|
||||
self.stdout.write('----')
|
||||
for template_class in PlatformTemplate.all():
|
||||
template = template_class()
|
||||
self.stdout.write(
|
||||
'* {}\t{}'.format(template.name, template.get_label())
|
||||
)
|
||||
|
||||
self.stdout.write('\n')
|
||||
else:
|
||||
try:
|
||||
template = PlatformTemplate.get(name=options['name'])
|
||||
except KeyError:
|
||||
self.stderr.write(
|
||||
'Unknown template "{}".'.format(options['name'])
|
||||
)
|
||||
exit(1)
|
||||
else:
|
||||
self.stdout.write(template().render(
|
||||
context_string=options.get('context'))
|
||||
)
|
||||
Reference in New Issue
Block a user