def convert_to_png(self, input_file, output_file, width=None, height=None): """Convert svg to png.""" cmd = [self.cmd, "-f", "png", "-o", output_file] if width and height: cmd.extend(["-w", str(width), "-h", str(height)]) cmd.append(input_file) execute(cmd)
def convert_to_png(self, input_file, output_file, width=None, height=None): """Convert svg to png.""" cmd = [self.cmd, "-z", "-f", input_file, "-e", output_file] if width and height: cmd.extend(["-w", str(width), "-h", str(height)]) # Fix for inkscape 0.92 execute(cmd, False)
def convert_to_png(self, input_file, output_file, width=None, height=None): """Convert svg to png.""" cmd = [self.cmd, input_file, output_file] if width and height: cmd.extend(["{0!s}:{1!s}".format(str(width), str(height))]) cmd.extend([input_file, output_file]) execute(cmd)
def extract(self, icon_path): """Extract the zip file in /tmp directory.""" if path.exists(self.tmp_path): rmtree(self.tmp_path) makedirs(self.tmp_path, exist_ok=True) execute(["chmod", "0777", self.tmp_path]) with ZipFile(icon_path + self.binary) as zf: zf.extractall(self.tmp_path)
def pack(self, icon_path): """Recreate the zip file from the tmp directory.""" binary_file = icon_path + self.get_binary() if path.exists(binary_file): remove(binary_file) copy_file(self.tmp_path + "package.json", icon_path + "package.json") make_archive(binary_file, 'zip', self.tmp_path) move(binary_file + ".zip", binary_file + ".nw") execute(["/usr/bin/nw", binary_file + ".nw > " + binary_file]) execute(["chmod", "+x", binary_file])
def replace_vars_path(self, _path): """Replace common variables informations.""" old_path = _path _path = _path.replace("{userhome}", USERHOME) _path = _path.replace("{size}", str(self.default_icon_size)) _path = _path.replace("{arch}", ARCH) if self.data["exec_path_script"]: script_path = path.join(absolute_path, "paths", self.data["exec_path_script"]) if path.exists(script_path): _path = execute([script_path, _path], verbose=True).decode("utf-8").strip() else: logging.error("Script file `%s` not found", script_path) if _path != old_path: logging.debug("new application %s path : %s", self.data["name"], _path) return _path
def extract(self, icon_path): """Extract the zip file in /tmp directory.""" if path.exists(self.tmp_path): rmtree(self.tmp_path) execute(["unzip", icon_path + self.get_binary(), "-d", self.tmp_path]) execute(["chmod", "0777", self.tmp_path])