diff --git a/paddlehub/commands/convert.py b/paddlehub/commands/convert.py index 0ff13888c1b1105f893122a230bf093678483599..c963841a77c7e8c4bf5a42b99725e77ef69be8c7 100644 --- a/paddlehub/commands/convert.py +++ b/paddlehub/commands/convert.py @@ -140,6 +140,9 @@ class ConvertCommand(BaseCommand): self.module = args.module_name self.version = args.module_version if args.module_version is not None else '1.0.0' self.src = args.model_dir + if not os.path.isdir(self.src): + print('`{}` is not exists or not a directory path'.format(self.src)) + return False self.dest = args.output_dir if args.output_dir is not None else os.path.join( '{}_{}'.format(self.module, str(time.time()))) diff --git a/paddlehub/common/hub_server.py b/paddlehub/common/hub_server.py index f7c27ce7f179da47497a0d0b8215f2d810523c7c..1ae2496db0984be7743eec9af39a62201cc6bbba 100644 --- a/paddlehub/common/hub_server.py +++ b/paddlehub/common/hub_server.py @@ -250,9 +250,15 @@ class HubServer(object): if not os.path.exists(CACHE_HOME): utils.mkdir(CACHE_HOME) try: - r = requests.get(self.get_server_url() + '/' + 'search') - data = json.loads(r.text) cache_path = os.path.join(CACHE_HOME, RESOURCE_LIST_FILE) + if os.path.exists(cache_path): + r = requests.get( + self.get_server_url() + '/' + 'search', timeout=0.5) + else: + r = requests.get( + self.get_server_url() + '/' + 'search', timeout=8) + data = json.loads(r.text) + with open(cache_path, 'w+') as fp: yaml.safe_dump({'resource_list': data['data']}, fp) return True diff --git a/paddlehub/version.py b/paddlehub/version.py index 37817839cb85e7bbf74b466675db24d9fef2580a..b250a1f8fcbc30a5bafd9b82b54a22951086688c 100644 --- a/paddlehub/version.py +++ b/paddlehub/version.py @@ -13,5 +13,5 @@ # See the License for the specific language governing permissions and # limitations under the License. """ PaddleHub version string """ -hub_version = "1.8.1" +hub_version = "1.8.3" module_proto_version = "1.0.0"