File: delete.py

package info (click to toggle)
mc-foo 0.0.13
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 268 kB
  • ctags: 532
  • sloc: python: 1,967; makefile: 6
file content (31 lines) | stat: -rw-r--r-- 947 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""delete songs from the playqueue by song id"""

import McFoo.client
import sys, os.path
from twisted.internet import reactor
from twisted.python import usage

class Options(usage.Options):
    synopsis = "Usage: %s [options] delete ID.." % os.path.basename(sys.argv[0])

    def __init__(self):
        usage.Options.__init__(self)

    def parseArgs(self, *ids):
        ids=map(lambda x: int(x), ids)
        self.ids = ids

    def postOptions(self):
        if not self.ids:
            raise usage.UsageError, ("delete: no ids specified")
        c = McFooClientDelete(self.ids)
        c()

class McFooClientDelete(McFoo.client.McFooClientSimple):
    def __init__(self, ids):
        McFoo.client.McFooClientSimple.__init__(self)
        self.ids=ids

    def handle_login(self, perspective):
        McFoo.client.McFooClientSimple.handle_login(self, perspective)
        self.remote.callRemote("delete", self.ids).addCallback(self.stop)