Skip to content

Commit

Permalink
Improve jobs view (#1303)
Browse files Browse the repository at this point in the history
* Improve jobs view

* Fix missing rename
  • Loading branch information
twizmwazin authored Jul 31, 2024
1 parent 9e76ecf commit 271fa18
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 216 deletions.
18 changes: 11 additions & 7 deletions angrmanagement/logic/jobmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,15 @@ def add_job(self, job: Job) -> None:
self.callback_job_added(job)
self.jobs_queue.put(job)

def cancel_job(self, job: Job) -> None:
def cancel_job(self, job: Job) -> bool:
if job in self.jobs:
self.jobs.remove(job)
if self.worker_thread is not None and self.worker_thread.current_job == job:
self.worker_thread.keyboard_interrupt()
job.cancelled = True
if self.worker_thread is not None and self.worker_thread.current_job == job:
self.worker_thread.keyboard_interrupt()

return True
return False

def interrupt_current_job(self) -> None:
"""Notify the current running job that the user requested an interrupt. The job may ignore it."""
Expand Down Expand Up @@ -201,7 +205,7 @@ def callback_job_added(self, job: Job) -> None:
"""
if self.workspace.view_manager.first_view_in_category("jobs") is not None:
jobs_view = self.workspace.view_manager.first_view_in_category("jobs")
gui_thread_schedule_async(jobs_view.q_jobs.add_new_job, args=[job])
gui_thread_schedule_async(jobs_view.qjobs.add_new_job, args=[job])

def callback_worker_progress(self, job: Job) -> None:
"""
Expand All @@ -210,7 +214,7 @@ def callback_worker_progress(self, job: Job) -> None:
"""
if self.workspace.view_manager.first_view_in_category("jobs") is not None:
jobs_view = self.workspace.view_manager.first_view_in_category("jobs")
gui_thread_schedule_async(jobs_view.q_jobs.change_job_progress, args=[job])
gui_thread_schedule_async(jobs_view.qjobs.change_job_progress, args=[job])

def callback_worker_new_job(self, job: Job) -> None:
"""
Expand All @@ -219,7 +223,7 @@ def callback_worker_new_job(self, job: Job) -> None:
"""
if self.workspace.view_manager.first_view_in_category("jobs") is not None:
jobs_view = self.workspace.view_manager.first_view_in_category("jobs")
gui_thread_schedule_async(jobs_view.q_jobs.change_job_running, args=(job,))
gui_thread_schedule_async(jobs_view.qjobs.change_job_running, args=(job,))

def callback_job_complete(self, job: Job):
"""
Expand All @@ -228,6 +232,6 @@ def callback_job_complete(self, job: Job):
"""
if self.workspace.view_manager.first_view_in_category("jobs") is not None:
jobs_view = self.workspace.view_manager.first_view_in_category("jobs")
gui_thread_schedule_async(jobs_view.q_jobs.change_job_finish, args=[job])
gui_thread_schedule_async(jobs_view.qjobs.change_job_finish, args=[job])

# Private methods
13 changes: 6 additions & 7 deletions angrmanagement/ui/views/jobs_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,24 @@


class JobsView(InstanceView):
"""
This creates a view for the jobs view which creates a table to display
all the jobs being ran or in queue
"""
"""JobsView displays all pending, running, and finished jobs in the project."""

qjobs: QJobs

def __init__(self, workspace: Workspace, default_docking_position: str, instance: Instance) -> None:
super().__init__("jobs", workspace, default_docking_position, instance)
self.base_caption = "Jobs"

# The QJobs widget is initialized in the view, most functions of jobs table is done through QJobs
self.q_jobs = QJobs(workspace)
self.qjobs = QJobs(workspace)
vlayout = QVBoxLayout()
vlayout.addWidget(self.q_jobs)
vlayout.addWidget(self.qjobs)
vlayout.setContentsMargins(0, 0, 0, 0)
self.setLayout(vlayout)
self.reload()

def closeEvent(self, event) -> None:
self.q_jobs.close()
self.qjobs.close()
super().closeEvent(event)

def reload(self) -> None:
Expand Down
Loading

0 comments on commit 271fa18

Please sign in to comment.