core package¶
Submodules¶
Module contents¶
Provides core functionality that doesn’t fit into any other package.
- classcore.AutoUnload(*args,**kwargs)[source]¶
Bases:
objectClass used to auto unload specific instances.
Each inheriting class must implement an _unload_instance method.
- core.BoostPythonClass¶
alias of
class
- classcore.ConfigFile(path,encoding='utf-8',comment_prefix='//',as_strings=False)[source]¶
Bases:
listClass used to parse a configuration file.
- classcore.GameConfigObj(infile,*args,**kwargs)[source]¶
Bases:
ConfigObjClass used to parse specific game data.
- classcore.OutputReturn¶
Bases:
enum- BLOCK=_core.OutputReturn.BLOCK¶
- CONTINUE=_core.OutputReturn.CONTINUE¶
- names={'BLOCK':_core.OutputReturn.BLOCK,'CONTINUE':_core.OutputReturn.CONTINUE}¶
- values={0:_core.OutputReturn.BLOCK,1:_core.OutputReturn.CONTINUE}¶
- classcore.Tokenize(string,comment_prefix=None)[source]¶
Bases:
listParses the arguments from the given string.
- classcore.WeakAutoUnload(*args,**kwargs)[source]¶
Bases:
AutoUnloadSubclass of AutoUnload used to store weak references to instances.
- core.check_info_output(output)[source]¶
Return whether the output of
spinfohas been modified.- Parameters:
output (str) – The output of
spinfo.- Raises:
ValueError – Raised if the checksum was not found in the output.
- Returns:
Trueif the output has been modified.- Return type:
- core.console_message((str)arg1)→None:¶
Output a message to the server console.
- core.echo_console(text)[source]¶
Echo a message to the server’s console.
Note
Unlike
console_message, this function automatically adds a newlineat the end of the message.- Parameters:
text (str) – Message to print to the console.
- core.get_core_modules()→list:¶
Return a list of all modules exposed by Source.Python’s core.
- Return type:
- core.get_interface((str)arg1,(str)arg2)→object:¶
Retrieve an interface from a library.
- core.get_public_ip()[source]¶
Return the server’s public IPv4.
- Return type:
Note
This functions makes a call to
http://api.ipify.orgto retrieve the public IP.
- core.ignore_unicode_errors(errors='ignore')[source]¶
Overwrite the
strictcodecs error handler temporarily.This is useful e.g. if the engine truncates a string, which results in astring that contains a splitted multi-byte character at the end of thestring.
- Parameters:
errors (str) – Error handler that will be looked up via
codecs.lookup_error().- Raises:
LookupError – Raised if the error handler was not found.
Example:
importmemory# Allocate four bytes to create an erroneous stringptr=memory.alloc(4)# Write data to the memory that will usually result in a# UnicodeDecodeErrorptr.set_uchar(ord('a'),0)ptr.set_uchar(ord('b'),1)ptr.set_uchar(226,2)# Add the invalid byteptr.set_uchar(0,3)# Indicate the end of the stringwithignore_unicode_errors():# Read the data as a string. Now, it will only print 'ab', because# the invalid byte has been removed/ignored.print(ptr.get_string_array())
- core.server_output(action=_core.OutputReturn.CONTINUE)[source]¶
Gather all server output sent during the execution of the with-statement.
- Parameters:
action (OutputReturn) – Determines what happens with the output.
- Return type:
- Returns:
A list that will be filled with a tuple for every line that is beinglogged. The tuple contains the severity and the message.
Example:
fromcvarsimportcvarfromcoreimportserver_outputfromcoreimportOutputReturnstatus=cvar.find_command('status')withserver_output(OutputReturn.BLOCK)asoutput:status()# Print everything that was logged by the 'status' commandprint(output)
Output:
[(_core.MessageSeverity.MESSAGE,'hostname: Counter-Strike: Global Offensive\n'),(_core.MessageSeverity.MESSAGE,'version : 1.35.8.4/13584 513/6771 secure [A:1:2435270659:8640]\n'),(_core.MessageSeverity.MESSAGE,'udp/ip : 192.168.178.60:27015 (public ip: 46.83.158.27)\n'),(_core.MessageSeverity.MESSAGE,'os : Windows\n'),(_core.MessageSeverity.MESSAGE,'type : community dedicated\n'),(_core.MessageSeverity.MESSAGE,'players : 0 humans, 0 bots (20/0 max) (hibernating)\n\n'),(_core.MessageSeverity.MESSAGE,'# userid name uniqueid connected ping loss state rate'),(_core.MessageSeverity.MESSAGE,' adr'),(_core.MessageSeverity.MESSAGE,'\n'),(_core.MessageSeverity.MESSAGE,'#end\n')]
- core.core_plugin_manager¶
The singleton object of the
_CorePluginManagerclass.
