# HG changeset patch # User renatofilho # Date 1187708684 -3600 # Node ID 7f290a3a34b18e7b38e88ad32a2c7e3f1877a19e # Parent 8a6b143057d7f6216795c5bb24e93fcc2d04a4f2 [svn r821] created debian packages;\nImplemented server deamon;\n diff -r 8a6b143057d7 -r 7f290a3a34b1 gmyth-stream/server/0.3/debian/changelog --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/server/0.3/debian/changelog Tue Aug 21 16:04:44 2007 +0100 @@ -0,0 +1,6 @@ +gms (0.3-indt1) unstable; urgency=low + + * First package + + -- Renato Araujo Oliveira Filho Thu, 16 Aug 2007 14:55:00 -0300 + diff -r 8a6b143057d7 -r 7f290a3a34b1 gmyth-stream/server/0.3/debian/compat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/server/0.3/debian/compat Tue Aug 21 16:04:44 2007 +0100 @@ -0,0 +1,1 @@ +5 diff -r 8a6b143057d7 -r 7f290a3a34b1 gmyth-stream/server/0.3/debian/control --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/server/0.3/debian/control Tue Aug 21 16:04:44 2007 +0100 @@ -0,0 +1,13 @@ +Source: gms +Section: sound +Priority: optional +Maintainer: Renato Araujo Oliveira Filho +Build-Depends: debhelper (>= 5.0.38), python-support (>= 0.5), python-central (>= 0.5) +Standards-Version: 3.7.2 + +Package: gms +Architecture: any +Depends: ${python:Depends}, libgstreamer0.10-0, gstreamer0.10-plugins-base, gstreamer0.10-plugins-good +Recommends: gstreamer0.10-plugins-ugly +Description: Media transcoder deamon + Homepage: http://gmyth.sourceforge.net/ diff -r 8a6b143057d7 -r 7f290a3a34b1 gmyth-stream/server/0.3/debian/copyright --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/server/0.3/debian/copyright Tue Aug 21 16:04:44 2007 +0100 @@ -0,0 +1,19 @@ +It was downloaded from: http://gmyth.sourceforge.net/wiki/ + +License: + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian systems, the complete text of the GNU General Public License can +be found in `/usr/share/common-licenses/GPL'. diff -r 8a6b143057d7 -r 7f290a3a34b1 gmyth-stream/server/0.3/debian/gms.install --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/server/0.3/debian/gms.install Tue Aug 21 16:04:44 2007 +0100 @@ -0,0 +1,8 @@ +debian/tmp/usr/share/gms/lib/*.py usr/share/gms/lib +debian/tmp/usr/share/gms/plugins/*.py usr/share/gms/plugins +debian/tmp/usr/share/gms/plugins/transcoders/*.py usr/share/gms/plugins/transcoders +debian/tmp/usr/share/gms/plugins/transcoders/mencoder_lib/*.py usr/share/gms/plugins/transcoders/mencoder_lib +debian/tmp/usr/share/gms/html/* usr/share/gms/html +debian/tmp/usr/bin/* usr/bin +debian/etc/init.d/gmsd etc/init.d +debian/etc/gms/*.conf etc/gms/ diff -r 8a6b143057d7 -r 7f290a3a34b1 gmyth-stream/server/0.3/debian/gms.postinst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/server/0.3/debian/gms.postinst Tue Aug 21 16:04:44 2007 +0100 @@ -0,0 +1,29 @@ +#! /bin/sh +# postinst script for gms + +set -e + +case "$1" in + configure) + if ! getent passwd gms >/dev/null; then + adduser --disabled-password --quiet --system \ + --home /var/gms-media \ + --gecos "GMS media dir" --group gms + fi + if ! getent passwd gms | grep -q /var/run/gms; then + usermod -d /var/gms-media gms + fi + update-rc.d gmsd defaults + invoke-rc.d gmsd start + ;; + abort-upgrade|abort-remove|abort-deconfigure) + ;; + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 diff -r 8a6b143057d7 -r 7f290a3a34b1 gmyth-stream/server/0.3/debian/gms.postrm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/server/0.3/debian/gms.postrm Tue Aug 21 16:04:44 2007 +0100 @@ -0,0 +1,13 @@ +#!/bin/sh + +set -e + +#DEBHELPER# + +if [ "$1" = "purge" ] ; then + invoke-rc.d --force gms stop + deluser --quiet --system gms > /dev/null || true + delgroup --quiet --system gms > /dev/null || true +fi + +exit 0 diff -r 8a6b143057d7 -r 7f290a3a34b1 gmyth-stream/server/0.3/debian/rules --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/server/0.3/debian/rules Tue Aug 21 16:04:44 2007 +0100 @@ -0,0 +1,52 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +PYVER=2.5 +PYTHON=python$(PYVER) + +PREFIX=debian/tmp + +build: build-stamp + +build-stamp: + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + dh_clean + +install: build + dh_testdir + dh_testroot + dh_installdirs + dh_clean -k + + @rm -rf build + @$(PYTHON) setup.py install --prefix=$(PREFIX)/usr --no-compile --install-purelib=$(PREFIX)/usr/share/gms + install -D -o root -g root -m 755 $(PREFIX)/usr/etc/init.d/gmsd debian/$(cdbs_curpkg)/etc/init.d/gmsd + install -D -o root -g root -m 755 $(PREFIX)/usr/etc/gms/server.conf debian/$(cdbs_curpkg)/etc/gms/server.conf + + dh_install + +# Build architecture-independent files here. +binary-indep: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep +.PHONY: clean binary-indep binary install + diff -r 8a6b143057d7 -r 7f290a3a34b1 gmyth-stream/server/0.3/gms.py --- a/gmyth-stream/server/0.3/gms.py Tue Aug 21 16:02:24 2007 +0100 +++ b/gmyth-stream/server/0.3/gms.py Tue Aug 21 16:04:44 2007 +0100 @@ -5,12 +5,18 @@ __license__ = "GPL" __version__ = "0.3" __thanks__ = "Gustavo Sverzut Barbieri" +__GMS_DATA_DIR__ = "/usr/share/gms/" import sys import os import mimetypes import logging as log + +if os.path.exists (__GMS_DATA_DIR__): + sys.path.append(__GMS_DATA_DIR__) + from lib.server import serve_forever, load_plugins_transcoders +from lib.utils import config mimetypes.init() log_level = log.INFO @@ -23,9 +29,46 @@ "\t%(message)s"), datefmt="%Y-%m-%d %H:%M:%S") -if not os.path.exists(".transcoded"): - os.mkdir(".transcoded") +if config.get_transcoded_location () is None: + print "Gms not configured" + exit (0) -pd = os.path.join("plugins", "transcoders") -load_plugins_transcoders(pd) +if not os.path.exists(config.get_transcoded_location()): + os.mkdir(config.get_transcoded_location()) + + +if "-d" in sys.argv: + #run with deamon + try: + pid = os.fork() + if pid > 0: + sys.exit(0) + except OSError, e: + print >>sys.stderr, "Fail to start deamon: %d (%s)" % (e.errno, e.strerror) + sys.exit(1) + + os.chdir("/") + os.setsid() + os.umask(0) + + try: + pid = os.fork() + if pid > 0: + fp = open ("/var/run/gms.pid", "w") + fp.write ("%d" % pid) + fp.close () + sys.exit(0) + except OSError, e: + print >>sys.stderr, "Fail to start deamon: %d (%s)" % (e.errno, e.strerror) + sys.exit(1) + +# main deamon +pd = os.path.join(__GMS_DATA_DIR__, "plugins", "transcoders") +if os.path.exists (pd): + load_plugins_transcoders(pd) + +pd = os.path.join("plugins", "transcoders"); +if os.path.exists (pd): + load_plugins_transcoders(pd) + serve_forever() diff -r 8a6b143057d7 -r 7f290a3a34b1 gmyth-stream/server/0.3/lib/file_handler.py --- a/gmyth-stream/server/0.3/lib/file_handler.py Tue Aug 21 16:02:24 2007 +0100 +++ b/gmyth-stream/server/0.3/lib/file_handler.py Tue Aug 21 16:04:44 2007 +0100 @@ -32,14 +32,20 @@ name = os.path.basename(self.opts["uri"][0]) self.opts["original"] = [name] output_file = os.path.basename(self.opts["outfile"][0]) - output = open(".transcoded/%s.dat" % \ - os.path.splitext(output_file)[0], "wb") + dat_file = output_file + ".dat"; + dat_path = os.path.join (utils.config.get_transcoded_location(), + dat_file); + + output = open(dat_path, "wb") # dumps data using the highest protocol pickle.dump(self.opts, output, -1) output.close() else: name = os.path.splitext(os.path.basename(filename))[0] - pkl_file = open(".transcoded/%s.dat" % name, "rb") + dat_file = name + ".dat"; + dat_path = os.path.join (utils.config.get_transcoded_location(), + dat_file); + pkl_file = open(dat_path, "rb") self.opts = pickle.load(pkl_file) # __init__() diff -r 8a6b143057d7 -r 7f290a3a34b1 gmyth-stream/server/0.3/lib/gmsconfig.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/server/0.3/lib/gmsconfig.py Tue Aug 21 16:04:44 2007 +0100 @@ -0,0 +1,42 @@ +#!/usr/bin/env + +__author__ = "Renato Araujo Oliveira Filho" +__author_email__ = "renato.filho@indt.org.br" +__license__ = "GPL" +__version__ = "0.3" + + +import os +import ConfigParser + +__all__ = ("GmsConfig") + +class GmsConfig: + config = ConfigParser.ConfigParser() + __CONFIG_FILE__ = "server.conf" + + def __init__(self): + file_name = os.path.join (os.path.expanduser("~"), ".gms", self.__CONFIG_FILE__) + print "test config file: %s" % file_name + if os.path.exists (file_name): + fp = open (file_name, "r") + self.config.readfp (fp) + return + + file_name = os.path.join ("/", "etc", "gms", self.__CONFIG_FILE__) + print "test config file: %s" % file_name + if os.path.exists (file_name): + fp = open (file_name, "r") + self.config.readfp (fp) + return + # __init__() + + def get_transcoded_location (self): + try: + return self.config.get("PATHS", "transcoded") + except: + return None + # get_transcoded_location() + + +# GmsConfig diff -r 8a6b143057d7 -r 7f290a3a34b1 gmyth-stream/server/0.3/lib/request_handler.py --- a/gmyth-stream/server/0.3/lib/request_handler.py Tue Aug 21 16:02:24 2007 +0100 +++ b/gmyth-stream/server/0.3/lib/request_handler.py Tue Aug 21 16:04:44 2007 +0100 @@ -145,7 +145,7 @@ if body: file_list = [] - files.list_media_files(".transcoded", file_list) + files.list_media_files(utils.config.get_transcoded_location(), file_list) output = files.FileList(map(lambda x, y: x+y, file_list, ["
"]*len(file_list))) self.wfile.write(output) @@ -362,7 +362,7 @@ return #Only stream files on .transcode dir - filename = ".transcoded/" + os.path.basename(filename) + filename = os.path.join (utils.config.get_transcoded_location(), os.path.basename(filename)) self.log.error("Stream file: %s" % filename) if not os.path.exists (filename): self.send_error(404, "File not found") diff -r 8a6b143057d7 -r 7f290a3a34b1 gmyth-stream/server/0.3/lib/utils.py --- a/gmyth-stream/server/0.3/lib/utils.py Tue Aug 21 16:02:24 2007 +0100 +++ b/gmyth-stream/server/0.3/lib/utils.py Tue Aug 21 16:04:44 2007 +0100 @@ -13,7 +13,10 @@ import gobject import imp +import gmsconfig + log = logging.getLogger("gms.utils") +config = gmsconfig.GmsConfig() __all__ = ("which", "load_plugins", "PluginSet", "getHTML", "progress_bar", "create_tid", "list_media_files") @@ -188,4 +191,3 @@ return tid # create_id() - diff -r 8a6b143057d7 -r 7f290a3a34b1 gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py --- a/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py Tue Aug 21 16:02:24 2007 +0100 +++ b/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py Tue Aug 21 16:04:44 2007 +0100 @@ -60,7 +60,7 @@ outfile = self.params_first("outfile", "") if outfile != "": - path = os.path.join(sys.path[0], ".transcoded", outfile) + path = os.path.join(utils.config.get_transcoded_location(), outfile) self._insert_param("-o", "file://%s" % path) else: self._insert_param ("-o", "fd://%d" % outfd.fileno()) diff -r 8a6b143057d7 -r 7f290a3a34b1 gmyth-stream/server/0.3/setup.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/server/0.3/setup.py Tue Aug 21 16:04:44 2007 +0100 @@ -0,0 +1,17 @@ +from distutils.core import setup +from glob import glob + +setup(name='gms', + version='0.6', + description='carman rich view package', + long_description='carman rich view (SDL based) package', + url='http://www.indt.org.br', + scripts=['gms.py'], + package_dir={'lib': 'lib', 'plugins' : 'plugins','data' : 'data' }, + packages=['lib','plugins','plugins.transcoders','plugins.transcoders.mencoder_lib'], + data_files = [ + ('share/gms/html', glob("html/*")), + ('etc/init.d', ['data/gmsd']), + ('etc/gms', ['data/server.conf']) + ], + )