def start_job(request): if "autosave" in request.session: del request.session['autosave'] t = Templeton(request.user.username) statusdir = "/tmp/.pigjobs/%s/%s_%s" % ( request.user.username, request.POST['title'].lower().replace( " ", "_"), datetime.now().strftime("%s")) script_file = statusdir + "/script.pig" pig_script = request.POST['pig_script'] pig_script = process_pig_script(pig_script, request, statusdir) _do_newfile_save(request.fs, script_file, pig_script, "utf-8") args = filter(bool, request.POST.getlist("pigParams")) job_type = Job.EXECUTE execute = None if request.POST.get("explain"): execute = "explain -script %s" % (request.fs.fs_defaultfs + script_file) job_type = Job.EXPLAINE script_file = None if request.POST.get("syntax_check"): args.append("-check") job_type = Job.SYNTAX_CHECK callback = request.build_absolute_uri("/pig/notify/$jobId/") LOG.debug( "User %s started pig job via webhcat: curl -s -d file=%s -d statusdir=%s -d callback=%s %s" % (request.user.username, script_file, statusdir, callback, "".join( ["-d arg=%s " % a for a in args]))) job = t.pig_query(pig_file=script_file, execute=execute, statusdir=statusdir, callback=callback, arg=args) if request.POST.get("script_id"): script = PigScript.objects.get(pk=request.POST['script_id']) else: script = PigScript(user=request.user, saved=False, title=request.POST['title']) script.pig_script = request.POST['pig_script'] script.python_script = request.POST['python_script'] script.arguments = "\t".join(args) script.save() Job.objects.create(user=script.user, job_id=job['id'], statusdir=statusdir, script_title=script.title, job_type=job_type, email_notification=bool(request.POST.get('email'))) return HttpResponse( json.dumps({ "job_id": job['id'], "text": "The Job <a href='%s' target='_blank'>%s</a> has been started successfully. <br>\ You can always go back to <a href='%s'>Query History</a> for results after the run." % (reverse("single_job", args=[job['id']]), job['id'], reverse("query_history")) }))
def start_job(request): if "autosave" in request.session: del request.session['autosave'] t = Templeton(request.user.username) statusdir = "/tmp/.pigjobs/%s/%s_%s" % (request.user.username, request.POST['title'].lower().replace(" ", "_"), datetime.now().strftime("%s")) script_file = statusdir + "/script.pig" pig_script = request.POST['pig_script'] pig_script = process_pig_script(pig_script, request, statusdir) _do_newfile_save(request.fs, script_file, pig_script, "utf-8") args = filter(bool, request.POST.getlist("pigParams")) job_type = Job.EXECUTE execute = None if request.POST.get("explain"): execute = "explain -script %s" % (request.fs.fs_defaultfs + script_file) job_type = Job.EXPLAINE script_file = None if request.POST.get("syntax_check"): args.append("-check") job_type = Job.SYNTAX_CHECK callback = request.build_absolute_uri("/pig/notify/$jobId/") LOG.debug("User %s started pig job via webhcat: curl -s -d file=%s -d statusdir=%s -d callback=%s %s" % ( request.user.username, script_file, statusdir, callback, "".join(["-d arg=%s " % a for a in args]) )) job = t.pig_query(pig_file=script_file, execute=execute, statusdir=statusdir, callback=callback, arg=args) if request.POST.get("script_id"): script = PigScript.objects.get(pk=request.POST['script_id']) else: script = PigScript(user=request.user, saved=False, title=request.POST['title']) script.pig_script = request.POST['pig_script'] script.python_script = request.POST['python_script'] script.arguments = "\t".join(args) script.save() Job.objects.create(user=script.user, job_id=job['id'], statusdir=statusdir, script_title=script.title, job_type=job_type, email_notification=bool(request.POST.get('email'))) return HttpResponse( json.dumps( { "job_id": job['id'], "text": "The Job <a href='%s' target='_blank'>%s</a> has been started successfully. <br>\ You can always go back to <a href='%s'>Query History</a> for results after the run." % ( reverse("single_job", args=[job['id']]), job['id'], reverse("query_history") ) } ) )
def start_job(request): if "autosave" in request.session: del request.session['autosave'] t = Templeton(request.user.username) statusdir = "/tmp/.pigjobs/%s" % datetime.now().strftime("%s") script_file = statusdir + "/script.pig" pig_script = request.POST['pig_script'] if request.POST.get("python_script"): pig_script = augmate_python_path(request.POST.get("python_script"), pig_script) pig_script = process_pig_script(pig_script, request) _do_newfile_save(request.fs, script_file, pig_script, "utf-8") job = t.pig_query( pig_file=script_file, statusdir=statusdir, callback=request.build_absolute_uri("/pig/notify/$jobId/")) if request.POST.get("script_id"): script = PigScript.objects.get(pk=request.POST['script_id']) else: script = PigScript(user=request.user, saved=False, title=request.POST['title']) script.pig_script = request.POST['pig_script'] script.python_script = request.POST['python_script'] script.save() Job.objects.create(job_id=job['id'], statusdir=statusdir, script=script, email_notification=bool(request.POST['email'])) return HttpResponse( json.dumps({ "job_id": job['id'], "text": "The Job <a href='%s' target='_blank'>%s</a> has been started successfully. <br>\ You can always go back to <a href='%s'>Query History</a> for results after the run." % (reverse("single_job", args=[job['id']]), job['id'], reverse("query_history")) }))
def start_job(request): if "autosave" in request.session: del request.session['autosave'] t = Templeton(request.user.username) statusdir = "/tmp/.pigjobs/%s" % datetime.now().strftime("%s") script_file = statusdir + "/script.pig" pig_script = request.POST['pig_script'] if request.POST.get("python_script"): pig_script = augmate_python_path(request.POST.get("python_script"), pig_script) pig_script = process_pig_script(pig_script, request) _do_newfile_save(request.fs, script_file, pig_script, "utf-8") job = t.pig_query(pig_file=script_file, statusdir=statusdir, callback=request.build_absolute_uri("/pig/notify/$jobId/")) if request.POST.get("script_id"): script = PigScript.objects.get(pk=request.POST['script_id']) else: script = PigScript(user=request.user, saved=False, title=request.POST['title']) script.pig_script = request.POST['pig_script'] script.python_script = request.POST['python_script'] script.save() Job.objects.create(job_id=job['id'], statusdir=statusdir, script=script, email_notification=bool(request.POST['email'])) return HttpResponse( json.dumps( { "job_id": job['id'], "text": "The Job <a href='%s' target='_blank'>%s</a> has been started successfully. <br>\ You can always go back to <a href='%s'>Query History</a> for results after the run." % ( reverse("single_job", args=[job['id']]), job['id'], reverse("query_history") ) } ) )