Skip to content

Commit

Permalink
fixed #32 and #34
Browse files Browse the repository at this point in the history
  • Loading branch information
dcvan24 committed Jun 6, 2018
1 parent 8f254bf commit 5da2ec4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions container/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
from util import parse_datetime


short_id_pattern = '(.*)\@([a-zA-Z0-9\.-]+)'
short_id_pattern = r'@([a-zA-Z0-9\.-]+)'


def get_short_ids(p):
return [p2 for p1, p2 in re.compile(short_id_pattern).findall(p) if not p1]
return [p2 for p1, p2 in re.compile(short_id_pattern).findall(p) if not p1] if p else []


def parse_container_short_id(p, appliance):
return re.sub(r'%s(.*)'%short_id_pattern,
return re.sub(r'([^@]*)%s([^@]*)'%short_id_pattern,
r'\1\2-%s.marathon.containerip.dcos.thisdcos.directory\3'%appliance,
str(p))

Expand Down Expand Up @@ -435,7 +435,7 @@ def parse(cls, data):
if data['type'] == ContainerType.JOB.value:
from container.job import Job
return 200, Job(**data), None
return 422, 'Unknown container type: %s'%data['type']
return 422, 'Unknown container type: %s'%data['type'], None

def __init__(self, id, appliance, type, image, resources, cmd=None, args=[], env={},
volumes=[], network_mode=NetworkMode.HOST, endpoints=[], ports=[],
Expand All @@ -447,11 +447,11 @@ def __init__(self, id, appliance, type, image, resources, cmd=None, args=[], env
self.__type = type if isinstance(type, ContainerType) else ContainerType(type)
self.__image = image
self.__resources = Resources(**resources)
self.__cmd = cmd
self.__args = list(args)
self.__cmd = cmd and str(cmd)
self.__args = [a and str(a) for a in args]
if self.__cmd and self.__args:
raise ValueError("Cannot specify both 'cmd' and 'args'")
self.__env = dict(env)
self.__env = {k: v and str(v) for k, v in env.items()}
self.__volumes = [Volume(**v) for v in volumes]
self.__network_mode = network_mode if isinstance(network_mode, NetworkMode) \
else NetworkMode(network_mode.upper())
Expand Down

0 comments on commit 5da2ec4

Please sign in to comment.