Example #1
0
    def view(self):
        print "REQ", self.request.args
        print "KW", self.kwargs
        print "CONT", self.context

        source_path = cgi.escape(self.request.args["source_path"][0])
        dest_path = cgi.escape(self.request.args["dest_path"][0])
        notify_url = cgi.escape(self.request.args["notify_url"][0])
        preset = cgi.escape(self.request.args["preset"][0])
        user_job_options = cgi.escape(self.request.args["job_options"][0])
        user_job_options = simplejson.loads(user_job_options)

        print "SOURCE", source_path
        print "DEST", dest_path
        print "NOTIFY", notify_url
        print "OPTIONS", user_job_options

        # Retrieve the given preset from nomconf.
        try:
            preset_dict = settings.PRESETS[preset]
        except KeyError:
            self.set_error("No such preset.")
            return

        # Determine the nommer based on the preset.
        nommer = preset_dict["nommer"]
        # Get the preset's job options dict.
        job_options = preset_dict["options"]
        # Override preset's options with user-specified values.
        # TODO: Fix this for multi-pass!
        # job_options.update(user_job_options)
        print "NEW OPTS", job_options

        # Create a new job and save it to the DB/queue.
        job = EncodingJob(source_path, dest_path, nommer, job_options, notify_url=notify_url)
        unique_job_id = job.save()
        # Add the job to the local job cache.
        JobCache.update_job(job)

        # This is serialized and returned to the user.
        self.context.update({"job_id": unique_job_id})
Example #2
0
    def set_context(self, request):
        payload = self.user_input
        print(payload)

        for key in self.required_keys:
            if not payload.get(key):
                msg = "Missing/invalid required key+val: ['%s']" % key
                self.set_error(msg)
                return

        for key in self.required_job_options_keys:
            if not payload['job_options'].get(key):
                msg = "Missing/invalid required key+val: ['job_options'][%s]" % key
                self.set_error(msg)
                return

        source_path = payload['source_path']
        dest_path = payload['dest_path']
        notify_url = payload.get('notify_url')
        job_options = payload['job_options']['options']
        nommer = payload['job_options']['nommer']

        #print "SOURCE", source_path
        #print "DEST", dest_path
        #print "NOTIFY", notify_url
        #print "OPTIONS", job_options
        #print "NOMMER", nommer

        # Create a new job and save it to the DB/queue.
        job = EncodingJob(source_path,
                          dest_path,
                          nommer,
                          job_options,
                          notify_url=notify_url)
        unique_job_id = job.save()
        # Add the job to the local job cache.
        JobCache.update_job(job)

        # This is serialized and returned to the user.
        self.context.update({'job_id': unique_job_id})
Example #3
0
    def set_context(self, request):
        payload = self.user_input
        print(payload)

        for key in self.required_keys:
            if not payload.get(key):
                msg = "Missing/invalid required key+val: ['%s']" % key
                self.set_error(msg)
                return

        for key in self.required_job_options_keys:
            if not payload['job_options'].get(key):
                msg = "Missing/invalid required key+val: ['job_options'][%s]" % key
                self.set_error(msg)
                return

        source_path = payload['source_path']
        dest_path = payload['dest_path']
        notify_url = payload.get('notify_url')
        job_options = payload['job_options']['options']
        nommer = payload['job_options']['nommer']

        #print "SOURCE", source_path
        #print "DEST", dest_path
        #print "NOTIFY", notify_url
        #print "OPTIONS", job_options
        #print "NOMMER", nommer

        # Create a new job and save it to the DB/queue.
        job = EncodingJob(source_path, dest_path, nommer, job_options,
                          notify_url=notify_url)
        unique_job_id = job.save()
        # Add the job to the local job cache.
        JobCache.update_job(job)

        # This is serialized and returned to the user.
        self.context.update({'job_id': unique_job_id})