def optimize(self, filepath):
        self.filepath = filepath
        params = self.get_params_for(filepath)
        self.cmdline = params % self.cmdline_template
        self.dest_path = self.dest_path_template % params
        process = Popen(self.cmdline, shell=True, stdout=PIPE, stderr=PIPE)
        self.stdout, self.stderr = process.stdout.read(), process.stderr.read()
        self.retval = process.wait()
        if self.retval:
            self.error('Cairotext external optimizer failure')
        elif not exists(self.dest_path):
            self.error('Cairotext optimized image missing')
        elif self.stdout or self.stderr:
            if not self.stderr.startswith('libpng warning: '):
                self.error('Cairotext optimizer output')
        if exists(self.dest_path):
            # os.rename overwrites existing destination
            rename(self.dest_path, filepath)
dataset/ETHPy150Open akaihola/django-cairo-text/cairotext/templatetags/cairotext.py/Optimizer.optimize/swapped operands of `%`