Admin Plugin can't load

All other Source.Python topics and issues.
User avatar
BlagoYar
Junior Member
Posts: 5
Joined: Wed Dec 09, 2020 6:58 am
Location: Чернигов град
Contact:

Admin Plugin can't load

Postby BlagoYar » Wed Dec 09, 2020 10:20 am

Errors:

Code: Select all

sp plugin load admin
[SP] Загрузка плагина 'admin'...
[SP] Перехвачено исключение:
Traceback (most recent call last):
File "../addons/source-python/packages/source-python/plugins/command.py", line 164, in load_plugin
plugin = self.manager.load(plugin_name)
File "../addons/source-python/packages/source-python/plugins/manager.py", line 207, in load
plugin._load()
File "../addons/source-python/packages/source-python/plugins/instance.py", line 74, in _load
self.module = import_module(self.import_name)
File "../addons/source-python/plugins/admin/admin.py", line 10, in <module>
from .core import models
File "../addons/source-python/plugins/admin/core/__init__.py", line 7, in <module>
from .logger import admin_logger
File "../addons/source-python/plugins/admin/core/logger.py", line 15, in <module>
_config_strings = LangStrings('admin/config/logger')
File "../addons/source-python/packages/source-python/translations/strings.py", line 80, in __init__
self._create_server_file()
File "../addons/source-python/packages/source-python/translations/strings.py", line 180, in _create_server_file
server_file.write()
File "../addons/source-python/packages/site-packages/configobj.py", line 2119, in write
'ascii')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 2-5: ordinal not in range(128)
[SP] Плагин 'admin' не может быть загружен.


and else when start server

Code: Select all

[Source.Python] Loading...
[SP] Получено предупреждение:
File '../addons/source-python/packages/site-packages/mutagen/id3/_specs.py', line 666: DeprecationWarning
invalid escape sequence \s
[Source.Python] Loaded successfully.
DeaD_EyE
Member
Posts: 34
Joined: Wed Jan 08, 2014 10:32 am

Re: Admin Plugin can't load

Postby DeaD_EyE » Wed Dec 09, 2020 2:13 pm

Use "utf8" as encoding, then it won't try to encode to ascii.

Code: Select all

from configobj import ConfigObj


cfg = ConfigObj(infile="settings.ini", encoding="utf8")
cfg["text"] = "[SP] Плагин 'admin' не может быть загружен."
cfg.write()


# reading later
cfg = ConfigObj(infile="settings.ini", encoding="utf8")
print(cfg["text"])
User avatar
BlagoYar
Junior Member
Posts: 5
Joined: Wed Dec 09, 2020 6:58 am
Location: Чернигов град
Contact:

Re: Admin Plugin can't load

Postby BlagoYar » Fri Dec 11, 2020 7:09 pm

DeaD_EyE wrote:Use "utf8" as encoding, then it won't try to encode to ascii.

Code: Select all

from configobj import ConfigObj


cfg = ConfigObj(infile="settings.ini", encoding="utf8")
cfg["text"] = "[SP] Плагин 'admin' не может быть загружен."
cfg.write()


# reading later
cfg = ConfigObj(infile="settings.ini", encoding="utf8")
print(cfg["text"])


Where do you need to write it?
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Admin Plugin can't load

Postby Ayuto » Fri Dec 11, 2020 7:41 pm

It's an error in SP when using unicode characters in configuration files. In your case it happens if you change SP's language to Russian and try to load the SP Admin plugin.

I just fixed the error:
https://github.com/Source-Python-Dev-Te ... 4740d9833a

You can quickly fix the error by doing the same change like shown in the link or simply wait for the next release (probably tomorrow). Switching back your language to english in core_settings.ini would also "fix" the error.
User avatar
BlagoYar
Junior Member
Posts: 5
Joined: Wed Dec 09, 2020 6:58 am
Location: Чернигов град
Contact:

Re: Admin Plugin can't load

Postby BlagoYar » Fri Dec 11, 2020 9:45 pm

Ayuto wrote:It's an error in SP when using unicode characters in configuration files. In your case it happens if you change SP's language to Russian and try to load the SP Admin plugin.

I just fixed the error:
https://github.com/Source-Python-Dev-Te ... 4740d9833a

You can quickly fix the error by doing the same change like shown in the link or simply wait for the next release (probably tomorrow). Switching back your language to english in core_settings.ini would also "fix" the error.

I can't find the file - core_settings.ini
Where is it?

I changed

Code: Select all

addons/source-python/packages/source-python/translations/strings.py


added

Code: Select all

self._encoding = encoding

here

Code: Select all

        # Get the path to the given file
        self._mainfile = TRANSLATION_PATH / infile + '.ini'
        self._encoding = encoding
        # Does the file exist?


and replaced

Code: Select all

server_file = GameConfigObj(self._serverfile)

this

Code: Select all

server_file = GameConfigObj(self._serverfile, encoding=self._encoding)


but i give

Code: Select all

[SP] Загрузка плагина 'admin'...
[SP] Получено предупреждение:
File '../addons/source-python/packages/site-packages/sqlalchemy/dialects/sqlite/base.py', line 558: DeprecationWarning
invalid escape sequence \d
[SP] Получено предупреждение:
File '../addons/source-python/packages/site-packages/sqlalchemy/dialects/sqlite/base.py', line 1331: DeprecationWarning
invalid escape sequence \w
[SP] Получено предупреждение:
File '../addons/source-python/packages/site-packages/sqlalchemy/dialects/sqlite/base.py', line 1332: DeprecationWarning
invalid escape sequence \(
MOTDPlayer package is not installed, MoTD frontend will be disabled.
[SP] Успешная загрузка плагина 'admin'.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Admin Plugin can't load

Postby Ayuto » Fri Dec 11, 2020 10:24 pm

core_settings.ini is located in your cfg/source-python folder. But you don't need to switch back the language as you applied the actual fix.

As you can see the plugin loads fine now. There are just three deprecation warnings, but can safely ignore them. With the next start of the server they won't appear anymore.
User avatar
BlagoYar
Junior Member
Posts: 5
Joined: Wed Dec 09, 2020 6:58 am
Location: Чернигов град
Contact:

Re: Admin Plugin can't load

Postby BlagoYar » Fri Dec 11, 2020 10:58 pm

Ayuto wrote:core_settings.ini is located in your cfg/source-python folder. But you don't need to switch back the language as you applied the actual fix.

As you can see the plugin loads fine now. There are just three deprecation warnings, but can safely ignore them. With the next start of the server they won't appear anymore.

core-settings is probably generated automatically? therefore I did not find it.

There are other errors

Code: Select all

[SP] Caught an Exception:
Traceback (most recent call last):
File "../addons/source-python/packages/source-python/entities/_base.py", line 132, in __call__
obj = super().__call__(index)
File "../addons/source-python/packages/source-python/entities/_base.py", line 199, in __init__
super().__init__(index)
ValueError: Conversion from "Index" (324) to "BaseEntity" failed.
[SP] Caught an Exception:
Traceback (most recent call last):
File "../addons/source-python/packages/source-python/entities/_base.py", line 132, in __call__
obj = super().__call__(index)
File "../addons/source-python/packages/source-python/entities/_base.py", line 199, in __init__
super().__init__(index)
ValueError: Conversion from "Index" (322) to "BaseEntity" failed.
[SP] Caught an Exception:
Traceback (most recent call last):
File "../addons/source-python/packages/source-python/entities/_base.py", line 132, in __call__
obj = super().__call__(index)
File "../addons/source-python/packages/source-python/entities/_base.py", line 199, in __init__
super().__init__(index)
ValueError: Conversion from "Index" (201) to "BaseEntity" failed.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Admin Plugin can't load

Postby Ayuto » Fri Dec 11, 2020 11:43 pm

Yes, sorry, it's generated when SP is loaded the very first time. But then it defaults to english, so you must have changed that setting at some point.

Are those the full exceptions? They somehow seem to be truncated.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 16 guests