diff --git a/scripts/classes/Cleanup.py b/scripts/classes/Cleanup.py index ecc6099..5c1b74c 100644 --- a/scripts/classes/Cleanup.py +++ b/scripts/classes/Cleanup.py @@ -21,7 +21,7 @@ class Cleanup(): def deleteAllFilesInFolder(self,folder_path): try: self.cli.executeCommand('rm -r ' + folder_path + '*') - except Exception as error: + except Exception: pass def cleanupFiles(self,file_type): @@ -31,7 +31,7 @@ class Cleanup(): def cleanupForUser(self,user): try: self.cli.executeCommand('find "' + self.paths.getDataFolderPath(Paths.TYPE_ENCRYPTED) + '" -not -name "*' + str(user) +'*" -type f -print | xargs rm -v') - except Exception as error: + except Exception: pass self.cleanupFiles(Paths.TYPE_DECRYPTED) diff --git a/scripts/classes/Decryption.py b/scripts/classes/Decryption.py index 0b10799..a367104 100644 --- a/scripts/classes/Decryption.py +++ b/scripts/classes/Decryption.py @@ -9,7 +9,7 @@ class AutomaticIdentificationImpossibleException(Exception): class Decryption(): def __init__(self,cli,paths): - self.user_id='0'; + self.user_id='0' self.user_password='' self.cli = cli self.paths = paths diff --git a/scripts/classes/Encryption.py b/scripts/classes/Encryption.py index c996860..cf77f4c 100644 --- a/scripts/classes/Encryption.py +++ b/scripts/classes/Encryption.py @@ -1,7 +1,6 @@ import random import string import math -import numpy import re import json from .Paths import Paths @@ -32,13 +31,13 @@ class Encryption(): user_count = 1 while user_count <= self.amount_of_secret_holders: self.user_mapped_data[str(user_count)] = {"groups":{},"user_password":self.createPassword(self.USER_PASSWORD_LENGTHS),"about":{}} - user_count += 1; + user_count += 1 def initializeGroupData(self): self.group_mapped_data = {} def addInformationToUser(self,user_id,label,content): - self.user_mapped_data[user_id]['about'][label] = content; + self.user_mapped_data[user_id]['about'][label] = content def getCoSecretHoldersRange(): return range(Encryption.MINIMUM_SECRET_HOLDERS,(Encryption.MAXIMUM_SECRET_HOLDERS+1)) @@ -89,14 +88,14 @@ class Encryption(): password_group_name = ''.join(sorted(str(index))) if self.isGroupValid(password_group_name): password_group_index_int = int(password_group_name) - if not password_group_index_int in self.group_mapped_data: + if password_group_index_int not in self.group_mapped_data: self.group_mapped_data[password_group_index_int] = {} self.group_mapped_data[password_group_index_int]['members'] = {} self.group_mapped_data[password_group_index_int]['password'] = '' password = '' for secret_holder_index in password_group_name: self.group_mapped_data[password_group_index_int]['members'][secret_holder_index]={} - particial_password_length= int(self.OVERALL_PASSWORD_LENGTHS*self.quota_factor); + particial_password_length= int(self.OVERALL_PASSWORD_LENGTHS*self.quota_factor) password_part = self.createPassword(particial_password_length) self.group_mapped_data[password_group_index_int]['members'][secret_holder_index] = password_part password += password_part diff --git a/scripts/classes/Paths.py b/scripts/classes/Paths.py index 1ac5063..b61857e 100644 --- a/scripts/classes/Paths.py +++ b/scripts/classes/Paths.py @@ -34,10 +34,10 @@ class Paths(): return '.json' + self.getFileExtension(file_type) def getUserFilePath(self,user_id,file_type): - return self.getUserFilesPath(file_type) + user_id + self.getUserFileSuffix(file_type); + return self.getUserFilesPath(file_type) + user_id + self.getUserFileSuffix(file_type) def getGroupFilePath(self,group_id,file_type): - return self.getGroupFilesFolderPath(file_type) + str(group_id) + '.txt' + self.getFileExtension(file_type); + return self.getGroupFilesFolderPath(file_type) + str(group_id) + '.txt' + self.getFileExtension(file_type) def getAccumulatedFilePath(self,file_type): - return self.getDataFolderPath(file_type) + 'accumulated.json' + self.getFileExtension(file_type); \ No newline at end of file + return self.getDataFolderPath(file_type) + 'accumulated.json' + self.getFileExtension(file_type) \ No newline at end of file diff --git a/scripts/main.py b/scripts/main.py index d9967e5..7079203 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -1,7 +1,7 @@ import argparse from classes.Encryption import Encryption from classes.Cleanup import Cleanup -from classes.Decryption import Decryption, AutomaticIdentificationImpossibleException +from classes.Decryption import Decryption from getpass import getpass import traceback from classes.Cli import Cli @@ -56,7 +56,7 @@ try: print("Deleting all encrypted and decrypted files.") cleanup.deleteAll() standard_exit() - print("Deleting all files which aren't related to user: " + str(args.user)); + print("Deleting all files which aren't related to user: " + str(args.user)) cleanup.cleanupForUser(args.user) standard_exit() print("Deleting all " + args.file_types + " files.") @@ -94,15 +94,15 @@ try: decrypt.setUserPassword(getpass()) print("Decrypting User File...") try: - decrypt.initializeUserDataDecryption(); - break; + decrypt.initializeUserDataDecryption() + break except Exception as error: print("An error occured. Propably you typed in a wrong password :( The error is: " + str(error)) else: decrypt.setUserPassword(args.user_password) print("Decrypting User File...") try: - decrypt.initializeUserDataDecryption(); + decrypt.initializeUserDataDecryption() except Exception as error: print("An error occured. Propably you passed a wrong password :( The error is: " + str(error)) clean_exit() @@ -144,7 +144,7 @@ try: print("\nDecrypting group password file.\n") decrypt.initializeGroupDataEncryption() print("THE MASTER PASSWORD IS: " + decrypt.getMasterPassword()) - break; + break except: print("An unexpected error occured: \n" + traceback.format_exc()) print("Decrypting main data.")