示例#1
0
    def _do_configuration(self, request):
        if request.method == 'POST':
            try:
                section = request.POST.get('section')
                option  = request.POST.get('option')
                value   = request.POST.get(option)

                Mediaplat.request({'module' : 'settings', 
                                   'action' : 'set_value', 
                                   'params' : (section, option, value)})

                settings.load_settings()
            except:
                log.exception('Fail to apply configuration changes')

        self.args['cur_menu']     = 'setting'
        self.args['submenu']      = 'configuration'
        self.args['submenu_list'] = submenu_list
        self.args['settings']     = settings.to_data()
        return ('configuration.html', self.args)
示例#2
0
    def _do_modules(self, request):
        if request.method == 'POST':
            try:
                if 'file' in request.FILES:
                    file = request.FILES['file']

                    fname = file.name.encode('utf-8')
                    tmp_upload_path = '/tmp/{}'.format(fname)
                    fp = open(tmp_upload_path, 'wb')
                    for chunk in file.chunks():
                        fp.write(chunk)
                    fp.close()

                    zip = ZipFile(tmp_upload_path, 'r')
                    zip.extractall(path=PluginManager.PLUGIN_DIRECTORY)

                    Mediaplat.request({'module' : 'plugin_manager', 
                                       'action' : 'load_all_plugins', 
                                       'params' : None})
                else:
                    action = request.POST.get('action')
                    plugin = request.POST.get('plugin')

                    if action not in ['activate', 'deactivate', 'remove']:
                        log.error('Invalid request : ' + action)
                    else:
                        Mediaplat.request({'module' : 'plugin_manager', 
                                           'action' : action, 
                                           'params' : (plugin)})
            except (IOError, BadZipfile):
                log.exception('module error')
        
        self.args['cur_menu']     = 'setting'
        self.args['submenu']      = 'modules'
        self.args['submenu_list'] = submenu_list
        self.args['modules']      = PluginManager.get_plugin_info()
        return ('modules.html', self.args)