2015-12-07 02:40:13 +01:00
|
|
|
"""
|
|
|
|
world.py: Stores global state variables for PyLink.
|
|
|
|
"""
|
2015-08-29 04:27:38 +02:00
|
|
|
|
2015-08-29 18:39:33 +02:00
|
|
|
from collections import defaultdict
|
|
|
|
import threading
|
2015-09-19 20:51:56 +02:00
|
|
|
import subprocess
|
2015-09-29 04:12:45 +02:00
|
|
|
import os
|
2015-08-29 18:39:33 +02:00
|
|
|
|
2015-08-29 04:27:38 +02:00
|
|
|
# Global variable to indicate whether we're being ran directly, or imported
|
2015-12-25 03:24:42 +01:00
|
|
|
# for a testcase. This defaults to True.
|
2015-08-29 04:27:38 +02:00
|
|
|
testing = True
|
|
|
|
|
2015-12-25 03:24:42 +01:00
|
|
|
# Sets the default protocol module to use with tests.
|
|
|
|
testing_ircd = 'inspircd'
|
|
|
|
|
2015-09-27 19:53:25 +02:00
|
|
|
global commands, hooks
|
2015-08-29 18:39:33 +02:00
|
|
|
# This should be a mapping of command names to functions
|
2015-09-27 19:53:25 +02:00
|
|
|
commands = defaultdict(list)
|
|
|
|
hooks = defaultdict(list)
|
2015-08-29 18:39:33 +02:00
|
|
|
networkobjects = {}
|
|
|
|
schedulers = {}
|
2015-09-27 19:27:32 +02:00
|
|
|
plugins = {}
|
2015-08-29 18:39:33 +02:00
|
|
|
whois_handlers = []
|
|
|
|
started = threading.Event()
|
2015-09-19 20:51:56 +02:00
|
|
|
|
2015-11-23 05:14:47 +01:00
|
|
|
plugins_folder = os.path.join(os.getcwd(), 'plugins')
|
|
|
|
protocols_folder = os.path.join(os.getcwd(), 'protocols')
|
2015-09-29 04:12:45 +02:00
|
|
|
|
2015-09-19 20:51:56 +02:00
|
|
|
version = "<unknown>"
|
|
|
|
source = "https://github.com/GLolol/PyLink" # CHANGE THIS IF YOU'RE FORKING!!
|
|
|
|
|
|
|
|
# Only run this once.
|
|
|
|
if version == "<unknown>":
|
|
|
|
# Get version from Git tags.
|
|
|
|
try:
|
|
|
|
version = 'v' + subprocess.check_output(['git', 'describe', '--tags']).decode('utf-8').strip()
|
2015-09-19 20:55:29 +02:00
|
|
|
except Exception as e:
|
|
|
|
print('ERROR: Failed to get version from "git describe --tags": %s: %s' % (type(e).__name__, e))
|