Skip to content

Instantly share code, notes, and snippets.

Avatar
🏡
Working from home

Hervé Beraud 4383

🏡
Working from home
View GitHub Profile
@4383
4383 / fast8.sh
Created Jun 21, 2019 — forked from zaneb/fast8.sh
Run flake8 against only files that have changed
View fast8.sh
#!/bin/bash
set -e
enable_env() {
local env_name="$1"
local env_dir=".tox/${env_name}"
if [ ! -d "${env_dir}" ]; then
if [ ! -f tox.ini ]; then
echo 'No tox.ini found' >&2
@4383
4383 / oslo-service-reproducer.py
Created Jun 20, 2019
oslo-service-reproducer
View oslo-service-reproducer.py
#!/usr/bin/env python
#
import logging
from oslo_service import service
from oslo_config import cfg
import pdb
import traceback
import os
import time
@4383
4383 / eventlet_threading.py
Created Jun 4, 2019
verify that the threading module come from the stdlib
View eventlet_threading.py
import eventlet
import threading
eventlet.monkey_patch()
print(threading.current_thread.__module__)
# Will print "eventlet.green.threading"
assert threading.current_thread.__module__ == 'threading'
# Will raise the following assertion error:
# Traceback (most recent call last):
@4383
4383 / eventlet_threading.py
Last active Jun 4, 2019
always use pthread on monkey patched environment
View eventlet_threading.py
import eventlet
eventlet.monkey_patch()
if eventlet.patcher.is_monkey_patched("thread"):
print("Patched")
threading = eventlet.patcher.original("threading")
else:
print("Not Patched")
import threading
@4383
4383 / test.py
Created May 17, 2019 — forked from zzzeek/test.py
Python getargspec, getfullargspec, Signature performance comparison
View test.py
# So interestingly, Signature seems to be twice as fast in Python 3.6 and 3.7 as it
# was in Python 3.3 and 3.4. However, it is still 6-18 times slower than the old
# getargspec or getfullargspec that was in Python 3.3.
Python 2.7 getargspec (doesn't use Signature) : specimen_one (6 args) : 0.0503
Python 2.7 getargspec (doesn't use Signature) : specimen_two (0 args) : 0.0496
Python 2.7 getargspec (doesn't use Signature) : specimen_three (6 args) : 0.0500
Python 2.7 getargspec (doesn't use Signature) : specimen_four (13 args) : 0.0652
Python 3.3 getfullargspec (doesn't use Signature) : specimen_one (6 args) : 0.0539
@4383
4383 / openstack-oslo-projects.yaml
Last active May 16, 2019
Openstack oslo projects - yaml format to automatize things
View openstack-oslo-projects.yaml
projects:
automaton:
Summary: a framework for building state machines.
Proposal: https://review.openstack.org/#/c/141961/
Source: http://git.openstack.org/cgit/openstack/automaton
Bugs: https://bugs.launchpad.net/automaton
Core: https://review.openstack.org/#/admin/groups/106,members
Documentation: http://docs.openstack.org/developer/automaton/
Github: https://github.com/openstack/automaton
castellan:
View trigger-zuul-periodic-job.sh
./tools/trigger-job.py --job periodic-foobar-proposal --project dev/foobar --pipeline periodic --url https://zuul.example.org/p --logpath /dev/null --newrev refs/heads/master --refname refs/heads/master
@4383
4383 / padding.py
Last active May 4, 2019
Test padding implementation
View padding.py
threads = [
"",
"1111111111111-thread1-base ",
"1111111111111-thread2-base ",
"1111111111111-thread3-very-long ",
"1111111111111-short ",
"1111111111111-thread4-base ",
"1111111111111-thread3-very-long-long ",
"1111111111111-short ",
"1111111111111-thread5-base ",
@4383
4383 / scan.sh
Last active May 3, 2019
scan python dependencies
View scan.sh
cd /tmp
mkdir keystone
pipenv shell
pip install keystone
pypath=$(dirname $(which python) | sed 's/bin/lib/g')
grep -ri ${mypath} -e subprocess -exclude-dir="*/__pycache__" | grep import | more
@4383
4383 / patch.sh
Last active Apr 24, 2019
patch code from review
View patch.sh
for el in $(ls /var/log/containers); do cp -v /var/log/containers/nova/impl_rabbit.py /var/log/containers/${el}; done
for el in $(infect_who_use_oslo messaging); do \
name=$(echo $el | awk -F "_" '{print $1}'); \
echo -e "patch ${name}\n"; \
docker exec -it --user root ${el} cp /var/log/${name}/impl_rabbit.py /usr/lib/python2.7/site-packages/oslo_messaging/_drivers; \
docker restart ${el}; \
done
curl -4 https://review.opendev.org/changes/643056/revisions/current/patch?download | base64 -d | sudo patch -p1