On Sat, Dec 8, 2012 at 7:18 PM, Josu Lazkano <span dir="ltr">&lt;<a href="mailto:josu.lazkano@gmail.com" target="_blank">josu.lazkano@gmail.com</a>&gt;</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 &lt;<a href="mailto:michael@thewatsonfamily.id.au">michael@thewatsonfamily.id.au</a>&gt;:<br>
<div class="im">&gt; #!/usr/bin/env python<br>
&gt; # -*- coding: UTF-8 -*-<br>
&gt; #<br>
&gt;<br>
&gt; import socket, time<br>
&gt; from MythTV import MythDB<br>
&gt;<br>
&gt;<br>
&gt; def shutdown_frontend(hostname):<br>
&gt;     db = MythDB()<br>
&gt;     frontend = db.getFrontend(hostname)<br>
&gt;     location = frontend.sendQuery(&#39;Location&#39;)<br>
&gt;<br>
&gt;    # If we are currently in playback, set bookmark before exiting<br>
&gt;     if str.split(location)[0] == &quot;Playback&quot;:<br>
&gt;         frontend.key[&#39;enter&#39;]<br>
&gt;         frontend.jump[&#39;mainmenu&#39;]<br>
&gt;         location = frontend.sendQuery(&#39;Location&#39;)<br>
&gt;<br>
&gt;     if location != &quot;mainmenu&quot;:<br>
&gt;         frontend.jump[&#39;mainmenu&#39;]<br>
&gt;<br>
&gt;     # Shutdown Frontend<br>
&gt;     frontend.key[&#39;escape&#39;]<br>
&gt;     frontend.key[&#39;down&#39;]<br>
&gt;     frontend.key[&#39;enter&#39;]<br>
&gt;     time.sleep(5)<br>
&gt;<br>
&gt;<br>
&gt; if __name__ == &#39;__main__&#39;:<br>
&gt;     frontendhostname = socket.gethostname()<br>
&gt;     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 &quot;shutdown.py&quot;, line 32, in &lt;module&gt;<br>
    shutdown_frontend(frontendhostname)<br>
  File &quot;shutdown.py&quot;, line 11, in shutdown_frontend<br>
    frontend = db.getFrontend(hostname)<br>
  File &quot;/usr/lib/python2.7/dist-packages/MythTV/methodheap.py&quot;, line<br>
975, in getFrontend<br>
    return Frontend(host,port)<br>
  File &quot;/usr/lib/python2.7/dist-packages/MythTV/methodheap.py&quot;, line<br>
578, in __init__<br>
    FEConnection.__init__(self, *args, **kwargs)<br>
  File &quot;/usr/lib/python2.7/dist-packages/MythTV/connections.py&quot;, line<br>
462, in __init__<br>
    self.connect(test)<br>
  File &quot;/usr/lib/python2.7/dist-packages/MythTV/connections.py&quot;, 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>