This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import ctypes | |
from ctypes import CDLL | |
import sys | |
import random | |
import string | |
from errno import EEXIST | |
# C stuff | |
libc = CDLL('libc.so.6', use_errno=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TimeoutMixin: | |
def send(self, *args, **kwargs): | |
if hasattr(self, 'timeout') and 'timeout' not in kwargs: | |
kwargs['timeout'] = self.timeout | |
return super().send(*args, **kwargs) | |
# Use | |
import requests | |
class Session(TimeoutMixin, requests.Session): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-n', '--count', metavar='TIMES', default=None, type=int) | |
parser.add_argument('-e', '--every', metavar='SECONDS', default=5, type=float) | |
parser.add_argument('-o', '--stdout', action='store_true') | |
parser.add_argument('-H', '--header', dest='headers', metavar=('KEY', 'VALUE'), action='append', default=[], nargs=2) | |
parser.add_argument('-t', '--template', default='%Y-%m-%dT%H:%M:%S.%f%:z') | |
parser.add_argument('--timeout', metavar='SECONDS', default=60, type=float) | |
parser.add_argument('url') |
OlderNewer