Skip to content

Instantly share code, notes, and snippets.

@yelluw
Last active April 11, 2017 15:01
Show Gist options
  • Save yelluw/9c2537b91db81d6600a15bd590f298f2 to your computer and use it in GitHub Desktop.
Save yelluw/9c2537b91db81d6600a15bd590f298f2 to your computer and use it in GitHub Desktop.
class testDelay(object):
"""
Measures, tracks, and saves script delay into txt file
"""
def __init__(self, accUser=None, accKey=None, myMask=None):
self.__accUser=accUser
self.__accKey=accKey
self.__myMask=myMask
def run(self):
"""
Run the testDelay script.
Saves results in txt file for each user.
"""
filename = os.path.join('./output/' + self.__accUser+"_delay.txt")
# this makes sure the file is closed automaticall
with open(filename, "w") as f:
init_time=datetime.datetime.now()
try:
client = SoftLayer.create_client_from_env(username=self.__accUser, api_key=self.__accKey)
resp = client.call('Account', 'getObject',mask=self.__myMask)
except Exception as e:
exceptStr = "Error client {0} for the key {1}".format(self.__accuser, self.__accKey)
f.write(exceptStr)
end_time = datetime.datetime.now()
delay = end_time - init_time
delayStr = str(delay)
f.write(delayStr)
return 0 # Why return zero?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment