示例#1
0
def job_saved(sender,**kwargs):
    job = kwargs['instance']
    try:
        file = job.template.template
        file.open(mode='rb')
        template = Template(file.read())
        params = merge(job.get_params(),{'update_url':job.update_url})
        c = Context(params)
        rendered = template.render(c)
        script = open(job.script_path, 'w')
        script.write(rendered)
        script.close()
        st = os.stat(job.script_path)
        os.chmod(job.script_path, st.st_mode | 0111)
    except Exception, e:
        job.delete()
        raise e
示例#2
0
def job_saved(sender, **kwargs):
    job = kwargs['instance']
    try:
        if job.template:
            file = job.template.template
            file.open(mode='rb')
            template = Template(file.read())
            params = merge(job.get_params(), {'update_url': job.update_url})
            c = Context(params)
            rendered = template.render(c)
            script = open(job.script_path, 'w')
            script.write(rendered)
            script.close()
            st = os.stat(job.script_path)
            os.chmod(job.script_path, st.st_mode | 0111)
    except Exception, e:
        job.delete()
        raise e
示例#3
0
def update_job(request, job_id):
    api_key = request.GET.get('api_key')
    job = Job.objects.get(id=job_id, api_key=api_key)
    data = json.loads(request.body)

    print data
    #callback(job.callback,job=job,data=data)
    if data.has_key('data'):
        job.data = merge(job.data, data['data'])
    if data.has_key('status'):
        job.status = data['status'].upper()
    if data.has_key('output_directory'):
        job.output_directory = data['output_directory']
    job.save()
    if job.callback_id:
        Callback = get_callback(job.callback_id)
        if Callback:
            Callback.run(job=job, data=data)
    return JsonResponse({'status': 'success'})
示例#4
0
def update_job(request,job_id):
    api_key = request.GET.get('api_key')
    job = Job.objects.get(id=job_id,api_key=api_key)
    data =json.loads(request.body)
    
    print data
    #callback(job.callback,job=job,data=data)
    if data.has_key('data'):
        job.data = merge(job.data,data['data'])
    if data.has_key('status'):
        job.status = data['status'].upper()
    if data.has_key('output_directory'):
        job.output_directory = data['output_directory']
    job.save()
    if job.callback_id:
        Callback = get_callback(job.callback_id)
        if Callback:
            Callback.run(job=job,data=data)
    return JsonResponse({'status':'success'})
示例#5
0
 def get_params(self):
     return merge(self.template.default_params,self.params)
示例#6
0
 def get_params(self):
     return merge(self.template.default_params, self.params)