Re: Assistance with my settings class (Python)

2020-11-21 Thread AudioGames . net Forum — Developers room : tunmi13 via Audiogames-reflector


  


Re: Assistance with my settings class (Python)

@11 Apologies. But I have to describe the error one way or another don't I? 

URL: https://forum.audiogames.net/post/591616/#p591616




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Assistance with my settings class (Python)

2020-11-20 Thread AudioGames . net Forum — Developers room : bhanuponguru via Audiogames-reflector


  


Re: Assistance with my settings class (Python)

@11yeah yeah yeah. tunmi, you did that.

URL: https://forum.audiogames.net/post/591551/#p591551




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Assistance with my settings class (Python)

2020-11-20 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: Assistance with my settings class (Python)

This is where I have to point out that you just posted all the info that any of us would need to trivially decrypt your files.

URL: https://forum.audiogames.net/post/591547/#p591547




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Assistance with my settings class (Python)

2020-11-20 Thread AudioGames . net Forum — Developers room : Turret via Audiogames-reflector


  


Re: Assistance with my settings class (Python)

Your key has to be 16 bytes.

URL: https://forum.audiogames.net/post/591542/#p591542




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Assistance with my settings class (Python)

2020-11-20 Thread AudioGames . net Forum — Developers room : tunmi13 via Audiogames-reflector


  


Re: Assistance with my settings class (Python)

Hi.The error log returns the following errors when I run.dicdata = data.decrypt(dicdata, self.key)decryptor = AES.new(key, AES.MODE_CFB, iv)return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)return modes[mode](factory, **kwargs)raise ValueError("Incorrect IV length (it must be %d bytes long)" %ValueError: Incorrect IV length (it must be 16 bytes long)

URL: https://forum.audiogames.net/post/591528/#p591528




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Assistance with my settings class (Python)

2020-11-20 Thread AudioGames . net Forum — Developers room : tunmi13 via Audiogames-reflector


  


Re: Assistance with my settings class (Python)

Ah, I see. Okay thanks for the help.

URL: https://forum.audiogames.net/post/591522/#p591522




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Assistance with my settings class (Python)

2020-11-20 Thread AudioGames . net Forum — Developers room : stewie via Audiogames-reflector


  


Re: Assistance with my settings class (Python)

@tunmi13 you only initialize sd within the try block so when that try block ends sd goes out of scope. Your later code tries to use it and then errors as a result. Your excepts are using the pass statement so you aren't seeing any errors.

URL: https://forum.audiogames.net/post/591520/#p591520




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Assistance with my settings class (Python)

2020-11-20 Thread AudioGames . net Forum — Developers room : pauliyobo via Audiogames-reflector


  


Re: Assistance with my settings class (Python)

From what I can see, you are trying to read a file as plain text, when actually you've written it as binarywhat you'd want to use when reading is the "rb" mode.And the issue I can also see, is that you are using a lot of try and except blocks, without actually specifing which exception to catch. Therefore adding these many try except blocks will just prevent you  from actually finding out what's wrong.As a good rule of thumb, always catch the exceptions you need.Using just except without specifying any exception, is going to hide whatever other error you are getting.Also, when dealing with  file handles, you could also consider using the finally clause to close it. Finally always executes whether the try operation was successful or not, and you do always want to close the file handleSo after my nonsensical talk, here should be a working class # I'll pretend that the modules have been importedclass SaveData:    def __init__(self, filename, key):        self.d = {}        self.filename = filename        self.key = key    def load(self):        sd = None # let's keep the future  handle out of the try scope, so we can use it later        dicdata = ""        try:            sd = open(self.filename, "rb")            dicdata = sd.read()        except FileNotFoundError: # exception raised when file not found            pass        finally:            if sd:                sd.close()        # here we can decide to decrypt the data if a key is present        if self.key != "":            dicdata = data.decript(dicdata, self.key)        # finally, let's load json        self.d = json.loads(dicdata)in the future, you might want to explore also utilizing the with statement, when dealing with IO operations, it'll make your life much better in most casesI hope it made some sense. And if not feel free to ask.

URL: https://forum.audiogames.net/post/591518/#p591518




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Assistance with my settings class (Python)

2020-11-20 Thread AudioGames . net Forum — Developers room : Turret via Audiogames-reflector


  


Re: Assistance with my settings class (Python)

I also would suggest creating the file if it doesn't exist. LOL.

URL: https://forum.audiogames.net/post/591513/#p591513




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Assistance with my settings class (Python)

2020-11-20 Thread AudioGames . net Forum — Developers room : Turret via Audiogames-reflector


  


Re: Assistance with my settings class (Python)

LOL I don't think you know what I meant. Put 'rb', not 'r'. That does read binary. Also, it is generally bad practice to use a general except. Because they catch *everything*. E.G., SyntaxError, ValueError, any kind of error. Might I suggestexcept ValueError:Or whatever the Exception raised is.

URL: https://forum.audiogames.net/post/591512/#p591512




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Assistance with my settings class (Python)

2020-11-20 Thread AudioGames . net Forum — Developers room : tunmi13 via Audiogames-reflector


  


Re: Assistance with my settings class (Python)

Yes, but if the file didn't exist and you tried to open the file anyways, it'd fail to open it, thus crashing the application. If it passes the statement the file probably doesn't exist.

URL: https://forum.audiogames.net/post/591510/#p591510




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Assistance with my settings class (Python)

2020-11-20 Thread AudioGames . net Forum — Developers room : Turret via Audiogames-reflector


  


Re: Assistance with my settings class (Python)

I don't have a tun of time at the moment, and will look more later, but try using rb when opening the file to read.

URL: https://forum.audiogames.net/post/591506/#p591506




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector