def remove_job(self, job_guid):
"""
Remove a job given its GUID, including decreasing the job counter of the queue
:param job_guid: the GUID of the job to remove from queue
:return: void
"""
global _os_ver
occurs = [(oc.start(), oc.end()) for oc in
list(re.finditer('%s' % (BITSStateFile.JOB_HEADER_FOOTER_HEX[_os_ver].decode('hex')),
self._original_data))
]
if occurs:
self.set_jobs_counter(self.get_jobs_counter() - 1)
state_off = self._get_job_state_off(job_guid)
new_data_list = list(self._new_data)
job_start_off, job_end_off = BITSStateFile._get_job_limits_by_index_in_between(occurs, state_off)
new_data_list = new_data_list[:job_start_off + 1] + new_data_list[job_end_off + 1:]
self._update_new_data(0, "".join(new_data_list))
self.commit()
评论列表
文章目录