Best Python code snippet using localstack_python
collect_debug_info.py
Source:collect_debug_info.py
...39# Private interface.40#41###############################################################################42varSeparator = "###$^%~~~"43def _collect(results, prefix, name, t):44 results.append("%s - %s - os.getenv(): %r" % (prefix, name, os.getenv(45 name)))46 results.append("%s - %s - os.environ.get(): %r" % (prefix, name,47 os.environ.get(name)))48 external_values = _getExternalValues(t, name)49 results.append("%s - %s - external: %r" % (prefix, name,50 external_values[name]))51def _collectDebugInfo_environ(t):52 dummyVars = ["WOOF_WOOFIE_%d" % x for x in xrange(4)]53 global tag54 tag = "XXX in os.environ"55 try:56 def f(name):57 return "%s: %s" % (name, name in os.environ)58 _infoX(f(x) for x in dummyVars)59 except:60 _info_exc()61 tag = "os.environ[XXX]"62 try:63 def f(name):64 try:65 result = os.environ[name]66 except:67 result = _str_exc()68 return "%s: %r" % (name, result)69 _infoX(f(x) for x in dummyVars)70 except:71 _info_exc()72 tag = "os.environ.get(XXX)"73 try:74 def f(name):75 return "%s: %r" % (name, os.environ.get(name))76 _infoX(f(x) for x in dummyVars)77 except:78 _info_exc()79 tag = "os.getenv(XXX)"80 try:81 def f(name):82 return "%s: %r" % (name, os.getenv(name))83 _infoX(f(x) for x in dummyVars)84 except:85 _info_exc()86 name = dummyVars[0]87 value = "foo"88 tag = "os.putenv(%s) to %r" % (name, value)89 try:90 results = []91 _collect(results, "before", name, t)92 os.putenv(name, value)93 _collect(results, "after", name, t)94 _infoX(results)95 except:96 _info_exc()97 name = dummyVars[1]98 value = "bar"99 tag = "os.environ[%s] to %r" % (name, value)100 try:101 results = []102 _collect(results, "before", name, t)103 os.environ[name] = value104 _collect(results, "after", name, t)105 _infoX(results)106 except:107 _info_exc()108 name = dummyVars[1]109 value = "baz"110 tag = "os.putenv(%s) to %r" % (name, value)111 try:112 results = []113 _collect(results, "before", name, t)114 os.putenv(name, value)115 _collect(results, "after", name, t)116 _infoX(results)117 except:118 _info_exc()119 name = dummyVars[1]120 value = ""121 tag = "os.putenv(%s) to %r" % (name, value)122 try:123 results = []124 _collect(results, "before", name, t)125 os.putenv(name, value)126 _collect(results, "after", name, t)127 _infoX(results)128 except:129 _info_exc()130 name = dummyVars[2]131 value = "foo"132 tag = "os.unsetenv(%s) from %r" % (name, value)133 try:134 results = []135 os.environ[name] = value136 _collect(results, "before", name, t)137 os.unsetenv(name)138 _collect(results, "after", name, t)139 _infoX(results)140 except:141 _info_exc()142 name = dummyVars[2]143 value = "foo"144 tag = "del os.environ[%s] from %r" % (name, value)145 try:146 results = []147 os.environ[name] = value148 _collect(results, "before", name, t)149 del os.environ[name]150 _collect(results, "after", name, t)151 _infoX(results)152 except:153 _info_exc()154 name = dummyVars[2]155 value = "foo"156 tag = "os.environ.pop(%s) from %r" % (name, value)157 try:158 results = []159 os.environ[name] = value160 _collect(results, "before", name, t)161 os.environ.pop(name)162 _collect(results, "after", name, t)163 _infoX(results)164 except:165 _info_exc()166 name = dummyVars[2]167 value1 = "foo"168 value2 = ""169 tag = "os.environ[%s] to %r from %r" % (name, value2, value1)170 try:171 results = []172 os.environ[name] = value1173 _collect(results, "before", name, t)174 os.environ[name] = value2175 _collect(results, "after", name, t)176 _infoX(results)177 except:178 _info_exc()179 name = dummyVars[3]180 value = '""'181 tag = "os.environ[%s] to %r" % (name, value)182 try:183 results = []184 _collect(results, "before", name, t)185 os.environ[name] = value186 _collect(results, "after", name, t)187 _infoX(results)188 except:189 _info_exc()190def _getExternalValues(t, *args):191 t.run_build_system(["---var-name=%s" % x for x in args])192 result = dict()193 for x in args:194 m = re.search(r"^\*\*\*ENV\*\*\* %s: '(.*)' \*\*\*$" % x, t.stdout(),195 re.MULTILINE)196 if m:197 result[x] = m.group(1)198 else:199 result[x] = None200 return result...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!