def write_to_package_job(control, path, callback_version_id):
# copy to temporary
"""
This job will be called when any field in .deb file control part
has been edited.
:param control: New Control Dict
:type control: dict
:param path: Original Package Path
:type path: str
:param callback_version_id: Callback Version ID, for callback query
:type callback_version_id: int
"""
abs_path = os.path.join(settings.MEDIA_ROOT, path)
temp_path = os.path.join(settings.TEMP_ROOT, str(uuid.uuid1()) + '.deb')
shutil.copyfile(abs_path, temp_path)
# read new package
temp_package = DebianPackage(temp_path)
temp_package.control = control
# save new package
temp_package.save()
t_version = Version.objects.get(id=callback_version_id)
t_version.write_callback(temp_package.path)
评论列表
文章目录