#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import random import string import os import tempfile import time import re import _env from lib.command import call_cmd, search_path assert search_path("file") # def call_cmd(cmd): # res = os.system(cmd) # if res != 0: # raise Exception("%s exit with %d" % (cmd, res)) def random_string(n): s = string.ascii_letters + string.digits result = "" for i in xrange(n): result += random.choice(s) return result def ping(ip): return 0 == os.system("ping -i0.3 -c2 -W1 %s >/dev/null" % (ip))
def available(): path = search_path("xm") return path and True or False