#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# All params from IdM is stored in environment and you can get them by os.environ["paramName"]
import sys, os
# this is needed for importing file winrm_wrapper from parent dir
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import winrm_wrapper
import codecs

uid = os.environ["__UID__"]

winrm_wrapper.writeLog("Delete start for " + uid)

# Load PS script from file and replace params
winrm_wrapper.writeLog("loading script")
f = codecs.open(os.environ["script"], encoding='utf-8', mode='r')
command = f.read()
command = command.replace("$uid", uid)

# Call wrapper
winrm_wrapper.executeScript(os.environ["endpoint"], os.environ["authentication"], os.environ["user"],
                                    os.environ["password"], os.environ["caTrustPath"], os.environ["ignoreCaValidation"], command, uid)

winrm_wrapper.writeLog("Delete end for " + uid)
print("__UID__=" + uid)
sys.exit()

[((351, 400), 'winrm_wrapper.writeLog', 'winrm_wrapper.writeLog', (["('Delete start for ' + uid)"], {}), "('Delete start for ' + uid)\n", (373, 400), False, 'import winrm_wrapper\n'), ((448, 488), 'winrm_wrapper.writeLog', 'winrm_wrapper.writeLog', (['"""loading script"""'], {}), "('loading script')\n", (470, 488), False, 'import winrm_wrapper\n'), ((493, 554), 'codecs.open', 'codecs.open', (["os.environ['script']"], {'encoding': '"""utf-8"""', 'mode': '"""r"""'}), "(os.environ['script'], encoding='utf-8', mode='r')\n", (504, 554), False, 'import codecs\n'), ((629, 839), 'winrm_wrapper.executeScript', 'winrm_wrapper.executeScript', (["os.environ['endpoint']", "os.environ['authentication']", "os.environ['user']", "os.environ['password']", "os.environ['caTrustPath']", "os.environ['ignoreCaValidation']", 'command', 'uid'], {}), "(os.environ['endpoint'], os.environ[\n    'authentication'], os.environ['user'], os.environ['password'], os.\n    environ['caTrustPath'], os.environ['ignoreCaValidation'], command, uid)\n", (656, 839), False, 'import winrm_wrapper\n'), ((867, 914), 'winrm_wrapper.writeLog', 'winrm_wrapper.writeLog', (["('Delete end for ' + uid)"], {}), "('Delete end for ' + uid)\n", (889, 914), False, 'import winrm_wrapper\n'), ((939, 949), 'sys.exit', 'sys.exit', ([], {}), '()\n', (947, 949), False, 'import sys, os\n'), ((252, 277), 'os.path.dirname', 'os.path.dirname', (['__file__'], {}), '(__file__)\n', (267, 277), False, 'import sys, os\n')]