REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 2.11 KB
Close
/lib/python3.6/site-packages/rhn/SmartIO.py
Text
Base64
# # Smart IO class # # Copyright (c) 2002--2016 Red Hat, Inc. # # Author: Mihai Ibanescu <misa@redhat.com> """ This module implements the SmartIO class """ import os try: # python2 from cStringIO import StringIO except ImportError: # python3 from io import BytesIO as StringIO class SmartIO: """ The SmartIO class allows one to put a cap on the memory consumption. StringIO objects are very fast, because they are stored in memory, but if they are too big the memory footprint becomes noticeable. The write method of a SmartIO determines if the data that is to be added to the (initially) StrintIO object does not exceed a certain threshold; if it does, it switches the storage to a temporary disk file """ def __init__(self, max_mem_size=16384, force_mem=0): self._max_mem_size = max_mem_size self._io = StringIO() # self._fixed is a flag to show if we're supposed to consider moving # the StringIO object into a tempfile # Invariant: if self._fixed == 0, we have a StringIO (if self._fixed # is 1 and force_mem was 0, then we have a file) if force_mem: self._fixed = 1 else: self._fixed = 0 def set_max_mem_size(self, max_mem_size): self._max_mem_size = max_mem_size def get_max_mem_size(self): return self._max_mem_size def write(self, data): if not self._fixed: # let's consider moving it to a file if len(data) + self._io.tell() > self._max_mem_size: # We'll overflow, change to a tempfile tmpfile = _tempfile() tmpfile.write(self._io.getvalue()) self._fixed = 1 self._io = tmpfile self._io.write(data) def __getattr__(self, name): return getattr(self._io, name) # Creates a temporary file and passes back its file descriptor def _tempfile(): import tempfile (fd, fname) = tempfile.mkstemp(prefix="_rhn_transports-%d-" \ % os.getpid()) # tempfile, unlink it os.unlink(fname) return os.fdopen(fd, "wb+")
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 2 × Files: 11
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
actions
DIR
-
drwxr-xr-x
2025-07-18 07:00:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__pycache__
DIR
-
drwxr-xr-x
2024-10-12 07:01:54
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
connections.py
9.48 KB
lrw-r--r--
2024-09-17 10:10:54
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
i18n.py
1.73 KB
lrw-r--r--
2018-02-19 08:18:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
nonblocking.py
2.37 KB
lrw-r--r--
2018-02-19 08:18:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rhnLockfile.py
3.35 KB
lrw-r--r--
2018-02-19 08:18:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rpclib.py
23.73 KB
lrw-r--r--
2024-09-17 10:10:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
SmartIO.py
2.11 KB
lrw-r--r--
2018-02-19 08:18:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
SSL.py
10.79 KB
lrw-r--r--
2024-09-17 10:10:54
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
tb.py
836 B
lrw-r--r--
2018-02-19 08:18:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
transports.py
31.23 KB
lrw-r--r--
2024-09-17 10:10:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
UserDictCase.py
2.96 KB
lrw-r--r--
2018-02-19 08:18:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__init__.py
132 B
lrw-r--r--
2018-02-19 08:18:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).