def pack(self, icon_path): """Recreate the zip file from the tmp directory.""" from HardcodeTray.app import App nwjs_sdk = App.get("nwjs") if nwjs_sdk: binary_file = path.join(gettempdir(), self.binary) Logger.debug( "NWJS Application: Creating new archive {}".format(self.binary)) make_archive(binary_file, "zip", self.tmp_path) move(binary_file + ".zip", binary_file + ".nw") local_binary_file = path.join(nwjs_sdk, self.binary) move(binary_file + ".nw", local_binary_file + ".nw") Logger.debug("NWJS Application: Creating executable file.") execute(["cat which nw " + self.binary + ".nw > " + self.binary], True, True, nwjs_sdk) remove(local_binary_file + ".nw") move(local_binary_file, path.join(str(icon_path), self.binary)) execute(["chmod", "+x", path.join(str(icon_path), self.binary)]) rmtree(self.tmp_path)
def pack(self, icon_path): """Recreate the zip file from the tmp directory.""" from HardcodeTray.app import App nwjs_sdk = App.get("nwjs") if nwjs_sdk: binary_file = path.join(gettempdir(), self.binary) Logger.debug("NWJS Application: Creating new archive {}".format( self.binary)) make_archive(binary_file, "zip", self.tmp_path) move(binary_file + ".zip", binary_file + ".nw") local_binary_file = path.join(nwjs_sdk, self.binary) move(binary_file + ".nw", local_binary_file + ".nw") Logger.debug("NWJS Application: Creating executable file.") execute(["cat which nw " + self.binary + ".nw > " + self.binary], True, True, nwjs_sdk) remove(local_binary_file + ".nw") move(local_binary_file, path.join(str(icon_path), self.binary)) execute(["chmod", "+x", path.join(str(icon_path), self.binary)]) rmtree(self.tmp_path)
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 extract(self, icon_path): """Extract the zip file in /tmp directory.""" if path.exists(self.tmp_path): rmtree(self.tmp_path) Logger.debug("NWJS Application: Extracting of {}".format(self.binary)) execute(["unzip", path.join(str(icon_path), self.binary), "-d", self.tmp_path])
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}:{1}".format(str(width), str(height))]) cmd.extend([input_file, output_file]) execute(cmd)
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, "-background", "none"] if width and height: cmd.extend(["-resize", "{0}x{1}".format(str(width), str(height))]) cmd.extend([input_file, output_file]) execute(cmd, True, False)
def extract(self, icon_path): """Extract the zip file in /tmp directory.""" if path.exists(self.tmp_path): rmtree(self.tmp_path) Logger.debug("NWJS Application: Extracting of {}".format(self.binary)) execute([ "unzip", path.join(str(icon_path), self.binary), "-d", self.tmp_path ])
def convert_to_png(self, input_file, output_file, width=None, height=None): """Convert svg to png.""" is_pre_v1 = run([self.cmd, '--without-gui'], shell=False, timeout=4, check=False) if is_pre_v1.returncode != 0: cmd = [self.cmd, '-o', output_file] else: cmd = [self.cmd, '-z', '-e', output_file] if width and height: cmd.extend(['-w', str(width), '-h', str(height)]) cmd.extend(input_file) execute(cmd, False)