Python: AttributeError: 'str' object has no attribute 'decompressUnknownOriginalSize' - python

First off, I'm not a programmer by any means. I just try to follow instructions.
So, I'm trying to use a script to decode game files. The problem is that I'm getting an error.
I've tried the script on 2 different machines wheres both give the same error. At the same time, I have friends using the exact same script w/o getting this error. Does anyone have any clue what is wrong?
Traceback (most recent call last):
File "F:\Frostbite Decoding\Decoding Files\bf4dumper.py", line 258, in <module>
if "tocRoot" in locals(): dumpRoot(tocRoot)
File "F:\Frostbite Decoding\Decoding Files\bf4dumper.py", line 249, in dumpRoot
dump(fname,targetDirectory)
File "F:\Frostbite Decoding\Decoding Files\bf4dumper.py", line 198, in dump
LZ77.decompressUnknownOriginalSize(catEntry.path,catEntry.offset,catEntry.size,targetPath)
AttributeError: 'str' object has no attribute 'decompressUnknownOriginalSize'
If you need anymore information, please let me know.

Python is saying that it is receiving a string and that there is no method for decompressUnknownOriginalSize. This sounds like the script needs to get some other data type or argument type than string. Look for where "decompressUnknownOriginalSize" is called and see what data type is being passed to that argument.

Related

Spyder Trace Debugging - Python

I am having a weird situation where the trace for an AttributeError keeps referencing the exact same absolute line number in my code.
Traceback (most recent call last):
File "<ipython-input-59-513669e63f3e>", line 4, in <module>
"line of code being run"
File "modulepath", line 148, in "method that contains the line of code"
"content of the line causing the error"
AttributeError: 'list' object has no attribute 'attribute_name'
If I make line 148 empty (by putting in new lines, etc.) or if I put a comment on line 148, the trace keeps pointing to line 148 as the source of the error.
I am having trouble debugging this particular error in general since I am (to the best of my knowledge) not using that particular attribute on any list object in my code (but it seems to indicate that I'm doing so). I will figure out that issue on my own. My main question is: what causes Spyder to repeatedly reference the exact same absolute line number in a traceback? Thank you.
When in doubt, use a fresh new console - that worked for me.

Possible to modify built-in error messages in Python? (If so, how?)

I am wondering if it is possible to edit/customize the behavior and printout of built-in errors in Python. For example, if I type:
>>> a = 1
>>> print A
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'A' is not defined
I want the output to instead be:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'A' is not defined. Check capitalization.
Moreover, I want this to occur at a global level, for ALL FUTURE CODE, without having to explicitly include an exception in my code. If such a change is possible, I would assume this needs to be done at the very source or library-file level of Python. However, I am not sure where exactly to look to know if this is even possible.
I am using Python 2.7 on both Ubuntu and OSX, so help on either system would be appreciated.
(My apologies in advance if this is covered elsewhere, but searching for threads on "changing Python error messages" generally gave me topics on Exceptions, which is not necessarily my interest here. If anyone can point me to a page on this though, I'd greatly appreciate it.)
YES! There is a way to exactly what you want!
traceback.py is the program that detects errors in your code. It then gives you an explanation of what happened (creates the error message that you see.)
You can find this file in your library folder for python.
When in that file you can change the messages that it outputs when you come across an error!
Please tell me if this helped you!

Cannot get any log information from pysimplesoap

I'm trying to use pysimplesoap (v.1.10) and getting what appears to be some kind of parsing error when executing a method request.
Stripped down version:
import pysimplesoap
soapURL = "https://site/path/to/soap"
namespace = "https://site/path/to/ns"
soapClient = pysimplesoap.client.SoapClient(location=soapURL + "?wsdl",namespace=namespace)
response = soapClient.getDocumentContent('1234567')
(python 2.7.8 btw)
Results in an error:
Traceback (most recent call last):
File ".\SOAPtest2.py", line 60, in <module>
response = soapClient.getDocumentContent('1234567')
File "build\bdist.win32\egg\pysimplesoap\client.py", line 139, in <lambda>
AttributeError: 'str' object has no attribute 'call'
However, the real question I have is that I am trying (unsuccessfully) to get logging working, but cannot see any output or determine/confirm what the XML structure it is sending/receiving. I might be able to diagnose the problem if I could see what it is receiving/trying to parse.
I have a gist of the code and the error I'm getting as well.
The odd part is that in my original script (before I stripped down to just some test code) I had a secondary logging instance and file handler and it worked just fine. So it seems specific to the pysimplesoap logging.
Any help would be greatly appreciated.
EDIT: Solution
Per KenK's recommendation, I modified my method call to be (documentId='1234567') and it worked. The script got past that error and I got a few log/debug lines in output. It seems that pysimplesoap simply has so few log/debug lines that none were reached prior to the error I was hitting.
Add the following code to your code:
import logging
logging.basicConfig(level=logging.DEBUG)
To fix the error you're getting, you need to specify an attribute name. Like this:
response = soapClient.getDocumentContent(name='1234567')
Replace name with whatever's defined for this function.

adding list item to list object has no attribute '__getitem__'

I am very confused why the code below doesn't work under Python 2.7.6 in OS X.
Code should basically iterate through one list and add items to another list (I want to add conditions later)..
import os
home_dir = os.listdir("/Users/")
users_list = []
for user in home_dir:
users_list.append(user)
I get the error message below when running it:
Traceback (most recent call last): File "myfile.py", line x, in
<module>
users_list.append[suser] TypeError: 'builtin_function_or_method' object has no attribute '__getitem__'
/edit: weirdly enough when I do the same thing outside of the file in the python interpreter it seems to work ok?
You should really show the real code which produces the error.
Taken from the Traceback:
users_list.append[suser] - this is wrong
users_list.append(suser) - this is correct

Image layering in Tkinter, Python [figured it out (smacks forehead)]

I am working with a graphics module called cTurtle, which builds upon TKinter. Each controllable 'Turtle' has an image assigned to it with TKinter. I am trying to add a method to the module that will allow me to change the layering position of a given 'Turtle'. Or to put it another way, i want to add a method that will allow me to put a given image on top of the displaylist. When i call the method i have made, i get this error
Traceback (most recent call last):
File "C:\Documents and Settings\login\Desktop\pYTHON EXPERIMENTS\canvastest.py", line 22, in <module>
bob.visUp()
File "C:\Documents and Settings\login\Desktop\pYTHON EXPERIMENTS\jTurtle.py", line 2017, in visUp
titem = self.turtle._item
File "C:\Documents and Settings\login\Desktop\pYTHON EXPERIMENTS\jTurtle.py", line 542, in _visUp
def _visUp(self, item):
File "<string>", line 1, in type
File "C:\Python32\lib\tkinter\__init__.py", line 2325, in type
return self.tk.call(self._w, 'type', tagOrId) or None
_tkinter.TclError: invalid command name ".16847312"
Does someone recognize why the function is rejecting what i passed to it? The number in quotes appears to be an object id, which should work.
EDIT
well, i did myself a great disservice here by not pasting everything involved. I coded these new methods several days ago, and have been trying to debug since. Turns out i coded them right the first time. The problem was in how i called them. I added the visup() test line after exitOnClick(), meaning that the widget had, in fact, already been destroyed.
But, hey, i coded it right the first time! sorta...

Categories

Resources