mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
py: Fix tabs in code comments
These were left by yapf formatter Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
committed by
Andrei Vagin
parent
34dbf67b24
commit
72402c6e7a
@@ -11,8 +11,8 @@ import pycriu.rpc_pb2 as rpc
|
||||
|
||||
class _criu_comm:
|
||||
"""
|
||||
Base class for communication classes.
|
||||
"""
|
||||
Base class for communication classes.
|
||||
"""
|
||||
COMM_SK = 0
|
||||
COMM_FD = 1
|
||||
COMM_BIN = 2
|
||||
@@ -22,22 +22,22 @@ class _criu_comm:
|
||||
|
||||
def connect(self, daemon):
|
||||
"""
|
||||
Connect to criu and return socket object.
|
||||
daemon -- is for whether or not criu should daemonize if executing criu from binary(comm_bin).
|
||||
"""
|
||||
Connect to criu and return socket object.
|
||||
daemon -- is for whether or not criu should daemonize if executing criu from binary(comm_bin).
|
||||
"""
|
||||
pass
|
||||
|
||||
def disconnect(self):
|
||||
"""
|
||||
Disconnect from criu.
|
||||
"""
|
||||
Disconnect from criu.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class _criu_comm_sk(_criu_comm):
|
||||
"""
|
||||
Communication class for unix socket.
|
||||
"""
|
||||
Communication class for unix socket.
|
||||
"""
|
||||
|
||||
def __init__(self, sk_path):
|
||||
self.comm_type = self.COMM_SK
|
||||
@@ -55,8 +55,8 @@ class _criu_comm_sk(_criu_comm):
|
||||
|
||||
class _criu_comm_fd(_criu_comm):
|
||||
"""
|
||||
Communication class for file descriptor.
|
||||
"""
|
||||
Communication class for file descriptor.
|
||||
"""
|
||||
|
||||
def __init__(self, fd):
|
||||
self.comm_type = self.COMM_FD
|
||||
@@ -74,8 +74,8 @@ class _criu_comm_fd(_criu_comm):
|
||||
|
||||
class _criu_comm_bin(_criu_comm):
|
||||
"""
|
||||
Communication class for binary.
|
||||
"""
|
||||
Communication class for binary.
|
||||
"""
|
||||
|
||||
def __init__(self, bin_path):
|
||||
self.comm_type = self.COMM_BIN
|
||||
@@ -139,8 +139,8 @@ class _criu_comm_bin(_criu_comm):
|
||||
|
||||
class CRIUException(Exception):
|
||||
"""
|
||||
Exception class for handling and storing criu errors.
|
||||
"""
|
||||
Exception class for handling and storing criu errors.
|
||||
"""
|
||||
typ = None
|
||||
_str = None
|
||||
|
||||
@@ -150,8 +150,8 @@ class CRIUException(Exception):
|
||||
|
||||
class CRIUExceptionInternal(CRIUException):
|
||||
"""
|
||||
Exception class for handling and storing internal errors.
|
||||
"""
|
||||
Exception class for handling and storing internal errors.
|
||||
"""
|
||||
|
||||
def __init__(self, typ, s):
|
||||
self.typ = typ
|
||||
@@ -161,8 +161,8 @@ class CRIUExceptionInternal(CRIUException):
|
||||
|
||||
class CRIUExceptionExternal(CRIUException):
|
||||
"""
|
||||
Exception class for handling and storing criu RPC errors.
|
||||
"""
|
||||
Exception class for handling and storing criu RPC errors.
|
||||
"""
|
||||
|
||||
def __init__(self, req_typ, resp_typ, errno):
|
||||
self.typ = req_typ
|
||||
@@ -196,8 +196,8 @@ class CRIUExceptionExternal(CRIUException):
|
||||
|
||||
class criu:
|
||||
"""
|
||||
Call criu through RPC.
|
||||
"""
|
||||
Call criu through RPC.
|
||||
"""
|
||||
opts = None #CRIU options in pb format
|
||||
|
||||
_comm = None #Communication method
|
||||
@@ -209,26 +209,26 @@ class criu:
|
||||
|
||||
def use_sk(self, sk_name):
|
||||
"""
|
||||
Access criu using unix socket which that belongs to criu service daemon.
|
||||
"""
|
||||
Access criu using unix socket which that belongs to criu service daemon.
|
||||
"""
|
||||
self._comm = _criu_comm_sk(sk_name)
|
||||
|
||||
def use_fd(self, fd):
|
||||
"""
|
||||
Access criu using provided fd.
|
||||
"""
|
||||
Access criu using provided fd.
|
||||
"""
|
||||
self._comm = _criu_comm_fd(fd)
|
||||
|
||||
def use_binary(self, bin_name):
|
||||
"""
|
||||
Access criu by execing it using provided path to criu binary.
|
||||
"""
|
||||
Access criu by execing it using provided path to criu binary.
|
||||
"""
|
||||
self._comm = _criu_comm_bin(bin_name)
|
||||
|
||||
def _send_req_and_recv_resp(self, req):
|
||||
"""
|
||||
As simple as send request and receive response.
|
||||
"""
|
||||
As simple as send request and receive response.
|
||||
"""
|
||||
# In case of self-dump we need to spawn criu swrk detached
|
||||
# from our current process, as criu has a hard time separating
|
||||
# process resources from its own if criu is located in a same
|
||||
@@ -262,8 +262,8 @@ class criu:
|
||||
|
||||
def check(self):
|
||||
"""
|
||||
Checks whether the kernel support is up-to-date.
|
||||
"""
|
||||
Checks whether the kernel support is up-to-date.
|
||||
"""
|
||||
req = rpc.criu_req()
|
||||
req.type = rpc.CHECK
|
||||
|
||||
@@ -274,8 +274,8 @@ class criu:
|
||||
|
||||
def dump(self):
|
||||
"""
|
||||
Checkpoint a process/tree identified by opts.pid.
|
||||
"""
|
||||
Checkpoint a process/tree identified by opts.pid.
|
||||
"""
|
||||
req = rpc.criu_req()
|
||||
req.type = rpc.DUMP
|
||||
req.opts.MergeFrom(self.opts)
|
||||
@@ -289,8 +289,8 @@ class criu:
|
||||
|
||||
def pre_dump(self):
|
||||
"""
|
||||
Checkpoint a process/tree identified by opts.pid.
|
||||
"""
|
||||
Checkpoint a process/tree identified by opts.pid.
|
||||
"""
|
||||
req = rpc.criu_req()
|
||||
req.type = rpc.PRE_DUMP
|
||||
req.opts.MergeFrom(self.opts)
|
||||
@@ -304,8 +304,8 @@ class criu:
|
||||
|
||||
def restore(self):
|
||||
"""
|
||||
Restore a process/tree.
|
||||
"""
|
||||
Restore a process/tree.
|
||||
"""
|
||||
req = rpc.criu_req()
|
||||
req.type = rpc.RESTORE
|
||||
req.opts.MergeFrom(self.opts)
|
||||
|
@@ -12,8 +12,8 @@
|
||||
# SIZE ::= "32 bit integer, equals the PAYLOAD length"
|
||||
#
|
||||
# Images v1.1 NOTE: MAGIC now consist of 2 32 bit integers, first one is
|
||||
# MAGIC_COMMON or MAGIC_SERVICE and the second one is same as MAGIC
|
||||
# in images V1.0. We don't keep "first" magic in json images.
|
||||
# MAGIC_COMMON or MAGIC_SERVICE and the second one is same as MAGIC
|
||||
# in images V1.0. We don't keep "first" magic in json images.
|
||||
#
|
||||
# In order to convert images to human-readable format, we use dict(json).
|
||||
# Using json not only allows us to easily read\write images, but also
|
||||
@@ -23,18 +23,18 @@
|
||||
# Using dict(json) format, criu images can be described like:
|
||||
#
|
||||
# {
|
||||
# 'magic' : 'FOO',
|
||||
# 'entries' : [
|
||||
# entry,
|
||||
# ...
|
||||
# ]
|
||||
# 'magic' : 'FOO',
|
||||
# 'entries' : [
|
||||
# entry,
|
||||
# ...
|
||||
# ]
|
||||
# }
|
||||
#
|
||||
# Entry, in its turn, could be described as:
|
||||
#
|
||||
# {
|
||||
# pb_msg,
|
||||
# 'extra' : extra_msg
|
||||
# pb_msg,
|
||||
# 'extra' : extra_msg
|
||||
# }
|
||||
#
|
||||
import io
|
||||
@@ -72,23 +72,23 @@ class MagicException(Exception):
|
||||
# format to/from dict(json).
|
||||
class entry_handler:
|
||||
"""
|
||||
Generic class to handle loading/dumping criu images
|
||||
entries from/to bin format to/from dict(json).
|
||||
"""
|
||||
Generic class to handle loading/dumping criu images
|
||||
entries from/to bin format to/from dict(json).
|
||||
"""
|
||||
|
||||
def __init__(self, payload, extra_handler=None):
|
||||
"""
|
||||
Sets payload class and extra handler class.
|
||||
"""
|
||||
Sets payload class and extra handler class.
|
||||
"""
|
||||
self.payload = payload
|
||||
self.extra_handler = extra_handler
|
||||
|
||||
def load(self, f, pretty=False, no_payload=False):
|
||||
"""
|
||||
Convert criu image entries from binary format to dict(json).
|
||||
Takes a file-like object and returnes a list with entries in
|
||||
dict(json) format.
|
||||
"""
|
||||
Convert criu image entries from binary format to dict(json).
|
||||
Takes a file-like object and returnes a list with entries in
|
||||
dict(json) format.
|
||||
"""
|
||||
entries = []
|
||||
|
||||
while True:
|
||||
@@ -128,17 +128,17 @@ class entry_handler:
|
||||
|
||||
def loads(self, s, pretty=False):
|
||||
"""
|
||||
Same as load(), but takes a string as an argument.
|
||||
"""
|
||||
Same as load(), but takes a string as an argument.
|
||||
"""
|
||||
f = io.BytesIO(s)
|
||||
return self.load(f, pretty)
|
||||
|
||||
def dump(self, entries, f):
|
||||
"""
|
||||
Convert criu image entries from dict(json) format to binary.
|
||||
Takes a list of entries and a file-like object to write entries
|
||||
in binary format to.
|
||||
"""
|
||||
Convert criu image entries from dict(json) format to binary.
|
||||
Takes a list of entries and a file-like object to write entries
|
||||
in binary format to.
|
||||
"""
|
||||
for entry in entries:
|
||||
extra = entry.pop('extra', None)
|
||||
|
||||
@@ -156,17 +156,17 @@ class entry_handler:
|
||||
|
||||
def dumps(self, entries):
|
||||
"""
|
||||
Same as dump(), but doesn't take file-like object and just
|
||||
returns a string.
|
||||
"""
|
||||
Same as dump(), but doesn't take file-like object and just
|
||||
returns a string.
|
||||
"""
|
||||
f = io.BytesIO('')
|
||||
self.dump(entries, f)
|
||||
return f.read()
|
||||
|
||||
def count(self, f):
|
||||
"""
|
||||
Counts the number of top-level object in the image file
|
||||
"""
|
||||
Counts the number of top-level object in the image file
|
||||
"""
|
||||
entries = 0
|
||||
|
||||
while True:
|
||||
@@ -183,10 +183,10 @@ class entry_handler:
|
||||
# Special handler for pagemap.img
|
||||
class pagemap_handler:
|
||||
"""
|
||||
Special entry handler for pagemap.img, which is unique in a way
|
||||
that it has a header of pagemap_head type followed by entries
|
||||
of pagemap_entry type.
|
||||
"""
|
||||
Special entry handler for pagemap.img, which is unique in a way
|
||||
that it has a header of pagemap_head type followed by entries
|
||||
of pagemap_entry type.
|
||||
"""
|
||||
|
||||
def load(self, f, pretty=False, no_payload=False):
|
||||
entries = []
|
||||
@@ -547,10 +547,10 @@ def __rhandler(f):
|
||||
|
||||
def load(f, pretty=False, no_payload=False):
|
||||
"""
|
||||
Convert criu image from binary format to dict(json).
|
||||
Takes a file-like object to read criu image from.
|
||||
Returns criu image in dict(json) format.
|
||||
"""
|
||||
Convert criu image from binary format to dict(json).
|
||||
Takes a file-like object to read criu image from.
|
||||
Returns criu image in dict(json) format.
|
||||
"""
|
||||
image = {}
|
||||
|
||||
m, handler = __rhandler(f)
|
||||
@@ -574,18 +574,18 @@ def info(f):
|
||||
|
||||
def loads(s, pretty=False):
|
||||
"""
|
||||
Same as load(), but takes a string.
|
||||
"""
|
||||
Same as load(), but takes a string.
|
||||
"""
|
||||
f = io.BytesIO(s)
|
||||
return load(f, pretty)
|
||||
|
||||
|
||||
def dump(img, f):
|
||||
"""
|
||||
Convert criu image from dict(json) format to binary.
|
||||
Takes an image in dict(json) format and file-like
|
||||
object to write to.
|
||||
"""
|
||||
Convert criu image from dict(json) format to binary.
|
||||
Takes an image in dict(json) format and file-like
|
||||
object to write to.
|
||||
"""
|
||||
m = img['magic']
|
||||
magic_val = magic.by_name[img['magic']]
|
||||
|
||||
@@ -609,9 +609,9 @@ def dump(img, f):
|
||||
|
||||
def dumps(img):
|
||||
"""
|
||||
Same as dump(), but takes only an image and returns
|
||||
a string.
|
||||
"""
|
||||
Same as dump(), but takes only an image and returns
|
||||
a string.
|
||||
"""
|
||||
f = io.BytesIO(b'')
|
||||
dump(img, f)
|
||||
return f.getvalue()
|
||||
|
Reference in New Issue
Block a user