import os
import yaml


filename = os.path.join('data', 'configs.yaml')
with open(filename) as handle:
    data = yaml.load(handle)

host = data.pop('docker_host')
data['docker_hosts'] = [host]

with open(filename, 'w') as handle:
    yaml.dump(data, handle, default_flow_style=False)

import os
import sys
import yaml


filename = os.path.join('data', 'configs.yaml')
try:
    with open(filename) as handle:
        data = yaml.load(handle)
except FileNotFoundError:
    # This is fine; will fail for new installs
    sys.exit(0)

host = data.pop('docker_host')
data['docker_hosts'] = [host]

with open(filename, 'w') as handle:
    yaml.dump(data, handle, default_flow_style=False)

Handle no config.yaml in migrations
Handle no config.yaml in migrations

  import os
+ import sys
  import yaml
  
  
  filename = os.path.join('data', 'configs.yaml')
+ try:
- with open(filename) as handle:
+     with open(filename) as handle:
-     data = yaml.load(handle)
+         data = yaml.load(handle)
+ except FileNotFoundError:
+     # This is fine; will fail for new installs
+     sys.exit(0)
  
  host = data.pop('docker_host')
  data['docker_hosts'] = [host]
  
  with open(filename, 'w') as handle:
      yaml.dump(data, handle, default_flow_style=False)
  
Handle no config.yaml in migrations
## Code Before:
import os
import yaml


filename = os.path.join('data', 'configs.yaml')
with open(filename) as handle:
    data = yaml.load(handle)

host = data.pop('docker_host')
data['docker_hosts'] = [host]

with open(filename, 'w') as handle:
    yaml.dump(data, handle, default_flow_style=False)

## Instruction:
Handle no config.yaml in migrations
## Code After:
import os
import sys
import yaml


filename = os.path.join('data', 'configs.yaml')
try:
    with open(filename) as handle:
        data = yaml.load(handle)
except FileNotFoundError:
    # This is fine; will fail for new installs
    sys.exit(0)

host = data.pop('docker_host')
data['docker_hosts'] = [host]

with open(filename, 'w') as handle:
    yaml.dump(data, handle, default_flow_style=False)
