[svn r821] created debian packages;\nImplemented server deamon;\n trunk
authorrenatofilho
Tue Aug 21 16:04:44 2007 +0100 (2007-08-21)
branchtrunk
changeset 8157f290a3a34b1
parent 814 8a6b143057d7
child 816 c404781fda4e
[svn r821] created debian packages;\nImplemented server deamon;\n
gmyth-stream/server/0.3/debian/changelog
gmyth-stream/server/0.3/debian/compat
gmyth-stream/server/0.3/debian/control
gmyth-stream/server/0.3/debian/copyright
gmyth-stream/server/0.3/debian/gms.install
gmyth-stream/server/0.3/debian/gms.postinst
gmyth-stream/server/0.3/debian/gms.postrm
gmyth-stream/server/0.3/debian/rules
gmyth-stream/server/0.3/gms.py
gmyth-stream/server/0.3/lib/file_handler.py
gmyth-stream/server/0.3/lib/gmsconfig.py
gmyth-stream/server/0.3/lib/request_handler.py
gmyth-stream/server/0.3/lib/utils.py
gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py
gmyth-stream/server/0.3/setup.py
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gmyth-stream/server/0.3/debian/changelog	Tue Aug 21 16:04:44 2007 +0100
     1.3 @@ -0,0 +1,6 @@
     1.4 +gms (0.3-indt1) unstable; urgency=low
     1.5 +
     1.6 +  * First package
     1.7 +
     1.8 + -- Renato Araujo Oliveira Filho <renato.filho@indt.org>  Thu, 16 Aug 2007 14:55:00 -0300
     1.9 +
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/gmyth-stream/server/0.3/debian/compat	Tue Aug 21 16:04:44 2007 +0100
     2.3 @@ -0,0 +1,1 @@
     2.4 +5
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/gmyth-stream/server/0.3/debian/control	Tue Aug 21 16:04:44 2007 +0100
     3.3 @@ -0,0 +1,13 @@
     3.4 +Source: gms
     3.5 +Section: sound
     3.6 +Priority: optional
     3.7 +Maintainer: Renato Araujo Oliveira Filho <renato.filho@indt.org>
     3.8 +Build-Depends: debhelper (>= 5.0.38), python-support (>= 0.5), python-central (>= 0.5)
     3.9 +Standards-Version: 3.7.2
    3.10 +
    3.11 +Package: gms
    3.12 +Architecture: any
    3.13 +Depends: ${python:Depends}, libgstreamer0.10-0, gstreamer0.10-plugins-base, gstreamer0.10-plugins-good
    3.14 +Recommends: gstreamer0.10-plugins-ugly
    3.15 +Description: Media transcoder deamon
    3.16 +  Homepage: http://gmyth.sourceforge.net/
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/gmyth-stream/server/0.3/debian/copyright	Tue Aug 21 16:04:44 2007 +0100
     4.3 @@ -0,0 +1,19 @@
     4.4 +It was downloaded from: http://gmyth.sourceforge.net/wiki/
     4.5 +
     4.6 +License:
     4.7 +   This package is free software; you can redistribute it and/or modify
     4.8 +   it under the terms of the GNU General Public License as published by
     4.9 +   the Free Software Foundation; either version 2 of the License, or
    4.10 +   (at your option) any later version.
    4.11 +
    4.12 +   This package is distributed in the hope that it will be useful,
    4.13 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.14 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    4.15 +   GNU General Public License for more details.
    4.16 +
    4.17 +   You should have received a copy of the GNU General Public License
    4.18 +   along with this package; if not, write to the Free Software
    4.19 +   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
    4.20 +
    4.21 +On Debian systems, the complete text of the GNU General Public License can
    4.22 +be found in `/usr/share/common-licenses/GPL'.
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/gmyth-stream/server/0.3/debian/gms.install	Tue Aug 21 16:04:44 2007 +0100
     5.3 @@ -0,0 +1,8 @@
     5.4 +debian/tmp/usr/share/gms/lib/*.py usr/share/gms/lib
     5.5 +debian/tmp/usr/share/gms/plugins/*.py usr/share/gms/plugins
     5.6 +debian/tmp/usr/share/gms/plugins/transcoders/*.py usr/share/gms/plugins/transcoders
     5.7 +debian/tmp/usr/share/gms/plugins/transcoders/mencoder_lib/*.py usr/share/gms/plugins/transcoders/mencoder_lib
     5.8 +debian/tmp/usr/share/gms/html/* usr/share/gms/html
     5.9 +debian/tmp/usr/bin/* usr/bin
    5.10 +debian/etc/init.d/gmsd etc/init.d
    5.11 +debian/etc/gms/*.conf etc/gms/
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/gmyth-stream/server/0.3/debian/gms.postinst	Tue Aug 21 16:04:44 2007 +0100
     6.3 @@ -0,0 +1,29 @@
     6.4 +#! /bin/sh
     6.5 +# postinst script for gms
     6.6 +
     6.7 +set -e
     6.8 +
     6.9 +case "$1" in
    6.10 +  configure)
    6.11 +    if ! getent passwd gms >/dev/null; then
    6.12 +      adduser --disabled-password  --quiet --system \
    6.13 +        --home /var/gms-media \
    6.14 +        --gecos "GMS media dir" --group gms
    6.15 +    fi
    6.16 +    if ! getent passwd gms | grep -q /var/run/gms; then
    6.17 +        usermod -d /var/gms-media gms
    6.18 +    fi
    6.19 +    update-rc.d gmsd defaults
    6.20 +    invoke-rc.d gmsd start
    6.21 +  ;;
    6.22 +  abort-upgrade|abort-remove|abort-deconfigure)
    6.23 +  ;;
    6.24 +  *)
    6.25 +    echo "postinst called with unknown argument \`$1'" >&2
    6.26 +    exit 1
    6.27 +  ;;
    6.28 +esac
    6.29 +
    6.30 +#DEBHELPER#
    6.31 +
    6.32 +exit 0
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/gmyth-stream/server/0.3/debian/gms.postrm	Tue Aug 21 16:04:44 2007 +0100
     7.3 @@ -0,0 +1,13 @@
     7.4 +#!/bin/sh
     7.5 +
     7.6 +set -e
     7.7 +
     7.8 +#DEBHELPER#
     7.9 +
    7.10 +if [ "$1" = "purge" ] ; then
    7.11 +        invoke-rc.d --force gms stop
    7.12 +        deluser --quiet --system gms > /dev/null || true
    7.13 +        delgroup --quiet --system gms > /dev/null || true
    7.14 +fi
    7.15 +
    7.16 +exit 0
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/gmyth-stream/server/0.3/debian/rules	Tue Aug 21 16:04:44 2007 +0100
     8.3 @@ -0,0 +1,52 @@
     8.4 +#!/usr/bin/make -f
     8.5 +# -*- makefile -*-
     8.6 +
     8.7 +# Uncomment this to turn on verbose mode.
     8.8 +#export DH_VERBOSE=1
     8.9 +
    8.10 +PYVER=2.5
    8.11 +PYTHON=python$(PYVER)
    8.12 +
    8.13 +PREFIX=debian/tmp
    8.14 +
    8.15 +build: build-stamp
    8.16 +
    8.17 +build-stamp:
    8.18 +	touch build-stamp
    8.19 +
    8.20 +clean:
    8.21 +	dh_testdir
    8.22 +	dh_testroot
    8.23 +	rm -f build-stamp
    8.24 +	dh_clean
    8.25 +
    8.26 +install: build
    8.27 +	dh_testdir
    8.28 +	dh_testroot
    8.29 +	dh_installdirs
    8.30 +	dh_clean -k
    8.31 +
    8.32 +	@rm -rf build
    8.33 +	@$(PYTHON) setup.py install --prefix=$(PREFIX)/usr --no-compile --install-purelib=$(PREFIX)/usr/share/gms
    8.34 +	install -D -o root -g root -m 755 $(PREFIX)/usr/etc/init.d/gmsd  debian/$(cdbs_curpkg)/etc/init.d/gmsd
    8.35 +	install -D -o root -g root -m 755 $(PREFIX)/usr/etc/gms/server.conf  debian/$(cdbs_curpkg)/etc/gms/server.conf
    8.36 +
    8.37 +	dh_install
    8.38 +
    8.39 +# Build architecture-independent files here.
    8.40 +binary-indep: build install
    8.41 +	dh_testdir
    8.42 +	dh_testroot
    8.43 +	dh_installchangelogs
    8.44 +	dh_installdocs
    8.45 +	dh_strip
    8.46 +	dh_compress
    8.47 +	dh_fixperms
    8.48 +	dh_installdeb
    8.49 +	dh_gencontrol
    8.50 +	dh_md5sums
    8.51 +	dh_builddeb
    8.52 +
    8.53 +binary: binary-indep
    8.54 +.PHONY: clean binary-indep binary install
    8.55 +
     9.1 --- a/gmyth-stream/server/0.3/gms.py	Tue Aug 21 16:02:24 2007 +0100
     9.2 +++ b/gmyth-stream/server/0.3/gms.py	Tue Aug 21 16:04:44 2007 +0100
     9.3 @@ -5,12 +5,18 @@
     9.4  __license__ = "GPL"
     9.5  __version__ = "0.3"
     9.6  __thanks__ = "Gustavo Sverzut Barbieri"
     9.7 +__GMS_DATA_DIR__ = "/usr/share/gms/"
     9.8  
     9.9  import sys
    9.10  import os
    9.11  import mimetypes
    9.12  import logging as log
    9.13 +
    9.14 +if os.path.exists (__GMS_DATA_DIR__):
    9.15 +    sys.path.append(__GMS_DATA_DIR__)
    9.16 +
    9.17  from lib.server import serve_forever, load_plugins_transcoders
    9.18 +from lib.utils import config
    9.19  
    9.20  mimetypes.init()
    9.21  log_level = log.INFO
    9.22 @@ -23,9 +29,46 @@
    9.23                          "\t%(message)s"),
    9.24                  datefmt="%Y-%m-%d %H:%M:%S")
    9.25  
    9.26 -if not os.path.exists(".transcoded"):
    9.27 -    os.mkdir(".transcoded")
    9.28 +if config.get_transcoded_location () is None:
    9.29 +    print "Gms not configured"
    9.30 +    exit (0)
    9.31  
    9.32 -pd = os.path.join("plugins", "transcoders")
    9.33 -load_plugins_transcoders(pd)
    9.34 +if not os.path.exists(config.get_transcoded_location()):
    9.35 +    os.mkdir(config.get_transcoded_location())
    9.36 +
    9.37 +
    9.38 +if "-d" in sys.argv:
    9.39 +    #run with deamon
    9.40 +    try:
    9.41 +        pid = os.fork()
    9.42 +        if pid > 0:
    9.43 +             sys.exit(0)
    9.44 +    except OSError, e:
    9.45 +        print >>sys.stderr, "Fail to start deamon: %d (%s)" % (e.errno, e.strerror) 
    9.46 +        sys.exit(1)
    9.47 +
    9.48 +    os.chdir("/")
    9.49 +    os.setsid()
    9.50 +    os.umask(0)
    9.51 +
    9.52 +    try:
    9.53 +        pid = os.fork()
    9.54 +        if pid > 0:
    9.55 +            fp = open ("/var/run/gms.pid", "w")
    9.56 +            fp.write ("%d" % pid)
    9.57 +            fp.close ()
    9.58 +            sys.exit(0)
    9.59 +    except OSError, e:
    9.60 +        print >>sys.stderr, "Fail to start deamon: %d (%s)" % (e.errno, e.strerror) 
    9.61 +        sys.exit(1)
    9.62 +
    9.63 +# main deamon
    9.64 +pd = os.path.join(__GMS_DATA_DIR__, "plugins", "transcoders")
    9.65 +if os.path.exists (pd):
    9.66 +    load_plugins_transcoders(pd)
    9.67 +
    9.68 +pd = os.path.join("plugins", "transcoders");
    9.69 +if os.path.exists (pd):
    9.70 +    load_plugins_transcoders(pd)
    9.71 +
    9.72  serve_forever()
    10.1 --- a/gmyth-stream/server/0.3/lib/file_handler.py	Tue Aug 21 16:02:24 2007 +0100
    10.2 +++ b/gmyth-stream/server/0.3/lib/file_handler.py	Tue Aug 21 16:04:44 2007 +0100
    10.3 @@ -32,14 +32,20 @@
    10.4              name = os.path.basename(self.opts["uri"][0])
    10.5              self.opts["original"] = [name]
    10.6              output_file = os.path.basename(self.opts["outfile"][0])
    10.7 -            output = open(".transcoded/%s.dat" % \
    10.8 -                          os.path.splitext(output_file)[0], "wb")
    10.9 +            dat_file = output_file + ".dat";
   10.10 +            dat_path = os.path.join (utils.config.get_transcoded_location(),
   10.11 +                dat_file);
   10.12 +
   10.13 +            output = open(dat_path, "wb")
   10.14              # dumps data using the highest protocol
   10.15              pickle.dump(self.opts, output, -1)
   10.16              output.close()
   10.17          else:
   10.18              name = os.path.splitext(os.path.basename(filename))[0]
   10.19 -            pkl_file = open(".transcoded/%s.dat" % name, "rb")
   10.20 +            dat_file = name + ".dat";
   10.21 +            dat_path = os.path.join (utils.config.get_transcoded_location(),
   10.22 +                dat_file);
   10.23 +            pkl_file = open(dat_path, "rb")
   10.24              self.opts = pickle.load(pkl_file)
   10.25      # __init__()
   10.26  
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/gmyth-stream/server/0.3/lib/gmsconfig.py	Tue Aug 21 16:04:44 2007 +0100
    11.3 @@ -0,0 +1,42 @@
    11.4 +#!/usr/bin/env
    11.5 +
    11.6 +__author__ = "Renato Araujo Oliveira Filho"
    11.7 +__author_email__ = "renato.filho@indt.org.br"
    11.8 +__license__ = "GPL"
    11.9 +__version__ = "0.3"
   11.10 +
   11.11 +
   11.12 +import os
   11.13 +import ConfigParser
   11.14 +
   11.15 +__all__ = ("GmsConfig")
   11.16 +
   11.17 +class GmsConfig:
   11.18 +    config = ConfigParser.ConfigParser()
   11.19 +    __CONFIG_FILE__ = "server.conf"
   11.20 +
   11.21 +    def __init__(self):
   11.22 +        file_name = os.path.join (os.path.expanduser("~"), ".gms", self.__CONFIG_FILE__)
   11.23 +        print "test config file: %s" % file_name
   11.24 +        if os.path.exists (file_name):
   11.25 +            fp = open (file_name, "r")
   11.26 +            self.config.readfp (fp)
   11.27 +            return
   11.28 +
   11.29 +        file_name = os.path.join ("/", "etc", "gms", self.__CONFIG_FILE__)
   11.30 +        print "test config file: %s" % file_name
   11.31 +        if os.path.exists (file_name):
   11.32 +            fp = open (file_name, "r")
   11.33 +            self.config.readfp (fp)
   11.34 +            return
   11.35 +    # __init__()
   11.36 +
   11.37 +    def get_transcoded_location (self):
   11.38 +        try:
   11.39 +            return self.config.get("PATHS", "transcoded")
   11.40 +        except:
   11.41 +            return None
   11.42 +    # get_transcoded_location()
   11.43 +
   11.44 +
   11.45 +# GmsConfig
    12.1 --- a/gmyth-stream/server/0.3/lib/request_handler.py	Tue Aug 21 16:02:24 2007 +0100
    12.2 +++ b/gmyth-stream/server/0.3/lib/request_handler.py	Tue Aug 21 16:04:44 2007 +0100
    12.3 @@ -145,7 +145,7 @@
    12.4  
    12.5          if body:
    12.6              file_list = []
    12.7 -            files.list_media_files(".transcoded", file_list)
    12.8 +            files.list_media_files(utils.config.get_transcoded_location(), file_list)
    12.9              output = files.FileList(map(lambda x, y: x+y, file_list,
   12.10                                          ["<br>"]*len(file_list)))
   12.11              self.wfile.write(output)
   12.12 @@ -362,7 +362,7 @@
   12.13              return
   12.14  
   12.15          #Only stream files on .transcode dir
   12.16 -        filename = ".transcoded/" + os.path.basename(filename)
   12.17 +        filename = os.path.join (utils.config.get_transcoded_location(), os.path.basename(filename))
   12.18          self.log.error("Stream file: %s" % filename)
   12.19          if not os.path.exists (filename):
   12.20              self.send_error(404, "File not found")
    13.1 --- a/gmyth-stream/server/0.3/lib/utils.py	Tue Aug 21 16:02:24 2007 +0100
    13.2 +++ b/gmyth-stream/server/0.3/lib/utils.py	Tue Aug 21 16:04:44 2007 +0100
    13.3 @@ -13,7 +13,10 @@
    13.4  import gobject
    13.5  import imp
    13.6  
    13.7 +import gmsconfig
    13.8 +
    13.9  log = logging.getLogger("gms.utils")
   13.10 +config = gmsconfig.GmsConfig()
   13.11  
   13.12  __all__ = ("which", "load_plugins", "PluginSet", "getHTML",
   13.13             "progress_bar", "create_tid", "list_media_files")
   13.14 @@ -188,4 +191,3 @@
   13.15      return tid
   13.16  # create_id()
   13.17  
   13.18 -
    14.1 --- a/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py	Tue Aug 21 16:02:24 2007 +0100
    14.2 +++ b/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py	Tue Aug 21 16:04:44 2007 +0100
    14.3 @@ -60,7 +60,7 @@
    14.4          outfile = self.params_first("outfile", "")
    14.5  
    14.6          if outfile != "":
    14.7 -            path = os.path.join(sys.path[0], ".transcoded", outfile)
    14.8 +            path = os.path.join(utils.config.get_transcoded_location(), outfile)
    14.9              self._insert_param("-o", "file://%s" % path)
   14.10          else:
   14.11              self._insert_param ("-o", "fd://%d" % outfd.fileno())
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/gmyth-stream/server/0.3/setup.py	Tue Aug 21 16:04:44 2007 +0100
    15.3 @@ -0,0 +1,17 @@
    15.4 +from distutils.core import setup
    15.5 +from glob import glob
    15.6 +
    15.7 +setup(name='gms',
    15.8 +      version='0.6',
    15.9 +      description='carman rich view package',
   15.10 +      long_description='carman rich view (SDL based) package',
   15.11 +      url='http://www.indt.org.br',
   15.12 +      scripts=['gms.py'],
   15.13 +      package_dir={'lib': 'lib', 'plugins' : 'plugins','data' : 'data' },
   15.14 +      packages=['lib','plugins','plugins.transcoders','plugins.transcoders.mencoder_lib'],
   15.15 +      data_files = [
   15.16 +               ('share/gms/html', glob("html/*")),
   15.17 +               ('etc/init.d', ['data/gmsd']),
   15.18 +               ('etc/gms', ['data/server.conf'])
   15.19 +               ],
   15.20 +      )