Skip to content

Commit 2f6c763

Browse files
committed
Merge pull request #353 from dnephin/add_flake8
Add flake8
2 parents 4caf90c + 939406c commit 2f6c763

10 files changed

Lines changed: 25 additions & 13 deletions

File tree

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ before_script:
1616
- 'if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then orchard hosts create $TRAVIS_JOB_ID; fi'
1717
script:
1818
- nosetests tests/unit
19+
- flake8 fig
1920
- 'if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then script/travis-integration; fi'
2021
after_script:
2122
- 'if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then orchard hosts rm -f $TRAVIS_JOB_ID; fi'

fig/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from __future__ import unicode_literals
2-
from .service import Service
2+
from .service import Service # noqa:flake8
33

44
__version__ = '0.5.2'

fig/cli/command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import re
99
import yaml
1010
from ..packages import six
11-
import sys
1211

1312
from ..project import Project
1413
from ..service import ConfigError
@@ -19,6 +18,7 @@
1918

2019
log = logging.getLogger(__name__)
2120

21+
2222
class Command(DocoptCommand):
2323
base_dir = '.'
2424

fig/cli/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,13 @@ def scale(self, options):
281281
try:
282282
num = int(num)
283283
except ValueError:
284-
raise UserError('Number of containers for service "%s" is not a number' % service)
284+
raise UserError('Number of containers for service "%s" is not a '
285+
'number' % service_name)
285286
try:
286287
self.project.get_service(service_name).scale(num)
287288
except CannotBeScaledError:
288289
raise UserError('Service "%s" cannot be scaled because it specifies a port on the host. If multiple containers for this service were created, the port would clash.\n\nRemove the ":" from the port definition in fig.yml so Docker can choose a random port for each container.' % service_name)
289290

290-
291291
def start(self, options):
292292
"""
293293
Start existing containers.
@@ -357,5 +357,6 @@ def handler(signal, frame):
357357
print("Gracefully stopping... (press Ctrl+C again to force)")
358358
self.project.stop(service_names=service_names)
359359

360+
360361
def list_containers(containers):
361362
return ", ".join(c.name for c in containers)

fig/cli/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ def prettydate(d):
6565
elif s < 120:
6666
return '1 minute ago'
6767
elif s < 3600:
68-
return '{0} minutes ago'.format(s/60)
68+
return '{0} minutes ago'.format(s / 60)
6969
elif s < 7200:
7070
return '1 hour ago'
7171
else:
72-
return '{0} hours ago'.format(s/3600)
72+
return '{0} hours ago'.format(s / 3600)
7373

7474

7575
def mkdir(path, permissions=0o700):
@@ -103,8 +103,8 @@ def split_buffer(reader, separator):
103103
index = buffered.find(separator)
104104
if index == -1:
105105
break
106-
yield buffered[:index+1]
107-
buffered = buffered[index+1:]
106+
yield buffered[:index + 1]
107+
buffered = buffered[index + 1:]
108108

109109
if len(buffered) > 0:
110110
yield buffered

fig/container.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import unicode_literals
22
from __future__ import absolute_import
33

4+
45
class Container(object):
56
"""
67
Represents a Docker container, constructed from the output of

fig/project.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def visit(n):
3838

3939
return sorted_services
4040

41+
4142
class Project(object):
4243
"""
4344
A collection of services.
@@ -216,6 +217,6 @@ def __init__(self, msg):
216217
def __str__(self):
217218
return self.msg
218219

220+
219221
class DependencyError(ConfigurationError):
220222
pass
221-

fig/service.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ def scale(self, desired_num):
132132

133133
self.remove_stopped()
134134

135-
136135
def remove_stopped(self, **options):
137136
for c in self.containers(stopped=True):
138137
if not c.is_running:
@@ -212,7 +211,7 @@ def start_container_if_stopped(self, container, **options):
212211
log.info("Starting %s..." % container.name)
213212
return self.start_container(container, **options)
214213

215-
def start_container(self, container=None, intermediate_container=None,**override_options):
214+
def start_container(self, container=None, intermediate_container=None, **override_options):
216215
if container is None:
217216
container = self.create_container(**override_options)
218217

@@ -342,7 +341,7 @@ def _get_container_create_options(self, override_options, one_off=False):
342341
if 'environment' in container_options:
343342
if isinstance(container_options['environment'], list):
344343
container_options['environment'] = dict(split_env(e) for e in container_options['environment'])
345-
container_options['environment'] = dict(resolve_env(k,v) for k,v in container_options['environment'].iteritems())
344+
container_options['environment'] = dict(resolve_env(k, v) for k, v in container_options['environment'].iteritems())
346345

347346
if self.can_be_built():
348347
if len(self.client.images(name=self._build_tag_name())) == 0:
@@ -459,13 +458,15 @@ def split_port(port):
459458
external_port = (external_ip,)
460459
return internal_port, external_port
461460

461+
462462
def split_env(env):
463463
if '=' in env:
464464
return env.split('=', 1)
465465
else:
466466
return env, None
467467

468-
def resolve_env(key,val):
468+
469+
def resolve_env(key, val):
469470
if val is not None:
470471
return key, val
471472
elif key in os.environ:

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ mock==1.0.1
22
nose==1.3.0
33
pyinstaller==2.1
44
unittest2
5+
flake8

tox.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ deps =
77
-rrequirements-dev.txt
88
commands =
99
nosetests {posargs}
10+
flake8 fig
11+
12+
[flake8]
13+
# ignore line-length for now
14+
ignore = E501,E203
15+
exclude = fig/packages/

0 commit comments

Comments
 (0)