Browse Source

Fix whitespace and line length issues

tags/v0.1.1
Chris Smith 7 years ago
parent
commit
6fdd89f2c9
1 changed files with 26 additions and 14 deletions
  1. 26
    14
      docker-rerun

+ 26
- 14
docker-rerun View File

@@ -8,13 +8,15 @@ import sys
8 8
 
9 9
 
10 10
 def inspect_container(container):
11
-    output = subprocess.check_output(['docker', 'inspect', '--type=container', container])
11
+    output = subprocess.check_output(['docker', 'inspect',
12
+                                      '--type=container', container])
12 13
     return json.loads(output.decode('utf-8'))[0]
13 14
 
14 15
 
15 16
 def handle_binds(container, config):
16 17
     if container['HostConfig']['Binds']:
17
-        config['args'].extend(['--volume=%s' % bind for bind in container['HostConfig']['Binds']])
18
+        config['args'].extend(['--volume=%s' % bind
19
+                               for bind in container['HostConfig']['Binds']])
18 20
 
19 21
 
20 22
 def handle_image(container, config):
@@ -22,15 +24,15 @@ def handle_image(container, config):
22 24
 
23 25
 
24 26
 def handle_name(container, config):
25
-    # Trim the leading / off the name. They're equivalent from docker's point of view, but having
26
-    # the plain name looks nicer from a human point of view.
27
+    # Trim the leading / off the name. They're equivalent from docker's point
28
+    # of view, but having the plain name looks nicer from a human point of view.
27 29
     config['args'].append('--name=%s' % container['Name'][1:])
28 30
 
29 31
 
30 32
 def handle_network_mode(container, config):
31 33
     network = container['HostConfig']['NetworkMode']
32 34
     if network != 'default':
33
-        config['args'].append('--net=%s' % network) 
35
+        config['args'].append('--net=%s' % network)
34 36
 
35 37
 
36 38
 def handle_ports(container, config):
@@ -38,10 +40,13 @@ def handle_ports(container, config):
38 40
     if ports:
39 41
         for port, bindings in ports.items():
40 42
             for binding in bindings:
41
-                if binding['HostIp']: 
42
-                    config['args'].append('-p=%s:%s:%s' % (binding['HostIp'], binding['HostPort'], port))
43
+                if binding['HostIp']:
44
+                    config['args'].append('-p=%s:%s:%s' % (binding['HostIp'],
45
+                                                           binding['HostPort'],
46
+                                                           port))
43 47
                 elif binding['HostPort']:
44
-                    config['args'].append('-p=%s:%s' % (binding['HostPort'], port))                
48
+                    config['args'].append('-p=%s:%s' % (binding['HostPort'],
49
+                                                        port))
45 50
                 else:
46 51
                     config['args'].append('-p=%s' % port)
47 52
 
@@ -57,21 +62,27 @@ def handle_restart(container, config):
57 62
 
58 63
 def handle_volumes_from(container, config):
59 64
     if container['HostConfig']['VolumesFrom']:
60
-        config['args'].extend(['--volumes-from=%s' % cont for cont in container['HostConfig']['VolumesFrom']])
65
+        config['args'].extend(['--volumes-from=%s' % cont for
66
+                               cont in container['HostConfig']['VolumesFrom']])
61 67
 
62 68
 
63 69
 def functions():
64
-    return [m for m in inspect.getmembers(sys.modules[__name__]) if inspect.isfunction(m[1])]
70
+    return [m for m
71
+            in inspect.getmembers(sys.modules[__name__])
72
+            if inspect.isfunction(m[1])]
65 73
 
66 74
 
67 75
 def handlers():
68 76
     return [func for (name, func) in functions() if name.startswith('handle_')]
69
-    
77
+
70 78
 
71 79
 def main():
72
-    parser = argparse.ArgumentParser(description='Reruns docker containers with different parameters.')
80
+    parser = argparse.ArgumentParser(description='Reruns docker containers ' \
81
+                                                 'with different parameters.')
73 82
     parser.add_argument('container', type=str, help='The container to rerun')
74
-    parser.add_argument('-d', '--dry-run', action='store_true', help='Don\'t actually re-run the container, just print what would happen.')
83
+    parser.add_argument('-d', '--dry-run', action='store_true',
84
+                        help='Don\'t actually re-run the container, just ' \
85
+                             'print what would happen.')
75 86
     args = parser.parse_args()
76 87
     container = inspect_container(args.container)
77 88
 
@@ -86,7 +97,8 @@ def main():
86 97
     ]
87 98
 
88 99
     if args.dry_run:
89
-        print('Performing dry run for container %s. The following would be executed:' % args.container)
100
+        print('Performing dry run for container %s. The following would be ' \
101
+              'executed:' % args.container)
90 102
         for command in commands:
91 103
             print(' '.join(command))
92 104
     else:

Loading…
Cancel
Save