Page 1 of 2

Error: _LoadedAddon has no attribute 'globals'

Posted: Wed Jul 18, 2012 4:06 am
by BackRaw
The attachment error.jpg is no longer available


I'm getting this error everytime I wanna load my addon sp_restrict

Syntax: Select all

import sp
from decorators import event

@event
def player_hurt(ev):
print(ev.eventname)

I ain't got no clue... does every module has "globals" as attribute by default?!

Posted: Wed Jul 18, 2012 4:13 am
by BackRaw
Well looking at addons/manager.py it should have "globals", I'm confused lol.

Posted: Wed Jul 18, 2012 4:53 am
by satoon101
I'm not sure how that would load anyway. You have to import event from events.decorator. Also, there is no need to import anything directly from the sp module as of yet. And eventname isn't a method/property/attribute of the GameEvent class (you should use GetName() instead).

Satoon

Posted: Wed Jul 18, 2012 4:54 am
by BackRaw
Woops! but

Syntax: Select all

from events.decorators import event

@event
def player_hurt(ev):
print(ev.GetName())

gives me the same error :/

Posted: Wed Jul 18, 2012 4:58 am
by satoon101
No idea... I do not get that error. Try deleting your _libs folder and reuploading the _libs directory. And again, it's from events.decorator not from events.decorators

Satoon

Posted: Wed Jul 18, 2012 5:00 am
by satoon101
Also, I would like it if people would not use the arguments ev or event_var for this. Instead of a dictionary class being passed, an IGameEvent instance is passed. I mean, if you wish to use it, fine, but "try" to get used to the ideas of this plugin. I typically use GameEvent anymore (since we decided upon naming conventions).

Satoon

Posted: Wed Jul 18, 2012 5:26 am
by BackRaw
Oops oh gosh... yeah that makes sense. I just used ev for testing =) Of course I can change it ;)

Well, but why doesn't SP give me an import error instead of this error? I mean, if the file's name is decorator and not decorators... misleading traceback^^

Posted: Wed Jul 18, 2012 5:35 am
by satoon101
That is why I asked if you could reupload. Using the same code you have, I get an error on sp_load. The error you get really makes no sense whatsoever.

If the base file (<script>/<script>.py) doesn't exist, we call FileNotFoundError, which passes silently. If the file exists, but the addon fails on __import__, an error "should" be being raised and then is printed to the console without the addon being added to the dictionary. If that doesn't happen, then and only then does a _LoadedAddon instance actually get passed back instead of "None". This instance "must" have a globals attribute. We even call <instance>.globals when loading an addon.

Satoon

Posted: Wed Jul 18, 2012 5:40 am
by satoon101
Are you using the version from the download or are you using TortoiseHG? I guess that "could" be an issue with the older version, which is in the download. To get the newest version, look at this wiki page:
http://www.sourcepython.com/forums/showwiki.php?title=Source_Python:Building_from_source

At this point, you don't necessarily have to build the .dll files as I don't think a whole lot has been added. But you should use that to update your sp.py as well as the _libs folder.

Satoon

Posted: Wed Jul 18, 2012 6:31 am
by BackRaw
I built it from source... maybe I'll just have to update it.

EDIT: now the server crashes on startup... lol

Posted: Wed Jul 18, 2012 6:42 am
by satoon101
Just updated mine, too. There was a crash that was occurring for some people, and the update for that included adding in 2 more files:
http://code.google.com/p/source-python/source/detail?r=f7e51298b09e0073c075d36b2ff8407401ca7ab6

Copy those files from your source, and upload them to the same directory on your server.

Satoon

Posted: Wed Jul 18, 2012 6:47 am
by BackRaw
Okay thanks. Gonna try it

EDIT: server still shuts down, getting the following error:


EDIT2: wow, you can see nothing in that picture... okay, it says

Code: Select all

[SP LOADER] Loading [.....]\plat-win\msvcr100d.dll
============================================
[SP LOADER] could not load visual studio runtime! Aborting load...
Failed to load plugin "addons/source-python"
Missing shutdown function for sv.Init( bDedicated ) : sv.Shutdown()

Posted: Wed Jul 18, 2012 6:55 am
by your-name-here
BackRaw wrote:Okay thanks. Gonna try it

EDIT: server still shuts down, getting the following error:



I don't know if you made the picture this size or if the forum did but oh god is that small :P

Also, please go to your addons/source-python/engines/plat-win directory and list out all of the dll files for me that you see.

Posted: Wed Jul 18, 2012 6:58 am
by BackRaw
I edited the post because the picture is so small^^

  • msvcp100d.dll
  • msvcp100.dll
  • python33.dll
  • python33_d.dll
  • sqlite3.dll
  • sqlite3_d.dll
Maybe renaming msvcp100d.dll to msvcp100_d.dll does the trick?

EDIT: it doesn't.

EDIT2: I'm confused, it's looking for msvc[color="#A52A2A"]r[/color]100d.dll, not msvc[color="#A52A2A"]p[/color]100d.dll

Posted: Wed Jul 18, 2012 6:59 am
by your-name-here
BackRaw wrote:Okay thanks. Gonna try it

EDIT: server still shuts down, getting the following error:

[ATTACH=CONFIG]15[/ATTACH]

EDIT2: wow, you can see nothing in that picture... okay, it says

Code: Select all

[SP LOADER] Loading [.....]\plat-win\msvcr100d.dll
============================================
[SP LOADER] could not load visual studio runtime! Aborting load...
Failed to load plugin "addons/source-python"
Missing shutdown function for sv.Init( bDedicated ) : sv.Shutdown()


You are missing the msvcr100.dll and msvcr100d.dll files.
Get them from here:
http://code.google.com/p/source-python/source/browse/#hg%2Faddons%2Fsource-python%2Fengines%2Fplat-win

Posted: Wed Jul 18, 2012 7:04 am
by BackRaw
I updated the source and compiled it again, but I forgot to copy over the addons directory...

Thanks for your help, it works now =)

+ the addon works now, too :D

EDIT: but, if I change the import to the wrong one (from events import decorators) on purpose, there's still the "globals" error =/

Posted: Wed Jul 18, 2012 7:22 am
by your-name-here
BackRaw wrote:I updated the source and compiled it again, but I forgot to copy over the addons directory...

Thanks for your help, it works now =)

+ the addon works now, too :D

EDIT: but, if I change the import to the wrong one (from events import decorators) on purpose, there's still the "globals" error =/


You are importing a module that doesn't exist within source.python's search paths. Python then attempts to load your addon and bails out because the module decorators. Because it bails out mid-load, nothing is setup for the module. This is why you don't have a globals attribute.

This is to be expected. Nothing is wrong here :)

Posted: Wed Jul 18, 2012 8:52 am
by BackRaw
your-name-here wrote:You are importing a module that doesn't exist within source.python's search paths. Python then attempts to load your addon and bails out because the module decorators. Because it bails out mid-load, nothing is setup for the module. This is why you don't have a globals attribute.

This is to be expected. Nothing is wrong here :)


True, true... but I can't do anything, I can't un- or reload the addon, I can't do nothing. It just gives me this message everytime. That's what's wrong imo^^

Posted: Wed Jul 18, 2012 2:47 pm
by satoon101
I honestly cannot replicate this issue. I have no idea why that is happening on your server. It does not make any sense...

I get this error when using the wrong import name:

Code: Select all

sp_load newtest
[SP] Loading "newtest"...

[SP] caught an exception:
Traceback (most recent call last):
  File "..\addons\source-python\_libs\addons\manager.py", line 42, in __getitem_
_
    value = _LoadedAddon(addon)
  File "..\addons\source-python\_libs\addons\manager.py", line 134, in __init__
    addon = __import__(addon_name + '.' + addon_name)
  File "..\addons\source-python\newtest\newtest.py", line 1, in <module>
    from events.decorators import event

ImportError: No module named 'events.decorators'

[SP] Addon "newtest" was unable to be loaded.

Satoon

Posted: Wed Jul 18, 2012 9:15 pm
by BackRaw
satoon101 wrote:It does not make any sense...
Satoon


Yep, it definitely doesn't!