From 579ccff9df679c9919e03c2d5232bea10a4e66f8 Mon Sep 17 00:00:00 2001 From: MRXLT Date: Mon, 9 Mar 2020 18:51:45 +0800 Subject: [PATCH] improve error info --- python/paddle_serving_server/__init__.py | 11 ++++++++--- python/paddle_serving_server_gpu/__init__.py | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/python/paddle_serving_server/__init__.py b/python/paddle_serving_server/__init__.py index ebd80a65..155f0b80 100644 --- a/python/paddle_serving_server/__init__.py +++ b/python/paddle_serving_server/__init__.py @@ -206,9 +206,11 @@ class Server(object): print('Frist time run, downloading PaddleServing components ...') r = os.system('wget ' + bin_url + ' --no-check-certificate') if r != 0: - print('Download failed') if os.path.exists(tar_name): os.remove(tar_name) + raise SystemExit( + 'Download failed, please check your network or permission of {}.'. + format(self.module_path)) else: try: print('Decompressing files ..') @@ -218,6 +220,9 @@ class Server(object): except: if os.path.exists(exe_path): os.remove(exe_path) + raise SystemExit( + 'Decompressing failed, please check your permission of {} or disk space left.'. + foemat(self.module_path)) finally: os.remove(tar_name) os.chdir(self.cur_path) @@ -231,7 +236,7 @@ class Server(object): os.system("mkdir {}".format(workdir)) os.system("touch {}/fluid_time_file".format(workdir)) - if not self.check_port(port): + if not self.port_is_available(port): raise SystemExit("Prot {} is already used".format(port)) self._prepare_resource(workdir) self._prepare_engine(self.model_config_path, device) @@ -248,7 +253,7 @@ class Server(object): self._write_pb_str(resource_fn, self.resource_conf) self._write_pb_str(model_toolkit_fn, self.model_toolkit_conf) - def check_port(self, port): + def port_is_available(self, port): with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock: sock.settimeout(2) result = sock.connect_ex(('127.0.0.1', port)) diff --git a/python/paddle_serving_server_gpu/__init__.py b/python/paddle_serving_server_gpu/__init__.py index 4372884a..ece80d5b 100644 --- a/python/paddle_serving_server_gpu/__init__.py +++ b/python/paddle_serving_server_gpu/__init__.py @@ -189,9 +189,11 @@ class Server(object): print('Frist time run, downloading PaddleServing components ...') r = os.system('wget ' + bin_url + ' --no-check-certificate') if r != 0: - print('Download failed') if os.path.exists(tar_name): os.remove(tar_name) + raise SystemExit( + 'Download failed, please check your network or permission of {}.'. + format(self.module_path)) else: try: print('Decompressing files ..') @@ -201,6 +203,9 @@ class Server(object): except: if os.path.exists(exe_path): os.remove(exe_path) + raise SystemExit( + 'Decompressing failed, please check your permission of {} or disk space left.'. + format(self.module_path)) finally: os.remove(tar_name) os.chdir(self.cur_path) @@ -214,7 +219,7 @@ class Server(object): os.system("mkdir {}".format(workdir)) os.system("touch {}/fluid_time_file".format(workdir)) - if not self.check_port(port): + if not self.port_is_available(port): raise SystemExit("Prot {} is already used".format(port)) self._prepare_resource(workdir) @@ -232,7 +237,7 @@ class Server(object): self._write_pb_str(resource_fn, self.resource_conf) self._write_pb_str(model_toolkit_fn, self.model_toolkit_conf) - def check_port(self, port): + def port_is_available(self, port): with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock: sock.settimeout(2) result = sock.connect_ex(('127.0.0.1', port)) -- GitLab