4 # Copyright 2009 Marcin Karpezo <sirmacik at gmail dot com>
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 from optparse
import OptionParser
27 print "Looking for cdrkit..."
28 if os
.path
.exists('/usr/bin/wodim') and os
.path
.exists('/usr/bin/genisoimage'):
29 globals() ["writer"] = 'wodim'
30 globals() ["isomaker"] = 'genisoimage'
34 print >>sys
.stderr
, "Not found\nLooking for cdrtools..."
35 if os
.path
.exists('/usr/bin/cdrecord') and os
.path
.exists('/usr/bin/mkisofs'):
36 globals() ["writer"] = 'cdrecord'
37 globals() ["isomaker"] = 'mkisofs'
40 print >>sys
.stderr
, "Not found: Please install cdrkit or cdrtools!"
43 print "Making iso image..."
44 command
= "%s -U -o %s %s" % (isomaker
, isoname
, datadir
)
45 makeiso
= subprocess
.Popen(command
, stdout
=subprocess
.PIPE
, shell
=True).communicate()[0]
47 print >>sys
.stderr
, "Failed!"
52 print "Burning iso..."
54 burnspeed
= " --speed=%s" % speed
61 command
= "%s --eject -v --dev=%s %s %s %s" % (writer
, device
, burnspeed
, runtest
, isoname
)
62 burniso
= subprocess
.Popen(command
, stdout
=subprocess
.PIPE
, shell
=True).communicate()[0]
64 print >>sys
.stderr
, "Failed!"
68 if __name__
=="__main__":
69 usage
= "usage: %prog [options]"
70 parser
= OptionParser(usage
=usage
)
71 parser
.add_option("--data", dest
="datadir",
72 help="set directory with data to burn")
73 parser
.add_option("--name", dest
="isoname",
74 help="set path and/or name of iso image")
75 parser
.add_option("--device", dest
="device", default
="/dev/sr0",
76 help="set device to use (default /dev/sr0)")
77 parser
.add_option("--speed", dest
="speed",
78 help="set burn speed (by default it will be autodetected)")
79 parser
.add_option("-t", "--test", action
="store_true", dest
="test", default
= False ,
80 help="run in test burn mode")
81 parser
.add_option("-b", "--burn-only", action
="store_true", dest
="burn", default
=False,
82 help="run without making iso image")
83 parser
.add_option("-m", "--makeiso", action
="store_true", dest
="make", default
=False,
84 help="make only iso image")
86 (options
, args
) = parser
.parse_args()
87 datadir
= options
.datadir
88 isoname
= options
.isoname
89 device
= options
.device