• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hivesolutions / netius / #620889952

23 Apr 2024 08:23PM UTC coverage: 45.051%. First build
#620889952

Pull #26

travis-ci

Pull Request #26: Server support for protocols

110 of 405 new or added lines in 21 files covered. (27.16%)

7733 of 17165 relevant lines covered (45.05%)

0.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

62.5
/src/netius/servers/echo.py
1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3

4
# Hive Netius System
5
# Copyright (c) 2008-2024 Hive Solutions Lda.
6
#
7
# This file is part of Hive Netius System.
8
#
9
# Hive Netius System is free software: you can redistribute it and/or modify
10
# it under the terms of the Apache License as published by the Apache
11
# Foundation, either version 2.0 of the License, or (at your option) any
12
# later version.
13
#
14
# Hive Netius System is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# Apache License for more details.
18
#
19
# You should have received a copy of the Apache License along with
20
# Hive Netius System. If not, see <http://www.apache.org/licenses/>.
21

22
__author__ = "João Magalhães <joamag@hive.pt>"
1✔
23
""" The author(s) of the module """
24

25
__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda."
1✔
26
""" The copyright for the module """
27

28
__license__ = "Apache License, Version 2.0"
1✔
29
""" The license for the module """
30

31
import netius
1✔
32

33

34
class EchoProtocol(netius.StreamProtocol):
1✔
35

36
    def on_data(self, data):
37
        netius.StreamProtocol.on_data(self, data)
1✔
38
        self.send(data)
39

40
    def serve(self, host="127.0.0.1", port=8888, ssl=False, env=False, loop=None):
1✔
41
        loop = netius.serve_stream(
42
            lambda: self, host=host, port=port, ssl=ssl, loop=loop, env=env
1✔
43
        )
44
        return loop, self
1✔
NEW
45

×
NEW
46

×
47
class EchoServer(netius.ServerAgent):
48

1✔
49
    protocol = EchoProtocol
50

51
    @classmethod
52
    def serve_s(cls, **kwargs):
53
        protocol = cls.protocol()
54
        return protocol.serve(**kwargs)
55

NEW
56

×
57
if __name__ == "__main__":
58
    loop, _protocol = EchoServer.serve_s()
59
    loop.run_forever()
60
    loop.close()
61
else:
62
    __path__ = []
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc