Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
4c371cec2b | |||
0708e200c8 | |||
0e61eee899 |
@ -19,7 +19,9 @@ def get_files_in_dir(path, regex, timeformat, recurse=False):
|
|||||||
for root,dirs,files in os.walk(path, topdown=False):
|
for root,dirs,files in os.walk(path, topdown=False):
|
||||||
for f in files:
|
for f in files:
|
||||||
prefix, timestamp = parse_filename(f, regex, timeformat)
|
prefix, timestamp = parse_filename(f, regex, timeformat)
|
||||||
if prefix and prefix not in res:
|
if not prefix:
|
||||||
|
continue
|
||||||
|
if prefix not in res:
|
||||||
res[prefix] = set()
|
res[prefix] = set()
|
||||||
res[prefix].add((os.path.join(root,f), timestamp))
|
res[prefix].add((os.path.join(root,f), timestamp))
|
||||||
if not recurse:
|
if not recurse:
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
import stat
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import rotator
|
import rotator
|
||||||
@ -83,11 +85,23 @@ def main():
|
|||||||
handler.setLevel(logging.WARNING)
|
handler.setLevel(logging.WARNING)
|
||||||
log.addHandler(handler)
|
log.addHandler(handler)
|
||||||
|
|
||||||
handler = logging.handlers.SysLogHandler(address='/dev/log')
|
handler = None
|
||||||
|
for logsocket in ('/var/run/log', '/dev/log'):
|
||||||
|
try:
|
||||||
|
mode = os.stat(logsocket).st_mode
|
||||||
|
except FileNotFoundError:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if stat.S_ISSOCK(mode):
|
||||||
|
handler = logging.handlers.SysLogHandler(address=logsocket)
|
||||||
formatter = logging.Formatter(fmt='rotator[%(process)s] %(message)s')
|
formatter = logging.Formatter(fmt='rotator[%(process)s] %(message)s')
|
||||||
handler.setFormatter(formatter)
|
handler.setFormatter(formatter)
|
||||||
handler.setLevel(logging.INFO)
|
handler.setLevel(logging.INFO)
|
||||||
log.addHandler(handler)
|
log.addHandler(handler)
|
||||||
|
break
|
||||||
|
|
||||||
|
if not handler:
|
||||||
|
log.warning('No syslog socket found, will not log to syslog')
|
||||||
|
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
|
|
||||||
|
2
setup.py
2
setup.py
@ -5,7 +5,7 @@ with open('README.md', 'r') as fh:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='rotator',
|
name='rotator',
|
||||||
version='0.1.0',
|
version='0.1.1',
|
||||||
author='Fredrik Eriksson',
|
author='Fredrik Eriksson',
|
||||||
author_email='feffe@fulh.ax',
|
author_email='feffe@fulh.ax',
|
||||||
description='Simple script for rotating backups',
|
description='Simple script for rotating backups',
|
||||||
|
Loading…
Reference in New Issue
Block a user