"""Source of Stream Spotify util functions.""" import os from garcon.contrib.dynamo_feed_status import \ feed_status_ingestion as feed_status import raven def is_spotify_ingested(date): """Get status of ingestion of the Spotify workflow. Args: date (str): Date in 'YYYY-MM-DD' format. Returns: bool: True if status is 'INGESTED', False otherwise. """ status = feed_status.get_overall_status('spotify', date) return status == feed_status.STATUS_INGESTED def capture_warning(message, activity): """Send warning either to Sentry, either to stdout of worker process. Args: message (str): The message to capture. activity (ActivityWorker): The activity worker. """ sentry = os.environ.get('SENTRY_DSN') if sentry: sentry_client_for_warnings = raven.Client(sentry) sentry_client_for_warnings.captureMessage(message) else: activity.logger.warning(message)