Debian Codegraph @

src/devedeng/mkisofs.py

raw
1 #!/usr/bin/env python3
2
3 # Copyright 2014 (C) Raster Software Vigo (Sergio Costas)
4 #
5 # This file is part of DeVeDe-NG
6 #
7 # DeVeDe-NG is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 3
9 # as published by the Free Software Foundation.
10 #
11 # DeVeDe-NG is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>
18
19 import os
20 import devedeng.configuration_data
21 import subprocess
22 import devedeng.executor
23
24
25 class mkisofs(devedeng.executor.executor):
26
27 supports_analize = False
28 supports_play = False
29 supports_convert = False
30 supports_menu = False
31 supports_mkiso = True
32 supports_burn = False
33 display_name = "MKISOFS"
34
35 @staticmethod
36 def check_is_installed():
37 try:
38 handle = subprocess.Popen(
39 ["mkisofs", "--help"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
40 (stdout, stderr) = handle.communicate()
41 if 0 == handle.wait():
42 return True
43 else:
44 return False
45 except:
46 return False
47
48 def __init__(self):
49
50 devedeng.executor.executor.__init__(self)
51 self.config = devedeng.configuration_data.configuration.get_config()
52
53 def create_iso(self, path, name, title):
54
55 filesystem_path = os.path.join(path, "dvd_tree")
56 final_path = os.path.join(path, name + ".iso")
57
58 if title == "":
59 final_title = "DVDVIDEO"
60 else:
61 final_title = title.upper().replace(" ", "_")[:31]
62
63 self.command_var = []
64 self.command_var.append("mkisofs")
65 self.command_var.append("-dvd-video")
66 self.command_var.append("-V")
67 self.command_var.append(final_title)
68 self.command_var.append("-v")
69 self.command_var.append("-udf")
70 self.command_var.append("-o")
71 self.command_var.append(final_path)
72 self.command_var.append(filesystem_path)
73 self.text = _("Creating ISO image")
74
75 def process_stdout(self, data):
76 return
77
78 def process_stderr(self, data):
79
80 if (data[0].find("% done") == -1):
81 return
82
83 l = data[0].split("%")
84 l0a = l[0]
85 l0b = l0a.replace(",", ".")
86 p = float(l0b)
87 self.progress_bar[1].set_fraction(p / 100.0)
88 self.progress_bar[1].set_text("%.1f%%" % (p))
89
90 return