Skip to content

Commit

Permalink
adding the option on management scripts to search for only unconfirme…
Browse files Browse the repository at this point in the history
…d hosts
  • Loading branch information
colevscode committed Dec 23, 2014
1 parent 7eba633 commit 963ca13
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,41 @@ def _matchhosts(name):
return map(lambda x: x.split("_")[-1], hosts)


def _print(hostid):
def _print(hostid, unconfirmed):
r = app.REDIS
if unconfirmed and r.get('forms_email_%s' % hostid):
return False
keys = r.keys("*%s*" % hostid)
results = dict((k,r.get(k)) for k in keys)
print results
return True


def _del(hostid):
def _del(hostid, unconfirmed):
r = app.REDIS
if unconfirmed and r.get('forms_email_%s' % hostid):
return False
keys = r.keys("*%s*" % hostid)
for k in keys:
r.delete(k)
return True


@manager.command
def print_hosts(name):
def print_hosts(name, unconfirmed=False):
count = 0
for host in _matchhosts(name):
_print(host)
count +=1
if _print(host, unconfirmed):
count +=1
print "found %d items" % count


@manager.command
def delete_hosts(name):
def delete_hosts(name, unconfirmed=False):
count = 0
for host in _matchhosts(name):
_del(host)
count +=1
if _del(host, unconfirmed):
count +=1
print "deleted %d items" % count


Expand Down

0 comments on commit 963ca13

Please sign in to comment.