Can python plugins call things like..
os.system()
call()
etc?
I can't seem to get this to work on my 433 RF Switches plugin.
https://github.com/flatsiedatsie/433Switches
If it is disabled on purpose somehow (security reasons?), then how can I do this:
- When users click a button in the interface I would like a RF sniffer script to be able to run for ten seconds in the background to listen to the 'on' signal from a remote control. Later on, I would like people to press a switch and then be able to transmit a code for a second.
Since the plugin development wiki page mentions that you should not use sleep and such in a plugin, I opted to call an external script in a new thread that would do this. But it now seems this is not possible? Is there any wat to make this work?
Can Python Plugins access the file system?
Moderator: leecollings
-
- Posts: 331
- Joined: Wednesday 21 December 2016 9:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: current
- Contact:
-
- Posts: 331
- Joined: Wednesday 21 December 2016 9:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: current
- Contact:
Re: Can Python Plugins access the file system?
It took a lot of experimenting, but I managed to get it to work. For anyone else finding this:
callCommand = "sudo " + str(sys.executable) + " " + str(self.dirName) + "/433cloner.py --txpin " + str(self.txpin)
Domoticz.Log(str(callCommand))
try:
call (callCommand, shell=True)
except:
cloner = os.popen(callCommand).read()
callCommand = "sudo " + str(sys.executable) + " " + str(self.dirName) + "/433cloner.py --txpin " + str(self.txpin)
Domoticz.Log(str(callCommand))
try:
call (callCommand, shell=True)
except:
cloner = os.popen(callCommand).read()
- Dnpwwo
- Posts: 820
- Joined: Sunday 23 March 2014 9:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Melbourne, Australia
- Contact:
Re: Can Python Plugins access the file system?
@blauwebuis,
To answer your question, the only constrant on the Python Framework is that authors can't create threads or subprocesses, apart from that they run in the same context and have the same rights as the Domoticz main process.
They can certainly read and write to the filesystem (although you appear to be trying to run a command rather than access the file system).
This is not a security problem or a bug.
Plugin are designed to support hardware and to be equivalent to C++ supported hardware to make it easier for people to add support their own devices and to slow down the new additions to the C++ code base.
From a security prespective you are downloading code from the internet and executing it on your machine which has inherent risk regardless of language.
To answer your question, the only constrant on the Python Framework is that authors can't create threads or subprocesses, apart from that they run in the same context and have the same rights as the Domoticz main process.
They can certainly read and write to the filesystem (although you appear to be trying to run a command rather than access the file system).
This is not a security problem or a bug.
Plugin are designed to support hardware and to be equivalent to C++ supported hardware to make it easier for people to add support their own devices and to slow down the new additions to the C++ code base.
From a security prespective you are downloading code from the internet and executing it on your machine which has inherent risk regardless of language.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
Who is online
Users browsing this forum: No registered users and 1 guest