Here are the examples of the python api crossbar.twisted.endpoint.create_listening_endpoint_from_config taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3 Examples
0
Source : test_endpoint.py
with MIT License
from fbla-competitive-events
with MIT License
from fbla-competitive-events
def test_unix(self):
"""
A config with type = "unix" will create an endpoint for a UNIX socket
at the given path.
"""
path = os.path.join("/", "tmp", uuid4().hex)
self.addCleanup(os.remove, path)
reactor = SelectReactor()
config = {
"type": "unix",
"path": path
}
endpoint = create_listening_endpoint_from_config(config, self.cbdir, reactor, self.log)
self.assertTrue(isinstance(endpoint, UNIXServerEndpoint))
factory = Factory.forProtocol(Echo)
endpoint.listen(factory)
self.assertIn(
factory,
[getattr(x, "factory", None) for x in reactor.getReaders()])
def test_unix_already_listening(self):
0
Source : test_endpoint.py
with MIT License
from fbla-competitive-events
with MIT License
from fbla-competitive-events
def test_unix_already_listening(self):
"""
A config with type = "unix" will create an endpoint for a UNIX socket
at the given path, and delete it if required.
"""
path = os.path.join("/", "tmp", uuid4().hex)
self.addCleanup(os.remove, path)
# Something is already there
open(path, "w").close()
reactor = SelectReactor()
config = {
"type": "unix",
"path": path
}
endpoint = create_listening_endpoint_from_config(config, self.cbdir,
reactor, self.log)
self.assertTrue(isinstance(endpoint, UNIXServerEndpoint))
factory = Factory.forProtocol(Echo)
endpoint.listen(factory)
self.assertIn(
factory,
[getattr(x, "factory", None) for x in reactor.getReaders()])
def test_unix_already_listening_cant_delete(self):
0
Source : test_endpoint.py
with MIT License
from fbla-competitive-events
with MIT License
from fbla-competitive-events
def test_unix_already_listening_cant_delete(self):
"""
A config with type = "unix" will create an endpoint for a UNIX socket
at the given path, and delete it if required. If it can't delete it, it
will raise an exception.
"""
parent_fp = os.path.join("/", "tmp", uuid4().hex)
os.makedirs(parent_fp)
fp = os.path.join(parent_fp, uuid4().hex)
# Something is already there
open(fp, "w").close()
os.chmod(fp, 0o544)
os.chmod(parent_fp, 0o544)
reactor = SelectReactor()
config = {
"type": "unix",
"path": fp
}
with self.assertRaises(OSError) as e:
create_listening_endpoint_from_config(config, self.cbdir,
reactor, self.log)
self.assertEqual(e.exception.errno, 13) # Permission Denied
os.chmod(parent_fp, 0o700)
shutil.rmtree(parent_fp)
if platform.isWindows():