adapt audience display for multiple values
[redakcja.git] / deployment.py
index 789d342..e478a47 100644 (file)
@@ -1,13 +1,17 @@
+# -*- coding: utf-8 -*-
+#
+# This file is part of MIL/PEER, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
 from __future__ import with_statement
 
 from __future__ import with_statement
 
-import shutil
 import os
 import sys
 import logging
 import os
 import sys
 import logging
+from string import Template
 
 logging.basicConfig(stream=sys.stderr, format="%(levelname)s:: %(message)s", level=logging.INFO)
 
 
 logging.basicConfig(stream=sys.stderr, format="%(levelname)s:: %(message)s", level=logging.INFO)
 
-from string import Template
 
 class DeploySite(object):
 
 
 class DeploySite(object):
 
@@ -67,6 +71,9 @@ class DeploySite(object):
     def update_app(self):
         pass
 
     def update_app(self):
         pass
 
+    def update_config(self):
+        pass
+
     def install_dependencies(self):
         pass
 
     def install_dependencies(self):
         pass
 
@@ -89,6 +96,7 @@ class DeploySite(object):
         site = cls(*args, **kwargs)
         return site.deploy()
 
         site = cls(*args, **kwargs)
         return site.deploy()
 
+
 class WSGISite(DeploySite):
 
     def __init__(self, **env):
 class WSGISite(DeploySite):
 
     def __init__(self, **env):
@@ -96,7 +104,9 @@ class WSGISite(DeploySite):
 
         if 'WSGI_FILE' not in self.env:
             self.env['WSGI_FILE'] = os.path.join(self.env['ROOT'], 'www',
 
         if 'WSGI_FILE' not in self.env:
             self.env['WSGI_FILE'] = os.path.join(self.env['ROOT'], 'www',
-                                        'wsgi', self.env['PROJECT_NAME']) + '.wsgi'
+                                                 'wsgi', self.env['PROJECT_NAME']) + '.wsgi'
+
+        self.env['WSGI_DIR'] = os.path.dirname(self.env['WSGI_FILE'])
 
         if 'WSGI_SOURCE_FILE' not in self.env:
             self.env['WSGI_SOURCE_FILE'] = 'wsgi_app.template'
 
         if 'WSGI_SOURCE_FILE' not in self.env:
             self.env['WSGI_SOURCE_FILE'] = 'wsgi_app.template'
@@ -109,9 +119,12 @@ class WSGISite(DeploySite):
         os.system("touch %s" % self.env['WSGI_FILE'])
 
     def update_config(self):
         os.system("touch %s" % self.env['WSGI_FILE'])
 
     def update_config(self):
+        super(WSGISite, self).update_config()
+
         source = self.find_resource(self.env['WSGI_SOURCE_FILE'])
         self.render_template(source, self.env['WSGI_FILE'])
 
         source = self.find_resource(self.env['WSGI_SOURCE_FILE'])
         self.render_template(source, self.env['WSGI_FILE'])
 
+
 class PIPSite(DeploySite):
 
     def install_dependencies(self):
 class PIPSite(DeploySite):
 
     def install_dependencies(self):
@@ -124,12 +137,14 @@ class PIPSite(DeploySite):
         except ValueError:
             pass
 
         except ValueError:
             pass
 
+
 class GitSite(DeploySite):
 
     def update_app(self):
         self.info("Updating repository.")
         os.system("cd %s; git pull" % self.env['APP_DIR'])
 
 class GitSite(DeploySite):
 
     def update_app(self):
         self.info("Updating repository.")
         os.system("cd %s; git pull" % self.env['APP_DIR'])
 
+
 class ApacheSite(DeploySite):
 
     def __init__(self, **env):
 class ApacheSite(DeploySite):
 
     def __init__(self, **env):
@@ -142,5 +157,7 @@ class ApacheSite(DeploySite):
             self.env['VHOST_FILE'] = os.path.join(self.env['CONFIG_DIR'], self.env['PROJECT_NAME'] + '.vhost')
 
     def update_config(self):
             self.env['VHOST_FILE'] = os.path.join(self.env['CONFIG_DIR'], self.env['PROJECT_NAME'] + '.vhost')
 
     def update_config(self):
+        super(ApacheSite, self).update_config()
+
         source = self.find_resource(self.env['VHOST_SOURCE_FILE'])
         source = self.find_resource(self.env['VHOST_SOURCE_FILE'])
-        self.render_template(source, self.env['VHOST_CONFIG_FILE'])
+        self.render_template(source, self.env['VHOST_FILE'])