Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

some cleanup / syntax fixes

  • Loading branch information...
commit a04660a541963424aaa1613d8cf9a04d52579fbe 1 parent 77f0d78
Jason Harvey authored
23 ZenPacks/chudler/xmppBot/Jabber/plugins/ack.py
@@ -28,14 +28,16 @@ def call(self, args, log, client, sender, messageType, **kw):
28 28 return False
29 29
30 30 if options.eventIds is None and options.device is None and not options.all and not arguments:
31   - message = 'must specify -a, -d, or event id list'
  31 + message = 'must specify --all, -d, or event id list'
32 32 client.sendMessage(message, sender, messageType)
33 33 return False
34 34
35   - eventIds = options.eventIds
  35 + if arguments and options.eventIds is None and options.device is None and not options.all:
  36 + idsToAck = arguments
  37 +
  38 + if options.eventIds:
  39 + idsToAck = options.eventIds.lower().split(',')
36 40
37   - if arguments and eventIds is None and options.device is None and not options.all:
38   - eventIds = arguments
39 41
40 42 # we will build this list of matching eventids, then ack them using acknowledge()
41 43 acking = []
@@ -43,7 +45,7 @@ def call(self, args, log, client, sender, messageType, **kw):
43 45 if options.all:
44 46 log.debug('User has requested to ack all events.')
45 47 for event in self.adapter.events():
46   - if event.severity < minseverity
  48 + if event.severity < self.minseverity:
47 49 continue
48 50 acking.append(event.evid)
49 51 log.debug('Queuing %s event to ack.' % event.evid)
@@ -52,18 +54,17 @@ def call(self, args, log, client, sender, messageType, **kw):
52 54 if options.device:
53 55 log.debug('User has requested to ack all events for device %s.' % options.device)
54 56 for event in self.adapter.events():
55   - if event.severity < minseverity
  57 + if event.severity < self.minseverity:
56 58 continue
57   - if event.device == options.device
  59 + if event.device == options.device:
58 60 acking.append(event.evid)
59 61 log.debug('Queuing %s event to ack.' % event.evid)
60 62 return self.acknowledge(client, options.test, options.verbose, acking, sender, messageType, log)
61 63
62   - idsToAck = eventIds.lower().split(',')
63 64 for event in self.adapter.events():
64 65 # python 2.5 will accept tuple instead of this.
65 66 for idToAck in idsToAck:
66   - if event.severity < minseverity
  67 + if event.severity < self.minseverity:
67 68 continue
68 69 eventid = event.evid
69 70 log.debug('Checking if eventid %s is one to ack (%s)' % (eventid, idToAck))
@@ -120,8 +121,8 @@ def findUser(self, sender):
120 121 def options(self):
121 122 parser = Options(description = 'Acknowledge events by eventid', prog = 'ack')
122 123 parser.add_option('-e', '--eventids', dest='eventIds', help='Complete or partial eventids to ack. Ids can be sepratated by commas. Partial ids can match either the beginning or end of the eventid.')
123   - parser.add_option('-a', '--all', dest='all', action='store_true', default=False, help='Acknowledge all events. If -e is also specified, it will still acknowledge every event.')
124   - parser.add_option('-d', '--device', dest='device', help='Only ack events that exist on this device. NOT IMPLEMENTED.')
  124 + parser.add_option('--all', dest='all', action='store_true', default=False, help='Acknowledge all events. If -e is also specified, it will still acknowledge every event.')
  125 + parser.add_option('-d', '--device', dest='device', help='Only ack events that exist on this device.')
125 126 parser.add_option('-v', '--verbose', dest='verbose', action='store_true', default=False, help='Send list of all acknowledged events. Can be noisy. USE WITH CAUTION.')
126 127 parser.add_option('-t', '--test', dest='test', action='store_true', default=False, help='Do not acknowledge events, but show what would be done. Works with -v.')
127 128 return parser
0  ZenPacks/chudler/xmppBot/daemons/xmppBot 100644 → 100755
File mode changed

0 comments on commit a04660a

Please sign in to comment.
Something went wrong with that request. Please try again.