Пример #1
0
 def running_callback(task):
     self._log.info("writing g-code to %s with%s start/end gcode", output_path, '' if add_start_end else 'out')
     try:
         with open(input_path) as ifp:
             with open(output_path, 'w') as ofp:
                 extruders = [e.strip() for e in slicer_settings.extruder.split(',')]
                 gcode_scaffold = profile.get_gcode_scaffold(
                     extruders,
                     slicer_settings.extruder_temperature,
                     slicer_settings.platform_temperature,
                     material_name)
                 if add_start_end:
                     for line in gcode_scaffold.start:
                         print(line, file=ofp)
                 for line in ifp.readlines():
                     ofp.write(line)
                 if add_start_end:
                     for line in gcode_scaffold.end:
                         print(line, file=ofp)
     except Exception as e:
         self._log.exception('unhandled exception; failed to add start/end g-code')
         failure = conveyor.util.exception_to_failure(e)
         task.fail(failure)
     else:
         task.end(None)
Пример #2
0
 def runningcallback(task):
     self._log.info("postweave processing on %s" % (gcode_path))
     try:
         conveyor.dualstrusion.post_weave(gcode_path, gcode_path_tmp, gcode_path_out, profile)
     except Exception as e:
         self._log.exception('unhandled exception; dualstrusion post-processing failed')
         failure = conveyor.util.exception_to_failure(e)
         task.fail(failure)
     else:
         task.end(None)
Пример #3
0
 def runningcallback(task):
     self._log.info('verifying s3g file %s', s3gpath)
     try:
         # If the filereader can parse it, then the s3g file is valid
         reader = makerbot_driver.FileReader.FileReader()
         with open(s3gpath, 'rb') as reader.file:
             payloads = reader.ReadFile(update)
         task.end(True)
     except makerbot_driver.FileReader.S3gStreamError as e:
         self._log.exception('unhandled exception; s3g verification failed')
         failure = conveyor.util.exception_to_failure(e)
         task.fail(failure)
Пример #4
0
 def _handleresponse(self, response, id):
     self._log.debug('response=%r, id=%r', response, id)
     task = self._tasks.pop(id, None)
     if None is task:
         self._log.debug('ignoring response for unknown id: %r', id)
     elif self._iserrorresponse(response):
         error = response['error']
         task.fail(error)
     elif self._issuccessresponse(response):
         result = response['result']
         task.end(result)
     else:
         raise ValueError(response)
Пример #5
0
 def running_callback(task):
     try:
         def work():
             slicer = conveyor.slicer.skeinforge.SkeinforgeSlicer(
                 profile, input_path, output_path, add_start_end,
                 slicer_settings, self._job.material_name,
                 dualstrusion, task, file_, profile_file)
             slicer.slice()
         self._server.queue_work(work)
     except Exception as e:
         self._log.exception('unhandled exception; failed to queue slice')
         failure = conveyor.util.exception_to_failure(e)
         task.fail(failure)
Пример #6
0
 def _handleresponse(self, response, id):
     self._log.debug('response=%r, id=%r', response, id)
     task = self._tasks.pop(id, None)
     if None is task:
         self._log.debug('ignoring response for unknown id: %r', id)
     elif self._iserrorresponse(response):
         error = response['error']
         task.fail(error)
     elif self._issuccessresponse(response):
         result = response['result']
         task.end(result)
     else:
         raise ValueError(response)
Пример #7
0
 def runningcallback(task):
     try:
         def work():
             self._job.driver.print_to_file(
                 self._job.profile, input_file, output_file,
                 self._job.file_type, True, self._job.extruder_name,
                 self._job.slicer_settings.extruder_temperature,
                 self._job.slicer_settings.platform_temperature,
                 self._job.material_name, self._job.name, task)
         self._server.queue_work(work)
     except Exception as e:
         self._log.exception('unhandled exception; failed to queue print-to-file')
         failure = conveyor.util.exception_to_failure(e)
         task.fail(failure)
Пример #8
0
 def runningcallback(task):
     self._log.info('processing gcode %s -> %s', inputpath, outputpath)
     try:
         with open(inputpath) as f:
             output = list(f)
             for gcodeprocessor in gcodeprocessors:
                 output = gcodeprocessor.process_gcode(output)
         with open(outputpath, 'w') as f:
             for line in output:
                 f.write(line)
     except Exception as e:
         self._log.exception('unhandled exception; gcode processing failed')
         failure = conveyor.util.exception_to_failure(e)
         task.fail(failure)
     else:
         task.end(None)
Пример #9
0
 def uploadfirmware(self, machine_type, filename, task):
     with self._condition:
         self._statetransition("idle", "uploadingfirmware")
         uploader = makerbot_driver.Firmware.Uploader()
         self._fp.close()
         try:
             uploader.upload_firmware(self._portname, machine_type, filename)
             task.end(None)
         except makerbot_driver.Firmware.subprocess.CalledProcessError as e:
             self._log.debug('handled exception', exc_info=True)
             message = str(e)
             task.fail(message)
         finally:
             self._fp.open()
             self._statetransition("uploadingfirmware", "idle")
             self._currenttask = None
Пример #10
0
 def uploadfirmware(self, machine_type, filename, task):
     with self._condition:
         self._statetransition("idle", "uploadingfirmware")
         uploader = makerbot_driver.Firmware.Uploader()
         self._fp.close()
         try:
             uploader.upload_firmware(self._portname, machine_type,
                                      filename)
             task.end(None)
         except makerbot_driver.Firmware.subprocess.CalledProcessError as e:
             self._log.debug('handled exception', exc_info=True)
             message = str(e)
             task.fail(message)
         finally:
             self._fp.open()
             self._statetransition("uploadingfirmware", "idle")
             self._currenttask = None
Пример #11
0
 def runningcallback(task):
     self._log.info("weaving together %s and %s to %s for dualstrusion" % (tool_0_path, tool_1_path, outputpath))
     try:
         with contextlib.nested(open(tool_0_path), open(tool_1_path)) as (t0, t1):
             t0_codes = conveyor.dualstrusion.GcodeObject(list(t0))
             t1_codes = conveyor.dualstrusion.GcodeObject(list(t1))
         weaver = conveyor.dualstrusion.DualstrusionWeaver(t0_codes, t1_codes, task)
         woven_codes = weaver.combine_codes()
         progress_processor = makerbot_driver.GcodeProcessors.DualstrusionProgressProcessor()
         output = progress_processor.process_gcode(woven_codes)
         with open(outputpath, 'w') as f:
             for line in output:
                 f.write(line)
     except Exception as e:
         self._log.exception('unhandled exception; dualstrusion weave failed')
         failure = conveyor.util.exception_to_failure(e)
         task.fail(failure)
     else:
         task.end(None)
Пример #12
0
 def runningcallback(task):
     try:
         # TODO: Attention future dave: makerbot_driver needs to import unicode literals
         in_name = inputpath
         for preprocessor in preprocessors:
             #The last prepro should output to the outputpath
             if preprocessor == preprocessors[-1]:
                 out_name = outputpath
             else:
                 with tempfile.NamedTemporaryFile(suffix='.gcode', delete=True) as f:
                     out_name = f.name 
             self._log.info('preprocessing %s -> %s', in_name, out_name)
             preprocessor.process_file(in_name, out_name)
             in_name = out_name
     except Exception as e:
         self._log.debug('unhandled exception', exc_info=True)
         task.fail(e)
     else:
         task.end(None)
Пример #13
0
 def runningcallback(task):
     try:
         # TODO: Attention future dave: makerbot_driver needs to import unicode literals
         in_name = inputpath
         for preprocessor in preprocessors:
             #The last prepro should output to the outputpath
             if preprocessor == preprocessors[-1]:
                 out_name = outputpath
             else:
                 with tempfile.NamedTemporaryFile(suffix='.gcode',
                                                  delete=True) as f:
                     out_name = f.name
             self._log.info('preprocessing %s -> %s', in_name, out_name)
             preprocessor.process_file(in_name, out_name)
             in_name = out_name
     except Exception as e:
         self._log.debug('unhandled exception', exc_info=True)
         task.fail(e)
     else:
         task.end(None)
Пример #14
0
 def runningcallback(task):
     self._log.info('verifying g-code file %s', gcodepath)
     try:
         parser = makerbot_driver.Gcode.GcodeParser()
         parser.state.values['build_name'] = "VALIDATION"
         parser.state.profile = profile._s3g_profile
         parser.s3g = mock.Mock()
         extruders = [e.strip() for e in slicer_settings.extruder.split(',')]
         gcode_scaffold = profile.get_gcode_scaffold(
             extruders,
             slicer_settings.extruder_temperature,
             slicer_settings.platform_temperature,
             material_name)
         parser.environment.update(gcode_scaffold.variables)
         with open(gcodepath) as f:
             for line in f:
                 parser.execute_line(line)
                 update(parser.state.percentage)
     except Exception as e:
         self._log.exception('unhandled exception; g-code verification failed')
         failure = conveyor.util.exception_to_failure(e)
         task.fail(failure)
     else:
         task.end(True)
Пример #15
0
 def func1(task):
     self.assertFalse(callback1.delivered)
     self.assertFalse(callback2.delivered)
     callback1()
     task.fail(None)
Пример #16
0
 def func1(task):
     self.assertFalse(callback1.delivered)
     self.assertFalse(callback2.delivered)
     callback1()
     task.fail(None)