1
# -*- coding: utf-8 -*-
2
# thanks to Dave Arter <davea@sucs.org>
3
# Copyright (c) 2005 Dave Arter
4
from subprocess import Popen
5
from subprocess import PIPE
9
"""Mkisofs is a wrapper for the mkisofs program. It simplifies
10
calls to mkisofs and tracks its progress. An optional hook is
11
provided which will be called whenever a percentage progress is
12
reported by mkisofs."""
15
self.progress_hook = None
19
def set_progress_hook(self, hook = None):
21
"""Sets the progress hook function to the argument hook. The
22
function specified by hook should accept a floating point number
23
as its only argument."""
26
self.progress_hook = hook
28
def _set_progress(self, progress):
30
self.progress = float(progress)
34
def report_progress(self):
36
"""Calls the progress hook if one has been specified."""
37
if callable(self.progress_hook):
38
self.progress_hook(self.progress)
40
def execute(self, command, path, destination):
42
"""Takes a source file path and creates an iso file with it, which
43
is written to the isofile path. mkisofs is called with option -r.
44
See the mkisofs manual for details"""
46
inFile = open(destination,'w')
47
process = Popen(args, 1, stdout=inFile, stderr=PIPE, cwd = path, shell = True )
48
self.retval = process.poll()
49
while (self.retval is None):
50
self._set_progress(-1)
51
self.report_progress()
52
self.retval = process.poll()
58
"""Gets the value returned by mkisofs or None if it hasn't