[CRIU] [PATCH 3/5] p.haul: minor style fixes for arguments parsing code
Nikita Spiridonov
nspiridonov at odin.com
Fri Nov 20 08:49:01 PST 2015
Move 'help' arguments of add_argument function to the end of arguments
list, rearrage calls a little, add comments.
Signed-off-by: Nikita Spiridonov <nspiridonov at odin.com>
---
p.haul | 38 ++++++++++++++++----------------------
p.haul-service | 8 +++++---
2 files changed, 21 insertions(+), 25 deletions(-)
diff --git a/p.haul b/p.haul
index 940c819..6c7a70a 100755
--- a/p.haul
+++ b/p.haul
@@ -28,38 +28,32 @@ def log_uncaught_exception(type, value, traceback):
logging.error(value, exc_info=(type, value, traceback))
+# Initialize arguments parser
parser = argparse.ArgumentParser("Process HAULer")
+parser.set_defaults(pre_dump=phaul.iters.PRE_DUMP_AUTO_DETECT)
parser.add_argument("type", choices=phaul.htype.get_haul_names(),
help="Type of hat to haul, e.g. vz, lxc, or docker")
parser.add_argument("id", help="ID of what to haul")
parser.add_argument("--to", help="IP where to haul")
-parser.add_argument("--fdrpc", help="File descriptor of rpc socket", type=int, required=True)
-parser.add_argument("--fdmem", help="File descriptor of memory socket", type=int, required=True)
-parser.add_argument("--fdfs", help="File descriptor of fs socket", type=int, required=True)
-parser.add_argument("-v", help="Verbosity level", default=phaul.criu_api.def_verb, type=int, dest="verbose")
-parser.add_argument("--keep-images", help="Keep images after migration", default=False, action='store_true')
-parser.add_argument("--dst-rpid", help="Write pidfile on restore", default=None)
-parser.add_argument("--img-path", help="Directory where to put images",
- default=phaul.images.def_path)
+parser.add_argument("--fdrpc", type=int, required=True, help="File descriptor of rpc socket")
+parser.add_argument("--fdmem", type=int, required=True, help="File descriptor of memory socket")
+parser.add_argument("--fdfs", type=int, required=True, help="File descriptor of fs socket")
+parser.add_argument("-v", default=phaul.criu_api.def_verb, type=int, dest="verbose", help="Verbosity level")
+parser.add_argument("--keep-images", default=False, action='store_true', help="Keep images after migration")
+parser.add_argument("--dst-rpid", default=None, help="Write pidfile on restore")
+parser.add_argument("--img-path", default=phaul.images.def_path,
+ help="Directory where to put images")
parser.add_argument("--pid-root", help="Path to tree's FS root")
-parser.add_argument("--force", help="Don't do any sanity (CPU compat) checks", default=False, action='store_true')
+parser.add_argument("--force", default=False, action='store_true', help="Don't do any sanity (CPU compat) checks")
parser.add_argument("--log-file", help="Write logging messages to specified file")
-parser.add_argument("-j", "--shell-job", help="Allow migration of shell jobs",
- default=False, action='store_true')
-
-
+parser.add_argument("-j", "--shell-job", default=False, action='store_true',
+ help="Allow migration of shell jobs")
parser.add_argument('--no-pre-dump', dest='pre_dump', action='store_const',
- const=phaul.iters.PRE_DUMP_DISABLE,
- help='Force disable pre-dumps')
+ const=phaul.iters.PRE_DUMP_DISABLE, help='Force disable pre-dumps')
parser.add_argument('--pre-dump', dest='pre_dump', action='store_const',
- const=phaul.iters.PRE_DUMP_ENABLE,
- help='Force enable pre-dumps')
-
-# If pre dumping is not explicitly enabled or disabled
-# it is phaul.iters.PRE_DUMP_AUTO_DETECT
-
-parser.set_defaults(pre_dump=phaul.iters.PRE_DUMP_AUTO_DETECT)
+ const=phaul.iters.PRE_DUMP_ENABLE, help='Force enable pre-dumps')
+# Parse arguments
args = parser.parse_args()
# Configure logging
diff --git a/p.haul-service b/p.haul-service
index b838c1c..cb20d71 100755
--- a/p.haul-service
+++ b/p.haul-service
@@ -19,12 +19,14 @@ def fin(foo, bar):
stop_fd.close()
+# Initialize arguments parser
parser = argparse.ArgumentParser("Process HAULer service server")
-parser.add_argument("--fdrpc", help="File descriptor of rpc socket", type=int, required=True)
-parser.add_argument("--fdmem", help="File descriptor of memory socket", type=int, required=True)
-parser.add_argument("--fdfs", help="File descriptor of fs socket", type=int, required=True)
+parser.add_argument("--fdrpc", type=int, required=True, help="File descriptor of rpc socket")
+parser.add_argument("--fdmem", type=int, required=True, help="File descriptor of memory socket")
+parser.add_argument("--fdfs", type=int, required=True, help="File descriptor of fs socket")
parser.add_argument("--log-file", help="Write logging messages to specified file")
+# Parse arguments
args = parser.parse_args()
# Configure logging
--
1.7.1
More information about the CRIU
mailing list