コード例 #1
0
ファイル: WebuiHooks.py プロジェクト: ebu/OSCIED
    def hook_config_changed(self):
        local_cfg = self.local_config

        self.info("Configure Apache 2")
        self.template2config(
            local_cfg.site_template_file,
            join(local_cfg.sites_available_path, self.name_slug),
            {"directory": local_cfg.site_directory, "domain": self.public_address},
        )
        self.cmd("a2dissite default")
        self.cmd("a2ensite {0}".format(self.name_slug))

        self.info("Configure CodeIgniter the PHP framework")
        self.storage_remount()
        self.api_register()
        infos = object2dict(self.config, include_properties=True)
        infos.update(object2dict(local_cfg, include_properties=True))
        infos["proxy_ips"] = self.proxy_ips_string
        infos["medias_uri"] = local_cfg.storage_uri(path=MEDIAS_PATH) or ""
        infos["uploads_uri"] = local_cfg.storage_uri(path=UPLOADS_PATH) or ""
        self.template2config(local_cfg.general_template_file, local_cfg.general_config_file, infos)
        self.template2config(local_cfg.database_template_file, local_cfg.database_config_file, infos)
        self.template2config(local_cfg.htaccess_template_file, local_cfg.htaccess_config_file, infos)
        if self.storage_is_mounted:
            self.info("Symlink shared storage for the web daemon")
            try_symlink(local_cfg.storage_medias_path(), local_cfg.medias_path)
            try_symlink(local_cfg.storage_uploads_path, local_cfg.uploads_path)
コード例 #2
0
ファイル: WebuiHooks.py プロジェクト: codecwatch/OSCIED
    def hook_config_changed(self):
        local_cfg = self.local_config
        # Apache site files must end with .conf for a2ensite to work
        site_file = self.name_slug + ".conf"

        self.info(u'Configure Apache 2')
        self.template2config(local_cfg.site_template_file, join(local_cfg.sites_available_path, site_file), {
            u'directory': local_cfg.site_directory, u'domain': self.public_address
        })
        self.cmd(u'a2dissite 000-default')
        self.cmd(u'a2ensite {0}'.format(site_file))

        self.info(u'Configure CodeIgniter the PHP framework')
        self.storage_remount()
        self.api_register()
        infos = object2dict(self.config, include_properties=True)
        infos.update(object2dict(local_cfg, include_properties=True))
        infos[u'proxy_ips'] = self.proxy_ips_string
        infos[u'medias_uri'] = local_cfg.storage_uri(path=MEDIAS_PATH) or u''
        infos[u'uploads_uri'] = local_cfg.storage_uri(path=UPLOADS_PATH) or u''
        self.template2config(local_cfg.general_template_file,  local_cfg.general_config_file,  infos)
        self.template2config(local_cfg.database_template_file, local_cfg.database_config_file, infos)
        self.template2config(local_cfg.htaccess_template_file, local_cfg.htaccess_config_file, infos)
        if self.storage_is_mounted:
            self.info(u'Symlink shared storage for the web daemon')
            try_symlink(local_cfg.storage_medias_path(), local_cfg.medias_path)
            try_symlink(local_cfg.storage_uploads_path,  local_cfg.uploads_path)
コード例 #3
0
ファイル: server.py プロジェクト: codecwatch/OSCIED
 def send_email_task(self, task, status, media=None, media_out=None):
     if task.send_email:
         user = self.get_user({u'_id': task.user_id}, {u'mail': 1})
         if not user:
             raise IndexError(to_bytes(u'Unable to find user with id {0}.'.format(task.user_id)))
         if isinstance(task, TransformTask):
             media_in = self.get_media({u'_id': task.media_in_id})
             if not media_in:
                 # FIXME maybe do not raise but put default value or return ?
                 raise IndexError(to_bytes(u'Unable to find input media asset with id {0}.'.format(
                                  task.media_in_id)))
             profile = self.get_transform_profile({u'_id': task.profile_id})
             if not profile:
                 # FIXME maybe do not raise but put default value or return ?
                 raise IndexError(to_bytes(u'Unable to find transformation profile with id {0}.'.format(
                                  task.profile_id)))
             task.load_fields(user, media_in, media_out, profile)
             template, name = self.config.email_ttask_template, u'Transformation'
         elif isinstance(task, PublisherTask):
             task.load_fields(user, media)
             template, name = self.config.email_ptask_template, u'Publication'
         else:
             return  # FIXME oups
         task.append_async_result()
         with open(template, u'r', u'utf-8') as template_file:
             text_plain = Template(template_file.read()).render(object2dict(task, include_properties=True))
             # FIXME YourFormatter().format(template_file.read(), task)
         self.send_email(task.user.mail, u'OSCIED - {0} task {1} {2}'.format(name, task._id, status), text_plain)