def test_unschedule(self): """ Simple Unschedule """ dt = self.insert_distro() dist = get_scheduled_distributions(1, dt)[0] unschedule_distribution(dist.id) dists = get_scheduled_distributions(1, dt) assert_equal(0, len(dists))
def unschedule(): """ Unschedule a distribution """ dist_id = request.args.get('distId') if not dist_id: msg = "a distribution ID is required" return jsonify({"err": [{"msg": msg}]}), 400 try: unschedule_distribution(dist_id) except (NoResultFound, DataError): msg = "dist_id {0} does not exist".format(dist_id) env.log("UPCOMING_ERROR msg: {0}".format(msg)) return jsonify({"err": [{"msg": msg}]}), 404 return jsonify({"unscheduled": [dist_id]}), 204
def deploy_scheduled(console_out, deploy_flag, leniency, verbose, quiet, *args, **kwargs): """ Find scheduled distributions and deploy """ if verbose: logger = setup_command_logger(logging.DEBUG) elif quiet: logger = setup_command_logger(logging.ERROR) else: logger = setup_command_logger(logging.INFO) from splice.queries import get_scheduled_distributions, unschedule_distribution import requests dt = datetime.utcnow() distributions = get_scheduled_distributions(leniency, dt) logger.info("{0} - found {1} distributions".format(dt, len(distributions))) dist_data = [] for dist in distributions: logger.info("fetching {0}".format(dist.url)) r = requests.get(dist.url) if r.status_code == 200: dist_data.append((r.json(), dist.channel_id, dist.id)) else: logger.error("FETCH_ERROR status_code:{0} url:{1}".format( r.status_code, dist.url)) from splice.ingest import ingest_links, distribute, IngestError if deploy_flag: for rawdata, channel_id, dist_id in dist_data: try: new_data = ingest_links(rawdata, channel_id) if console_out: print json.dumps(new_data, sort_keys=True, indent=2) distribute(new_data, channel_id, deploy_flag) unschedule_distribution(dist_id) except IngestError, e: raise InvalidCommand(e.message) except:
def deploy_scheduled(console_out, deploy_flag, leniency, verbose, quiet, *args, **kwargs): """ Find scheduled distributions and deploy """ if verbose: logger = setup_command_logger(logging.DEBUG) elif quiet: logger = setup_command_logger(logging.ERROR) else: logger = setup_command_logger(logging.INFO) from splice.queries import get_scheduled_distributions, unschedule_distribution import requests dt = datetime.utcnow() distributions = get_scheduled_distributions(leniency, dt) logger.info("{0} - found {1} distributions".format(dt, len(distributions))) dist_data = [] for dist in distributions: logger.info("fetching {0}".format(dist.url)) r = requests.get(dist.url) if r.status_code == 200: dist_data.append((r.json(), dist.channel_id, dist.id)) else: logger.error("FETCH_ERROR status_code:{0} url:{1}".format(r.status_code, dist.url)) from splice.ingest import ingest_links, distribute, IngestError if deploy_flag: for rawdata, channel_id, dist_id in dist_data: try: new_data = ingest_links(rawdata, channel_id) if console_out: print json.dumps(new_data, sort_keys=True, indent=2) distribute(new_data, channel_id, deploy_flag) unschedule_distribution(dist_id) except IngestError, e: raise InvalidCommand(e.message) except:
def test_unschedule_inexistent(self): with assert_raises(NoResultFound): unschedule_distribution(5)
def test_unschedule_inexistent(self): "Unschedule something that doesn't exist" with assert_raises(NoResultFound): unschedule_distribution(5)