genisoimage.py 2.67 KB
Newer Older
1
2
3
4
5
6
7
8
#!/usr/bin/env python3

# Copyright 2014 (C) Raster Software Vigo (Sergio Costas)
#
# This file is part of DeVeDe-NG
#
# DeVeDe-NG is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License.
10
11
12
13
14
15
16
17
18
19
#
# DeVeDe-NG is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>

import os
20
import devedeng.configuration_data
21
import subprocess
22
import devedeng.executor
23

Sergio Costas's avatar
Sergio Costas committed
24

25
class genisoimage(devedeng.executor.executor):
26
27
28
29
30
31
32
33
34
35
36
37

    supports_analize = False
    supports_play = False
    supports_convert = False
    supports_menu = False
    supports_mkiso = True
    supports_burn = False
    display_name = "GENISOIMAGE"

    @staticmethod
    def check_is_installed():
        try:
Sergio Costas's avatar
Sergio Costas committed
38
39
            handle = subprocess.Popen(
                ["genisoimage", "--help"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
40
            (stdout, stderr) = handle.communicate()
Sergio Costas's avatar
Sergio Costas committed
41
            if 0 == handle.wait():
42
43
44
45
46
47
48
49
                return True
            else:
                return False
        except:
            return False

    def __init__(self):

50
51
        devedeng.executor.executor.__init__(self)
        self.config = devedeng.configuration_data.configuration.get_config()
52

53
    def create_iso(self, path, name, title):
54

Sergio Costas's avatar
Sergio Costas committed
55
56
        filesystem_path = os.path.join(path, "dvd_tree")
        final_path = os.path.join(path, name + ".iso")
57

58
59
60
61
62
        if title == "":
            final_title = "DVDVIDEO"
        else:
            final_title = title.upper().replace(" ", "_")[:31]

Sergio Costas's avatar
Sergio Costas committed
63
        self.command_var = []
64
65
66
        self.command_var.append("genisoimage")
        self.command_var.append("-dvd-video")
        self.command_var.append("-V")
67
        self.command_var.append(final_title)
68
69
70
71
72
73
74
        self.command_var.append("-v")
        self.command_var.append("-udf")
        self.command_var.append("-o")
        self.command_var.append(final_path)
        self.command_var.append(filesystem_path)
        self.text = _("Creating ISO image")

Sergio Costas's avatar
Sergio Costas committed
75
    def process_stdout(self, data):
76
77
        return

Sergio Costas's avatar
Sergio Costas committed
78
    def process_stderr(self, data):
79
80
81
82
83

        if (data[0].find("% done") == -1):
            return

        l = data[0].split("%")
84
85
86
        l0a = l[0]
        l0b = l0a.replace(",", ".")
        p = float(l0b)
Sergio Costas's avatar
Sergio Costas committed
87
        self.progress_bar[1].set_fraction(p / 100.0)
88
89
90
        self.progress_bar[1].set_text("%.1f%%" % (p))

        return