]> kaliko git repositories - mpd-goodies.git/blob - lib/mpdclass.py
* Add wakeup script.
[mpd-goodies.git] / lib / mpdclass.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4
5 from socket import error as SocketError
6
7 try:
8     from mpd import (MPDClient, CommandError)
9 except ImportError, err:
10     print 'ERROR: "%s"\n\nPlease install python-mpd module.\n' % err
11     sys.exit(1)
12
13
14 class MPDClass(object):
15     """Connect to MPD server
16     """
17
18     def __init__(self):
19         self.client = MPDClient()
20
21     def mpdConnect(self):#{{{
22         """
23         Simple wrapper to connect MPD.
24         """
25         con_id = dict({'host':self.cli_options.host, 'port':self.cli_options.port})
26         try:
27             self.client.connect(**con_id)
28         except SocketError:
29             return False
30         return True#}}}
31
32     def mpdAuth(self, secret):#{{{
33         """ Authenticate"""
34         try:
35             self.client.password(secret)
36         except CommandError:
37             return False
38         return True#}}}
39
40
41 def main():
42     pass
43
44 # Script starts here
45 if __name__ == '__main__':
46     main()
47
48 # VIM MODLINE
49 # vim: ai ts=4 sw=4 sts=4 expandtab
50