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