Skip to content

Commit

Permalink
Add is_jid to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
thatch45 authored and basepi committed Apr 11, 2013
1 parent b941f6b commit 4572dcf
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions salt/utils/__init__.py
Expand Up @@ -410,6 +410,22 @@ def jid_load(jid, cachedir, sum_type, serial='msgpack'):
return serial.load(fp_)


def is_jid(jid):
'''
Returns True if the passed in value is a job id
'''
if not isinstance(jid, basestring):
return False
if not len(jid) == 20:
return False
try:
int(jid)
return True
except ValueError:
return False
return False


def check_or_die(command):
'''
Simple convenience function for modules to use for gracefully blowing up
Expand Down

0 comments on commit 4572dcf

Please sign in to comment.