Merge branch 'master' of waschsauger:git/dirty-helpers

master
neingeist 9 years ago
commit cd582bc29c

@ -0,0 +1,23 @@
#!/usr/bin/python
"""Check Docker images for security/distro updates. Assumes DNF."""
from __future__ import division, print_function
from docker import Client
import subprocess
c = Client(base_url='unix://var/run/docker.sock')
for container in c.containers():
name = container['Names'][0]
id_ = container['Id']
image_id = c.inspect_container(id_)['Image']
print('Container: {}'.format(name))
print('Image: {} '.format(image_id))
# Not using the API here for simplicity (for now)
subprocess.call(['docker', 'run', '-t', '--rm',
image_id,
'/bin/bash', '-c',
'dnf -q check-update;' +
'if [ $? == 100 ]; then echo "Updates available"; fi'])

@ -0,0 +1,25 @@
#!/usr/bin/python
"""Print fetchmail errors in journal since yesterday, if more than MINCOUNT"""
import datetime
import systemd.journal as journal
yesterday = datetime.datetime.today() - datetime.timedelta(1)
SINCE = yesterday
MINCOUNT = 5
j = journal.Reader()
j.log_level(journal.LOG_ERR) # or more severe
j.add_match(_COMM="fetchmail")
entries = [entry for entry in j
# j.seek_realtime() does not work as expected, so filtering here:
if entry['_SOURCE_REALTIME_TIMESTAMP'] >= SINCE]
if len(entries) >= MINCOUNT:
for entry in entries:
print(entry['_SOURCE_REALTIME_TIMESTAMP'])
print(entry['MESSAGE'])

@ -7,7 +7,7 @@ from __future__ import division, print_function
import os import os
import os.path import os.path
import re import re
import yaml
def maildirs(startdir): def maildirs(startdir):
for dirpath, dirnames, _ in os.walk(startdir): for dirpath, dirnames, _ in os.walk(startdir):
@ -35,9 +35,15 @@ def mailbox_name(maildir, root):
return name return name
ignore_zero = True config_filename = '~/.config/maildir-zero.yml'
ignore = [r'spam'] config = {}
sort_by_count = True try:
config = yaml.load(open(os.path.expanduser(config_filename)))
except:
pass
ignore_zero = config.get('ignore_zero', True)
ignore = config.get('ignore', [r'spam'])
sort_by_count = config.get('sort_by_count', True)
root = os.path.expanduser('~/Maildir') root = os.path.expanduser('~/Maildir')

Loading…
Cancel
Save