예제 #1
0
def plugout(request,*kw,**kwargs):
    if request.method == 'GET':
        form = forms.PlugoutForm()
        return  django.shortcuts.render_to_response('bots/plugout.html', {'form': form},context_instance=django.template.RequestContext(request))
    else:
        if 'submit' in request.POST:
            form = forms.PlugoutForm(request.POST)
            if form.is_valid():
                botsglobal.logger.info(_(u'Start writing plugin "%s".'),form.cleaned_data['filename'])
                try:
                    pluglib.plugoutcore(form.cleaned_data)
                except botslib.PluginError, txt:
                    botsglobal.logger.info(u'%s',str(txt))
                    request.user.message_set.create(message='%s'%txt)
                else:
                    botsglobal.logger.info(_(u'Plugin "%s" created successful.'),form.cleaned_data['filename'])
                    request.user.message_set.create(message=_(u'Plugin %s created successful.')%form.cleaned_data['filename'])
예제 #2
0
파일: views.py 프로젝트: avkameth/bots.v220
def plugout(request,*kw,**kwargs):
    if request.method == 'GET':
        form = forms.PlugoutForm()
        return  django.shortcuts.render_to_response('bots/plugout.html', {'form': form},context_instance=django.template.RequestContext(request))
    else:
        if 'submit' in request.POST:
            form = forms.PlugoutForm(request.POST)
            if form.is_valid():
                filename = botslib.join(botsglobal.ini.get('directories','botssys'),'plugin_temp.zip')
                botsglobal.logger.info(_(u'Start writing plugin "%s".'),filename)
                try:
                    pluglib.plugoutcore(form.cleaned_data,filename)
                except botslib.PluginError, msg:
                    botsglobal.logger.info(u'%s',str(msg))
                    request.user.message_set.create(message='%s'%msg)
                else:
                    botsglobal.logger.info(_(u'Plugin "%s" created successful.'),filename)
                    response = django.http.HttpResponse(open(filename, 'rb').read(), content_type='application/zip')
                    #~ response['Content-Length'] = os.path.getsize(filename)
                    response['Content-Disposition'] = 'attachment; filename=' + 'plugin' + time.strftime('_%Y%m%d') + '.zip'
                    return response