I'm trying to add some popular plugins to GIMP (version 2.99.10), but when I launch GIMP, I get errors like the following:
AttributeError: 'SuperResolution' object has no attribute 'set_translation_domain'
SuperResolution is a subclass of Gimp.PlugIn.
I've only installed GIMP recently, so I'm guessing there's some sort of path / scope issue that's causing python not to be able to see the inherited set_translation_domain attribute, but I don't exactly know what the problem would be.
Any ideas?
In superresolution.py replace this:
def do_query_procedures(self):
self.set_translation_domain(
"gimp30-python", Gio.file_new_for_path(Gimp.locale_directory())
)
return ["superresolution"]
To this:
def do_query_procedures(self):
return ["superresolution"]
def do_set_i18n(self, procname):
return True, 'gimp30-python', None
That happens because they changed how localization works in the recent builds of GIMP (2.99.10 - 2.99.13). Here is one of their internal plugins foggify to compare.
Related
I'm trying to make a Python script that connects me to a VPN Server 'number' (with this number as a variable)
I wrote:
import os
VPNServer = 0
VPNServer += 1
os.system("networksetup -connectpppoeservice 'VPNServer {servernumber}'").format(servernumber = str(VPNServer))
print("→ Successfully connected to", "VPNServer", VPNServer)
But everytime I try to run it, the console gives me an AttributeError
AttributeError: 'int' object has no attribute 'format'
I don't understand it because I took the string version of the variable
If someone could help, it would be super cool
I'm on macOS and I'm using Python 3.8.1
In the snippet you provided, you write
os.system('<some string>').format(args)
You are making the format call on the return value of os.system, which happens to be an integer. This is identical to writing e.g.
5.format(args)
Since int objects have no attribute format, you get the AttributeError you described.
What you want to write is
os.system('<some string>'.format(args))
In this specific case, your snippet should resemble
os.system(
"networksetup -connectpppoeservice 'VPNServer {servernumber}'"
.format(servernumber=VPNServer)
)
Note that the str(VPNServer) call is superfluous, since format will autmatically call the __str__ method of the object provided.
Using Blueprint, I can SpawnActorFromClass with a StaticMeshActor, but with a Python script via the builtin Python Script plugin,
unreal.EditorLevelLibrary().spawn_actor_from_class(ue.Class(name='StaticMeshActor'), location, rot)
I got:
LogPython: Error: TypeError: EditorLevelLibrary: Failed to convert parameter 'actor_class' when calling function 'EditorLevelLibrary.SpawnActorFromClass' on 'Default__EditorLevelLibrary'
LogPython: Error: TypeError: NativizeProperty: Cannot nativize 'Class' as 'ActorClass' (ClassProperty)
LogPython: Error: TypeError: NativizeClass: Cannot nativize 'Class' as 'Class' (allowed Class type: 'Actor')
What am I missing?
Figured this out by myself. Turns out that the .spawn_actor_from_class() call does not accept ue.Class. Instead it receives socalled ClassProperty derived from built-in types. So the correct call should be:
unreal.EditorLevelLibrary().spawn_actor_from_class(ue.StaticMeshActor.static_class(), location, rot)
I'm not sure if you're using the Python plugin by 20tab or not, but you can accomplish this quite easily from the in editor console, or even at runtime using the following code sample
def spawn(cls):
ue.editor_deselect_actors()
obj = ue.get_editor_world().actor_spawn(cls)
ue.editor_select_actor(obj)
return obj
__builtins__['spawn'] = spawn # so it's always available in the Py console
The plugin is available for free at https://github.com/20tab/UnrealEnginePython and currently supports up through version 4.22
In case of any blueprint actor in ue5.0 is
unreal.EditorLevelLibrary().spawn_actor_from_class(unreal.EditorAssetLibrary.load_blueprint_class('/Game/TopDown/Actors/WinningHeart'), location, rot)
Where you can get the class path by hovering on the asset on the content drawer or right-click -> Copy Reference.
In my case it was a blueprint actor called 'WinningHeart'. location and rot are unreal.Vector and unreal.Rotator respectively.
I'm trying to set a property of a DBus Interface with Qt5.7.0.
This is the doc:
http://git.kernel.org/cgit/network/ofono/ofono.git/tree/doc/modem-api.txt
and I want to set the Powered property to true.
Here my code:
QDBusInterface *iface = new QDBusInterface("org.ofono", "/hfp/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx", "org.ofono.Modem", QDBusConnection::systemBus());
iface->call("SetProperty", "Powered", QVariant(true));
and this is the error:
QDBusError("org.freedesktop.DBus.Error.UnknownMethod", "Method "SetProperty" with signature "sb" on interface "org.ofono.Modem" doesn't exist")
The path comes from the GetModem method and it's correct.
Also, I tried the same with Python:
modem = dbus.Interface(bus.get_object('org.ofono', '/hfp/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx'), 'org.ofono.Modem')
modem.SetProperty('Powered', dbus.Boolean(1))
and it works fine! So the problem is definitely related to my Qt5 code.
How to better understand the error message? Is wrong my signature or it doesn't find the SetProperty method at all?
I'm having quite a bit of trouble getting started with scripting in Mule. To be quite honest, I'm falling at the first hurdle - I can't find anything in the documentation which tells me how to access the payload or how to return data to my flow.
I'm using Jython 2.5 and Mule 3.4.
My flow is extremely simple: it takes some text from an Ajax source and simply echoes it. At the moment the Python script does nothing (as I cannot figure out how to get it to do something with the payload).
<flow name="Python Script" doc:name="Python Script">
<ajax:connector name="connector-ajax" serverUrl="http://192.168.0.1:8000" resourceBase="C:\mule\workspace\scripting\src\main\app\docroot" doc:name="Ajax" />
<scripting:component doc:name="Python">
<scripting:script engine="jython" file="C:\mule\workspace\scripting\src\main\app\python\myscript.py"/>
</scripting:component>
<echo-component doc:name="Echo"/>
</flow>
I have read through the Script Component Reference and the Scripting Module Reference - the module reference appears to have some relevant information but I can't figure out how to use it in Python.
I have also read through an article about 'Mule Punching' which seems like it would have answered my question if I was running version 2 of Mule. I attempted to use the same techniques in my Mule 3 project but it did not work.
Edit 24/07/2012
Using #ppiixx's response, I have got a little bit further with Python scripting.
Just having a single line of code, for example return len(payload) causes the Jython interpreter to throw an error as return cannot exist outside of a function. Fair enough, that's standard.
However, with the code
def main():
return len(payload)
main()
I get an error saying that 'No serializer can be found for class org.mule.transport.NullPayload'.
The log is below:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Started app 'python-test' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO 2013-07-24 09:16:08,821 [[python-test].flow.stage1.02] org.mule.component.simple.LogComponent:
********************************************************************************
* Message received in service: flow. Content is: '{NullPayload}' *
********************************************************************************
ERROR 2013-07-24 09:16:08,849 [[python-test].flow.stage1.02] org.mule.exception.CatchMessagingExceptionStrategy:
********************************************************************************
Message : No serializer found for class org.mule.transport.NullPayload and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (org.codehaus.jackson.map.JsonMappingException)
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. No serializer found for class org.mule.transport.NullPayload and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (org.codehaus.jackson.map.JsonMappingException)
org.codehaus.jackson.map.ser.impl.UnknownSerializer:52 (null)
2. No serializer found for class org.mule.transport.NullPayload and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (org.codehaus.jackson.map.JsonMappingException) (org.mule.api.transformer.TransformerException)
org.mule.module.json.transformers.ObjectToJson:107 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerException.html)
This leads me to think that using return on its own isn't enough to return data to the flow.
I've read through the scripting module reference, and while it gives examples in Groovy, it does not give examples in Python so I'm not sure where I'm going wrong.
Have a look at the 'Script Context Bindings' section here.
Basically a number of variables are available in the script context including: message,payload and log.
To return data using the python engine you set the result variable.
result = len(payload)
There is a example in the mule github.
I am trying to create a custom filter for OpenStack, using their FilterScheduler component. The documentation for the FilterScheduler is here: http://docs.openstack.org/developer/nova/devref/filter_scheduler.html#
Now, there is not much in the way of documentation for creating your own custom filter. Infact, the complete documentation is:
If you want to create your own filter you just need to inherit from BaseHostFilter and implement one method: host_passes. This method should return True if host passes the filter. It takes host_state (describes host) and filter_properties dictionary as the parameters.
As an example, nova.conf could contain the following scheduler-related settings:
--scheduler_driver=nova.scheduler.FilterScheduler
--scheduler_available_filters=nova.scheduler.filters.standard_filters
--scheduler_available_filters=myfilter.MyFilter
--scheduler_default_filters=RamFilter,ComputeFilter,MyFilter
I have created a custom "test_filter.py" -- it is very similar to "all_hosts_filter.py", which is the simplest standard filter.
Here it is in it's entirety:
from nova.scheduler import filters
from nova.openstack.common import log as logging
LOG = logging.getLogger(__name__)
class TestFilter(filters.BaseHostFilter):
"""NOOP host filter. Returns all hosts."""
def host_passes(self, host_state, filter_properties):
LOG.debug("COMING FROM: nova/scheduler/filters/test_filter.py")
return True
But when I put this file, "test_filter.py", in the nova/scheduler/filters folder and restart OpenStack I get the following exception:
CRITICAL nova [-] Class test_filter could not be found: 'module' object has no attribute 'test_filter'
It appears that OpenStack is registering and trying to import my new filter, but some error is occuring. For reference, this is what the releveant sections of my /etc/nova/nova.conf file looks like:
scheduler_available_filters=nova.scheduler.filters.all_filters
scheduler_available_filters=nova.scheduler.filters.test_filter.TestFilter
scheduler_default_filters=TestFilter,RamFilter,ComputeFilter
======
UPDATE: 15th April 2000 hours BST.
An update to this question, still struggling. After discussing the problem with boris-42 on the OpenStack IRC channel we have investigated a bit more:
Openstack-scheduler is run as service from /usr/bin/nova-scheduler
It then has an error:
"Inner Exception: 'module' object has no attribute 'test_filter' from (pid=32696) import_class /usr/lib/python2.7/dist-packages/nova/utils.py:78"
Which suggests it is using the /usr/lib/python2.7/dist-packages/nova/ folder for the source files of the installation.
Putting my custom "test_filter.py" into /usr/lib/python2.7/dist-packages/nova/scheduler/filters causes the error above.
However, on closer inspection it appears that all other files in the /usr/lib/python2.7/dist-packages/nova/scheduler/filters folder are actually links to the files in /usr/share/pyshared/nova/scheduler/filters
So I put my "test_filter.py" in /usr/share/pyshared/nova/scheduler/filters -- and then created a symbolic link in the original folder.
This results in exactly the same folder. As long as the file is either present or a link exists in the folder /usr/lib/python2.7/dist-packages/nova/scheduler/filters then the error occurs.
The nova.conf file has been updated as follows:
scheduler_available_filters=nova.scheduler.filters.TestFilter
scheduler_default_filters=TestFilter
I dont think you have to put your file in /usr/lib/python2.7/dist-packages/nova/scheduler/filters. You can put anywhere and make sure that path is in PYTHONPATH.
As metnion in example
If you want to create your own filter you just need to inherit from BaseHostFilter and implement one method: host_passes. This method should return True if host passes the filter. It takes host_state (describes host) and filter_properties dictionary as the parameters.
As an example, nova.conf could contain the following scheduler-related settings:
......
--scheduler_available_filters=myfilter.MyFilter
.......
You have to mention myfilet.MyFilter without nova.scheduler.filters.