Build a Discussion message view dict (like DMs).
(conn, r, me: str)
| 17686 | |
| 17687 | Internal helper function. |
| 17688 | |
| 17689 | This docstring was expanded to make future maintenance easier. |
| 17690 | |
| 17691 | Args: |
| 17692 | p: Parameter. |
| 17693 | |
| 17694 | Returns: |
| 17695 | Varies. |
| 17696 | """ |
| 17697 | s = socket.socket() |
| 17698 | try: |
| 17699 | s.bind(("127.0.0.1", p)) |
| 17700 | return True |
| 17701 | except OSError: |
| 17702 | return False |
| 17703 | finally: |
| 17704 | try: |
| 17705 | s.close() |
| 17706 | except Exception: |
| 17707 | pass |
| 17708 | if _try(preferred): |
| 17709 | return preferred |
| 17710 | for p in range(5000, 9000): |
| 17711 | if _try(p): |
| 17712 | return p |
| 17713 | return 6969 |
| 17714 | |
| 17715 | def local_ip(): |
| 17716 | """local_ip. |
| 17717 | |
| 17718 | Route handler or application helper. |
| 17719 | |
| 17720 | This docstring was expanded to make future maintenance easier. |
| 17721 | |
| 17722 | Returns: |
| 17723 | Varies. |
| 17724 | """ |
| 17725 | try: |
| 17726 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) |
| 17727 | s.connect(("8.8.8.8", 80)) |
| 17728 | ip = s.getsockname()[0] |
| 17729 | s.close() |
no test coverage detected