django-orchestra/orchestra/apps/webapps/backends/__init__.py

35 lines
1015 B
Python
Raw Normal View History

2014-05-08 16:59:35 +00:00
import pkgutil
2014-10-10 14:39:46 +00:00
import textwrap
2014-05-08 16:59:35 +00:00
class WebAppServiceMixin(object):
model = 'webapps.WebApp'
def create_webapp_dir(self, context):
2014-10-10 14:39:46 +00:00
self.append(textwrap.dedent("""
path=""
for dir in $(echo %(app_path)s | tr "/" "\n"); do
path="${path}/${dir}"
[ -d $path ] || {
mkdir "${path}"
chown %(user)s.%(group)s "${path}"
}
done
""" % context))
2014-05-08 16:59:35 +00:00
def delete_webapp_dir(self, context):
self.append("rm -fr %(app_path)s" % context)
def get_context(self, webapp):
return {
2014-10-10 14:39:46 +00:00
'user': webapp.account.username,
'group': webapp.account.username,
2014-05-08 16:59:35 +00:00
'app_name': webapp.name,
'type': webapp.type,
2014-10-10 14:39:46 +00:00
'app_path': webapp.get_path().rstrip('/'),
2014-05-08 16:59:35 +00:00
'banner': self.get_banner(),
}
for __, module_name, __ in pkgutil.walk_packages(__path__):
exec('from . import %s' % module_name)