"row_total": None, "subtotals": None, "dynamic_fields": None, "query_timezone": "America/Los_Angeles", "has_table_calculations": False, "model": "i__looker" } if args.resume: with open(args.filename) as json_schedules: data = json.load(json_schedules) print("Resumed from " + args.filename) for schedule in data: # resume all schedules, or a specific schedule if a id is passed as a command-line argument if (args.resume != -1 and int(schedule['scheduled_plan.id']) == int(args.resume)) or args.resume == -1: looker.update_schedule(schedule['scheduled_plan.id'], body={"crontab":schedule['scheduled_plan.cron_schedule']}) elif args.pause: scheduler_data = looker.run_inline_query(body=query_body) for schedule in scheduler_data: # Don't overwrite already-paused schedules if schedule['scheduled_plan.cron_schedule'] == "0 5 31 2 *": paused_id = schedule['scheduled_plan.id'] try: with open(args.filename) as json_schedules: paused_data = json.load(json_schedules) for paused_schedule in paused_data: # If a schedule has already been paused, preserve the existing paused value if int(paused_id) == paused_schedule['scheduled_plan.id']: schedule['scheduled_plan.cron_schedule'] = paused_schedule['scheduled_plan.cron_schedule'] except:
email_list.append(value) print "Getting Schedule information from Look" # get look plan ID from a Look(158). look_plan_id = looker.get_look_schedule(task_report)[0]['id'] # Pass those emails into an update_schedule call using the above look_plan_id into below plan # Loop through the email list, appending to and creating and concatenating the string to be used for the # body of the API call in json form i = 1 list_of_schedule_plan_destinations = '' for email in email_list: if i == len(email_list): list_of_schedule_plan_destinations += ( '{{"scheduled_plan_id": {},"format": "csv","address": "{}","type": "email"}}]}}' .format(look_plan_id, email)) else: list_of_schedule_plan_destinations += ( '{{"scheduled_plan_id": {},"format": "csv","address": "{}","type": "email" }},' .format(look_plan_id, email)) i += 1 start_string = '{"scheduled_plan_destination":[' full_body = start_string + list_of_schedule_plan_destinations # Make the call print "Updating Schedule" looker.update_schedule(look_plan_id, body=full_body) print "Done"