"""
   This sample shows how to loop through all users
   and delete all their content and groups

"""

import arcrest
from arcresthelper import resettools
from arcresthelper import common
def trace():
    """
        trace finds the line, the filename
        and error message and returns it
        to the user
    """
    import traceback, inspect
    tb = sys.exc_info()[2]
    tbinfo = traceback.format_tb(tb)[0]
    filename = inspect.getfile(inspect.currentframe())
    # script name + line number
    line = tbinfo.split(", ")[1]
    # Get Python syntax error
    #
    synerror = traceback.format_exc().splitlines()[-1]
    return line, filename, synerror

def main():
    proxy_port = None
    proxy_url = None    

    securityinfo = {}
    securityinfo['security_type'] = 'NTLM'#LDAP, NTLM, OAuth, Portal, PKI
    securityinfo['username'] = "mich3661"#Username
    securityinfo['password'] = "220seahorses"#Password
    securityinfo['org_url'] = "https://arcrestdev2.esri.com/portal"
    securityinfo['proxy_url'] = proxy_url
    securityinfo['proxy_port'] = proxy_port
    securityinfo['referer_url'] = None
    securityinfo['token_url'] = None
    securityinfo['certificatefile'] = None
    securityinfo['keyfile'] = None
    securityinfo['client_id'] = None
    securityinfo['secret_id'] = None   

    try:
        
        rst = resettools.resetTools(securityinfo=securityinfo)
        if rst.valid:
            
            users = rst.securityhandler.username# comma delimited list of users  ex: 'User1, User2'
            
            rst.removeUserData(users=users)
            rst.removeUserGroups(users=users) 
        else:
            print rst.message
    except (common.ArcRestHelperError),e:
        print "error in function: %s" % e[0]['function']
        print "error on line: %s" % e[0]['line']
        print "error in file name: %s" % e[0]['filename']
        print "with error message: %s" % e[0]['synerror']
        if 'arcpyError' in e[0]:
            print "with arcpy message: %s" % e[0]['arcpyError']
    except:
        line, filename, synerror = trace()
        print "error on line: %s" % line
        print "error in file name: %s" % filename
        print "with error message: %s" % synerror

if __name__ == "__main__":
    main()
"""
   This sample shows how to loop through all users
   and delete all their content and groups

"""

import arcrest
from arcresthelper import resettools
from arcresthelper import common
def trace():
    """
        trace finds the line, the filename
        and error message and returns it
        to the user
    """
    import traceback, inspect
    tb = sys.exc_info()[2]
    tbinfo = traceback.format_tb(tb)[0]
    filename = inspect.getfile(inspect.currentframe())
    # script name + line number
    line = tbinfo.split(", ")[1]
    # Get Python syntax error
    #
    synerror = traceback.format_exc().splitlines()[-1]
    return line, filename, synerror

def main():
    proxy_port = None
    proxy_url = None    

    securityinfo = {}
    securityinfo['security_type'] = 'NTLM'#LDAP, NTLM, OAuth, Portal, PKI
    securityinfo['username'] = ""#Username
    securityinfo['password'] = ""#Password
    securityinfo['org_url'] = ""
    securityinfo['proxy_url'] = proxy_url
    securityinfo['proxy_port'] = proxy_port
    securityinfo['referer_url'] = None
    securityinfo['token_url'] = None
    securityinfo['certificatefile'] = None
    securityinfo['keyfile'] = None
    securityinfo['client_id'] = None
    securityinfo['secret_id'] = None   

    try:
        
        rst = resettools.resetTools(securityinfo=securityinfo)
        if rst.valid:
            
            users = rst.securityhandler.username# comma delimited list of users  ex: 'User1, User2'
            
            rst.removeUserData(users=users)
            rst.removeUserGroups(users=users) 
        else:
            print rst.message
    except (common.ArcRestHelperError),e:
        print "error in function: %s" % e[0]['function']
        print "error on line: %s" % e[0]['line']
        print "error in file name: %s" % e[0]['filename']
        print "with error message: %s" % e[0]['synerror']
        if 'arcpyError' in e[0]:
            print "with arcpy message: %s" % e[0]['arcpyError']
    except:
        line, filename, synerror = trace()
        print "error on line: %s" % line
        print "error in file name: %s" % filename
        print "with error message: %s" % synerror

if __name__ == "__main__":
    main()

Update remove_all_content_groups_allusers.py