2015-08-28 19:27:38 -07:00
|
|
|
# world.py: global state variables go here
|
|
|
|
|
2015-08-29 09:39:33 -07:00
|
|
|
from collections import defaultdict
|
|
|
|
import threading
|
2015-09-19 11:51:56 -07:00
|
|
|
import subprocess
|
2015-09-28 19:12:45 -07:00
|
|
|
import os
|
2015-08-29 09:39:33 -07:00
|
|
|
|
2015-08-28 19:27:38 -07:00
|
|
|
# Global variable to indicate whether we're being ran directly, or imported
|
|
|
|
# for a testcase.
|
|
|
|
testing = True
|
|
|
|
|
2015-09-27 10:53:25 -07:00
|
|
|
global commands, hooks
|
2015-08-29 09:39:33 -07:00
|
|
|
# This should be a mapping of command names to functions
|
2015-09-27 10:53:25 -07:00
|
|
|
commands = defaultdict(list)
|
|
|
|
hooks = defaultdict(list)
|
2015-08-29 09:39:33 -07:00
|
|
|
networkobjects = {}
|
|
|
|
schedulers = {}
|
2015-09-27 10:27:32 -07:00
|
|
|
plugins = {}
|
2015-08-29 09:39:33 -07:00
|
|
|
whois_handlers = []
|
|
|
|
started = threading.Event()
|
2015-09-19 11:51:56 -07:00
|
|
|
|
2015-11-22 20:14:47 -08:00
|
|
|
plugins_folder = os.path.join(os.getcwd(), 'plugins')
|
|
|
|
protocols_folder = os.path.join(os.getcwd(), 'protocols')
|
2015-09-28 19:12:45 -07:00
|
|
|
|
2015-09-19 11:51:56 -07: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 11:55:29 -07:00
|
|
|
except Exception as e:
|
|
|
|
print('ERROR: Failed to get version from "git describe --tags": %s: %s' % (type(e).__name__, e))
|