提交 579ccff9 编写于 作者: M MRXLT

improve error info

上级 6ea67de5
...@@ -206,9 +206,11 @@ class Server(object): ...@@ -206,9 +206,11 @@ class Server(object):
print('Frist time run, downloading PaddleServing components ...') print('Frist time run, downloading PaddleServing components ...')
r = os.system('wget ' + bin_url + ' --no-check-certificate') r = os.system('wget ' + bin_url + ' --no-check-certificate')
if r != 0: if r != 0:
print('Download failed')
if os.path.exists(tar_name): if os.path.exists(tar_name):
os.remove(tar_name) os.remove(tar_name)
raise SystemExit(
'Download failed, please check your network or permission of {}.'.
format(self.module_path))
else: else:
try: try:
print('Decompressing files ..') print('Decompressing files ..')
...@@ -218,6 +220,9 @@ class Server(object): ...@@ -218,6 +220,9 @@ class Server(object):
except: except:
if os.path.exists(exe_path): if os.path.exists(exe_path):
os.remove(exe_path) os.remove(exe_path)
raise SystemExit(
'Decompressing failed, please check your permission of {} or disk space left.'.
foemat(self.module_path))
finally: finally:
os.remove(tar_name) os.remove(tar_name)
os.chdir(self.cur_path) os.chdir(self.cur_path)
...@@ -231,7 +236,7 @@ class Server(object): ...@@ -231,7 +236,7 @@ class Server(object):
os.system("mkdir {}".format(workdir)) os.system("mkdir {}".format(workdir))
os.system("touch {}/fluid_time_file".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)) raise SystemExit("Prot {} is already used".format(port))
self._prepare_resource(workdir) self._prepare_resource(workdir)
self._prepare_engine(self.model_config_path, device) self._prepare_engine(self.model_config_path, device)
...@@ -248,7 +253,7 @@ class Server(object): ...@@ -248,7 +253,7 @@ class Server(object):
self._write_pb_str(resource_fn, self.resource_conf) self._write_pb_str(resource_fn, self.resource_conf)
self._write_pb_str(model_toolkit_fn, self.model_toolkit_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: with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
sock.settimeout(2) sock.settimeout(2)
result = sock.connect_ex(('127.0.0.1', port)) result = sock.connect_ex(('127.0.0.1', port))
......
...@@ -189,9 +189,11 @@ class Server(object): ...@@ -189,9 +189,11 @@ class Server(object):
print('Frist time run, downloading PaddleServing components ...') print('Frist time run, downloading PaddleServing components ...')
r = os.system('wget ' + bin_url + ' --no-check-certificate') r = os.system('wget ' + bin_url + ' --no-check-certificate')
if r != 0: if r != 0:
print('Download failed')
if os.path.exists(tar_name): if os.path.exists(tar_name):
os.remove(tar_name) os.remove(tar_name)
raise SystemExit(
'Download failed, please check your network or permission of {}.'.
format(self.module_path))
else: else:
try: try:
print('Decompressing files ..') print('Decompressing files ..')
...@@ -201,6 +203,9 @@ class Server(object): ...@@ -201,6 +203,9 @@ class Server(object):
except: except:
if os.path.exists(exe_path): if os.path.exists(exe_path):
os.remove(exe_path) os.remove(exe_path)
raise SystemExit(
'Decompressing failed, please check your permission of {} or disk space left.'.
format(self.module_path))
finally: finally:
os.remove(tar_name) os.remove(tar_name)
os.chdir(self.cur_path) os.chdir(self.cur_path)
...@@ -214,7 +219,7 @@ class Server(object): ...@@ -214,7 +219,7 @@ class Server(object):
os.system("mkdir {}".format(workdir)) os.system("mkdir {}".format(workdir))
os.system("touch {}/fluid_time_file".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)) raise SystemExit("Prot {} is already used".format(port))
self._prepare_resource(workdir) self._prepare_resource(workdir)
...@@ -232,7 +237,7 @@ class Server(object): ...@@ -232,7 +237,7 @@ class Server(object):
self._write_pb_str(resource_fn, self.resource_conf) self._write_pb_str(resource_fn, self.resource_conf)
self._write_pb_str(model_toolkit_fn, self.model_toolkit_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: with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
sock.settimeout(2) sock.settimeout(2)
result = sock.connect_ex(('127.0.0.1', port)) result = sock.connect_ex(('127.0.0.1', port))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册