X-Git-Url: http://mmka.chem.univ.gda.pl/gitweb/?a=blobdiff_plain;ds=sidebyside;f=qcg%2Fviews.py;h=a760425ed103819c2dbe4d95c2da0a8130fe0de6;hb=3e5a486378702cab1366d377240a6f405d71a078;hp=c34af9bb06e1ce0c707f22d84baf2f27664ba28e;hpb=cc336624de8fa227d247f0e71bd24f829802deb6;p=qcg-portal.git diff --git a/qcg/views.py b/qcg/views.py index c34af9b..a760425 100644 --- a/qcg/views.py +++ b/qcg/views.py @@ -16,7 +16,8 @@ from pyqcg.description import JobDescription from pyqcg.utils import Credential from qcg.forms import FiltersForm, ColumnsForm, JobDescriptionForm, EnvFormSet -from qcg.utils import update_user_data, paginator_context +from qcg.utils import paginator_context +from qcg.service import update_user_data def index(request): @@ -56,8 +57,8 @@ def parse_date(string): @login_required def jobs_list(request): - # QCG.start() - # update_user_data(request.user, request.session['proxy']) + QCG.start() + update_user_data(request.user, request.session['proxy']) tasks = request.user.tasks.order_by('-job__submission_time', '-submission_time') \ .select_related('job').prefetch_related('allocations__nodes') @@ -160,59 +161,50 @@ def job_new(request): if form.is_valid() and env_formset.is_valid(): print form.cleaned_data + print env_formset.cleaned_data desc = JobDescription(Credential(request.session['proxy'])) - application = form.cleaned_data['application'] - if '/' in application: - app, ver = application.split('1', 1) - desc.application.set_name(app) - desc.application.set_version(ver) - else: - desc.application.set_name(application) - + direct_map = ('arguments', 'note', 'grant', 'hosts', 'properties', 'queue', 'procs', 'wall_time', 'memory', + 'memory_per_slot', 'modules', 'native', 'notify', 'preprocess', 'postprocess', 'persistent') + + for name in direct_map: + if form.cleaned_data[name]: + setattr(desc, name, form.cleaned_data[name]) + + if form.cleaned_data['application']: + desc.set_application(*form.cleaned_data['application']) + if form.cleaned_data['nodes']: + desc.set_nodes(*form.cleaned_data['nodes']) + if form.cleaned_data['reservation']: + desc.set_reservation(form.cleaned_data['reservation']) + if form.cleaned_data['watch_output']: + desc.set_watch_output(form.cleaned_data['watch_output'], form.cleaned_data['watch_output_pattern']) + desc.env_variables += [(env['name'], env['value']) + for env in env_formset.cleaned_data if env and not env['DELETE']] # TODO script # TODO executable - desc.arguments = form.cleaned_data['arguments'] - desc.note = form.cleaned_data['note'] - desc.grant = form.cleaned_data['grant'] - desc.host_candidates = [(form.cleaned_data['host'], 'type?')] # FIXME WTF ?!? - desc.properties = form.cleaned_data['properties'] - # TODO queue - # TODO procs - # TODO nodes - desc.wall_time = timedelta(seconds=form.cleaned_data['wall_time']) # FIXME odpowiedni typ pola - desc.memory = form.cleaned_data['memory'] - desc.memory_per_slot = form.cleaned_data['memory_per_slot'] - desc.variable = [(env['name'], env['value']) for env in env_formset.cleaned_data if not env['DELETE']] - desc.modules = form.cleaned_data['modules'] - desc.natives = form.cleaned_data['native'] - desc.reservation = ("LOCAL", form.cleaned_data['reservation']) # TODO input # TODO stage_in # TODO stage_out # TODO monitoring - # TODO notify_type - # TODO notify_address - # TODO watch_output_type - # TODO watch_output_address - # TODO watch_output_pattern - # TODO preprocess_type - # TODO preprocess_cmd - # TODO preprocess_script - # TODO postprocess_type - # TODO postprocess_cmd - # TODO postprocess_script - desc.persistent = form.cleaned_data['persistent'] - - for prop in ('arguments', 'note', 'grant', 'host_candidates', 'wall_time', 'memory', - 'memory_per_slot', 'properties', 'variable', 'modules', 'natives', 'persistent', 'reservation'): + + for prop in direct_map + ('application', 'nodes', 'env_variables', 'reservation', 'watch_output'): print prop, type(getattr(desc, prop)), repr(getattr(desc, prop)) print desc.xml_description + print repr(form.errors) + print repr(env_formset.errors) else: form = JobDescriptionForm() env_formset = EnvFormSet() - return render(request, 'qcg/job_new.html', {'form': form, 'env_formset': env_formset}) + errors = form.errors or (env_formset.is_bound and not env_formset.is_valid) + + return render(request, 'qcg/job_new.html', {'form': form, 'env_formset': env_formset, 'errors': errors}) + + +@login_required +def gridftp(request): + return render(request, 'qcg/gridftp.html')