refactor code to use the create_path and remove_path functions

This commit is contained in:
Andreas Zweili 2019-02-03 21:35:53 +01:00
parent 1ae842f81e
commit f5c052c2ee
2 changed files with 5 additions and 6 deletions

View File

@ -5,7 +5,7 @@ import json
from PyQt5.QtCore import QThread from PyQt5.QtCore import QThread
from helper import BorgException from helper import BorgException, create_path, remove_path
def _process_json_error(json_err): def _process_json_error(json_err):
@ -114,12 +114,11 @@ class RestoreThread(QThread):
def stop(self): def stop(self):
self.p.kill() self.p.kill()
shutil.rmtree(self.restore_path) remove_path(self.restore_path)
self.json_err = None self.json_err = None
def run(self): def run(self):
if not os.path.exists(self.restore_path): create_path(self.restore_path)
os.makedirs(self.restore_path)
self.p = subprocess.Popen(['borg', 'extract', '--log-json', self.p = subprocess.Popen(['borg', 'extract', '--log-json',
('::' ('::'
+ self.archive_name)], + self.archive_name)],

View File

@ -6,6 +6,7 @@ import unittest
import warnings import warnings
from main_window import MainWindow from main_window import MainWindow
from helper import remove_path
def fxn(): def fxn():
@ -37,5 +38,4 @@ class BorgInterfaceTest(unittest.TestCase):
stderr=subprocess.PIPE) stderr=subprocess.PIPE)
def tearDown(self): def tearDown(self):
if os.path.exists(self.repository_path): remove_path(self.repository_path)
shutil.rmtree(self.repository_path)