3 # Copyright (c) 2009, Marcin Karpezo
6 # Redistribution and use in source and binary forms, with or without modification,
7 # are permitted provided that the following conditions are met:
9 # * Redistributions of source code must retain the above copyright notice,
10 # this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above copyright notice,
12 # this list of conditions and the following disclaimer in the documentation
13 # and/or other materials provided with the distribution.
14 # * Neither the name of the simpleburner nor the names of its contributors may
15 # be used to endorse or promote products derived from this software without
16 # specific prior written permission.
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24 # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
32 from optparse
import OptionParser
35 print "Looking for cdrkit..."
36 if os
.path
.exists('/usr/bin/wodim') and os
.path
.exists('/usr/bin/genisoimage'):
37 globals() ["writer"] = 'wodim'
38 globals() ["isomaker"] = 'genisoimage'
42 print >>sys
.stderr
, "Not found\nLooking for cdrtools..."
43 if os
.path
.exists('/usr/bin/cdrecord') and os
.path
.exists('/usr/bin/mkisofs'):
44 globals() ["writer"] = 'cdrecord'
45 globals() ["isomaker"] = 'mkisofs'
48 print >>sys
.stderr
, "Not found: Please install cdrkit or cdrtools!"
53 print >>sys
.stderr
, "Failed! You must deine --data option."
55 elif not os
.path
.exists(datadir
):
56 print >>sys
.stderr
, "Failed! Data directory does not exist!"
59 print "Making iso image..."
60 command
= "%s -U -quiet -o %s "%s"" % (isomaker
, isoname
, datadir
)
61 makeiso
= subprocess
.Popen(command
, stdout
=subprocess
.PIPE
, shell
=True).communicate()[0]
63 print >>sys
.stderr
, "Failed!"
66 print "[OK]\nFile stored in %s" % isoname
68 print "Burning iso..."
70 burnspeed
= " --speed=%s" % speed
77 command
= "%s --eject -vs -%s --dev=%s %s %s %s" % (writer
, mode
, device
, burnspeed
, runtest
, isoname
)
78 burniso
= subprocess
.Popen(command
, stdout
=subprocess
.PIPE
, shell
=True).communicate()[0]
80 print >>sys
.stderr
, "Failed or ended successfully with warnings"
85 if __name__
=="__main__":
86 usage
= "usage: %prog [options]"
87 parser
= OptionParser(usage
=usage
)
88 parser
.add_option("--data", dest
="datadir",
89 help="set directory with data to burn")
90 parser
.add_option("--name", dest
="isoname", default
="/tmp/cd.iso",
91 help="set path and/or name of iso image (by default /tmp/cd.iso)")
92 parser
.add_option("--device", dest
="device", default
="/dev/sr0",
93 help="set device to use (default /dev/sr0)")
94 parser
.add_option("--speed", dest
="speed",
95 help="set burn speed (by default it will be autodetected)")
96 parser
.add_option("--mode", dest
="mode", default
="tao",
97 help="set burn mode; available options are: TAO (default), DAO, SAO, RAW)")
98 parser
.add_option("-t", "--test", action
="store_true", dest
="test", default
= False ,
99 help="run in test burn mode")
100 parser
.add_option("-b", "--burn-only", action
="store_true", dest
="burn", default
=False,
101 help="run without making iso image")
102 parser
.add_option("-m", "--makeiso", action
="store_true", dest
="make", default
=False,
103 help="make only iso image")
105 (options
, args
) = parser
.parse_args()
106 datadir
= options
.datadir
107 isoname
= options
.isoname
108 device
= options
.device
109 speed
= options
.speed