New python try of abcde
[clinton/abcde.git] /
2c5ad283 1#!env python
2# Copyright (c) 2007 Jesus Climent <>
3# This code is hereby licensed for public consumption under either the
4# GNU GPL v2 or greater, or Larry Wall's Artistic license - your choice.
6# You should have received a copy of the GNU General Public License along
7# with this program; if not, write to the Free Software Foundation, Inc.,
8# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
10# $Id: abcde 232 2007-03-22 21:39:30Z data $
13# import those needed modules.
15import os
16import re
18version = "1.0-$Revision$"
20help = """This is abcde version """ + version + """
22usage: [options] [tracks]
24-1 Encode the whole CD in a single file
25-a <action1[,action2]...>
26 Actions to perform:
27 cddb,read,normalize,encode,tag,move,replaygain,playlist,clean
28-b Enable batch normalization
29-c <file>
30 Specify a configuration file (overrides system and user config files)
31-C <discid#>
32 Specify discid to resume from (only needed if you no longer have the cd)
33-d <device>
34 Specify CDROM device to grab (flac uses a single-track flac file)
35-D Debugging mode (equivalent to sh -x abcde)
36-e Erase encoded track information from status file
37-f Force operations that otherwise are considered harmful. Read "man abcde"
38-g Use "lame --nogap" for MP3 encoding. Disables low disk and pipes flags
39-h This help information
40#-i Tag files while encoding, when possible (local only) -NWY-
41-j <#> Number of encoder processes to run at once (localhost)
42-k Keep the wav tracks for later use
43-l Use low disk space algorithm
44-L Use local CDDB storage directory
45-n No lookup. Don't query CDDB, just create and use template
46-N Noninteractive. Never prompt for anything
47-m Modify playlist to include CRLF endings, to comply with some players
48 WARNING: Deprecated. Use \"cue\" action
49-o <type1[,type2]...>
50 Output file type(s) (vorbis,mp3,flac,spx,mpc,wav,m4a). Defaults to vorbis
51-p Pad track numbers with 0's (if less than 10 tracks)
52-P Use UNIX pipes to read+encode without wav files
53-q <level>
54 Set quality level (high,medium,low)
55-r <host1[,host2]...>
56 Also encode on these remote hosts
57-R Use local CDDB in recursive mode
58-s <field>
59 Show dielfs from the CDDB info (year,genre)
60-S <#> Set the CD speed
61-t <#> Start the track numbering at a given number
62-T <#> Same as -t but modifies tag numbering
63-U Do NOT use UNICODE (UTF8) tags and comments
64-v Show version number and exit
65-V Be a bit more verbose about what is happening behind the scenes
66-x Eject CD after all tracks are read
67-w <comment>
68 Add a comment to the CD tracks
69-W <#> Contatenate CDs: -T #01 -w "CD #"
70-z Use debug CDROMREADERSYNTAX option (needs cdparanoia)
72Tracks is a space-delimited list of tracks to grab.
73Ranges specified with hyphens are allowed (i.e., 1-5).
77def usage ():
78 print help
80def addstatus(status):
81 pass
83def log(status,logstring):
84 pass
86def f_seq_row (min,max):
87 try:
88 seq = range(min,max)
89 return seq
90 except:
91 log(error,"syntax error while processing track numbers")
92 return -1
94def f_seq_line (min,max):
95 try:
96 seq = range(min,max)
97 return seq
98 except:
99 log(error,"syntax error while processing track numbers")
100 return -1
104# get_first and get_last can be substituted by range[0] and range[:-1]
106# checkstatus(string)
107# Returns "0" if the string was found, returns 1 if it wasn't
108# Puts the blurb content, if available, on stdout.
109# Otherwise, returns "".
110def checkstatus (string, file):
112 patern = re.compile("^"+string+"(=.*)?$")
114 try:
115 file = open(file, "r")
116 except:
117 log("error","file",file,"cannot be read")
118 return -1
120 blurb = []
121 while 1:
122 line = file.readline()
123 if line == "": break
124 blurb.append(,line).string)
126 print blurb
127 if blurb[-1]:
128 return 0
129 else:
130 return 1
132print checkstatus("test", "/tmp/status")