mirror of
https://github.com/simon987/hexlib.git
synced 2025-04-19 17:56:43 +00:00
Change silent_stdout
This commit is contained in:
parent
3db293c867
commit
51a4c7854d
@ -1,10 +1,10 @@
|
|||||||
import time
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
from threading import Lock
|
||||||
|
|
||||||
import atexit
|
import atexit
|
||||||
import siphash
|
import siphash
|
||||||
from threading import Lock
|
|
||||||
|
|
||||||
last_time_called = dict()
|
last_time_called = dict()
|
||||||
|
|
||||||
@ -61,10 +61,19 @@ def signed64(i):
|
|||||||
return -(i & 0x8000000000000000) | (i & 0x7fffffffffffffff)
|
return -(i & 0x8000000000000000) | (i & 0x7fffffffffffffff)
|
||||||
|
|
||||||
|
|
||||||
def silent_stdout(func, *args, **kwargs):
|
class CustomStdOut:
|
||||||
with open(os.devnull, 'w') as null:
|
original_stdout = sys.stdout
|
||||||
stdout = sys.stdout
|
|
||||||
sys.stdout = null
|
def __init__(self, fname):
|
||||||
res = func(*args, **kwargs)
|
self.fname = fname
|
||||||
sys.stdout = stdout
|
|
||||||
return res
|
def __enter__(self):
|
||||||
|
self.fp = open(self.fname, "w")
|
||||||
|
sys.stdout = self.fp
|
||||||
|
|
||||||
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
|
sys.stdout = CustomStdOut.original_stdout
|
||||||
|
self.fp.close()
|
||||||
|
|
||||||
|
|
||||||
|
silent_stdout = CustomStdOut(os.devnull)
|
||||||
|
2
setup.py
2
setup.py
@ -2,7 +2,7 @@ from setuptools import setup
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="hexlib",
|
name="hexlib",
|
||||||
version="1.10",
|
version="1.11",
|
||||||
description="Misc utility methods",
|
description="Misc utility methods",
|
||||||
author="simon987",
|
author="simon987",
|
||||||
author_email="me@simon987.net",
|
author_email="me@simon987.net",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user