On Sat, Dec 8, 2012 at 7:18 PM, Josu Lazkano <span dir="ltr"><<a href="mailto:josu.lazkano@gmail.com" target="_blank">josu.lazkano@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
2012/12/9 Michael Watson <<a href="mailto:michael@thewatsonfamily.id.au">michael@thewatsonfamily.id.au</a>>:<br>
<div class="im">> #!/usr/bin/env python<br>
> # -*- coding: UTF-8 -*-<br>
> #<br>
><br>
> import socket, time<br>
> from MythTV import MythDB<br>
><br>
><br>
> def shutdown_frontend(hostname):<br>
> db = MythDB()<br>
> frontend = db.getFrontend(hostname)<br>
> location = frontend.sendQuery('Location')<br>
><br>
> # If we are currently in playback, set bookmark before exiting<br>
> if str.split(location)[0] == "Playback":<br>
> frontend.key['enter']<br>
> frontend.jump['mainmenu']<br>
> location = frontend.sendQuery('Location')<br>
><br>
> if location != "mainmenu":<br>
> frontend.jump['mainmenu']<br>
><br>
> # Shutdown Frontend<br>
> frontend.key['escape']<br>
> frontend.key['down']<br>
> frontend.key['enter']<br>
> time.sleep(5)<br>
><br>
><br>
> if __name__ == '__main__':<br>
> frontendhostname = socket.gethostname()<br>
> shutdown_frontend(frontendhostname)<br>
<br>
</div>Thanks Michael, I try it but this is the output:<br>
<br>
$ python shutdown.py<br>
Traceback (most recent call last):<br>
File "shutdown.py", line 32, in <module><br>
shutdown_frontend(frontendhostname)<br>
File "shutdown.py", line 11, in shutdown_frontend<br>
frontend = db.getFrontend(hostname)<br>
File "/usr/lib/python2.7/dist-packages/MythTV/methodheap.py", line<br>
975, in getFrontend<br>
return Frontend(host,port)<br>
File "/usr/lib/python2.7/dist-packages/MythTV/methodheap.py", line<br>
578, in __init__<br>
FEConnection.__init__(self, *args, **kwargs)<br>
File "/usr/lib/python2.7/dist-packages/MythTV/connections.py", line<br>
462, in __init__<br>
self.connect(test)<br>
File "/usr/lib/python2.7/dist-packages/MythTV/connections.py", line<br>
508, in connect<br>
raise MythFEError(MythError.FE_CONNECTION, self.host, self.port)<br>
MythTV.exceptions.MythFEError: Connection to frontend htpc:6546 failed<br>
<br>
Need I to configure something? I am not familiar with python.<br>
<br>
Thanks for your help.<br><br></blockquote></div><br></div><div class="gmail_extra">Have you activated the frontend network control socket?</div><div class="gmail_extra"><br></div>