Gentoo Archives: gentoo-commits

From: "Patrick Lauer (patrick)" <patrick@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in media-sound/edna/files: edna-0.6-flac.patch edna-0.6-syslog.patch edna.gentoo edna-0.6-daemon.patch edna-0.6-SystemExit.patch
Date: Sun, 01 Mar 2009 14:07:05
Message-Id: E1LdmJq-0007cD-6k@stork.gentoo.org
1 patrick 09/03/01 14:07:02
2
3 Modified: edna.gentoo
4 Added: edna-0.6-flac.patch edna-0.6-syslog.patch
5 edna-0.6-daemon.patch edna-0.6-SystemExit.patch
6 Log:
7 Bump to 0.6. Fixes #137569. Patches by Chris Mayo.
8 (Portage version: 2.2_rc23/cvs/Linux x86_64)
9
10 Revision Changes Path
11 1.7 media-sound/edna/files/edna.gentoo
12
13 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/edna/files/edna.gentoo?rev=1.7&view=markup
14 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/edna/files/edna.gentoo?rev=1.7&content-type=text/plain
15 diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/edna/files/edna.gentoo?r1=1.6&r2=1.7
16
17 Index: edna.gentoo
18 ===================================================================
19 RCS file: /var/cvsroot/gentoo-x86/media-sound/edna/files/edna.gentoo,v
20 retrieving revision 1.6
21 retrieving revision 1.7
22 diff -u -r1.6 -r1.7
23 --- edna.gentoo 9 Sep 2005 22:04:04 -0000 1.6
24 +++ edna.gentoo 1 Mar 2009 14:07:02 -0000 1.7
25 @@ -7,24 +7,25 @@
26 # pidfile: /var/run/ednad.pid
27 # config:
28
29 -export PYTHONPATH=/usr/lib/edna
30 +PYTHONPATH=/usr/lib/edna
31 EDNA=/usr/bin/edna
32 EDNACONF=/etc/edna/edna.conf
33 PIDFILE=/var/run/edna.pid
34 +USER=edna
35
36 depend() {
37 - need local
38 + need local
39 }
40
41 start() {
42 - ebegin "Starting ednad mp3 server"
43 - start-stop-daemon -m -b --start --quiet --pidfile $PIDFILE \
44 - --exec $EDNA -- $EDNACONF
45 - eend $?
46 + ebegin "Starting edna mp3 server"
47 + start-stop-daemon --env PYTHONPATH=$PYTHONPATH \
48 + --start --exec $EDNA -- --daemon --user=$USER --pidfile=$PIDFILE $EDNACONF
49 + eend $?
50 }
51
52 stop() {
53 - ebegin "Stopping ednad"
54 - start-stop-daemon -o --quiet --stop --pidfile $PIDFILE
55 - eend $?
56 + ebegin "Stopping ednad"
57 + start-stop-daemon --quiet --stop --pidfile $PIDFILE
58 + eend $?
59 }
60
61
62
63 1.1 media-sound/edna/files/edna-0.6-flac.patch
64
65 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/edna/files/edna-0.6-flac.patch?rev=1.1&view=markup
66 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/edna/files/edna-0.6-flac.patch?rev=1.1&content-type=text/plain
67
68 Index: edna-0.6-flac.patch
69 ===================================================================
70 --- edna.py.orig 2007-01-31 19:25:14.000000000 +0000
71 +++ edna.py 2007-01-31 20:55:09.000000000 +0000
72 @@ -64,6 +64,12 @@
73 oggSupport = 'no'
74
75 try:
76 + from mutagen.flac import FLAC
77 + flacSupport = True
78 +except ImportError:
79 + flacSupport = False
80 +
81 +try:
82 import cStringIO
83 StringIO = cStringIO
84 except ImportError:
85 @@ -920,6 +926,9 @@
86 if ext == '.ogg':
87 info = OggInfo(fullpath)
88 self.__dict__.update(info.__dict__)
89 + elif ext == '.flac':
90 + info = FlacInfo(fullpath)
91 + self.__dict__.update(info.__dict__)
92 else:
93 info = MP3Info.MP3Info(open(fullpath, 'rb'))
94 self.__dict__.update(info.__dict__)
95 @@ -1001,6 +1010,45 @@
96 self.transcoded = val
97 self.valid = 1
98
99 +class FlacInfo:
100 + def __init__(self, name):
101 + # Setup the defaults
102 + self.valid = 0
103 + self.total_time = 0
104 + self.samplerate = 'unknown'
105 + self.bitrate = 'unknown'
106 + self.mode = ''
107 + self.mode_extension = ''
108 +
109 + if not flacSupport: return
110 +
111 + mflac = FLAC(name)
112 + streaminfo = mflac.metadata_blocks[0]
113 +
114 + self.samplerate = streaminfo.sample_rate
115 + self.total_time = streaminfo.length
116 + self.bitrate =int(round((streaminfo.bits_per_sample * streaminfo.total_samples) / streaminfo.length))
117 + self.filesize = os.path.getsize(name) / (1024 ** 2)
118 +
119 + for key, val in mflac.tags:
120 + if key == 'TITLE':
121 + self.title = val
122 + elif key == 'ARTIST':
123 + self.artist = val
124 + elif key == 'ALBUM':
125 + self.album = val
126 + elif key == 'DATE':
127 + self.year = val
128 + elif key == 'GENRE':
129 + self.genre = val
130 + elif key == 'VENDOR':
131 + self.vendor = val
132 + elif key == 'TRACKNUMBER':
133 + self.track = val
134 + elif key == 'DESCRIPTION':
135 + self.comment = val
136 +
137 + self.valid = 1
138
139 def _usable_file(fname):
140 return fname[0] != '.'
141 @@ -1044,6 +1092,7 @@
142 '.avi' : 'video/x-msvideo',
143 '.mpg' : 'video/mpeg',
144 '.ogg' : 'application/x-ogg',
145 + '.flac' : 'audio/x-flac',
146 '.m4a' : 'audio/mp4',
147 '.mp4' : 'video/mp4',
148 }
149
150
151
152 1.1 media-sound/edna/files/edna-0.6-syslog.patch
153
154 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/edna/files/edna-0.6-syslog.patch?rev=1.1&view=markup
155 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/edna/files/edna-0.6-syslog.patch?rev=1.1&content-type=text/plain
156
157 Index: edna-0.6-syslog.patch
158 ===================================================================
159 --- edna.py.orig 2007-01-27 18:53:24.000000000 +0000
160 +++ edna.py 2007-01-27 18:58:38.000000000 +0000
161 @@ -42,6 +42,7 @@
162 import socket
163 import re
164 import stat
165 +import syslog
166 import random
167 import time
168 import struct
169 @@ -144,6 +145,12 @@
170 self.log = open(log, 'a')
171 except IOError:
172 pass
173 + else:
174 + try:
175 + syslog.openlog('edna')
176 + self.log = True
177 + except:
178 + pass
179
180 template_path = config.get('server', 'template-dir')
181 template_file = config.get('server', 'template')
182 @@ -254,7 +261,7 @@
183 (config.get('server', 'binding-hostname'), self.port),
184 EdnaRequestHandler)
185 except socket.error, value:
186 - self.log_message( "edna: bind(): %s" % str(value[1]) )
187 + self.log_message( "bind(): %s" % str(value[1]) )
188 raise SystemExit
189
190 def server_bind(self):
191 @@ -290,12 +297,17 @@
192 return 0
193
194 def log_message(self, msg):
195 - if self.log:
196 - try:
197 - self.log.write(msg + '\n')
198 - self.log.flush()
199 - except IOError:
200 - pass
201 + if self.log == True:
202 + try:
203 + syslog.syslog(msg)
204 + except:
205 + pass
206 + elif self.log:
207 + try:
208 + self.log.write('edna: ' + msg + '\n')
209 + self.log.flush()
210 + except IOError:
211 + pass
212
213 def debug_message(self, msg):
214 if debug_level<1:
215 @@ -1125,21 +1137,21 @@
216
217 svr = Server(fname)
218 if oggSupport == 'yes':
219 - svr.log_message('edna: Ogg Vorbis support enabled')
220 + svr.log_message('Ogg Vorbis support enabled')
221 else:
222 - svr.log_message('edna: Ogg Vorbis support disabled, to enable it you will need to install the "pyogg" and the "pyvorbis" modules')
223 + svr.log_message('Ogg Vorbis support disabled, to enable it you will need to install the "pyogg" and the "pyvorbis" modules')
224
225 - svr.log_message("edna: serving on port %d..." % svr.port)
226 + svr.log_message("serving on port %d..." % svr.port)
227 try:
228 while running:
229 # print 'waiting ... '
230 if config_needed:
231 - svr.log_message('edna: Reloading config %s' % fname)
232 + svr.log_message('Reloading config %s' % fname)
233 svr.server_close()
234 svr = Server(fname)
235 config_needed = None
236 svr.handle_request()
237 - svr.log_message ("edna: exiting")
238 + svr.log_message ("exiting")
239 sys.exit(0)
240 except KeyboardInterrupt:
241 print "\nCaught ctr-c, taking down the server"
242
243
244
245 1.1 media-sound/edna/files/edna-0.6-daemon.patch
246
247 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/edna/files/edna-0.6-daemon.patch?rev=1.1&view=markup
248 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/edna/files/edna-0.6-daemon.patch?rev=1.1&content-type=text/plain
249
250 Index: edna-0.6-daemon.patch
251 ===================================================================
252 --- edna.py.orig 2007-01-27 18:49:16.000000000 +0000
253 +++ edna.py 2007-01-27 18:47:19.000000000 +0000
254 @@ -36,7 +36,9 @@
255 import string
256 import os
257 import cgi
258 +import ctypes
259 import urllib
260 +import pwd
261 import socket
262 import re
263 import stat
264 @@ -1149,7 +1151,7 @@
265 print ' if config-file is not specified, then edna.conf is used'
266 sys.exit(0)
267
268 -def daemonize(stdin='/dev/null', stdout='/dev/null', stderr='/dev/null',pname=''):
269 +def daemonize(stdin='/dev/null', stdout='/dev/null', stderr='/dev/null', pname='', uid = None):
270 '''This forks the current process into a daemon.
271 The stdin, stdout, and stderr arguments are file names that
272 will be opened and be used to replace the standard file descriptors
273 @@ -1159,6 +1161,11 @@
274 if it shares a file with stdout then interleaved output
275 may not appear in the order that you expect.
276 '''
277 + # Rename process in /proc/<pid>/stat from python to edna
278 + # (helps start-stop-daemon find us)
279 + libc = ctypes.CDLL('/lib/libc.so.6')
280 + libc.prctl(15, 'edna\0', 0, 0, 0)
281 +
282 # Do first fork.
283 try:
284 pid = os.fork()
285 @@ -1186,6 +1193,8 @@
286 sys.stderr.write("fork #2 failed: (%d) %s\n" % (e.errno, e.strerror) )
287 sys.exit(1)
288 # Now I am a daemon!
289 + # If specified change the process owner
290 + if uid: os.setuid(uid)
291 # Redirect standard file descriptors.
292 si = open(stdin, 'r')
293 so = open(stdout, 'a+')
294 @@ -1198,9 +1207,16 @@
295 if __name__ == '__main__':
296 fname = 'edna.conf'
297 daemon_mode=0
298 + uid = os.getuid()
299 + pidfile = '/var/run/edna.pid'
300 for a in sys.argv[1:]:
301 if a == "--daemon":
302 daemon_mode=1
303 + elif a.startswith("--user"):
304 + uname = a.split("=")[1].strip()
305 + uid = pwd.getpwnam(uname)[2]
306 + elif a.startswith("--pidfile"):
307 + pidfile = a.split("=")[1].strip()
308 elif a == "--help" or a == "-h" or string.find(a, '--')==0:
309 usage()
310 else:
311 @@ -1211,6 +1227,6 @@
312 raise SystemExit
313
314 if daemon_mode:
315 - daemonize('/dev/null', '/var/log/edna.log', '/var/log/edna.log', '/var/run/edna.pid')
316 + daemonize(uid = uid, pname = pidfile)
317
318 run_server(fname)
319
320
321
322 1.1 media-sound/edna/files/edna-0.6-SystemExit.patch
323
324 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/edna/files/edna-0.6-SystemExit.patch?rev=1.1&view=markup
325 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/edna/files/edna-0.6-SystemExit.patch?rev=1.1&content-type=text/plain
326
327 Index: edna-0.6-SystemExit.patch
328 ===================================================================
329 --- edna.py.orig 2007-01-27 15:31:00.000000000 +0000
330 +++ edna.py 2007-01-27 16:03:30.000000000 +0000
331 @@ -1159,7 +1159,7 @@
332
333 if os.path.isfile(fname) != 1:
334 print "edna: %s:No such file" %fname
335 - raise systemExit
336 + raise SystemExit
337
338 if daemon_mode:
339 daemonize('/dev/null', '/var/log/edna.log', '/var/log/edna.log', '/var/run/edna.pid')