1111if not os .path .exists (ROOT_DIR ):
1212 os .mkdir (ROOT_DIR )
1313
14- MATCH = re .compile ('(?P<app>[a-z0-9-]+)_?(?P<version>v[0-9]+)?\.?(?P<c_type>[a-z]+)?.(?P<c_num>[0-9]+)' )
14+ MATCH = re .compile (
15+ '(?P<app>[a-z0-9-]+)_?(?P<version>v[0-9]+)?\.?(?P<c_type>[a-z]+)?.(?P<c_num>[0-9]+)' )
16+
1517
1618class FleetClient (object ):
1719
@@ -76,15 +78,15 @@ def _create_container(self, name, image, command, template, env, **kwargs):
7678 # prepare memory limit for the container type
7779 mem = kwargs .get ('memory' , {}).get (l ['c_type' ], None )
7880 if mem :
79- l .update ({'memory' : '-m {}' .format (mem .lower ())})
81+ l .update ({'memory' : '-m {}' .format (mem .lower ())})
8082 else :
81- l .update ({'memory' : '' })
83+ l .update ({'memory' : '' })
8284 # prepare memory limit for the container type
8385 cpu = kwargs .get ('cpu' , {}).get (l ['c_type' ], None )
8486 if cpu :
85- l .update ({'cpu' : '-c {}' .format (cpu )})
87+ l .update ({'cpu' : '-c {}' .format (cpu )})
8688 else :
87- l .update ({'cpu' : '' })
89+ l .update ({'cpu' : '' })
8890 env .update ({'FLEETW_UNIT' : name + '.service' })
8991 # construct unit from template
9092 unit = template .format (** l )
@@ -148,7 +150,7 @@ def _wait_for_announcer(self, name, env):
148150 # we bump to 20 minutes here to match the timeout on the router and in the app unit files
149151 for _ in range (1200 ):
150152 status = subprocess .check_output (
151- "fleetctl.sh list-units --no-legend --fields unit,sub | grep {name}-announce.service | awk '{{print $2}}'" .format (** locals ()),
153+ "fleetctl.sh list-units --no-legend --fields unit,sub | grep {name}-announce.service | awk '{{print $2}}'" .format (** locals ()), # noqa
152154 shell = True , env = env ).strip ('\n ' )
153155 if status == 'running' :
154156 break
@@ -246,7 +248,7 @@ def attach(self, name):
246248ExecStart=/bin/sh -c "IMAGE=$(etcdctl get /deis/registry/host 2>&1):$(etcdctl get /deis/registry/port 2>&1)/{image}; port=$(docker inspect -f '{{{{range $k, $v := .ContainerConfig.ExposedPorts }}}}{{{{$k}}}}{{{{end}}}}' $IMAGE | cut -d/ -f1) ; docker run --name {name} {memory} {cpu} -P -e PORT=$port $IMAGE {command}"
247249ExecStop=/usr/bin/docker rm -f {name}
248250TimeoutStartSec=20m
249- """
251+ """ # noqa
250252
251253# TODO revisit the "not getting a port" issue after we upgrade to Docker 1.1.0
252254ANNOUNCE_TEMPLATE = """
@@ -263,7 +265,7 @@ def attach(self, name):
263265
264266[X-Fleet]
265267X-ConditionMachineOf={name}.service
266- """
268+ """ # noqa
267269
268270LOG_TEMPLATE = """
269271[Unit]
@@ -277,4 +279,4 @@ def attach(self, name):
277279
278280[X-Fleet]
279281X-ConditionMachineOf={name}.service
280- """
282+ """ # noqa
0 commit comments