Skip to content

Instantly share code, notes, and snippets.

View evilkost's full-sized avatar

Valentin Gologuzov evilkost

  • Czech Republic, Prague
View GitHub Profile
def rs(length=8):
return ''.join([
choice('abcdefghijklmnopqrstuvwxyz0123456789'
+ 'abcdefghijklmnopqrstuvwxyz'.upper())
for _ in range(length)
])
import logging
logging.basicConfig(
level=logging.INFO,
format= '[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s',
datefmt='%H:%M:%S'
)
log = logging.getLogger(__name__)
log.info("Logger initiated")
import os
class Writer(object):
def __init__(self, base_dir):
self.base_dir = base_dir
self.pool = {}
def _get_fh(self, name):
if name not in self.pool:
self.pool[name] = open(os.path.join(self.base_dir, name), "w")
#!/bin/sh
for package in $@
do
echo "removing config files for $package"
for file in $(rpm -q --configfiles $package)
do
echo " removing $file"
rm -f $file
done
#!/usr/bin/python
import os
from time import sleep
import plumbum as pb
import plumbum.cli as cli
from plumbum.cmd import inotifywait
@pytest.yield_fixture
def mc_logging():
with mock.patch("backend.daemons.log.logging") as mc_logging:
yield mc_logging
from celery.contrib import rdb; rdb.set_trace()
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
import os
from pwd import getpwnam
from grp import getgrnam
import logging
from subprocess import Popen, PIPE
PGPASSWORD=coprpass psql -a -h localhost -U copr-fe coprdb -c "\copy (select api_login, api_token from public.user where username='kost2') to '/tmp/credentionals.csv' with csv "
class RedisLogHandler(Process):
"""
Single point to collect logs through redis pub/sub and write
them through standard python logging lib
"""
def __init__(self, opts):
Process.__init__(self, name="log_handler")