I'm using the Weblogic Scripting Tool aka WLST, a Python-based shell environment, to programmatically edit variables in Plan.xml files for projects to be deployed to the Weblogic server. I can get as far as getting an instance of the WLSTPlan Object, and can run getVariables and other methods to check that it is populated and view its contents. However, when I try to call the setVariable method, I get an AttributeError, which to my limited understanding means the method doesn't exist:
wls:/UoADevDomain/serverConfig> plan.setVariable("foo", "bar")
Traceback (innermost last):
File "<console>", line 1, in ?
AttributeError: setVariable
As the docs linked above (which I checked are the right version) show, this method definitely should exist, and other methods listed in the same doc work. I'm not sure if this is an issue with Weblogic or with my understanding of Python, but either way it's beyond me. I tried using the dir() function to list the plan object's attributes, but it returned an empty set so I guess that trick doesn't work in this environment.
Can anyone suggest how to go about diagnosing this problem, or better still fixing it?
Using javap and looking for setters on the WLSTPlan bean shows only the following setter
void setVariableValue(java.lang.String, java.lang.String);
Could be a typo in the docs. Can you try 'setVariableValue' instead.
The documentation is rather unclear, but from reading between the lines, it looks like setVariable is a method that you invoke on a VariableBean.
I'd try using the following:
plan.createVariable("foo").setVariable("foo", "bar");
(that's without having tested the code, though)
Related
Good day,
I'm very new to the Blender API.
Ultimately, I am trying to get the currently selected object. I know this is available bpy.context.selected_objects. However, I'm running my script from a python file and the context object is different. in my current context the selected_objects does not exist.
I've searched around and at most I've been able to find that you can edit in which context some operators are run by overriding their settings. But bpy.context.selected_objects is not an operator.
Perhaps there is a method or operator inside bpy.data which returns the selected object? I can't seem to find the part of the documentation which shows what attributes are exposed inside bpy.data https://docs.blender.org/api/current/search.html?q=bpy.data.&check_keywords=yes&area=default#
Thanks in advance.
As your running this from blender scripting possibly using bpy.context.active_object rather then bpy.context.selected_objects might work better.
There can be an active object when no objects are selected, here's more info on them: https://blender.stackexchange.com/questions/27396/whats-the-difference-among-object-active-object-and-selected-objects
It's also quite hard to tell what could be going on without more details on the internal functionings, so attaching code would be usefull.
I'm not too well-versed in Python, although, I think this question is mostly language-agnostic, but wanted to see if there was a particular way to do it for Python.
I'm working with a couple of Pytorch Python scripts.
The function test_qtensor_cpu on line 147 in https://github.com/pytorch/pytorch/blob/fbcode/warm/test/quantization/core/test_quantized_tensor.py is being executed when I run the script in https://github.com/pytorch/pytorch/blob/fbcode/warm/test/test_quantization.py, but I cannot find the function that calls test_qtensor_cpu. I did a grep -ri "test_qtensor_cpu*" . in the root director of this repo and the only result was the definition of this function.
Is there a way for this function to be called without explicitly writing out the function's name?
Just add:
def my_func_i_cant_figure_out_whats_calling_it()
import traceback
traceback.print_stack()
That will show you the callstack at that point, even without a breakpoint.
Yes, its possible to call a function without explicitly writing it out.
(and figuring out how to use a debugger is super useful... future you will thank you if you figure it out sooner rather than later)
Line 29 of test_quantization.py imports TestQuantizedTensor (which includes the test_qtensor_cpu method).
The run_tests() (source here) at the bottom of the file will automatically run all test cases that have been imported (which includes TestQuantitizedTensor) via unittest (usually via unittest.main, though this can be changed by args passed to the test suite).
I am working with pydev (latest version) and the debugger is not working anymore (specifically breakpoints do not work). I get a strange error:
pydev debugger: starting
Traceback (most recent call last):
with no further text. ...
I am working with stackless python 2.7 and pyside (almost latest version). The breakpoints that are not working are not within stackless tasklets.
Anyone know the cause or a fix?
OK, (slightly embarassed) i have had a similar problem in the past, posted here and got extensive help here
I used that post to pinpoint the problem to this method:
def __getattr__(self, name):
if name in self._code_:
func = self.getfunction(name)
setattr(self, name, func)
return func
else:
return super(AtomicProcess, self).__getattr__(name)
I would like to use this or a similar method to set the attribute at the latest possible time (when it is called).I added the super call to possibly fix the problem, but no dice.
Does anyone know what causes the problem in this method?
Does anyone have a fix that achieves the late initialization but avoids the pydev problem?
Also I should mention that my code runs without problem but that the debugger seems to go into some infinite recursion in the method above, recovers and ignores breakpoints after this method.
Cheers, Lars
PS: anyone? Are pydev developers following stackoverflow or is there another place i might try?
It seems it's something as the previous issue although I'm not sure what (if you can pass me the code I can take a look at it, but without it, the only thing I can do is point to the last thread we had).
Keep in mind that if you have a recursion exception, this is something that breaks the Python debugging facility... What you can do as a workaround in the meanwhile is using the remote debugger to improve on that.
I do have a hunch thought:
My guess is that you access something in 'self' which is calling __getattr__ again... (which generates a recursion and breaks the debugger).
Another possible thing: instead of using the 'super' idiom in: super(AtomicProcess, self).__getattr__(name), use the superclass directly: Superclass.__getattr__(self, name)...
Cheers,
Fabio
I find it hard to explain my problem as the problem is not within the code itself. If you need more input to understand the following better, please let me know.
I'm using ArcGIS to call a bunch of python scripts, one after another. The scripts use the same class by importing it, or inherit from it. To initialize the class I often use the same name. I have no idea how the communication between ArcGIS and python is implemented. But I noticed that my scripts are not always behaving like they should. I suppose that the reference to the object still exists (even though the script the object was created with has finished) when I call the second script.
First of all: How can I make sure my suspicion is true?
Secondly, if this is the case: is it a good idea to destroy all references to all objects using del or __del__? What is the best way to do this?
Trace tracing your code and walking through it with a debugger? Quickest way to tell if it's accessing correct code. Python Debugger
If you read the documentation, what you want to do is use a break point to make sure code reaches that point in code.
This is the syntax with the debugger.
b(reak) [[filename:]lineno | function[, condition]]
http://code.google.com/chrome/extensions/npapi.html
I have read through this, and am thoroughly confused. I have built the sample npapi .so plugin from http://www.firebreath.org/display/documentation/Building+on+Linux
Everything worked fine (plugin is installed correctly and recognized) until I went to use it in my popup.html in my unpacked extension, which threw:
<embed type="application/x-sample" id="sample">
<script>
console.log((document.getElementById("sample"))().echo("asdf"));
popup.html:18Uncaught ReferenceError: NPObject deleted
From various testing, it appears calling the constructor on the plugin object throws the error. I have no idea what's going on here.
All I really want to do is to compile a .py file using Cython into a .so or .dll, and then be able to call its methods in my extension.
Does anyone know of an easy way to do this? / Can anyone provide a simple 'hello, world' example of this working?
where is your extra () coming from? Most likely it should be this:
console.log(document.getElementById("sample").echo("asdf"));
What you were trying to do would probably end up trying to call the "default" method on the NPObject, which is probably nonexistent and will thus throw an exception.