summaryrefslogtreecommitdiff
path: root/media-sound/edna/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /media-sound/edna/files
reinit the tree, so we can have metadata
Diffstat (limited to 'media-sound/edna/files')
-rw-r--r--media-sound/edna/files/edna-0.6-SystemExit.patch11
-rw-r--r--media-sound/edna/files/edna-0.6-daemon.patch67
-rw-r--r--media-sound/edna/files/edna-0.6-flac.patch79
-rw-r--r--media-sound/edna/files/edna-0.6-syslog.patch83
-rw-r--r--media-sound/edna/files/edna.gentoo31
5 files changed, 271 insertions, 0 deletions
diff --git a/media-sound/edna/files/edna-0.6-SystemExit.patch b/media-sound/edna/files/edna-0.6-SystemExit.patch
new file mode 100644
index 000000000000..78aec6f3176a
--- /dev/null
+++ b/media-sound/edna/files/edna-0.6-SystemExit.patch
@@ -0,0 +1,11 @@
+--- edna.py.orig 2007-01-27 15:31:00.000000000 +0000
++++ edna.py 2007-01-27 16:03:30.000000000 +0000
+@@ -1159,7 +1159,7 @@
+
+ if os.path.isfile(fname) != 1:
+ print "edna: %s:No such file" %fname
+- raise systemExit
++ raise SystemExit
+
+ if daemon_mode:
+ daemonize('/dev/null', '/var/log/edna.log', '/var/log/edna.log', '/var/run/edna.pid')
diff --git a/media-sound/edna/files/edna-0.6-daemon.patch b/media-sound/edna/files/edna-0.6-daemon.patch
new file mode 100644
index 000000000000..e003689956a7
--- /dev/null
+++ b/media-sound/edna/files/edna-0.6-daemon.patch
@@ -0,0 +1,67 @@
+--- edna.py.orig 2007-01-27 18:49:16.000000000 +0000
++++ edna.py 2007-01-27 18:47:19.000000000 +0000
+@@ -36,7 +36,9 @@
+ import string
+ import os
+ import cgi
++import ctypes
+ import urllib
++import pwd
+ import socket
+ import re
+ import stat
+@@ -1149,7 +1151,7 @@
+ print ' if config-file is not specified, then edna.conf is used'
+ sys.exit(0)
+
+-def daemonize(stdin='/dev/null', stdout='/dev/null', stderr='/dev/null',pname=''):
++def daemonize(stdin='/dev/null', stdout='/dev/null', stderr='/dev/null', pname='', uid = None):
+ '''This forks the current process into a daemon.
+ The stdin, stdout, and stderr arguments are file names that
+ will be opened and be used to replace the standard file descriptors
+@@ -1159,6 +1161,11 @@
+ if it shares a file with stdout then interleaved output
+ may not appear in the order that you expect.
+ '''
++ # Rename process in /proc/<pid>/stat from python to edna
++ # (helps start-stop-daemon find us)
++ libc = ctypes.CDLL('/lib/libc.so.6')
++ libc.prctl(15, 'edna\0', 0, 0, 0)
++
+ # Do first fork.
+ try:
+ pid = os.fork()
+@@ -1186,6 +1193,8 @@
+ sys.stderr.write("fork #2 failed: (%d) %s\n" % (e.errno, e.strerror) )
+ sys.exit(1)
+ # Now I am a daemon!
++ # If specified change the process owner
++ if uid: os.setuid(uid)
+ # Redirect standard file descriptors.
+ si = open(stdin, 'r')
+ so = open(stdout, 'a+')
+@@ -1198,9 +1207,16 @@
+ if __name__ == '__main__':
+ fname = 'edna.conf'
+ daemon_mode=0
++ uid = os.getuid()
++ pidfile = '/var/run/edna.pid'
+ for a in sys.argv[1:]:
+ if a == "--daemon":
+ daemon_mode=1
++ elif a.startswith("--user"):
++ uname = a.split("=")[1].strip()
++ uid = pwd.getpwnam(uname)[2]
++ elif a.startswith("--pidfile"):
++ pidfile = a.split("=")[1].strip()
+ elif a == "--help" or a == "-h" or string.find(a, '--')==0:
+ usage()
+ else:
+@@ -1211,6 +1227,6 @@
+ raise SystemExit
+
+ if daemon_mode:
+- daemonize('/dev/null', '/var/log/edna.log', '/var/log/edna.log', '/var/run/edna.pid')
++ daemonize(uid = uid, pname = pidfile)
+
+ run_server(fname)
diff --git a/media-sound/edna/files/edna-0.6-flac.patch b/media-sound/edna/files/edna-0.6-flac.patch
new file mode 100644
index 000000000000..b22687d2fb05
--- /dev/null
+++ b/media-sound/edna/files/edna-0.6-flac.patch
@@ -0,0 +1,79 @@
+--- edna.py.orig 2007-01-31 19:25:14.000000000 +0000
++++ edna.py 2007-01-31 20:55:09.000000000 +0000
+@@ -64,6 +64,12 @@
+ oggSupport = 'no'
+
+ try:
++ from mutagen.flac import FLAC
++ flacSupport = True
++except ImportError:
++ flacSupport = False
++
++try:
+ import cStringIO
+ StringIO = cStringIO
+ except ImportError:
+@@ -920,6 +926,9 @@
+ if ext == '.ogg':
+ info = OggInfo(fullpath)
+ self.__dict__.update(info.__dict__)
++ elif ext == '.flac':
++ info = FlacInfo(fullpath)
++ self.__dict__.update(info.__dict__)
+ else:
+ info = MP3Info.MP3Info(open(fullpath, 'rb'))
+ self.__dict__.update(info.__dict__)
+@@ -1001,6 +1010,45 @@
+ self.transcoded = val
+ self.valid = 1
+
++class FlacInfo:
++ def __init__(self, name):
++ # Setup the defaults
++ self.valid = 0
++ self.total_time = 0
++ self.samplerate = 'unknown'
++ self.bitrate = 'unknown'
++ self.mode = ''
++ self.mode_extension = ''
++
++ if not flacSupport: return
++
++ mflac = FLAC(name)
++ streaminfo = mflac.metadata_blocks[0]
++
++ self.samplerate = streaminfo.sample_rate
++ self.total_time = streaminfo.length
++ self.bitrate =int(round((streaminfo.bits_per_sample * streaminfo.total_samples) / streaminfo.length))
++ self.filesize = os.path.getsize(name) / (1024 ** 2)
++
++ for key, val in mflac.tags:
++ if key == 'TITLE':
++ self.title = val
++ elif key == 'ARTIST':
++ self.artist = val
++ elif key == 'ALBUM':
++ self.album = val
++ elif key == 'DATE':
++ self.year = val
++ elif key == 'GENRE':
++ self.genre = val
++ elif key == 'VENDOR':
++ self.vendor = val
++ elif key == 'TRACKNUMBER':
++ self.track = val
++ elif key == 'DESCRIPTION':
++ self.comment = val
++
++ self.valid = 1
+
+ def _usable_file(fname):
+ return fname[0] != '.'
+@@ -1044,6 +1092,7 @@
+ '.avi' : 'video/x-msvideo',
+ '.mpg' : 'video/mpeg',
+ '.ogg' : 'application/x-ogg',
++ '.flac' : 'audio/x-flac',
+ '.m4a' : 'audio/mp4',
+ '.mp4' : 'video/mp4',
+ }
diff --git a/media-sound/edna/files/edna-0.6-syslog.patch b/media-sound/edna/files/edna-0.6-syslog.patch
new file mode 100644
index 000000000000..4ff0bbf8bdb9
--- /dev/null
+++ b/media-sound/edna/files/edna-0.6-syslog.patch
@@ -0,0 +1,83 @@
+--- edna.py.orig 2007-01-27 18:53:24.000000000 +0000
++++ edna.py 2007-01-27 18:58:38.000000000 +0000
+@@ -42,6 +42,7 @@
+ import socket
+ import re
+ import stat
++import syslog
+ import random
+ import time
+ import struct
+@@ -144,6 +145,12 @@
+ self.log = open(log, 'a')
+ except IOError:
+ pass
++ else:
++ try:
++ syslog.openlog('edna')
++ self.log = True
++ except:
++ pass
+
+ template_path = config.get('server', 'template-dir')
+ template_file = config.get('server', 'template')
+@@ -254,7 +261,7 @@
+ (config.get('server', 'binding-hostname'), self.port),
+ EdnaRequestHandler)
+ except socket.error, value:
+- self.log_message( "edna: bind(): %s" % str(value[1]) )
++ self.log_message( "bind(): %s" % str(value[1]) )
+ raise SystemExit
+
+ def server_bind(self):
+@@ -290,12 +297,17 @@
+ return 0
+
+ def log_message(self, msg):
+- if self.log:
+- try:
+- self.log.write(msg + '\n')
+- self.log.flush()
+- except IOError:
+- pass
++ if self.log == True:
++ try:
++ syslog.syslog(msg)
++ except:
++ pass
++ elif self.log:
++ try:
++ self.log.write('edna: ' + msg + '\n')
++ self.log.flush()
++ except IOError:
++ pass
+
+ def debug_message(self, msg):
+ if debug_level<1:
+@@ -1125,21 +1137,21 @@
+
+ svr = Server(fname)
+ if oggSupport == 'yes':
+- svr.log_message('edna: Ogg Vorbis support enabled')
++ svr.log_message('Ogg Vorbis support enabled')
+ else:
+- svr.log_message('edna: Ogg Vorbis support disabled, to enable it you will need to install the "pyogg" and the "pyvorbis" modules')
++ svr.log_message('Ogg Vorbis support disabled, to enable it you will need to install the "pyogg" and the "pyvorbis" modules')
+
+- svr.log_message("edna: serving on port %d..." % svr.port)
++ svr.log_message("serving on port %d..." % svr.port)
+ try:
+ while running:
+ # print 'waiting ... '
+ if config_needed:
+- svr.log_message('edna: Reloading config %s' % fname)
++ svr.log_message('Reloading config %s' % fname)
+ svr.server_close()
+ svr = Server(fname)
+ config_needed = None
+ svr.handle_request()
+- svr.log_message ("edna: exiting")
++ svr.log_message ("exiting")
+ sys.exit(0)
+ except KeyboardInterrupt:
+ print "\nCaught ctr-c, taking down the server"
diff --git a/media-sound/edna/files/edna.gentoo b/media-sound/edna/files/edna.gentoo
new file mode 100644
index 000000000000..add215faca76
--- /dev/null
+++ b/media-sound/edna/files/edna.gentoo
@@ -0,0 +1,31 @@
+#!/sbin/openrc-run
+#
+# Startup script for the edna mp3 mini server
+#
+# description: edna is a mini mp3 webserver
+# processname: python
+# pidfile: /var/run/ednad.pid
+# config:
+
+PYTHONPATH=/usr/lib/edna
+EDNA=/usr/bin/edna
+EDNACONF=/etc/edna/edna.conf
+PIDFILE=/var/run/edna.pid
+USER=edna
+
+depend() {
+ need local
+}
+
+start() {
+ ebegin "Starting edna mp3 server"
+ start-stop-daemon --env PYTHONPATH=$PYTHONPATH \
+ --start --exec $EDNA -- --daemon --user=$USER --pidfile=$PIDFILE $EDNACONF
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ednad"
+ start-stop-daemon --quiet --stop --pidfile $PIDFILE
+ eend $?
+}