Skip to content

Instantly share code, notes, and snippets.

@hpk42
Created September 4, 2013 13:09
Show Gist options
  • Save hpk42/6436702 to your computer and use it in GitHub Desktop.
Save hpk42/6436702 to your computer and use it in GitHub Desktop.
def first_location_match(channel, locations):
import os.path
for x in locations:
if os.path.exists(x):
channel.send(x)
break
else:
channel.send(None)
if __name__ == "__main__":
import execnet
gw = execnet.makegateway()
ch = gw.remote_exec(first_location_match,
locations = ['/sbin/service', '/usr/sbin/service'])
print "matched location:", ch.receive()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment