<commit_before>#!/usr/bin/env python
#
# Delete user events from Sysdig Cloud
#

import json
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..'))
from sdcclient import SdcClient

#
# Parse arguments
#
if len(sys.argv) != 2:
    print 'usage: %s <sysdig-token>' % sys.argv[0]
    print 'You can find your token at https://app.sysdigcloud.com/#/settings/user'
    sys.exit(1)

sdc_token = sys.argv[1]

#
# Instantiate the SDC client
#
sdclient = SdcClient(sdc_token)

#
# Get the events that match a name
#
res = sdclient.get_events(name='test event')

if not res[0]:
	print res[1]
	sys.exit(1)

#
# Delete the first event among the returned ones
#
for event in res[1]['events']:
	print "Deleting event " + event['name']

	res = sdclient.delete_event(event)

	if not res[0]:
		print res[1]
		sys.exit(1)
	else:
		sys.exit(0)<commit_msg>Proper cleanup<commit_after>#!/usr/bin/env python
#
# Delete user events from Sysdig Cloud
#

import json
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..'))
from sdcclient import SdcClient

#
# Parse arguments
#
if len(sys.argv) != 2:
    print 'usage: %s <sysdig-token>' % sys.argv[0]
    print 'You can find your token at https://app.sysdigcloud.com/#/settings/user'
    sys.exit(1)

sdc_token = sys.argv[1]

#
# Instantiate the SDC client
#
sdclient = SdcClient(sdc_token)

#
# Get the events that match a name
#
res = sdclient.get_events(name='test event')

if not res[0]:
	print res[1]
	sys.exit(1)

#
# Delete the first event among the returned ones
#
for event in res[1]['events']:
	print "Deleting event " + event['name']

	res = sdclient.delete_event(event)

	if not res[0]:
		print res[1]
		sys.exit(1)
{'fraction_non_alphanumeric': 0.14675767918088736, 'fraction_numerical': 0.015358361774744027, 'mean_word_length': 4.054597701149425, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5075853', 'n_tokens_mistral': 686, 'n_tokens_neox': 667, 'n_words': 176}