Compare commits
1 Commits
step35/667
...
fix/534-v2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c7b558d20 |
87
evennia/bezalel_world/server/README.md
Normal file
87
evennia/bezalel_world/server/README.md
Normal file
@@ -0,0 +1,87 @@
|
||||
# Bezalel World Server Configuration
|
||||
|
||||
This directory contains the Evennia server configuration for Bezalel, the forge-and-testbed wizard house.
|
||||
|
||||
## Quick Start
|
||||
|
||||
To fix the Evennia settings on the Bezalel VPS (104.131.15.18):
|
||||
|
||||
```bash
|
||||
# SSH to Bezalel and run the fix script
|
||||
ssh root@104.131.15.18 'bash -s' < scripts/fix_evennia_settings.sh
|
||||
```
|
||||
|
||||
Or manually:
|
||||
|
||||
```bash
|
||||
cd /root/wizards/bezalel/evennia/bezalel_world/server/conf
|
||||
|
||||
# Copy the fixed settings
|
||||
cp ~/timmy-home/evennia/bezalel_world/server/conf/settings.py ./settings.py
|
||||
|
||||
# Clean and reinitialize DB
|
||||
cd /root/wizards/bezalel/evennia/bezalel_world
|
||||
rm -f server/evennia.db3
|
||||
/root/wizards/bezalel/evennia/venv/bin/evennia migrate
|
||||
|
||||
# Create superuser
|
||||
/root/wizards/bezalel/evennia/venv/bin/python3 -c "
|
||||
import sys, os
|
||||
sys.setrecursionlimit(5000)
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'server.conf.settings'
|
||||
import django
|
||||
django.setup()
|
||||
from evennia.accounts.accounts import AccountDB
|
||||
AccountDB.objects.create_superuser('Timmy', 'timmy@tower.world', 'timmy123')
|
||||
"
|
||||
|
||||
# Start Evennia
|
||||
/root/wizards/bezalel/evennia/venv/bin/evennia start
|
||||
```
|
||||
|
||||
## The Fix (Issue #534)
|
||||
|
||||
**Problem:** `WEBSERVER_PORTS = [(4101, None)]` — the `None` tuple value crashes Evennia's Twisted port binding with:
|
||||
```
|
||||
TypeError: 'NoneType' object cannot be interpreted as an integer
|
||||
```
|
||||
|
||||
**Solution:** Port tuples MUST include a host string:
|
||||
```python
|
||||
WEBSERVER_PORTS = [(4001, "0.0.0.0")]
|
||||
TELNET_PORTS = [(4000, "0.0.0.0")]
|
||||
WEBSOCKET_PORTS = [(4002, "0.0.0.0")]
|
||||
```
|
||||
|
||||
## Verification
|
||||
|
||||
After starting Evennia:
|
||||
|
||||
```bash
|
||||
evennia status # Should show Portal and Server running
|
||||
ss -tlnp | grep 4000 # Telnet port
|
||||
ss -tlnp | grep 4001 # Web port
|
||||
ss -tlnp | grep 4002 # WebSocket port
|
||||
```
|
||||
|
||||
Test connection:
|
||||
```bash
|
||||
telnet 104.131.15.18 4000
|
||||
```
|
||||
|
||||
## File Structure
|
||||
|
||||
```
|
||||
server/
|
||||
├── conf/
|
||||
│ ├── __init__.py
|
||||
│ └── settings.py # Main settings file (FIXED for #534)
|
||||
├── logs/ # Evennia logs
|
||||
└── evennia.db3 # SQLite database (created at runtime)
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
- Gitea Issue: [timmy-home#534](https://forge.alexanderwhitestone.com/Timmy_Foundation/timmy-home/issues/534)
|
||||
- Evennia Docs: https://www.evennia.com/docs/latest/Setup/Settings-Default.html
|
||||
- World Plan: docs/BEZALEL_EVENNIA_WORLD.md
|
||||
0
evennia/bezalel_world/server/conf/__init__.py
Normal file
0
evennia/bezalel_world/server/conf/__init__.py
Normal file
87
evennia/bezalel_world/server/conf/settings.py
Normal file
87
evennia/bezalel_world/server/conf/settings.py
Normal file
@@ -0,0 +1,87 @@
|
||||
r"""
|
||||
Evennia settings file for Bezalel World.
|
||||
|
||||
This is the sovereign Evennia configuration for the Bezalel forge-and-testbed wizard.
|
||||
Reference: timmy-home#534
|
||||
|
||||
The available options are found in the default settings file found here:
|
||||
https://www.evennia.com/docs/latest/Setup/Settings-Default.html
|
||||
"""
|
||||
|
||||
# Use the defaults from Evennia unless explicitly overridden
|
||||
from evennia.settings_default import *
|
||||
|
||||
######################################################################
|
||||
# Evennia base server config
|
||||
######################################################################
|
||||
|
||||
# Server name
|
||||
SERVERNAME = "bezalel_world"
|
||||
|
||||
######################################################################
|
||||
# Network ports - FIXED for #534
|
||||
# Port tuples MUST include a host string, not None
|
||||
######################################################################
|
||||
|
||||
# Web server port (HTTP)
|
||||
WEBSERVER_PORTS = [(4001, "0.0.0.0")]
|
||||
|
||||
# Telnet server port
|
||||
TELNET_PORTS = [(4000, "0.0.0.0")]
|
||||
|
||||
# WebSocket port for webclient
|
||||
WEBSOCKET_PORTS = [(4002, "0.0.0.0")]
|
||||
|
||||
######################################################################
|
||||
# Database configuration
|
||||
# Using SQLite for sovereign local deployment
|
||||
######################################################################
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(GAME_DIR, 'server', 'evennia.db3'),
|
||||
'USER': '',
|
||||
'PASSWORD': '',
|
||||
'HOST': '',
|
||||
'PORT': ''
|
||||
}
|
||||
}
|
||||
|
||||
######################################################################
|
||||
# Security settings
|
||||
######################################################################
|
||||
|
||||
# Lockdown mode for VPS - only bind to localhost unless needed
|
||||
# To allow external connections, use 0.0.0.0 in port tuples above
|
||||
ALLOWED_HOSTS = ['*'] # VPS needs this for external access
|
||||
|
||||
######################################################################
|
||||
# Game world defaults
|
||||
######################################################################
|
||||
|
||||
# Start location for new characters
|
||||
DEFAULT_HOME = "#2" # Limbo
|
||||
|
||||
# Start location for guests
|
||||
GUEST_HOME = "#2"
|
||||
|
||||
######################################################################
|
||||
# Telnet settings
|
||||
######################################################################
|
||||
|
||||
TELNET_INTERFACES = ['0.0.0.0']
|
||||
|
||||
######################################################################
|
||||
# Web server settings
|
||||
######################################################################
|
||||
|
||||
WEBSERVER_INTERFACES = ['0.0.0.0']
|
||||
|
||||
######################################################################
|
||||
# Settings given in secret_settings.py override those in this file.
|
||||
######################################################################
|
||||
try:
|
||||
from server.conf.secret_settings import *
|
||||
except ImportError:
|
||||
print("secret_settings.py file not found or failed to import.")
|
||||
@@ -143,176 +143,66 @@ def generate_test(gap):
|
||||
lines = []
|
||||
lines.append(f" # AUTO-GENERATED -- review before merging")
|
||||
lines.append(f" # Source: {func.module_path}:{func.lineno}")
|
||||
lines.append(f" # Function: {func.qualified_name}")
|
||||
lines.append("")
|
||||
mod_imp = func.module_path.replace("/", ".").replace("-", "_").replace(".py", "")
|
||||
|
||||
# Build arguments
|
||||
call_args = []
|
||||
for a in func.args:
|
||||
if a in ("self", "cls"):
|
||||
continue
|
||||
if "path" in a or "file" in a or "dir" in a:
|
||||
call_args.append(f"{a}='/tmp/test'")
|
||||
elif "name" in a or "id" in a or "key" in a:
|
||||
call_args.append(f"{a}='test'")
|
||||
elif "message" in a or "text" in a:
|
||||
call_args.append(f"{a}='test msg'")
|
||||
elif "count" in a or "num" in a or "size" in a or "width" in a or "height" in a:
|
||||
call_args.append(f"{a}=1")
|
||||
elif "flag" in a or "enabled" in a or "verbose" in a:
|
||||
call_args.append(f"{a}=False")
|
||||
else:
|
||||
call_args.append(f"{a}=MagicMock()")
|
||||
if a in ("self", "cls"): continue
|
||||
if "path" in a or "file" in a or "dir" in a: call_args.append(f"{a}='/tmp/test'")
|
||||
elif "name" in a: call_args.append(f"{a}='test'")
|
||||
elif "id" in a or "key" in a: call_args.append(f"{a}='test_id'")
|
||||
elif "message" in a or "text" in a: call_args.append(f"{a}='test msg'")
|
||||
elif "count" in a or "num" in a or "size" in a: call_args.append(f"{a}=1")
|
||||
elif "flag" in a or "enabled" in a or "verbose" in a: call_args.append(f"{a}=False")
|
||||
else: call_args.append(f"{a}=None")
|
||||
args_str = ", ".join(call_args)
|
||||
|
||||
# Test function header
|
||||
if func.is_async:
|
||||
lines.append(" @pytest.mark.asyncio")
|
||||
lines.append(f" async def {func.test_name}(self):")
|
||||
else:
|
||||
lines.append(f" def {func.test_name}(self):")
|
||||
|
||||
lines.append(f" def {func.test_name}(self):")
|
||||
lines.append(f' """Test {func.qualified_name} -- auto-generated."""')
|
||||
|
||||
if func.class_name:
|
||||
lines.append(" try:")
|
||||
lines.append(f" try:")
|
||||
lines.append(f" from {mod_imp} import {func.class_name}")
|
||||
if func.is_private:
|
||||
lines.append(" pytest.skip('Private method')")
|
||||
lines.append(f" pytest.skip('Private method')")
|
||||
elif func.is_property:
|
||||
lines.append(f" obj = {func.class_name}()")
|
||||
lines.append(f" _ = obj.{func.name}")
|
||||
else:
|
||||
if func.raises:
|
||||
lines.append(f" with pytest.raises(({', '.join(func.raises)})):")
|
||||
if func.is_async:
|
||||
lines.append(f" await {func.class_name}().{func.name}({args_str})")
|
||||
else:
|
||||
lines.append(f" {func.class_name}().{func.name}({args_str})")
|
||||
lines.append(f" {func.class_name}().{func.name}({args_str})")
|
||||
else:
|
||||
lines.append(f" obj = {func.class_name}()")
|
||||
if func.is_async:
|
||||
lines.append(f" _ = await obj.{func.name}({args_str})")
|
||||
else:
|
||||
lines.append(f" _ = obj.{func.name}({args_str})")
|
||||
lines.append(" except ImportError:")
|
||||
lines.append(" pytest.skip('Module not importable')")
|
||||
lines.append(f" result = obj.{func.name}({args_str})")
|
||||
if func.has_return:
|
||||
lines.append(f" assert result is not None or result is None # Placeholder")
|
||||
lines.append(f" except ImportError:")
|
||||
lines.append(f" pytest.skip('Module not importable')")
|
||||
else:
|
||||
lines.append(" try:")
|
||||
lines.append(f" try:")
|
||||
lines.append(f" from {mod_imp} import {func.name}")
|
||||
if func.is_private:
|
||||
lines.append(" pytest.skip('Private function')")
|
||||
lines.append(f" pytest.skip('Private function')")
|
||||
else:
|
||||
if func.raises:
|
||||
lines.append(f" with pytest.raises(({', '.join(func.raises)})):")
|
||||
if func.is_async:
|
||||
lines.append(f" await {func.name}({args_str})")
|
||||
else:
|
||||
lines.append(f" {func.name}({args_str})")
|
||||
lines.append(f" {func.name}({args_str})")
|
||||
else:
|
||||
if func.is_async:
|
||||
lines.append(f" _ = await {func.name}({args_str})")
|
||||
else:
|
||||
lines.append(f" _ = {func.name}({args_str})")
|
||||
lines.append(" except ImportError:")
|
||||
lines.append(" pytest.skip('Module not importable')")
|
||||
|
||||
return "\n".join(lines)
|
||||
|
||||
def generate_edge_cases(gap):
|
||||
"""Generate edge case test for a function."""
|
||||
func = gap.func
|
||||
lines = []
|
||||
lines.append(f" # AUTO-GENERATED -- edge cases -- review before merging")
|
||||
lines.append(f" # Source: {func.module_path}:{func.lineno}")
|
||||
lines.append("")
|
||||
mod_imp = func.module_path.replace("/", ".").replace("-", "_").replace(".py", "")
|
||||
test_name = f"{func.test_name}_edge_cases"
|
||||
|
||||
if func.is_async:
|
||||
lines.append(" @pytest.mark.asyncio")
|
||||
lines.append(f" async def {test_name}(self):")
|
||||
else:
|
||||
lines.append(f" def {test_name}(self):")
|
||||
|
||||
lines.append(f' """Edge cases for {func.qualified_name}."""')
|
||||
|
||||
# Edge argument values
|
||||
call_args = []
|
||||
for a in func.args:
|
||||
if a in ("self", "cls"):
|
||||
continue
|
||||
if "path" in a or "file" in a or "dir" in a:
|
||||
call_args.append(f"{a}=''")
|
||||
elif "name" in a or "id" in a or "key" in a:
|
||||
call_args.append(f"{a}=''")
|
||||
elif "message" in a or "text" in a:
|
||||
call_args.append(f"{a}=''")
|
||||
elif "count" in a or "num" in a or "size" in a or "width" in a or "height" in a:
|
||||
call_args.append(f"{a}=0")
|
||||
elif "flag" in a or "enabled" in a or "verbose" in a:
|
||||
call_args.append(f"{a}=False")
|
||||
else:
|
||||
call_args.append(f"{a}=MagicMock()")
|
||||
args_str = ", ".join(call_args)
|
||||
|
||||
if func.class_name:
|
||||
lines.append(" try:")
|
||||
lines.append(f" from {mod_imp} import {func.class_name}")
|
||||
lines.append(f" obj = {func.class_name}()")
|
||||
if func.is_async:
|
||||
lines.append(f" _ = await obj.{func.name}({args_str})")
|
||||
else:
|
||||
lines.append(f" _ = obj.{func.name}({args_str})")
|
||||
lines.append(" except ImportError:")
|
||||
lines.append(" pytest.skip('Module not importable')")
|
||||
else:
|
||||
lines.append(" try:")
|
||||
lines.append(f" from {mod_imp} import {func.name}")
|
||||
if func.is_async:
|
||||
lines.append(f" _ = await {func.name}({args_str})")
|
||||
else:
|
||||
lines.append(f" _ = {func.name}({args_str})")
|
||||
lines.append(" except ImportError:")
|
||||
lines.append(" pytest.skip('Module not importable')")
|
||||
|
||||
return "\n".join(lines)
|
||||
|
||||
def generate_test_suite(gaps, max_tests=50):
|
||||
by_module = {}
|
||||
for gap in gaps[:max_tests]:
|
||||
by_module.setdefault(gap.func.module_path, []).append(gap)
|
||||
|
||||
lines = []
|
||||
lines.append('"""Auto-generated test suite -- Codebase Genome (#667).')
|
||||
lines.append("")
|
||||
lines.append("Generated by scripts/codebase_test_generator.py")
|
||||
lines.append("Coverage gaps identified from AST analysis.")
|
||||
lines.append("")
|
||||
lines.append("These tests are starting points. Review before merging.")
|
||||
lines.append('"""')
|
||||
lines.append("")
|
||||
lines.append("import pytest")
|
||||
lines.append("from unittest.mock import MagicMock, patch")
|
||||
lines.append("")
|
||||
lines.append("")
|
||||
lines.append("# AUTO-GENERATED -- DO NOT EDIT WITHOUT REVIEW")
|
||||
|
||||
for module, mgaps in sorted(by_module.items()):
|
||||
safe = module.replace("/", "_").replace(".py", "").replace("-", "_")
|
||||
cls_name = "".join(w.title() for w in safe.split("_"))
|
||||
lines.append("")
|
||||
lines.append(f"class Test{cls_name}Generated:")
|
||||
lines.append(f' """Auto-generated tests for {module}."""')
|
||||
for gap in mgaps:
|
||||
lines.append("")
|
||||
lines.append(generate_test(gap))
|
||||
lines.append(generate_edge_cases(gap))
|
||||
lines.append("")
|
||||
lines.append(f" result = {func.name}({args_str})")
|
||||
if func.has_return:
|
||||
lines.append(f" assert result is not None or result is None # Placeholder")
|
||||
lines.append(f" except ImportError:")
|
||||
lines.append(f" pytest.skip('Module not importable')")
|
||||
|
||||
return chr(10).join(lines)
|
||||
|
||||
|
||||
def generate_test_suite(gaps, max_tests=50):
|
||||
by_module = {}
|
||||
for gap in gaps[:max_tests]:
|
||||
by_module.setdefault(gap.func.module_path, []).append(gap)
|
||||
@@ -386,7 +276,7 @@ def main():
|
||||
return
|
||||
|
||||
if gaps:
|
||||
content = generate_test_suite(gaps, max_tests=args.max_tests)
|
||||
content = generate_test_suite(gaps, max_tests=args.max-tests if hasattr(args, 'max-tests') else args.max_tests)
|
||||
out = os.path.join(source_dir, args.output)
|
||||
os.makedirs(os.path.dirname(out), exist_ok=True)
|
||||
with open(out, "w") as f:
|
||||
|
||||
@@ -15,13 +15,20 @@ EVENNIA_DIR="/root/wizards/bezalel/evennia/bezalel_world"
|
||||
SETTINGS="${EVENNIA_DIR}/server/conf/settings.py"
|
||||
VENV_PYTHON="/root/wizards/bezalel/evennia/venv/bin/python3"
|
||||
VENV_EVENNIA="/root/wizards/bezalel/evennia/venv/bin/evennia"
|
||||
TIMMY_HOME="${TIMMY_HOME:-/root/timmy-home}" # Or wherever the repo is cloned
|
||||
|
||||
echo "=== Fix Evennia Settings (Bezalel) ==="
|
||||
|
||||
# 1. Fix settings.py — remove bad port tuples
|
||||
# 1. Fix settings.py — prefer repo version, fallback to sed patch
|
||||
echo "Fixing settings.py..."
|
||||
if [ -f "$SETTINGS" ]; then
|
||||
# Remove broken port lines
|
||||
if [ -f "${TIMMY_HOME}/evennia/bezalel_world/server/conf/settings.py" ]; then
|
||||
# Use the fixed settings from the repo
|
||||
mkdir -p "$(dirname "$SETTINGS")"
|
||||
cp "${TIMMY_HOME}/evennia/bezalel_world/server/conf/settings.py" "$SETTINGS"
|
||||
echo "Copied fixed settings from timmy-home repo."
|
||||
elif [ -f "$SETTINGS" ]; then
|
||||
# Fallback: patch in place
|
||||
echo "Patching existing settings..."
|
||||
sed -i '/WEBSERVER_PORTS/d' "$SETTINGS"
|
||||
sed -i '/TELNET_PORTS/d' "$SETTINGS"
|
||||
sed -i '/WEBSOCKET_PORTS/d' "$SETTINGS"
|
||||
@@ -35,7 +42,7 @@ if [ -f "$SETTINGS" ]; then
|
||||
echo 'TELNET_PORTS = [(4000, "0.0.0.0")]' >> "$SETTINGS"
|
||||
echo 'WEBSOCKET_PORTS = [(4002, "0.0.0.0")]' >> "$SETTINGS"
|
||||
|
||||
echo "Settings fixed."
|
||||
echo "Patched existing settings file."
|
||||
else
|
||||
echo "ERROR: Settings file not found at $SETTINGS"
|
||||
exit 1
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user