Add customstderr

This commit is contained in:
simon987 2021-04-18 12:17:00 -04:00
parent 765f6f59b7
commit ae59522b27
2 changed files with 20 additions and 3 deletions

View File

@ -1,9 +1,8 @@
import atexit
import os
import sys
import time
from threading import Lock
import atexit
from time import sleep
import siphash
@ -23,7 +22,9 @@ def retry(attempts, callback=None, retry_sleep=0):
callback(e)
retries -= 1
sleep(retry_sleep)
return wrapper
return decorate
@ -105,4 +106,20 @@ class CustomStdOut:
self.fp.close()
class CustomStdErr:
original_stderr = sys.stderr
def __init__(self, fname):
self.fname = fname
def __enter__(self):
self.fp = open(self.fname, "w")
sys.stderr = self.fp
def __exit__(self, exc_type, exc_val, exc_tb):
sys.stdout = CustomStdErr.original_stderr
self.fp.close()
silent_stdout = CustomStdOut(os.devnull)
silent_stderr = CustomStdErr(os.devnull)

View File

@ -2,7 +2,7 @@ from setuptools import setup
setup(
name="hexlib",
version="1.39",
version="1.40",
description="Misc utility methods",
author="simon987",
author_email="me@simon987.net",