def handle_noargs(self, **options): #check if rabbitmq is working try: connection = pika.BlockingConnection( pika.ConnectionParameters(settings.RABBITMQ_SERVER)) except: logger.critical( "We are experiencing a connection problem and cannot perform uploads for now. Please try again later." ) logger.info("Uploading file to s3...") upload_to_s3(FILE_KEY, FILE_LOCATION) logger.info("Upload process successful.") logger.info("Enqueuing slug to rabbitmq...") enqueue(FILE_KEY) logger.info("Enqueue process successful.") #should indicate that video was uploaded and is stored in s3 logger.info("Checking if video is already in s3 (should be there)...") check_from_s3(FILE_KEY) #check if an expiring url can be generated, similar to how Screenbird gets url for video playing logger.info("Checking generation of expiring url...") try: conn = Connection(is_secure=True) url = conn.generate_object_expiring_url(FILE_KEY) if not url: logger.critical("Failed to generate expiring url.") raise Exception except: logger.critical("Failed to check for an expiring url.") logger.info("Expiring url successfully generated.") logger.info("Deleting file from s3...") delete_from_s3(FILE_KEY) logger.info("Delete process successful.") #should indicate that video is not anymore stored in s3 because of the delete logger.info( "Checking if video is still in s3 (should NOT be there anymore)..." ) check_from_s3(FILE_KEY)
def handle_noargs(self, **options): #check if rabbitmq is working try: connection = pika.BlockingConnection(pika.ConnectionParameters(settings.RABBITMQ_SERVER)) except: logger.critical("We are experiencing a connection problem and cannot perform uploads for now. Please try again later.") logger.info("Uploading file to s3...") upload_to_s3(FILE_KEY, FILE_LOCATION) logger.info("Upload process successful.") logger.info("Enqueuing slug to rabbitmq...") enqueue(FILE_KEY) logger.info("Enqueue process successful.") #should indicate that video was uploaded and is stored in s3 logger.info("Checking if video is already in s3 (should be there)...") check_from_s3(FILE_KEY) #check if an expiring url can be generated, similar to how Screenbird gets url for video playing logger.info("Checking generation of expiring url...") try: conn = Connection(is_secure=True) url = conn.generate_object_expiring_url(FILE_KEY) if not url: logger.critical("Failed to generate expiring url.") raise Exception except: logger.critical("Failed to check for an expiring url.") logger.info("Expiring url successfully generated.") logger.info("Deleting file from s3...") delete_from_s3(FILE_KEY) logger.info("Delete process successful.") #should indicate that video is not anymore stored in s3 because of the delete logger.info("Checking if video is still in s3 (should NOT be there anymore)...") check_from_s3(FILE_KEY)
# Simulating waiting for encoding to finish logger.info("Waiting for encoding to finish.") wait_time = math.ceil((LONG_VIDEO_ENCODING * 2) * 60) logger.info("ETA: %s" % wait_time) time.sleep(wait_time) check = check_from_s3(slug) if check != "Video is in s3": raise AssertionError("Long video encoding timed out.") else: logger.info("Encoding successful.") # check if an expiring url can be generated, similar to how Screenbird gets url for video playing logger.info("Checking generation of expiring url and video rendering...") try: conn = Connection(is_secure=True) url = conn.generate_object_expiring_url(slug) if not url: raise AssertionError("Failed to generate expiring url and render video.") except Exception, e: raise AssertionError("Failed to check for an expiring url: %s" % e) logger.info("Expiring url successfully generated and video rendered.") # Checks video = Video.objects.get(slug=slug) video_duration = video.video_duration encoded_filename = "longvideo.mp4" get_from_s3_to_filename(slug, encoded_filename) if os.path.isfile(encoded_filename): process = subprocess.Popen( ["ffmpeg", "-i", encoded_filename], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
# Simulating waiting for encoding to finish logger.info("Waiting for encoding to finish.") wait_time = math.ceil((LONG_VIDEO_ENCODING * 2) * 60) logger.info("ETA: %s" % wait_time) time.sleep(wait_time) check = check_from_s3(slug) if check != 'Video is in s3': raise AssertionError('Long video encoding timed out.') else: logger.info("Encoding successful.") #check if an expiring url can be generated, similar to how Screenbird gets url for video playing logger.info( "Checking generation of expiring url and video rendering...") try: conn = Connection(is_secure=True) url = conn.generate_object_expiring_url(slug) if not url: raise AssertionError( "Failed to generate expiring url and render video.") except Exception, e: raise AssertionError("Failed to check for an expiring url: %s" % e) logger.info("Expiring url successfully generated and video rendered.") # Checks video = Video.objects.get(slug=slug) video_duration = video.video_duration encoded_filename = 'longvideo.mp4' get_from_s3_to_filename(slug, encoded_filename) if os.path.isfile(encoded_filename): process = subprocess.Popen(['ffmpeg', '-i', encoded_filename],