@@ -52,14 +52,17 @@ def createEmailList(self):
5252 try :
5353 getEmail = EmailsInList .objects .get (owner = newList , email = value )
5454 except :
55- newEmail = EmailsInList (owner = newList , email = value ,
56- verificationStatus = 'NOT CHECKED' ,
57- dateCreated = time .strftime ("%I-%M-%S-%a-%b-%Y" ))
58- newEmail .save ()
55+ try :
56+ newEmail = EmailsInList (owner = newList , email = value ,
57+ verificationStatus = 'NOT CHECKED' ,
58+ dateCreated = time .strftime ("%I-%M-%S-%a-%b-%Y" ))
59+ newEmail .save ()
60+ except :
61+ pass
5962 logging .CyberCPLogFileWriter .statusWriter (self .extraArgs ['tempStatusPath' ], str (counter ) + ' emails read.' )
6063 counter = counter + 1
6164 except BaseException as msg :
62- logging .CyberCPLogFileWriter .writeToFile (str (msg ))
65+ logging .CyberCPLogFileWriter .writeToFile ('%s. [createEmailList]' % ( str (msg ) ))
6366 continue
6467 elif self .extraArgs ['path' ].endswith ('.txt' ):
6568 with open (self .extraArgs ['path' ], 'r' ) as emailsList :
@@ -155,30 +158,27 @@ def verificationJob(self):
155158 ValidationLog (owner = verificationList , status = backupSchedule .INFO , message = 'Starting email verification..' ).save ()
156159
157160 for items in allEmailsInList :
161+
158162 if items .verificationStatus != 'Verified' :
159163 try :
160164 email = items .email
161165 self .currentEmail = email
162166 domainName = email .split ('@' )[1 ]
163167 records = DNS .dnslookup (domainName , 'MX' )
164168
165- ValidationLog (owner = verificationList , status = backupSchedule .INFO ,
166- message = 'Trying to verify %s ..' % (email )).save ()
169+ counterGlobal = counterGlobal + 1
167170
168171 for mxRecord in records :
172+
169173 # Get local server hostname
170174 host = socket .gethostname ()
171175
172176 ## Only fetching smtp object
173177
174178 if os .path .exists (finalPath ):
175179 try :
176- ValidationLog (owner = verificationList , status = backupSchedule .INFO ,
177- message = 'Checking if delay is enabled for verification..' ).save ()
178180 delay = self .delayData ['delay' ]
179181 if delay == 'Enable' :
180- ValidationLog (owner = verificationList , status = backupSchedule .INFO ,
181- message = 'It seems delay is enabled...' ).save ()
182182 if counterGlobal == int (self .delayData ['delayAfter' ]):
183183 ValidationLog (owner = verificationList , status = backupSchedule .INFO ,
184184 message = 'Sleeping for %s seconds...' % (self .delayData ['delayTime' ])).save ()
@@ -198,10 +198,9 @@ def verificationJob(self):
198198
199199 if self .currentIP == '' :
200200 self .currentIP = self .findNextIP ()
201-
202- ValidationLog (owner = verificationList , status = backupSchedule .INFO ,
203- message = 'IP being used for validation until next sleep: %s.' % (
204- str (self .currentIP ))).save ()
201+ ValidationLog (owner = verificationList , status = backupSchedule .INFO ,
202+ message = 'IP being used for validation until next sleep: %s.' % (
203+ str (self .currentIP ))).save ()
205204
206205 if self .currentIP == None :
207206 server = smtplib .SMTP ()
@@ -222,8 +221,6 @@ def verificationJob(self):
222221
223222 server = smtplib .SMTP ()
224223 else :
225- ValidationLog (owner = verificationList , status = backupSchedule .INFO ,
226- message = 'Delay not configured..' ).save ()
227224 server = smtplib .SMTP ()
228225
229226 ###
@@ -239,8 +236,6 @@ def verificationJob(self):
239236
240237 # Assume 250 as Success
241238 if code == 250 :
242- ValidationLog (owner = verificationList , status = backupSchedule .INFO ,
243- message = 'Verified %s successfully.' % (email )).save ()
244239 items .verificationStatus = 'Verified'
245240 items .save ()
246241 break
@@ -250,20 +245,18 @@ def verificationJob(self):
250245 items .verificationStatus = 'Verification Failed'
251246 items .save ()
252247
248+
253249 logging .CyberCPLogFileWriter .statusWriter (tempStatusPath , str (counter ) + ' emails verified so far..' )
254250 counter = counter + 1
255251 except BaseException as msg :
256252 items .verificationStatus = 'Verification Failed'
257253 items .save ()
258254 counter = counter + 1
259- logging .CyberCPLogFileWriter .writeToFile (str (msg ))
260255 ValidationLog (owner = verificationList , status = backupSchedule .ERROR ,
261256 message = 'Failed to verify %s. Error message %s' % (
262257 self .currentEmail , str (msg ))).save ()
263258
264259
265- counterGlobal = counterGlobal + 1
266-
267260 verificationList .notVerified = verificationList .emailsinlist_set .filter (verificationStatus = 'Verification Failed' ).count ()
268261 verificationList .verified = verificationList .emailsinlist_set .filter (verificationStatus = 'Verified' ).count ()
269262 verificationList .save ()
0 commit comments