Example #1
0
  def process_file(self, input_path, output_path):
    """
    Given a filepath, reads each line of that file and, if necessary, 
    transforms it into another format.  If either of these filepaths
    do not lead to .gcode files, we throw a NotGCodeFileError.

    @param input_path: The input file path
    @param output_path: The output file path
    """
    self.inputs_are_gcode(input_path, output_path)

    rp = RpmPreprocessor()
    with tempfile.NamedTemporaryFile(suffix='.gcode', delete=True) as f:
      remove_rpm_path = f.name
    rp.process_file(input_path, remove_rpm_path)

    with tempfile.NamedTemporaryFile(suffix=".gcode", delete=True) as f:
      progress_path = f.name

    #Open both the files
    with contextlib.nested(open(remove_rpm_path), open(progress_path, 'w')) as (i, o):
      #For each line in the input file
      for read_line in i:
        line = self._transform_line(read_line)
        o.write(line)            

    #Do this last for the most accurate progress updates
    pp = ProgressPreprocessor()
    pp.process_file(progress_path, output_path)
Example #2
0
  def process_file(self, input_path, output_path):
    self.inputs_are_gcode(input_path, output_path)

    rp = RpmPreprocessor()
    with tempfile.NamedTemporaryFile(suffix='.gcode', delete=True) as f:
      remove_rpm_path = f.name
    rp.process_file(input_path, remove_rpm_path)

    with tempfile.NamedTemporaryFile(suffix=".gcode", delete=True) as f:
      progress_path = f.name

    #Open both the files
    with contextlib.nested(open(remove_rpm_path), open(progress_path, 'w')) as (i, o):
      #For each line in the input file
      for read_line in i:
        line = self._transform_line(read_line)
        o.write(line)            

    pp = ProgressPreprocessor()
    pp.process_file(progress_path, output_path)
Example #3
0
    def process_file(self, input_path, output_path):
        self.inputs_are_gcode(input_path, output_path)

        rp = RpmPreprocessor()
        with tempfile.NamedTemporaryFile(suffix='.gcode', delete=True) as f:
            remove_rpm_path = f.name
        rp.process_file(input_path, remove_rpm_path)

        with tempfile.NamedTemporaryFile(suffix=".gcode", delete=True) as f:
            progress_path = f.name

        #Open both the files
        with contextlib.nested(open(remove_rpm_path), open(progress_path,
                                                           'w')) as (i, o):
            #For each line in the input file
            for read_line in i:
                line = self._transform_line(read_line)
                o.write(line)

        pp = ProgressPreprocessor()
        pp.process_file(progress_path, output_path)