[mythtv-users] command-line to control frontend
Josu Lazkano
josu.lazkano at gmail.com
Sun Dec 9 00:18:21 UTC 2012
2012/12/9 Michael Watson <michael at thewatsonfamily.id.au>:
> #!/usr/bin/env python
> # -*- coding: UTF-8 -*-
> #
>
> import socket, time
> from MythTV import MythDB
>
>
> def shutdown_frontend(hostname):
> db = MythDB()
> frontend = db.getFrontend(hostname)
> location = frontend.sendQuery('Location')
>
> # If we are currently in playback, set bookmark before exiting
> if str.split(location)[0] == "Playback":
> frontend.key['enter']
> frontend.jump['mainmenu']
> location = frontend.sendQuery('Location')
>
> if location != "mainmenu":
> frontend.jump['mainmenu']
>
> # Shutdown Frontend
> frontend.key['escape']
> frontend.key['down']
> frontend.key['enter']
> time.sleep(5)
>
>
> if __name__ == '__main__':
> frontendhostname = socket.gethostname()
> shutdown_frontend(frontendhostname)
Thanks Michael, I try it but this is the output:
$ python shutdown.py
Traceback (most recent call last):
File "shutdown.py", line 32, in <module>
shutdown_frontend(frontendhostname)
File "shutdown.py", line 11, in shutdown_frontend
frontend = db.getFrontend(hostname)
File "/usr/lib/python2.7/dist-packages/MythTV/methodheap.py", line
975, in getFrontend
return Frontend(host,port)
File "/usr/lib/python2.7/dist-packages/MythTV/methodheap.py", line
578, in __init__
FEConnection.__init__(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/MythTV/connections.py", line
462, in __init__
self.connect(test)
File "/usr/lib/python2.7/dist-packages/MythTV/connections.py", line
508, in connect
raise MythFEError(MythError.FE_CONNECTION, self.host, self.port)
MythTV.exceptions.MythFEError: Connection to frontend htpc:6546 failed
Need I to configure something? I am not familiar with python.
Thanks for your help.
Kind regards.
--
Josu Lazkano
More information about the mythtv-users
mailing list