Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Use regex to split
Browse files Browse the repository at this point in the history
Use regex to split.
  • Loading branch information
abuccts committed Jul 26, 2019
1 parent 07b8d14 commit be0263f
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/kube-runtime/src/runtime.d/port.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from __future__ import print_function

import os
import re
import sys
import socket

Expand All @@ -45,13 +46,11 @@ def main():
Check whether there's conflict in scheduled ports.
"""
port_list = os.environ.get("PAI_CONTAINER_HOST_PORT_LIST")
if port_list:
for each in port_list.split(";"):
portno_list = each.split(":")
if len(portno_list) > 1:
for portno in portno_list[1].split(","):
check_port(int(portno))
port_list_env = os.environ.get("PAI_CONTAINER_HOST_PORT_LIST")
if port_list_env:
for each in re.split(":|;|,", port_list_env):
if each.isdigit():
check_port(int(each))


if __name__ == "__main__":
Expand Down

0 comments on commit be0263f

Please sign in to comment.