[CRIU] [PATCH 1/3] p.haul: minor style fixes

Nikita Spiridonov nspiridonov at odin.com
Wed Sep 30 09:48:20 PDT 2015


Minor style fixes needed for logging refactoring.

Signed-off-by: Nikita Spiridonov <nspiridonov at odin.com>
---
 p.haul         |   30 ++++++++++++++++--------------
 p.haul-service |   39 +++++++++++++++++++--------------------
 2 files changed, 35 insertions(+), 34 deletions(-)

diff --git a/p.haul b/p.haul
index 00a3808..896b1fa 100755
--- a/p.haul
+++ b/p.haul
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+
 import sys
 import argparse
 import phaul.p_haul_iters as ph_iters
@@ -19,23 +20,24 @@ import phaul.xem_rpc as ph_xem_rpc
 #
 
 parser = argparse.ArgumentParser("Process HAULer")
-parser.add_argument("type", help = "Type of hat to haul, e.g. vz or lxc")
-parser.add_argument("id", help = "ID of what to haul")
-parser.add_argument("to", help = "IP where to haul")
-parser.add_argument("-v", help = "Verbosity level", default = ph_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 = "Dirctory where to put images", default = ph_images.def_path)
-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("--port", help = "Port where to haul", type = int, default = ph_xem_rpc.rpc_port)
+parser.add_argument("type", help="Type of hat to haul, e.g. vz or lxc")
+parser.add_argument("id", help="ID of what to haul")
+parser.add_argument("to", help="IP where to haul")
+parser.add_argument("-v", help="Verbosity level", default=ph_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="Dirctory where to put images", default=ph_images.def_path)
+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("--port", help="Port where to haul", type=int, default=ph_xem_rpc.rpc_port)
 
-args = vars(parser.parse_args())
+args = parser.parse_args()
 
-ph_type = (args.pop("type"), args.pop("id"))
-dst = (args.pop("to"), args.pop("port"))
+args_dict = vars(args)
+ph_type = (args_dict.pop("type"), args_dict.pop("id"))
+dst = (args_dict.pop("to"), args_dict.pop("port"))
 
 # Start the migration
 worker = ph_iters.phaul_iter_worker(ph_type, dst)
-worker.set_options(args)
+worker.set_options(args_dict)
 worker.start_migration()
diff --git a/p.haul-service b/p.haul-service
index 210b7da..65ba635 100755
--- a/p.haul-service
+++ b/p.haul-service
@@ -5,29 +5,28 @@ import argparse
 import phaul.xem_rpc as ph_xem_rpc
 import phaul.p_haul_service as ph_srv
 
-if __name__ == "__main__":
-	parser = argparse.ArgumentParser("Process HAULer service server")
-	parser.add_argument("--bind-addr", help = "IP to bind to", type = str, default = "0.0.0.0")
-	parser.add_argument("--bind-port", help = "Port to bind to", type = int, default = ph_xem_rpc.rpc_port)
+parser = argparse.ArgumentParser("Process HAULer service server")
+parser.add_argument("--bind-addr", help="IP to bind to", type=str, default="0.0.0.0")
+parser.add_argument("--bind-port", help="Port to bind to", type=int, default=ph_xem_rpc.rpc_port)
 
-	args = vars(parser.parse_args())
+args = parser.parse_args()
 
-	host = (args.pop("bind_addr"), args.pop("bind_port"))
+host = (args.bind_addr, args.bind_port)
 
-	sfd = None
-	def fin(foo, bar):
-		print "Stop by %d" % foo
-		sfd.close()
+sfd = None
+def fin(foo, bar):
+	print "Stop by %d" % foo
+	sfd.close()
 
-	print "Starting p.haul rpyc service"
-	t = ph_xem_rpc.rpc_threaded_srv(ph_srv.phaul_service, host)
+print "Starting p.haul rpyc service"
+t = ph_xem_rpc.rpc_threaded_srv(ph_srv.phaul_service, host)
 
-	# FIXME: Setup stop handlers
-	sfd = t.get_stop_fd()
-	signal.signal(signal.SIGTERM, fin)
-	signal.signal(signal.SIGINT, fin)
+# FIXME: Setup stop handlers
+sfd = t.get_stop_fd()
+signal.signal(signal.SIGTERM, fin)
+signal.signal(signal.SIGINT, fin)
 
-	t.start()
-	signal.pause()
-	t.join()
-	print "Bye!"
+t.start()
+signal.pause()
+t.join()
+print "Bye!"
-- 
1.7.1



More information about the CRIU mailing list