Blob Blame History Raw
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%{!?pyver: %global pyver %(%{__python} -c "import sys ; print sys.version[:3]")}

%global modname statscache


Name:           statscache
Version:        0.0.3
Release:        1%{?dist}
Summary:        A daemon to build and keep fedmsg statistics
Group:          Applications/Internet
License:        LGPLv2+
URL:            http://github.com/fedora-infra/statscache
Source0:        http://pypi.python.org/packages/source/s/%{name}/%{name}-%{version}.tar.gz

BuildArch:      noarch

BuildRequires:  python-devel
BuildRequires:  python-setuptools
# For tests
BuildRequires:  python-nose
BuildRequires:  python-six
BuildRequires:  python-mock
BuildRequires:  python-freezegun

BuildRequires:  fedmsg
BuildRequires:  python-fedmsg-meta-fedora-infrastructure
BuildRequires:  python-sqlalchemy
BuildRequires:  python-futures
Requires:       fedmsg
Requires:       python-fedmsg-meta-fedora-infrastructure
Requires:       python-sqlalchemy
Requires:       python-futures

%description
Statscache is a plugin to the fedmsg-hub that sits listening in our
infrastructure.  When new messages arrive, it will pass them off to `plugins
<https://github.com/fedora-infra/statscache_plugins>`_ that will calculate and
store various statistics.  If we want a new kind of statistic to be kept, we
write a new plugin for it.  It will come with a tiny flask frontend, much like
datagrepper, that allows you to query for this or that stat in this or that
format (csv, json, maybe html or svg too but that might be overkill).  The idea
being that we can then build neater smarter frontends that can render
fedmsg-based activity very quickly.. and perhaps later drill-down into the
*details* kept in datagrepper.

It is kind of like a data mart (http://en.wikipedia.org/wiki/Data_mart).

%package common
Summary: Statscache common library
Group: Applications/Internet

%description common
This package contains the common libraries required by other statscache
components.

%package web
Summary: A REST API server on top of statscache
Group: Applications/Internet

Requires: %{name}-common = %{version}-%{release}
Requires: python-flask

%description web
This package exposes a REST API server to render data generated by statscache.

%package consumer
Summary: Statscache consumer
Group: Applications/Internet
Requires: %{name}-common = %{version}-%{release}
Requires: fedmsg-hub

%description consumer
This runs a daemon which keeps listening to fedmsg and dispatches messages
to statscache plugins for storing data in required format.

%prep
%setup -q -n %{modname}-%{version}

%build
%{__python} setup.py build

%check
PYTHONPATH=$(pwd) python setup.py test

%install
%{__python} setup.py install -O1 --skip-build \
    --install-data=%{_datadir} --root %{buildroot}

%{__mkdir_p} %{buildroot}%{_sysconfdir}/fedmsg.d/
%{__cp} fedmsg.d/statscache.py %{buildroot}%{_sysconfdir}/fedmsg.d/.

mkdir -p %{buildroot}%{_datadir}/%{modname}/apache/
install -m 644 apache/%{modname}.wsgi %{buildroot}%{_datadir}/%{modname}/apache/%{modname}.wsgi
install -m 644 apache/%{modname}.conf %{buildroot}%{_datadir}/%{modname}/apache/%{modname}.conf

mkdir -p %{buildroot}%{_sysconfdir}/%{modname}/
install -m 644 apache/%{modname}.cfg %{buildroot}%{_sysconfdir}/%{modname}/%{modname}.cfg

%files common
%doc README.rst docs/
%license COPYING COPYING.LESSER

%dir %{python_sitelib}/%{modname}/
%{python_sitelib}/%{modname}/__init__.py*
%{python_sitelib}/%{modname}/utils.py*
%{python_sitelib}/%{modname}/plugins/
%{python_sitelib}/%{modname}-%{version}-py%{pyver}.egg-info/

%config(noreplace) %{_sysconfdir}/fedmsg.d/statscache.py*

%dir %{_sysconfdir}/%{modname}/
%config(noreplace) %{_sysconfdir}/%{modname}/%{modname}.cfg

%files web
%{python_sitelib}/%{modname}/app.py*
%{python_sitelib}/%{modname}/static/
%{python_sitelib}/%{modname}/templates/

%dir %{_datadir}/%{modname}
%dir %{_datadir}/%{modname}/apache/
%{_datadir}/%{modname}/apache/%{modname}.wsgi
%{_datadir}/%{modname}/apache/%{modname}.conf

%files consumer
%{python_sitelib}/%{modname}/consumer.py*
%{python_sitelib}/%{modname}/producer.py*

%changelog
* Fri Oct 30 2015 Ralph Bean <rbean@redhat.com> - 0.0.3-1
- new version

* Sat Jun 20 2015 Ratnadeep Debnath <rtnpro@gmail.com> - 0.0.1-1
- Initial packaging.