def update(): print "Deleting (reset) Mongo Collection named 'mac'" delete("mac") with Timeout(5, False): oui = urllib2.urlopen(OUI_URL, timeout=240) # code, oui = _sendGetRequest(OUI_URL, {}, {}) # print "IEEE Response Code was a " + str(code) count = 1 for totalcount, line in enumerate(oui, start=1): macHexVendor = re.match("^.*(" + OUI_HEX_REGEX + ").*" + "hex" + ".*?([A-Z].*)$", line) if macHexVendor: count += 1 macEntry = { "base16": macHexVendor.group(1).replace(OUI_MATCH, ""), "hex": macHexVendor.group(1).replace(OUI_MATCH, OUI_REPLACE), "organization": macHexVendor.group(2) } post_internal("mac", macEntry) if not VCAP_CONFIG: print macHexVendor.group(1).replace(OUI_MATCH, OUI_REPLACE) + ", " + \ macHexVendor.group(2) print "Number of MAC Entries matched: " + str(count) return ""
def update(): print "Deleting (reset) Mongo Collection named 'mac'" delete("mac") with Timeout(5, False): oui = urllib2.urlopen(OUI_URL, timeout=240) # code, oui = _sendGetRequest(OUI_URL, {}, {}) # print "IEEE Response Code was a " + str(code) count = 1 for totalcount, line in enumerate(oui, start=1): macHexVendor = re.match( "^.*(" + OUI_HEX_REGEX + ").*" + "hex" + ".*?([A-Z].*)$", line) if macHexVendor: count += 1 macEntry = { "base16": macHexVendor.group(1).replace(OUI_MATCH, ""), "hex": macHexVendor.group(1).replace(OUI_MATCH, OUI_REPLACE), "organization": macHexVendor.group(2) } post_internal("mac", macEntry) if not VCAP_CONFIG: print macHexVendor.group(1).replace(OUI_MATCH, OUI_REPLACE) + ", " + \ macHexVendor.group(2) print "Number of MAC Entries matched: " + str(count) return ""
def after_delete_project(project: dict): """Perform delete on the project's files too.""" from eve.methods.delete import delete pid = project['_id'] log.info('Project %s was deleted, also deleting its files.', pid) r, _, _, status = delete('files', {'project': pid}) if status != 204: log.warning('Unable to delete files of project %s: %s', pid, r)
def after_delete_project(project: dict): """Perform delete on the project's files too.""" from werkzeug.exceptions import NotFound from eve.methods.delete import delete pid = project['_id'] log.info('Project %s was deleted, also deleting its files.', pid) try: r, _, _, status = delete('files', {'project': pid}) except NotFound: # There were no files, and that's fine. return if status != 204: # Will never happen because bloody Eve always returns 204 or raises an exception. log.warning('Unable to delete files of project %s: %s', pid, r)
def delete_documents(resource): "Delete all documents of the given resource." with api.test_request_context(resource_url(resource)): return delete(resource)