From 3a327b77708f83c7e781b2d0c7aee81956567f01 Mon Sep 17 00:00:00 2001 From: Andrey Zhavoronkov <41117609+azhavoro@users.noreply.github.com> Date: Fri, 22 May 2020 16:34:11 +0300 Subject: [PATCH] Fixed git synchronization (#1582) * fixed git synchronization * Update CHANGELOG.md Co-authored-by: Nikita Manovich <40690625+nmanovic@users.noreply.github.com> --- CHANGELOG.md | 3 ++- cvat/apps/git/git.py | 17 ++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c86ade2fcaf..272b3c3f8eae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,7 +49,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed COCO keypoints skeleton parsing and saving (https://github.com/opencv/cvat/issues/1539) - Fixed an error when exporting a task with cuboids to any format except CVAT (https://github.com/opencv/cvat/pull/1577) - `tf.placeholder() is not compatible with eager execution` exception for auto_segmentation (https://github.com/opencv/cvat/pull/1562) -- Fixed a problem with mask to polygons conversion when polygons are too small (https://github.com/opencv/cvat/pull/1581) +- Synchronization with remote git repo (https://github.com/opencv/cvat/pull/1582) +- A problem with mask to polygons conversion when polygons are too small (https://github.com/opencv/cvat/pull/1581) ### Security - diff --git a/cvat/apps/git/git.py b/cvat/apps/git/git.py index bb960a23bd73..5d0e817829b3 100644 --- a/cvat/apps/git/git.py +++ b/cvat/apps/git/git.py @@ -10,13 +10,12 @@ import shutil import subprocess from glob import glob -from tempfile import TemporaryDirectory +import zipfile import django_rq import git from django.db import transaction from django.utils import timezone -from pyunpack import Archive from cvat.apps.dataset_manager.task import export_task from cvat.apps.engine.log import slogger @@ -284,16 +283,16 @@ def push(self, user, scheme, host, db_task, last_save): if ext == '.zip': shutil.move(dump_name, self._annotation_file) elif ext == '.xml': - with TemporaryDirectory() as tmp_dir: - # TODO: remove extra packing-unpacking - Archive(src_path).extractall(tmp_dir) - anno_paths = glob(osp.join(tmp_dir, '**', '*.xml'), - recursive=True) - shutil.move(anno_paths[0], self._annotation_file) + with zipfile.ZipFile(dump_name) as archive: + for f in archive.namelist(): + if f.endswith('.xml'): + with open(self._annotation_file, 'wb') as output: + output.write(archive.read(f)) + break + os.remove(dump_name) else: raise Exception("Got unknown annotation file type") - os.remove(dump_name) self._rep.git.add(self._annotation_file) # Merge diffs