@@ -77,46 +77,54 @@ def update_comment(self, sketch, results, current_date, log_entry, openFailFlag,
77
77
def handle_library_comment (self , library , current_date , log ):
78
78
url = '/library/' + library
79
79
identifier = 'ident:' + url
80
- paginator = disqusapi .Paginator (self .disqus .api .threads .list , forum = FORUM , thread = identifier , method = 'GET' )
81
- if paginator :
82
- for page in paginator :
83
- post_id , existing_message = self .get_posts (page ['id' ])
84
- if post_id and existing_message :
85
- new_message = self .messages ['library' ].replace ('TEST_DATE' , current_date )
86
- if url not in log :
87
- log [url ] = {}
88
- log [url ]['comment' ] = self .update_post (post_id , new_message )
89
- else :
80
+ try :
81
+ paginator = disqusapi .Paginator (self .disqus .api .threads .list , forum = FORUM , thread = identifier , method = 'GET' )
82
+ if paginator :
83
+ for page in paginator :
84
+ post_id , existing_message = self .get_posts (page ['id' ])
85
+ if post_id and existing_message :
86
+ new_message = self .messages ['library' ].replace ('TEST_DATE' , current_date )
87
+ if url not in log :
88
+ log [url ] = {}
89
+ log [url ]['comment' ] = self .update_post (post_id , new_message )
90
+ else :
91
+ log [url ]['comment' ] = False
92
+ except Exception as error :
93
+ print 'Error:' , error
90
94
log [url ]['comment' ] = False
91
95
return log
92
96
93
97
def handle_example_comment (self , url , results , current_date , log ):
94
98
identifier = url .replace ('https://codebender.cc' , '' )
95
99
identifier = 'ident:' + identifier
96
- paginator = disqusapi .Paginator (self .disqus .api .threads .list , forum = FORUM , thread = identifier , method = 'GET' )
97
- if paginator :
98
- for page in paginator :
99
- post_id , existing_message = self .get_posts (page ['id' ])
100
- if post_id and existing_message :
101
- boards = []
102
- unsupportedFlag = False
103
- for result in results :
104
- if result ['status' ] == 'success' :
105
- board = result ['board' ]
106
- if re .match (r'Arduino Mega.+' , board ):
107
- board = 'Arduino Mega'
108
- boards .append (board )
109
- elif result ['status' ] == 'unsupported' :
110
- unsupportedFlag = True
111
-
112
- new_message = self .messages ['example_fail' ].replace ('TEST_DATE' , current_date )
113
- if len (boards ) > 0 :
114
- new_message = self .messages ['example_success' ].replace ('TEST_DATE' , current_date ).replace ('BOARDS_LIST' , ', ' .join (boards ))
115
- elif unsupportedFlag :
116
- new_message = self .messages ['example_unsupported' ].replace ('TEST_DATE' , current_date )
117
- log [url ]['comment' ] = self .update_post (post_id , new_message )
118
- break
119
- else :
100
+ try :
101
+ paginator = disqusapi .Paginator (self .disqus .api .threads .list , forum = FORUM , thread = identifier , method = 'GET' )
102
+ if paginator :
103
+ for page in paginator :
104
+ post_id , existing_message = self .get_posts (page ['id' ])
105
+ if post_id and existing_message :
106
+ boards = []
107
+ unsupportedFlag = False
108
+ for result in results :
109
+ if result ['status' ] == 'success' :
110
+ board = result ['board' ]
111
+ if re .match (r'Arduino Mega.+' , board ):
112
+ board = 'Arduino Mega'
113
+ boards .append (board )
114
+ elif result ['status' ] == 'unsupported' :
115
+ unsupportedFlag = True
116
+
117
+ new_message = self .messages ['example_fail' ].replace ('TEST_DATE' , current_date )
118
+ if len (boards ) > 0 :
119
+ new_message = self .messages ['example_success' ].replace ('TEST_DATE' , current_date ).replace ('BOARDS_LIST' , ', ' .join (boards ))
120
+ elif unsupportedFlag :
121
+ new_message = self .messages ['example_unsupported' ].replace ('TEST_DATE' , current_date )
122
+ log [url ]['comment' ] = self .update_post (post_id , new_message )
123
+ break
124
+ else :
125
+ log [url ]['comment' ] = False
126
+ except Exception as error :
127
+ print 'Error:' , error
120
128
log [url ]['comment' ] = False
121
129
return log
122
130
0 commit comments