コード例 #1
0
ファイル: maintenance.py プロジェクト: zhxu73/atmosphere
    def handle_start(self, **options):
        start_date = options['start_date']
        if isinstance(start_date, str):
            try:
                start_date = parse(start_date)
            except Exception as exc:
                raise CommandError("Error parsing start_date: {}".format(exc))

        record = MaintenanceRecord(title=options['title'],
                                   message=options['message'],
                                   start_date=start_date)
        if options['dry_run']:
            self.stdout.write("{}: {}".format(self.style.NOTICE("Dry run"),
                                              record))
        else:
            record.save()
            self.stdout.write("{}: {}".format(
                self.style.SUCCESS("Record created"), record))