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

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
LuqueDaniel committed Oct 9, 2012
1 parent cffde18 commit 2df5145
Showing 1 changed file with 11 additions and 25 deletions.
36 changes: 11 additions & 25 deletions minecraft_backup/core/backup_manager.py
Expand Up @@ -36,20 +36,14 @@ class make_backup_thread(QThread):
def __init__(self, parent=None):
QThread.__init__(self, parent)

def run(self, dst_, backup_name):
def run(self, dst, backup_name):
"""Start QThread"""

# Decode and encode dst for Windows
if get_os() == 'Windows':
self.dst = dst_.decode('utf-8').encode('windows-1252')
else:
self.dst = dst_

if path.exists(self.dst):
if path.exists(dst):
self.emit(SIGNAL('direxists()'))
self.exit()
else:
self.make_backup(self.dst, backup_name)
self.make_backup(dst, backup_name)

self.exit()

Expand All @@ -67,21 +61,15 @@ def make_backup(self, dst, backup_name):
def save_backup_list(self, backup_name, path):
"""This function save backup list"""

# Decode in Windows and encode UTF-8 for save in Json
if get_os() == 'Windows':
self.path = path.decode('windows-1252').encode('utf-8')
else:
self.path = path.decode('ascii').encode('utf-8')

self.backup_list = load_backup_list()

if self.backup_list is not False:
self.backup_list[backup_name] = self.path
self.backup_list[backup_name] = path
save_backup_file(self.backup_list)

else:
self.first_backup_list = {}
self.first_backup_list[backup_name] = self.path
self.first_backup_list[backup_name] = path
save_backup_file(self.first_backup_list)


Expand Down Expand Up @@ -124,6 +112,7 @@ def load_backup_list():
load_backup_file = loads(list_backup_file.read(), encoding='utf-8')
list_backup_file.close()

print load_backup_file
return load_backup_file
else:
return False
Expand All @@ -140,24 +129,21 @@ def remove_backup_name(backup_name):
def remove_backup(backup_name):
"""Remove data and backup files"""

backup = backup_name
if backup == 'ñ':
print backup
else:
print 'Nop'
backup = unicode(backup_name, 'utf-8')

print backup

backup_list = load_backup_list()
print backup_list
rmtree(backup_list[backup])
print backup_list[backup]

rmtree(backup_list[backup])
remove_backup_name(backup)


def restore_backup(os, backup_name):
"""This function restore backup"""

backup = str(backup_name)

backup_list = load_backup_list()
dst = os
src = backup_list[backup]
Expand Down

0 comments on commit 2df5145

Please sign in to comment.