Merge branch 'plugins' of http://git.louiz.org/poezio into plugins
This commit is contained in:
commit
432afd6179
3 changed files with 18 additions and 32 deletions
|
@ -19,10 +19,9 @@ class Plugin(BasePlugin):
|
||||||
if not messages:
|
if not messages:
|
||||||
return None
|
return None
|
||||||
for message in messages[::-1]:
|
for message in messages[::-1]:
|
||||||
match = url_pattern.search(clean_text(message.txt))
|
matches = url_pattern.findall(clean_text(message.txt))
|
||||||
if match:
|
if matches:
|
||||||
self.core.information('[%s]' % (match.groups(),))
|
for url in matches[::-1]:
|
||||||
for url in list(match.groups())[::-1]:
|
|
||||||
if nb == 1:
|
if nb == 1:
|
||||||
return url
|
return url
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1730,7 +1730,7 @@ class Core(object):
|
||||||
try:
|
try:
|
||||||
self.remote_fifo.write(command)
|
self.remote_fifo.write(command)
|
||||||
except (IOError) as e:
|
except (IOError) as e:
|
||||||
self.information('Could not execute [%s]: %s' % (command, e,), 'Error')
|
self.information('Could not execute [%s]: %s' % (command.strip(), e,), 'Error')
|
||||||
self.remote_fifo = None
|
self.remote_fifo = None
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#/usr/bin/env python3
|
||||||
# Copyright 2011 Florent Le Coz <louiz@louiz.org>
|
# Copyright 2011 Florent Le Coz <louiz@louiz.org>
|
||||||
#
|
#
|
||||||
# This file is part of Poezio.
|
# This file is part of Poezio.
|
||||||
|
@ -6,15 +7,13 @@
|
||||||
# it under the terms of the zlib license. See the COPYING file.
|
# it under the terms of the zlib license. See the COPYING file.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
This file is a standalone program that creates a fifo file (if it doesn’t exist
|
This file is a standalone program that reads commands on
|
||||||
yet), opens it for reading, reads commands from it and executes them (each line
|
stdin and executes them (each line should be a command).
|
||||||
should be a command).
|
|
||||||
|
|
||||||
Usage: ./daemon.py <path_tofifo>
|
Usage: cat some_fifo | ./daemon.py
|
||||||
|
|
||||||
That fifo should be in a directory, shared through sshfs, with the remote
|
Poezio writes commands in the fifo, and this daemon executes them on the
|
||||||
machine running poezio. Poezio then writes command in it, and this daemon
|
local machine.
|
||||||
executes them on the local machine.
|
|
||||||
Note that you should not start this daemon if you do not trust the remote
|
Note that you should not start this daemon if you do not trust the remote
|
||||||
machine that is running poezio, since this could make it run any (dangerous)
|
machine that is running poezio, since this could make it run any (dangerous)
|
||||||
command on your local machine.
|
command on your local machine.
|
||||||
|
@ -24,8 +23,6 @@ import sys
|
||||||
import threading
|
import threading
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from fifo import Fifo
|
|
||||||
|
|
||||||
class Executor(threading.Thread):
|
class Executor(threading.Thread):
|
||||||
"""
|
"""
|
||||||
Just a class to execute commands in a thread.
|
Just a class to execute commands in a thread.
|
||||||
|
@ -38,26 +35,16 @@ class Executor(threading.Thread):
|
||||||
self.command = command
|
self.command = command
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
print('executing %s' % (self.command,))
|
print('executing %s' % (self.command.strip(),))
|
||||||
subprocess.call(self.command.split())
|
subprocess.call(self.command.split())
|
||||||
|
|
||||||
def main(path):
|
def main():
|
||||||
while True:
|
while True:
|
||||||
fifo = Fifo(path, 'r')
|
line = sys.stdin.readline()
|
||||||
while True:
|
|
||||||
line = fifo.readline()
|
|
||||||
if line == '':
|
if line == '':
|
||||||
del fifo
|
|
||||||
break
|
break
|
||||||
e = Executor(line)
|
e = Executor(line)
|
||||||
e.start()
|
e.start()
|
||||||
|
|
||||||
def usage():
|
|
||||||
print('Usage: %s <fifo_name>' % (sys.argv[0],))
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
argc = len(sys.argv)
|
main()
|
||||||
if argc != 2:
|
|
||||||
usage()
|
|
||||||
else:
|
|
||||||
main(sys.argv[1])
|
|
||||||
|
|
Loading…
Reference in a new issue