Skip to content

Commit bd3025f

Browse files
Merge pull request #120 from AutomationSolutionz/random_email_mod
Random email mod
2 parents 2a836d0 + cda3c86 commit bd3025f

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

Framework/Built_In_Automation/Sequential_Actions/common_functions.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3932,21 +3932,21 @@ def random_email_generator(data_set):
39323932

39333933
"""
39343934
usage: This action allows you to create random email
3935-
dataset : random email generator | common action | email
3935+
dataset : random email generator | common action | var_name
39363936
return : email address in string
39373937
note: email will be the variable name to store
39383938
"""
39393939

39403940
sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
39413941

39423942
try:
3943-
var_email = None
39443943
var_variable = None
39453944
for left, mid, right in data_set:
3945+
mid = mid.strip().lower()
39463946
if "action" in mid:
39473947
var_variable = right.strip()
39483948

3949-
if var_variable==None:
3949+
if var_variable is None:
39503950
CommonUtil.ExecLog(sModuleInfo, "Please provide variable name to store results", 3)
39513951
return "zeuz_failed"
39523952

@@ -3966,7 +3966,8 @@ def random_email_read(data_set):
39663966
usage: This action allows you to read email which are created using our random email generator action
39673967
dataset :
39683968
address | input parameter | address
3969-
random email read | common action | result
3969+
wait | optional parameter| 10
3970+
random email read | common action | var_name
39703971
39713972
return : return a dictionary which has one key(email)-value(list of emails)
39723973
note: address is the random email ,result will be the variable name to store
@@ -3976,32 +3977,39 @@ def random_email_read(data_set):
39763977
try:
39773978
var_email = None
39783979
var_variable = None
3980+
wait = 10
39793981

39803982
for left, mid, right in data_set:
3983+
left = left.strip().lower()
3984+
mid = mid.strip().lower()
39813985
if "address" in left:
39823986
var_email = right.strip()
3983-
if "action" in mid:
3987+
elif "action" in mid:
39843988
var_variable = right.strip()
3989+
elif "wait" == left:
3990+
wait = float(right.strip())
39853991

3986-
if var_variable==None:
3992+
if var_variable is None:
39873993
CommonUtil.ExecLog(sModuleInfo, "Please provide variable name to store results", 3)
39883994
return "zeuz_failed"
39893995

3990-
if var_email!=None:
3991-
3992-
res= RandomEmail1SecMail.checkMails(var_email)
3993-
3994-
if len(res[var_email])>0:
3995-
CommonUtil.ExecLog(sModuleInfo, "All mails are saved for '%s' in shared variable " % (var_email), 1)
3996-
return sr.Set_Shared_Variables(var_variable, res) #saved in shared variable inside variable key
3997-
else:
3998-
CommonUtil.ExecLog(sModuleInfo, "No email found for '%s' " % (var_email), 1)
3999-
return sr.Set_Shared_Variables(var_variable, res) #saved in shared variable inside variable key
4000-
4001-
else:
3996+
if var_email is None:
40023997
CommonUtil.ExecLog(sModuleInfo, "Please provide email address", 3)
40033998
return "zeuz_failed"
40043999

4000+
CommonUtil.ExecLog(sModuleInfo, "Waiting for %s seconds to receive the mail" % (wait), 1)
4001+
start = time.time()
4002+
while True:
4003+
res = RandomEmail1SecMail.checkMails(var_email)
4004+
if len(res[var_email]) > 0:
4005+
break
4006+
if start + wait < time.time():
4007+
CommonUtil.ExecLog(sModuleInfo, "No email found for '%s' after waiting %s seconds. You may need to increase wait time" % (var_email, wait), 1)
4008+
return sr.Set_Shared_Variables(var_variable, res) # saved in shared variable inside variable key
4009+
4010+
CommonUtil.ExecLog(sModuleInfo, "Mails are received at '%s' after waiting for %d seconds" % (var_email, int(time.time()-start)), 1)
4011+
return sr.Set_Shared_Variables(var_variable, res) # saved in shared variable inside variable key
4012+
40054013
except:
40064014
return CommonUtil.Exception_Handler(sys.exc_info())
40074015

@@ -4013,38 +4021,30 @@ def random_email_delete(data_set):
40134021
usage: This action allows you to delete email which are created using our random email generator action
40144022
dataset :
40154023
address | input parameter | address
4016-
random email delete | common action | result
4024+
random email delete | common action | random email delete
40174025
40184026
return : return True/False
40194027
note: address is the random email ,result will be the variable name to store
40204028
"""
4021-
4022-
40234029
sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
40244030
try:
40254031
var_email = None
40264032
for left, mid, right in data_set:
4027-
if "address" in left:
4033+
left = left.strip().lower()
4034+
if "address" == left:
40284035
var_email = right.strip()
4029-
if "action" in mid:
4030-
var_variable=right.strip()
40314036

4032-
if var_variable==None:
4033-
CommonUtil.ExecLog(sModuleInfo, "Please provide variable name to store results", 3)
4037+
if var_email is None:
4038+
CommonUtil.ExecLog(sModuleInfo, "Please provide email address", 3)
40344039
return "zeuz_failed"
40354040

4036-
if var_email!=None:
4037-
res = RandomEmail1SecMail.deleteMail(var_email)
4041+
res = RandomEmail1SecMail.deleteMail(var_email)
40384042

4039-
if res==True :
4040-
CommonUtil.ExecLog(sModuleInfo, "'%s' is deleted" % (var_email), 1)
4041-
return sr.Set_Shared_Variables(var_variable, res) #saved in shared variable inside random_email key
4042-
else:
4043-
CommonUtil.ExecLog(sModuleInfo, "'%s' can not be deleted " % (var_email), 1)
4044-
sr.Set_Shared_Variables(var_variable, res) #saved in shared variable inside variable key
4045-
return "zeuz_failed"
4043+
if res:
4044+
CommonUtil.ExecLog(sModuleInfo, "'%s' is deleted" % (var_email), 1)
4045+
return "passed"
40464046
else:
4047-
CommonUtil.ExecLog(sModuleInfo, "Please provide email address", 3)
4047+
CommonUtil.ExecLog(sModuleInfo, "'%s' can not be deleted" % (var_email), 1)
40484048
return "zeuz_failed"
40494049

40504050
except:

0 commit comments

Comments
 (0)