def get(self): # clears pictures and videos from prior call media = MediaUtility() media.media_cleanup() # uses overwatchleague twitter if none found in url try: username = request.args['user'] if username == '': html = "<h1>Please specify a user in the URL arguments</h1>" return html except Exception: html = "<h1>Please specify a user in the URL arguments</h1>" return html twitter = TwitterUtility() auth_exception = twitter.get_auth("keys") if auth_exception: return auth_exception tweets = twitter.get_tweets(username) if not tweets: html = "<h1>User has no tweets within the past 24 hours,\ try another user.</h1>" return html # error case for undefined user elif isinstance(tweets, str): return tweets # add the username to the queue here else: # if there are no errors authenticating and getting tweets, # queue the video creation for that user job = { "user": username, "id": config.index, "status": "in progress" } config.queuedJobs.append(job) config.index += 1 config.q.put(job) # wait until queue is empty before returning the video config.q.join() media.png_cleanup() return send_file(f"{username}_tweet_video.mp4")
def test_removeOnlyPNG(): testPNG = "tweet_0.png" testMP4 = "test.mp4" testFile = "test.txt" os.system("touch " + testPNG) os.system("touch " + testMP4) os.system("touch " + testFile) media = MediaUtility() media.png_cleanup() assert os.path.isfile(testPNG) is False assert os.path.isfile(testMP4) is True assert os.path.isfile(testFile) is True