~wesmason/conn-check/configs-django-dev

« back to all changes in this revision

Viewing changes to conn_check_configs/django.py

  • Committer: Wes Mason
  • Date: 2014-10-13 20:17:01 UTC
  • mfrom: (10.1.1 print-by-default)
  • Revision ID: wesley.mason@canonical.com-20141013201701-2wrio61yfifr1qx9
Tags: 1.0.4
Update changelog with latest release

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
 
145
145
def main(*args):
146
146
    parser = argparse.ArgumentParser()
147
 
    output_group = parser.add_mutually_exclusive_group()
148
 
    output_group.add_argument('-f', '--output-file',
 
147
    parser.add_argument('-f', '--output-file',
149
148
                              dest='output_file',
150
149
                              required=False,
151
150
                              help='File path to save YAML config to')
152
 
    output_group.add_argument('-P', '--print',
153
 
                              dest="print",
154
 
                              action="store_true",
155
 
                              help='Output YAML config to STDOUT')
156
151
    parser.add_argument('-m', '--settings-module',
157
152
                        dest="settings_module",
158
153
                        action="store",
180
175
 
181
176
    output = yaml.dump(gather_checks(opts), default_flow_style=False)
182
177
 
183
 
    if opts.print:
184
 
        print(output, file=sys.stdout)
185
 
    else:
 
178
    if opts.output_file:
186
179
        with open(opts.output_file, 'w') as f:
187
180
            f.write(output)
 
181
    else:
 
182
        print(output, file=sys.stdout)
188
183
 
189
184
    return 0
190
185