Esempio n. 1
0
    def pack(self, icon_path):
        """Recreate the zip file from the tmp directory."""
        from src.app import App
        nwjs_sdk = App.get("nwjs")
        if nwjs_sdk:
            binary_file = "/tmp/{0}".format(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)
Esempio n. 2
0
    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)
Esempio n. 3
0
    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)
Esempio n. 4
0
    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)
Esempio n. 5
0
    def extract(self, icon_path):
        """Extract the zip file in /tmp directory."""

        if path.exists(self.tmp_path):
            rmtree(self.tmp_path)

        execute([
            "unzip",
            path.join(str(icon_path), self.binary), "-d", self.tmp_path
        ])
Esempio n. 6
0
    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)
Esempio n. 7
0
    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(path.join(str(icon_path), self.binary)) as zip_object:
            zip_object.extractall(self.tmp_path)
Esempio n. 8
0
    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
        ])
Esempio n. 9
0
def get_version(path):
    version = utils.execute(path, '--version')
    version_line = ''
    for line in version.split('\n'):
        if 'Version' in line:
            version_line = line
            break

    return version_line.split(' ')[-1]
Esempio n. 10
0
def get_version(path):
    version = utils.execute(path, '--version')
    return ' '.join(version.split(' ')[1:])
Esempio n. 11
0
def get_version(path):
    #Not the best way to get the version
    version = utils.execute(path, '-m')
    return version.split(' ')[1][:-1]