From: Calin Crisan Date: Sun, 30 Aug 2015 10:07:26 +0000 (+0300) Subject: integration with setuptools almost complete X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=75a85a8785aa5243516d3ba3159b24a2caf85a33;p=motioneye-debian integration with setuptools almost complete --- diff --git a/MANIFEST.in b/MANIFEST.in index 1c2510d..24b32fc 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1 @@ -include README.md - +recursive-include extra * diff --git a/README.md b/README.md deleted file mode 100644 index de116c1..0000000 --- a/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# motionEye, the motion frontend # - -**motionEye **is a web-based user interface for [motion](http://www.lavrsen.dk/foswiki/bin/view/Motion). - -## Requirements ## - - * a machine running Linux - * python 2.6+ - * tornado 3.1+ - * jinja2 - * PIL - * pycurl - * motion - * ffmpeg - * v4l-utils - -## Installation ## - - 1. download the latest version from [bitbucket](https://bitbucket.org/ccrisan/motioneye/downloads) (use the *Tags* tab). - 2. extract the archive to a directory of your choice (e.g. your home directory): - - cd /home/user - tar zxvf ccrisan-motioneye-xyz.tar.gz - mv ccrisan-motioneye-xyz motioneye - - 3. create a `settings.py` file using the default template file (the default settings should do for now): - - cd motioneye - cp settings_default.py settings.py - - 4. motionEye can be run directly from the extracted directory; no root privileges are required: - - ./motioneye.py - - 5. point your favourite browser to diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..c5bee56 --- /dev/null +++ b/README.rst @@ -0,0 +1 @@ +**motionEye** is a web-based frontend for `motion `_. diff --git a/extra/motioneye.init-debian b/extra/motioneye.init-debian new file mode 100755 index 0000000..5d2d294 --- /dev/null +++ b/extra/motioneye.init-debian @@ -0,0 +1,71 @@ +#!/bin/sh -e +# +# /etc/init.d/motioneye: Start the motionEye server +# +### BEGIN INIT INFO +# Provides: motioneye +# Required-Start: $local_fs $syslog $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start the motionEye server +# Description: Start the motionEye server +### END INIT INFO + +NAME="motioneye" +PATH_BIN="/bin:/usr/bin:/sbin:/usr/sbin" +DAEMON="/usr/bin/meyectl" +PIDFILE="/var/run/$NAME.pid" +DESC="motionEye server" +USER="motion" +OPTIONS="startserver -c /etc/motioneye/motioneye.conf -l" + +. /lib/lsb/init-functions + +test -x $DAEMON || exit 0 + +RET=0 + +case "$1" in + start) + log_daemon_msg "Starting $DESC" + if start-stop-daemon --start --oknodo --exec $DAEMON -b --chuid $USER -- $OPTIONS; then + log_end_msg 0 + else + log_end_msg 1 + RET=1 + fi + ;; + + stop) + log_daemon_msg "Stopping $DESC" + if start-stop-daemon --stop --oknodo --exec $DAEMON --retry 5; then + log_end_msg 0 + else + log_end_msg 1 + RET=1 + fi + ;; + + restart) + log_action_begin_msg "Restarting $DESC" + if $0 stop && $0 start; then + log_action_end_msg 0 + else + log_action_cont_msg "(failed)" + RET=1 + fi + ;; + + status) + status_of_proc $DAEMON $NAME + ;; + + *) + echo "Usage: /etc/init.d/$NAME {start|stop|restart|status}" + RET=1 + ;; +esac + +exit $RET + diff --git a/extra/motioneye.systemd-unit b/extra/motioneye.systemd-unit new file mode 100644 index 0000000..3456142 --- /dev/null +++ b/extra/motioneye.systemd-unit @@ -0,0 +1,9 @@ +[Unit] +Description=motionEye Server + +[Service] +ExecStart=/usr/local/bin/meyectl startserver -c /etc/motioneye/motioneye.conf +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/motioneye/meyectl.py b/motioneye/meyectl.py index cfa3320..98782cb 100755 --- a/motioneye/meyectl.py +++ b/motioneye/meyectl.py @@ -116,7 +116,11 @@ def load_settings(): def configure_logging(cmd, log_to_file=False): - format = '%(asctime)s: [{cmd}] %(levelname)s: %(message)s'.format(cmd=cmd) + if log_to_file or cmd != 'motioneye': + format = '%(asctime)s: [{cmd}] %(levelname)s: %(message)s'.format(cmd=cmd) + + else: + format = '%(levelname)s: %(message)s'.format(cmd=cmd) for h in logging.getLogger().handlers: logging.getLogger().removeHandler(h) @@ -168,6 +172,8 @@ def make_arg_parser(command=None): action='store_true', dest='debug') parser.add_argument('-h', help='print this help and exit', action='help', default=argparse.SUPPRESS) + parser.add_argument('-l', help='log to file instead of standard error', + action='store_true', dest='log_to_file') parser.add_argument('-v', help='print program version and exit', action='version', default=argparse.SUPPRESS) diff --git a/motioneye/relayevent.py b/motioneye/relayevent.py index 2a91ba5..166287b 100644 --- a/motioneye/relayevent.py +++ b/motioneye/relayevent.py @@ -98,7 +98,7 @@ def main(parser, args): options = parse_options(parser, args) - meyectl.configure_logging('relayevent') + meyectl.configure_logging('relayevent', options.log_to_file) meyectl.configure_tornado() logging.debug('hello!') diff --git a/motioneye/sendmail.py b/motioneye/sendmail.py index df59222..ee3b6f3 100644 --- a/motioneye/sendmail.py +++ b/motioneye/sendmail.py @@ -142,7 +142,7 @@ def main(parser, args): options = parse_options(parser, args) - meyectl.configure_logging('sendmail') + meyectl.configure_logging('sendmail', options.log_to_file) meyectl.configure_tornado() logging.debug('hello!') diff --git a/motioneye/server.py b/motioneye/server.py index 3913873..1e138d0 100644 --- a/motioneye/server.py +++ b/motioneye/server.py @@ -15,7 +15,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import argparse import atexit import datetime import logging @@ -401,7 +400,7 @@ def main(parser, args, command): options = parse_options(parser, args) - meyectl.configure_logging('motioneye', options.background) + meyectl.configure_logging('motioneye', options.background or options.log_to_file) meyectl.configure_tornado() if command == 'start': diff --git a/motioneye/webhook.py b/motioneye/webhook.py index 2767c6c..2e7988a 100644 --- a/motioneye/webhook.py +++ b/motioneye/webhook.py @@ -34,7 +34,7 @@ def main(parser, args): options = parse_options(parser, args) - meyectl.configure_logging('webhook') + meyectl.configure_logging('webhook', options.log_to_file) meyectl.configure_tornado() logging.debug('hello!') diff --git a/setup.py b/setup.py index b963858..2f6dfe2 100644 --- a/setup.py +++ b/setup.py @@ -1,19 +1,23 @@ -# Always prefer setuptools over distutils +import os.path + from setuptools import setup -# To use a consistent encoding from codecs import open -from os import path -here = path.abspath(path.dirname(__file__)) +import motioneye + -with open(path.join(here, 'README.md'), encoding='utf-8') as f: +here = os.path.abspath(os.path.dirname(__file__)) +name = 'motioneye' +version = motioneye.VERSION + +with open(os.path.join(here, 'README.rst'), encoding='utf-8') as f: long_description = f.read() -setup( - name='motioneye', - version='0.25.2', +setup( + name=name, + version=version, description='motionEye server', long_description=long_description, @@ -25,7 +29,6 @@ setup( license='GPLv3', - # See https://pypi.python.org/pypi?%3Aaction=list_classifiers classifiers=[ 'Development Status :: 3 - Beta', @@ -47,18 +50,20 @@ setup( package_data={ 'motioneye': [ - 'static/*', + 'static/*.*', 'static/*/*', 'templates/*' ] }, - data_files=[], + data_files=[ + (os.path.join('share/%s' % name, root), [os.path.join(root, f) for f in files]) + for (root, dirs, files) in os.walk('extra') + ], entry_points={ 'console_scripts': [ - 'motioneye=motioneye.motioneye:main', + 'meyectl=motioneye.meyectl:main', ], - }, + } ) -