Port control.py to Python 3
This commit is contained in:
parent
5e52c03ef6
commit
f6608255f9
|
@ -1,3 +1,13 @@
|
||||||
|
"""Ported to Python 3.
|
||||||
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from future.utils import PY2
|
||||||
|
if PY2:
|
||||||
|
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
|
||||||
|
|
||||||
import os, time, tempfile
|
import os, time, tempfile
|
||||||
from zope.interface import implementer
|
from zope.interface import implementer
|
||||||
|
@ -13,17 +23,17 @@ from twisted.python import log
|
||||||
|
|
||||||
def get_memory_usage():
|
def get_memory_usage():
|
||||||
# this is obviously linux-specific
|
# this is obviously linux-specific
|
||||||
stat_names = ("VmPeak",
|
stat_names = (b"VmPeak",
|
||||||
"VmSize",
|
b"VmSize",
|
||||||
#"VmHWM",
|
#b"VmHWM",
|
||||||
"VmData")
|
b"VmData")
|
||||||
stats = {}
|
stats = {}
|
||||||
try:
|
try:
|
||||||
with open("/proc/self/status", "r") as f:
|
with open("/proc/self/status", "rb") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
name, right = line.split(":",2)
|
name, right = line.split(b":",2)
|
||||||
if name in stat_names:
|
if name in stat_names:
|
||||||
assert right.endswith(" kB\n")
|
assert right.endswith(b" kB\n")
|
||||||
right = right[:-4]
|
right = right[:-4]
|
||||||
stats[name] = int(right) * 1024
|
stats[name] = int(right) * 1024
|
||||||
except:
|
except:
|
||||||
|
@ -34,8 +44,8 @@ def get_memory_usage():
|
||||||
|
|
||||||
def log_memory_usage(where=""):
|
def log_memory_usage(where=""):
|
||||||
stats = get_memory_usage()
|
stats = get_memory_usage()
|
||||||
log.msg("VmSize: %9d VmPeak: %9d %s" % (stats["VmSize"],
|
log.msg("VmSize: %9d VmPeak: %9d %s" % (stats[b"VmSize"],
|
||||||
stats["VmPeak"],
|
stats[b"VmPeak"],
|
||||||
where))
|
where))
|
||||||
|
|
||||||
@implementer(IConsumer)
|
@implementer(IConsumer)
|
||||||
|
|
|
@ -29,6 +29,7 @@ PORTED_MODULES = [
|
||||||
"allmydata._monkeypatch",
|
"allmydata._monkeypatch",
|
||||||
"allmydata.blacklist",
|
"allmydata.blacklist",
|
||||||
"allmydata.codec",
|
"allmydata.codec",
|
||||||
|
"allmydata.control",
|
||||||
"allmydata.crypto",
|
"allmydata.crypto",
|
||||||
"allmydata.crypto.aes",
|
"allmydata.crypto.aes",
|
||||||
"allmydata.crypto.ed25519",
|
"allmydata.crypto.ed25519",
|
||||||
|
|
Loading…
Reference in New Issue