Example #1
0
    def slice_job_files(
            email, slicer, version, model_path, config_path,
            output_path, job_id):

        """Fires up the slicer and slices the given file with the given config.
        """

        # If we don't have right args, bail

        # Try slicing it
        slicer = SlicerFactory.create_slicer(slicer, version)
        if not slicer:
            raise Exception('unable to create slicer')

        r = slicer.slice_job(model_path, config_path, output_path)
        logging.info('result: %s' % r)
        if r:
            # When slicer is finished add task to queue to send state update
            # and notification for job_id
            return True
        else:
            return False
Example #2
0
    def write_slice_files(
        email, slicer, version, model_filename, model_raw, config_filename,
        config_raw):
        """Handles the slice request. Writes the 3d and config files
        to disk and stores the job in the db and adds it to the queue.
        This should be kicked off in a process to not block the return.
        """

        if not email or not model_filename or not model_raw or not config_raw:
            return False, 'Malformed arguments: %s:%s:%s' % (email,
                    model_filename, config_filename)
        try:
            logging.info('start slice')

            # Make static factory call to create specified slicer
            slicer = SlicerFactory.create_slicer(slicer, version)
            if not slicer:
                raise Exception

            output_filename = model_filename.replace('\.\w+', '') + '.gcode'

            # Write data to disk
            # Write the Configuration to the new folder - If we have a user
            slice_id = repr(slicer.gen_slice_id())
            SliceBase.write_files(
                slice_id, model_raw, config_raw, model_filename,
                config_filename)
            # we need to write this config to their user dir
                # Write into the DB an instance of the Slice
              # full path to stl, config, output
            # Slice should have timestamp of job start
            # Slice should have e-mail of who to send this too after
            # Adds the Slice to the job queue with status finished = False
            message = "Job %s successfully added to the queue" % slice_id
            return True , message, slice_id

        except Exception, e:
            m = "Job add failed: " + str(sys.exc_info()[0]) + ":" + str(e)
            return False, m