def delete_from_cloudinary(rating_key=None, delete_all=False): """ Deletes an image from Cloudinary """ if not plexpy.CONFIG.CLOUDINARY_CLOUD_NAME or not plexpy.CONFIG.CLOUDINARY_API_KEY or not plexpy.CONFIG.CLOUDINARY_API_SECRET: logger.error( u"Tautulli Helpers :: Cannot delete image from Cloudinary. Cloudinary settings not specified in the settings." ) return False cloudinary.config(cloud_name=plexpy.CONFIG.CLOUDINARY_CLOUD_NAME, api_key=plexpy.CONFIG.CLOUDINARY_API_KEY, api_secret=plexpy.CONFIG.CLOUDINARY_API_SECRET) if delete_all: delete_resources_by_tag('tautulli') logger.debug( u"Tautulli Helpers :: Deleted all images from Cloudinary.") elif rating_key: delete_resources_by_tag(str(rating_key)) logger.debug( u"Tautulli Helpers :: Deleted images from Cloudinary with rating_key {}." .format(rating_key)) else: logger.debug( u"Tautulli Helpers :: Unable to delete images from Cloudinary: No rating_key provided." ) return True
def test09b_delete_resources_by_prefix(self): """ should allow deleting resources by tags """ uploader.upload("tests/logo.png", public_id="api_test4", tags=["api_test_tag_for_delete"]) resource = api.resource("api_test4") self.assertNotEqual(resource, None) api.delete_resources_by_tag("api_test_tag_for_delete") self.assertRaises(api.NotFound, api.resource, ("api_test4"))
def test09c_delete_resources_by_transformations(self, mocker): """ should allow deleting resources by transformations """ mocker.return_value = MOCK_RESPONSE api.delete_resources(['api_test', 'api_test2'], transformations=['c_crop,w_100']) self.assertEqual(get_method(mocker), 'DELETE') self.assertEqual(get_param(mocker, 'transformations'), 'c_crop,w_100') api.delete_all_resources( transformations=['c_crop,w_100', { "crop": "scale", "width": 107 }]) self.assertEqual(get_method(mocker), 'DELETE') self.assertEqual(get_param(mocker, 'transformations'), 'c_crop,w_100|c_scale,w_107') api.delete_resources_by_prefix("api_test_by", transformations='c_crop,w_100') self.assertEqual(get_method(mocker), 'DELETE') self.assertEqual(get_param(mocker, 'transformations'), 'c_crop,w_100') api.delete_resources_by_tag("api_test_tag", transformations=['c_crop,w_100']) self.assertEqual(get_method(mocker), 'DELETE') self.assertEqual(get_param(mocker, 'transformations'), 'c_crop,w_100')
def test09b_delete_resources_by_tag(self, mocker): """ should allow deleting resources by tags """ mocker.return_value = MOCK_RESPONSE api.delete_resources_by_tag("api_test_tag_for_delete") args, kargs = mocker.call_args self.assertEqual(args[0], 'DELETE') self.assertTrue(get_uri(args).endswith('/resources/image/tags/api_test_tag_for_delete'))
def cleanup(): response = resources_by_tag(DEFAULT_TAG) resources = response.get('resources', []) if not resources: print("Clean Up: All alert images already deleted.") return print("Deleting {0:d} images...".format(len(resources))) delete_resources_by_tag(DEFAULT_TAG) print("Done!")
def cleanup(): response = resources_by_tag(DEFAULT_TAG) resources = response.get('resources', []) if not resources: print("No images found") return print("Deleting {0:d} images...".format(len(resources))) delete_resources_by_tag(DEFAULT_TAG) print("Done!")
def cleanup(): response = resources_by_tag(DEFAULT_TAG) count = len(response.get('resources', [])) if (count == 0): print "No images found" return print "Deleting %d images..." % (count,) delete_resources_by_tag(DEFAULT_TAG) print "Done!" pass
def cleanup(): response = resources_by_tag(DEFAULT_TAG) count = len(response.get('resources', [])) if (count == 0): print("No images found") return print("Deleting %d images..." % (count, )) delete_resources_by_tag(DEFAULT_TAG) print("Done!") pass
def cleanup(): tag = DEFAULT_OPTIONS['tags'] response = resources_by_tag(tag) count = len(response.get('resources', [])) if (count == 0): print "No images found" return print "Deleting %d images..." % (count,) delete_resources_by_tag(tag) print "Done!" pass
def cleanup(): try: global DEFAULT_TAG response = resources_by_tag(DEFAULT_TAG) count = len(response.get('resources', [])) print((colored("[+] Deleting %d images from previous sessions..." % (count), "white"))) if (count == 0): print((colored("[-] No images found", "white"))) return delete_resources_by_tag(DEFAULT_TAG) print((colored("[+] Done", "white"))) except: print((colored("[-] Error trying to remove previous images", "yellow")))
def test09c_delete_resources_by_transformations(self, mocker): """ should allow deleting resources by transformations """ mocker.return_value = MOCK_RESPONSE api.delete_resources(['api_test', 'api_test2'], transformations=['c_crop,w_100']) self.assertEqual(get_method(mocker), 'DELETE') self.assertEqual(get_param(mocker, 'transformations'), 'c_crop,w_100') api.delete_all_resources(transformations=['c_crop,w_100', {"crop": "scale", "width": 107}]) self.assertEqual(get_method(mocker), 'DELETE') self.assertEqual(get_param(mocker, 'transformations'), 'c_crop,w_100|c_scale,w_107') api.delete_resources_by_prefix("api_test_by", transformations='c_crop,w_100') self.assertEqual(get_method(mocker), 'DELETE') self.assertEqual(get_param(mocker, 'transformations'), 'c_crop,w_100') api.delete_resources_by_tag("api_test_tag", transformations=['c_crop,w_100']) self.assertEqual(get_method(mocker), 'DELETE') self.assertEqual(get_param(mocker, 'transformations'), 'c_crop,w_100')
def cleanup(): try: global DEFAULT_TAG response = resources_by_tag(DEFAULT_TAG) count = len(response.get('resources', [])) print((colored( "[+] Deleting %d images from previous sessions..." % (count), "white"))) if (count == 0): print((colored("[-] No images found", "white"))) return delete_resources_by_tag(DEFAULT_TAG) print((colored("[+] Done", "white"))) except: print((colored("[-] Error trying to remove previous images", "yellow")))
def tearDownClass(cls): try: api.delete_resources_by_tag(UNIQUE_TAG) except Exception as e: logger.exception("Failed to delete test resources %s", e) pass
def tearDownClass(cls): api.delete_resources_by_tag(TEST_TAG)
def delete_by_tag(self, tag): # TODO: error handling api.delete_resources_by_tag(tag)
def tearDownClass(cls): api.delete_resources_by_tag(ARCHIVE_TAG)
def cleanup_test_resources_by_tag(params): for tag_with_options in params: options = tag_with_options[1] if len(tag_with_options) > 1 else {} with ignore_exception(): api.delete_resources_by_tag(tag_with_options[0], **options)
def tearDownClass(cls): api.delete_resources_by_tag(TEST_TAG) api.delete_resources_by_tag(TEST_TAG, resource_type='raw')
caption = "{} {:.3f}".format(labels_to_names[label], score) draw_caption(draw, b, caption) if label == 43 or label == 76: draw = cv2.cvtColor(draw, cv2.COLOR_RGB2BGR) cv2.imwrite("out.jpg",draw) cloudinary.uploader.upload("out.jpg", public_id="intruder", tags="uploaded") cloudinary.utils.cloudinary_url("intruder.jpg") message = client.messages.create( media_url = 'http://res.cloudinary.com/diabloash/image/upload/intruder.jpg', body= 'Intruder Detected', from_='whatsapp:', # enter WhatsApp number to='whatsapp:' # enter WhatsApp number ) delete_resources_by_tag("uploaded") draw = cv2.cvtColor(draw, cv2.COLOR_BGR2RGB) draw = cv2.cvtColor(draw, cv2.COLOR_RGB2BGR) cv2.imshow("Frame", draw) key = cv2.waitKey(1) & 0xFF # if the `q` key was pressed, break from the loop if key == ord("q"): break # update the FPS counter fps.update() # stop the FPS counter
def tearDownClass(cls): try: api.delete_resources_by_tag(UNIQUE_TAG) except Exception as e: logger.exception("Failed to delete test resources %s", e)