Error: _LoadedAddon has no attribute 'globals'

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Error: _LoadedAddon has no attribute 'globals'

Postby BackRaw » Wed Jul 18, 2012 4:06 am

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?!
Attachments
error.jpg
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Wed Jul 18, 2012 4:13 am

Well looking at addons/manager.py it should have "globals", I'm confused lol.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Jul 18, 2012 4:53 am

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
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Wed Jul 18, 2012 4:54 am

Woops! but

Syntax: Select all

from events.decorators import event

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

gives me the same error :/
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Jul 18, 2012 4:58 am

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
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Jul 18, 2012 5:00 am

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
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Wed Jul 18, 2012 5:26 am

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^^
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Jul 18, 2012 5:35 am

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
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Jul 18, 2012 5:40 am

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
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Wed Jul 18, 2012 6:31 am

I built it from source... maybe I'll just have to update it.

EDIT: now the server crashes on startup... lol
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Jul 18, 2012 6:42 am

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
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Wed Jul 18, 2012 6:47 am

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()
Attachments
error2.jpg
your-name-here
Developer
Posts: 168
Joined: Sat Jul 07, 2012 1:58 am

Postby your-name-here » Wed Jul 18, 2012 6:55 am

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.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Wed Jul 18, 2012 6:58 am

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
your-name-here
Developer
Posts: 168
Joined: Sat Jul 07, 2012 1:58 am

Postby your-name-here » Wed Jul 18, 2012 6:59 am

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
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Wed Jul 18, 2012 7:04 am

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 =/
your-name-here
Developer
Posts: 168
Joined: Sat Jul 07, 2012 1:58 am

Postby your-name-here » Wed Jul 18, 2012 7:22 am

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 :)
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Wed Jul 18, 2012 8:52 am

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^^
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Jul 18, 2012 2:47 pm

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
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Wed Jul 18, 2012 9:15 pm

satoon101 wrote:It does not make any sense...
Satoon


Yep, it definitely doesn't!

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 24 guests