Skip to content

Commit e513b9f

Browse files
author
Konstantinacc
committed
Replaced code in open_all_libraries_and_examples with call to function resume_log.
Removed out of function resume_log veriable current_date used only to update disqus comments.
1 parent b48c11b commit e513b9f

File tree

1 file changed

+5
-29
lines changed

1 file changed

+5
-29
lines changed

codebender_testing/utils.py

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -407,31 +407,8 @@ def open_all_libraries_and_examples(self, url, logfile):
407407
libraries = self.execute_script(_GET_SKETCHES_SCRIPT.format(selector='.library_link'), '$')
408408
assert len(libraries) > 0
409409
examples_libraries = examples + libraries
410-
411-
log_time = gmtime()
412-
log_file = strftime(logfile, log_time)
413-
log_entry = {}
414-
415-
urls_visited = {}
416-
last_log = read_last_log('fetch')
417-
if last_log['log']:
418-
# resume previous compile
419-
log_time = strptime(last_log['timestamp'], '%Y-%m-%d_%H-%M-%S')
420-
log_file = strftime(logfile, log_time)
421-
log_entry = last_log['log']
422-
for url in last_log['log']:
423-
urls_visited[url] = True
424-
425-
urls_to_visit = []
426-
for url in examples_libraries:
427-
if url not in urls_visited:
428-
urls_to_visit.append(url)
429-
430-
if len(urls_to_visit) == 0:
431-
urls_to_visit = examples_libraries
432-
log_entry = {}
433-
log_time = gmtime()
434-
log_file = strftime(logfile, log_time)
410+
compile_type = 'fetch'
411+
urls_to_visit, log_entry, log_file, log_time = self.resume_log(logfile, compile_type, examples_libraries)
435412

436413
library_re = re.compile(r'^https://codebender.cc/library/.+$')
437414
example_re = re.compile(r'^https://codebender.cc/example/.+/.+$')
@@ -613,13 +590,11 @@ def resume_log (self, logfile, compile_type, sketches):
613590
log_entry = {}
614591
log_time = gmtime()
615592

616-
current_date = strftime('%Y-%m-%d', log_time)
617-
618593
""" If `logfile` has a value and is not `None` we create `log_file`."""
619594
if logfile:
620595
log_file = strftime(logfile, log_time)
621596

622-
return (urls_to_visit, log_entry, log_file, log_time, current_date)
597+
return (urls_to_visit, log_entry, log_file, log_time)
623598

624599
def create_log (self, log_file, log_entry,compile_type):
625600
# Dump the test results to `log_file`.
@@ -640,7 +615,7 @@ def compile_sketches(self, sketches, iframe=False, project_view=False, logfile=N
640615
number of sketches compiled to 1.
641616
"""
642617

643-
urls_to_visit, log_entry, log_file, log_time, current_date = self.resume_log(logfile, compile_type, sketches)
618+
urls_to_visit, log_entry, log_file, log_time = self.resume_log(logfile, compile_type, sketches)
644619

645620
# Initialize DisqusWrapper.
646621
disqus_wrapper = DisqusWrapper(log_time)
@@ -710,6 +685,7 @@ def compile_sketches(self, sketches, iframe=False, project_view=False, logfile=N
710685
self.create_log(log_file,log_entry, compile_type)
711686

712687
# Update Disqus comments.
688+
current_date = strftime('%Y-%m-%d', log_time)
713689
if comment and compile_type in ['library', 'target_library']:
714690
log_entry = disqus_wrapper.update_comment(sketch, results, current_date, log_entry, openFailFlag, total_sketches)
715691

0 commit comments

Comments
 (0)