Merge "Update logmgmt to use python3"
This commit is contained in:
commit
e275bab559
|
@ -9,12 +9,12 @@ URL: unknown
|
||||||
Source0: %{name}-%{version}.tar.gz
|
Source0: %{name}-%{version}.tar.gz
|
||||||
Source1: LICENSE
|
Source1: LICENSE
|
||||||
|
|
||||||
BuildRequires: python-setuptools
|
BuildRequires: python3-setuptools
|
||||||
BuildRequires: python2-pip
|
BuildRequires: python3-pip
|
||||||
BuildRequires: python2-wheel
|
BuildRequires: python3-wheel
|
||||||
BuildRequires: systemd-devel
|
BuildRequires: systemd-devel
|
||||||
Requires: systemd
|
Requires: systemd
|
||||||
Requires: python-daemon
|
Requires: python3-daemon
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Management of /var/log filesystem
|
Management of /var/log filesystem
|
||||||
|
@ -22,7 +22,7 @@ Management of /var/log filesystem
|
||||||
%define local_bindir /usr/bin/
|
%define local_bindir /usr/bin/
|
||||||
%define local_etc_initd /etc/init.d/
|
%define local_etc_initd /etc/init.d/
|
||||||
%define local_etc_pmond /etc/pmon.d/
|
%define local_etc_pmond /etc/pmon.d/
|
||||||
%define pythonroot /usr/lib64/python2.7/site-packages
|
%define pythonroot %{python3_sitearch}
|
||||||
|
|
||||||
%define debug_package %{nil}
|
%define debug_package %{nil}
|
||||||
|
|
||||||
|
@ -33,11 +33,11 @@ Management of /var/log filesystem
|
||||||
rm -rf *.egg-info
|
rm -rf *.egg-info
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%{__python} setup.py build
|
%{__python3} setup.py build
|
||||||
%py2_build_wheel
|
%{__python3} setup.py bdist_wheel
|
||||||
|
|
||||||
%install
|
%install
|
||||||
%{__python} setup.py install --root=$RPM_BUILD_ROOT \
|
%{__python3} setup.py install --root=$RPM_BUILD_ROOT \
|
||||||
--install-lib=%{pythonroot} \
|
--install-lib=%{pythonroot} \
|
||||||
--prefix=/usr \
|
--prefix=/usr \
|
||||||
--install-data=/usr/share \
|
--install-data=/usr/share \
|
||||||
|
@ -74,8 +74,8 @@ rm -rf $RPM_BUILD_ROOT
|
||||||
%{_unitdir}/logmgmt.service
|
%{_unitdir}/logmgmt.service
|
||||||
%dir %{pythonroot}/%{name}
|
%dir %{pythonroot}/%{name}
|
||||||
%{pythonroot}/%{name}/*
|
%{pythonroot}/%{name}/*
|
||||||
%dir %{pythonroot}/%{name}-%{version}.0-py2.7.egg-info
|
%dir %{pythonroot}/%{name}-%{version}.0-py3.6.egg-info
|
||||||
%{pythonroot}/%{name}-%{version}.0-py2.7.egg-info/*
|
%{pythonroot}/%{name}-%{version}.0-py3.6.egg-info/*
|
||||||
|
|
||||||
%package wheels
|
%package wheels
|
||||||
Summary: %{name} wheels
|
Summary: %{name} wheels
|
||||||
|
|
|
@ -42,7 +42,7 @@ LOGROTATE_PERIOD = 600 # Every ten minutes
|
||||||
###################
|
###################
|
||||||
def start_polling():
|
def start_polling():
|
||||||
logmgmt_daemon = LogMgmtDaemon()
|
logmgmt_daemon = LogMgmtDaemon()
|
||||||
logmgmt_runner = runner.DaemonRunner(logmgmt_daemon)
|
logmgmt_runner = MyDaemonRunner(logmgmt_daemon)
|
||||||
logmgmt_runner.daemon_context.umask = 0o022
|
logmgmt_runner.daemon_context.umask = 0o022
|
||||||
logmgmt_runner.do_action()
|
logmgmt_runner.do_action()
|
||||||
|
|
||||||
|
@ -57,6 +57,18 @@ def handle_exception(exc_type, exc_value, exc_traceback):
|
||||||
###################
|
###################
|
||||||
# CLASSES
|
# CLASSES
|
||||||
###################
|
###################
|
||||||
|
class MyDaemonRunner(runner.DaemonRunner):
|
||||||
|
# Workaround: fix the "unbuffered bytes I/O for py3" runtime
|
||||||
|
# error in pyhon3 env.
|
||||||
|
def _open_streams_from_app_stream_paths(self, app):
|
||||||
|
self.daemon_context.stdin = open(app.stdin_path, 'rt')
|
||||||
|
self.daemon_context.stdout = open(app.stdout_path, 'w+t')
|
||||||
|
try:
|
||||||
|
self.daemon_context.stderr = open(app.stderr_path, 'w+t', buffering=0)
|
||||||
|
except:
|
||||||
|
self.daemon_context.stderr = open(app.stderr_path, 'wb+', buffering=0)
|
||||||
|
|
||||||
|
|
||||||
class LogMgmtDaemon():
|
class LogMgmtDaemon():
|
||||||
"""Daemon process representation of the /var/log monitoring program"""
|
"""Daemon process representation of the /var/log monitoring program"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -122,7 +134,7 @@ class LogMgmtDaemon():
|
||||||
output = subprocess.check_output(['/usr/sbin/logrotate', '-d', '/etc/logrotate.conf'],
|
output = subprocess.check_output(['/usr/sbin/logrotate', '-d', '/etc/logrotate.conf'],
|
||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
for line in output.split('\n'):
|
for line in output.decode().split('\n'):
|
||||||
fields = line.split()
|
fields = line.split()
|
||||||
if len(fields) > 0 and fields[0] == "considering":
|
if len(fields) > 0 and fields[0] == "considering":
|
||||||
self.monitored_files.extend(glob.glob(fields[2]))
|
self.monitored_files.extend(glob.glob(fields[2]))
|
||||||
|
@ -140,7 +152,7 @@ class LogMgmtDaemon():
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output(['find', '/var/log', '-type', 'f'])
|
output = subprocess.check_output(['find', '/var/log', '-type', 'f'])
|
||||||
|
|
||||||
for fname in output.split('\n'):
|
for fname in output.decode().split('\n'):
|
||||||
if fname in self.monitored_files:
|
if fname in self.monitored_files:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Copyright (c) 2014 Wind River Systems, Inc.
|
Copyright (c) 2014 Wind River Systems, Inc.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Copyright (c) 2014 Wind River Systems, Inc.
|
Copyright (c) 2014 Wind River Systems, Inc.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Copyright (c) 2014 Wind River Systems, Inc.
|
Copyright (c) 2014 Wind River Systems, Inc.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Copyright (c) 2014 Wind River Systems, Inc.
|
Copyright (c) 2014 Wind River Systems, Inc.
|
||||||
|
|
Loading…
Reference in New Issue