Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Commit

Permalink
Merge pull request #85 from Oslandia/mkdtemp
Browse files Browse the repository at this point in the history
Fix import
  • Loading branch information
pblottiere committed Jan 7, 2019
2 parents 6c85e65 + a8aaa04 commit 9b4755c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions plugin.py
Expand Up @@ -621,7 +621,7 @@ def __import_project(self):
)

project_name = os.path.split(fil)[1][:-4]
dir_ = tempfile.gettempdir()
dir_ = tempfile.mkdtemp()
with zipfile.ZipFile(fil, "r") as z:
z.extractall(dir_)

Expand All @@ -631,22 +631,25 @@ def __import_project(self):
self.__iface.messageBar().pushInfo(
"Albion", "loading {} from {}".format(project_name, dump)
)
if Project.exists(project_name):

dbname = os.path.splitext(os.path.basename(dump))[0]

if Project.exists(dbname):
if (
QMessageBox.Yes
!= QMessageBox(
QMessageBox.Information,
"Delete existing DB",
"Database {} exits, to you want to delete it ?".format(
project_name
dbname
),
QMessageBox.Yes | QMessageBox.No,
).exec_()
):
return
Project.delete(project_name)
Project.delete(dbname)

project = Project.import_(project_name, dump)
project = Project.import_(dbname, dump)

QgsProject.instance().read(QFileInfo(prj))

Expand Down

0 comments on commit 9b4755c

Please sign in to comment.