Skip to content

Commit c77b5f5

Browse files
committed
Merge pull request #32 from codebendercc/email-fix
Fixed send of emails
2 parents 4666e88 + 13f09af commit c77b5f5

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

bin/seleniumbender.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,22 @@ def send_mail_with_logs(self, identifier):
6565
reports = os.path.join(root_dir, 'reports')
6666
log_regexp = re.compile('.+{identifier}.+'.format(identifier=identifier))
6767

68-
try:
69-
logfile = sorted([filename for filename in os.listdir(logs) if filename not in files_to_ignore and log_regexp.match(filename)], reverse=True)[0]
70-
logfile_timestamp = re.match(r'(\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2})-.+', logfile).group(1)
71-
72-
report_regexp = re.compile('report_{timestamp}-{identifier}_(\d+)'.format(timestamp=logfile_timestamp, identifier=identifier))
73-
reportfile = sorted([filename for filename in os.listdir(reports) if filename not in files_to_ignore and report_regexp.match(filename)], reverse=True)[0]
74-
changes = report_regexp.match(reportfile).group(1)
75-
76-
email_date = time.strftime('%Y-%m-%d %H:%M:%S')
77-
78-
command = [
79-
'(echo "Changes since the last time: {changes}";'.format(changes=changes),
80-
'uuencode "{logs}/{logfile}" "{logfile}";'.format(logs=logs, logfile=logfile),
81-
'uuencode "{reports}/{reportfile}" "{reportfile}")'.format(reports=reports, reportfile=reportfile),
82-
'| mail -s "Selenium Tests Report: {identifier} {email_date} Changes: {changes}" {email}'.format(identifier=identifier, email_date=email_date, changes=changes, email=self.email)
83-
]
84-
self.run_command(command)
85-
except:
86-
pass
68+
logfile = sorted([filename for filename in os.listdir(logs) if filename not in self.files_to_ignore and log_regexp.match(filename)], reverse=True)[0]
69+
logfile_timestamp = re.match(r'(\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2})-.+', logfile).group(1)
70+
71+
report_regexp = re.compile('report_{timestamp}-{identifier}_(\d+)'.format(timestamp=logfile_timestamp, identifier=identifier))
72+
reportfile = sorted([filename for filename in os.listdir(reports) if filename not in self.files_to_ignore and report_regexp.match(filename)], reverse=True)[0]
73+
changes = report_regexp.match(reportfile).group(1)
74+
75+
email_date = time.strftime('%Y-%m-%d %H:%M:%S')
76+
77+
command = [
78+
'(echo "Changes since the last time: {changes}";'.format(changes=changes),
79+
'uuencode "{logs}/{logfile}" "{logfile}";'.format(logs=logs, logfile=logfile),
80+
'uuencode "{reports}/{reportfile}" "{reportfile}")'.format(reports=reports, reportfile=reportfile),
81+
'| mail -s "Selenium Tests Report: {identifier} {email_date} Changes: {changes}" {email}'.format(identifier=identifier, email_date=email_date, changes=changes, email=self.email)
82+
]
83+
self.run_command(command)
8784

8885
def create_command(self, test_directory, *extra_arguments):
8986
return ['tox', 'tests/' + test_directory, '--', '--url={}'.format(TARGETS[self.url])] + list(extra_arguments)

codebender_testing/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ def delete_project(self, project_name):
431431
except:
432432
print "An action failed during deletion process of project:", project_name
433433

434-
def resume_log (self, logfile, compile_type, sketches):
434+
def resume_log(self, logfile, compile_type, sketches):
435435
"""Resume previous log, if any. Coves 3 cases:
436436
Case 1: Test runs for 1st time and there is no previous log file.
437437
Case 2: Test runs for 2nd time and there is a previous log file which contains

tests/compile_tester/test_compile_tester_projects.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from codebender_testing.config import COMPILE_TESTER_DIR
22
from codebender_testing.config import COMPILE_TESTER_LOGFILE
3-
from codebender_testing.config import COMPILE_TESTER_LOGFILE_STAGING
43
from codebender_testing.config import COMPILE_TESTER_URL
54
from codebender_testing.config import LIVE_SITE_URL
65
from codebender_testing.config import STAGING_SITE_URL
@@ -83,7 +82,7 @@ def test_compile_local_files(self, tester_login):
8382
'#user_projects tbody a',
8483
iframe=False,
8584
compile_type='sketch',
86-
create_report=True, logfile=COMPILE_TESTER_LOGFILE_STAGING)
85+
create_report=True, logfile=COMPILE_TESTER_LOGFILE)
8786

8887
for name in filenames:
8988
name = name.split('.')[0]

0 commit comments

Comments
 (0)