Changeset 13199 for main/waeup.kofa/trunk/src
- Timestamp:
- 15 Aug 2015, 20:08:02 (9 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/browser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py
r13198 r13199 246 246 entries.append(new_entry) 247 247 return entries 248 249 def running_jobs(view): 250 """True if any job is running. 251 """ 252 job_entries = view.context.get_running_export_jobs() 253 job_manager = getUtility(IJobManager) 254 entries = [] 255 for entry in job_entries: 256 job = job_manager.get(entry[0]) 257 status = job.finished and 'ready' or 'running' 258 status = job.failed and 'FAILED' or status 259 if status == 'running': 260 return True 261 return False 248 262 249 263 def getImporters(context): … … 1752 1766 self.entries = doll_up(self, user=None) 1753 1767 return 1768 if running_jobs(self): 1769 self.flash(_( 1770 "Sorry, another export job is running. " 1771 "Please try again later."), type='danger') 1772 self.entries = doll_up(self, user=None) 1773 return 1754 1774 job_id = self.context.start_export_job( 1755 1775 exporter, self.request.principal.id) -
main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py
r13198 r13199 212 212 self.browser.getControl(name="exporter").value = ['faculties'] 213 213 self.browser.getControl("Create CSV file").click() 214 self.assertEqual(self.browser.headers['Status'], '200 Ok') 214 # we can trigger export file creation only once 215 self.browser.getControl(name="exporter").value = ['departments'] 216 self.browser.getControl("Create CSV file").click() 217 self.assertTrue('Sorry, another export job is running.' 218 in self.browser.contents) 219 self.wait_for_export_job_completed() 220 self.assertEqual(len(self.app['datacenter'].running_exports), 1) 221 self.browser.getControl(name="exporter").value = ['departments'] 222 self.browser.getControl("Create CSV file").click() 223 self.assertEqual(self.browser.headers['Status'], '200 Ok') 224 self.assertEqual(len(self.app['datacenter'].running_exports), 2) 225 # The second job is running 226 self.assertTrue('<img src="/static/img/actionicon_reload.png" />' 227 in self.browser.contents) 215 228 self.cleanup_run_job() # make sure to remove temp dirs 229 # Also the second job must be cleaned up 230 manager = getUtility(IJobManager) 231 job_id = self.app['datacenter'].running_exports[1][0] 232 job = manager.get(job_id) 233 wait_for_result(job) 234 if os.path.exists(job.result): 235 shutil.rmtree(os.path.dirname(job.result)) 216 236 return 217 237 … … 363 383 'password,state,history,certcode,is_postgrad,current_level,' 364 384 'current_session\r\n') 365 self.cleanup_run_job()366 385 logfile = os.path.join( 367 386 self.app['datacenter'].storage, 'logs', 'datacenter.log') … … 376 395 '- downloaded: WAeUP.Kofa_students_%s.csv, job_id=%s' 377 396 % (job_id, job_id) in logcontent) 397 self.cleanup_run_job() 378 398 return 379 399
Note: See TracChangeset for help on using the changeset viewer.