From 627abd412522201878dbc8cf8ba8cc1cca4f25a1 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowak Date: Wed, 20 Jan 2016 15:14:33 +0100 Subject: [PATCH] Unified exception in repo create Change-Id: I75b7f24d6fe2d60039488c3d672b2e5bcd3111de --- solar/core/resource/repository.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/solar/core/resource/repository.py b/solar/core/resource/repository.py index 95bb8ae3..ecfa1993 100644 --- a/solar/core/resource/repository.py +++ b/solar/core/resource/repository.py @@ -153,12 +153,20 @@ class Repository(object): os.mkdir(self.fpath) except OSError as e: if e.errno == errno.EEXIST: - raise RepositoryExists("Repository %s exists" % self.name) + raise RepositoryExists("Repository %s " + "already exists" % self.name) else: raise self._add_contents(source) else: - os.symlink(source, self.fpath) + try: + os.symlink(source, self.fpath) + except OSError as e: + if e.errno == errno.EEXIST: + raise RepositoryExists("Repository %s " + "already exists" % self.name) + else: + raise def update(self, source, overwrite=False): self._add_contents(source, overwrite)