<commit_before>"""
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""

##############################################
# queries active directory for each computer
# and finds the running services and adds as application components to Device42 via REST APIs
# works best with Device42 v5.6.0 and above (to automatically add the service accounts as components)
#   Requires:
#       powershell
#       ironpython
#       .net 4
#
#   to run:
#       ipy.exe ad-sample.py
#   v1.0, Created: 02-08-2014
##############################################

import types
import os.path
import urllib
import urllib2
import traceback
import base64
import System
import clr
import math
clr.AddReference("System.DirectoryServices")
clr.AddReference('System.Management.Automation')

from System.Management.Automation import RunspaceInvoke
# +---------------------------------------------------------------------------

# create a runspace to run shell commands from
RUNSPACE = RunspaceInvoke()

D42_URL='https://your-url-here'                        #make sure to NOT to end in /
D42_USER    ='put-your-user-name-here'
D42_PASSWORD='<PASSWORD>'

PATH_NAME_STRINGS_TO_IGNORE = ['system32', 'vmware', ]     #Any service running under a path containing this string will be ignored.
ADD_SERVICE_ACCOUNT_AS_DEPENDENCY = True                   #Change to False if you don't want to record dependency on service account
SERVICE_ACCOUNT_PREFIX = 'ServiceAccount_'                 #Prefix to add to service accounts to see the impact - change to '' if no prefix is required
IGNORE_ALL_SERVICES_RUNNING_AS_LOCALSYSTEM = True         #If you just want to get services running under service accounts - set this to True

DRY_RUN = False                                            #Set to True to NOT post to D42 and just print the parameters that will be sent
DEBUG = False<commit_msg>localsystem account ignore set to False by default<commit_after>"""
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""

##############################################
# queries active directory for each computer
# and finds the running services and adds as application components to Device42 via REST APIs
# works best with Device42 v5.6.0 and above (to automatically add the service accounts as components)
#   Requires:
#       powershell
#       ironpython
#       .net 4
#
#   to run:
#       ipy.exe ad-sample.py
#   v1.0, Created: 02-08-2014
##############################################

import types
import os.path
import urllib
import urllib2
import traceback
import base64
import System
import clr
import math
clr.AddReference("System.DirectoryServices")
clr.AddReference('System.Management.Automation')

from System.Management.Automation import RunspaceInvoke
# +---------------------------------------------------------------------------

# create a runspace to run shell commands from
RUNSPACE = RunspaceInvoke()

D42_URL='https://your-url-here'                        #make sure to NOT to end in /
D42_USER    ='put-your-user-name-here'
D42_PASSWORD='<PASSWORD>'

PATH_NAME_STRINGS_TO_IGNORE = ['system32', 'vmware', ]     #Any service running under a path containing this string will be ignored.
ADD_SERVICE_ACCOUNT_AS_DEPENDENCY = True                   #Change to False if you don't want to record dependency on service account
SERVICE_ACCOUNT_PREFIX = 'ServiceAccount_'                 #Prefix to add to service accounts to see the impact - change to '' if no prefix is required
IGNORE_ALL_SERVICES_RUNNING_AS_LOCALSYSTEM = False         #If you just want to get services running under service accounts - set this to True

DRY_RUN = False                                            #Set to True to NOT post to D42 and just print the parameters that will be sent
DEBUG = False
{'fraction_non_alphanumeric': 0.12494539100043688, 'fraction_numerical': 0.013543031891655745, 'mean_word_length': 3.1855575868372945, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2594735', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1133, 'n_words': 520}