/usr/lib/python2.7/dist-packages/air_modes/raw_server.py is in gr-air-modes 0.0.0.e47992d-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #
# Copyright 2010 Nick Foster
#
# This file is part of gr-air-modes
#
# gr-air-modes is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# gr-air-modes is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with gr-air-modes; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
import time, os, sys, socket
from string import split, join
from datetime import *
class raw_server:
def __init__(self, port):
self._s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._s.bind(('', port))
self._s.listen(1)
self._s.setblocking(0) #nonblocking
self._conns = [] #list of active connections
def __del__(self):
self._s.close()
def output(self, msg):
for conn in self._conns[:]: #iterate over a copy of the list
try:
conn.send(msg)
except socket.error:
self._conns.remove(conn)
print "Connections: ", len(self._conns)
def add_pending_conns(self):
try:
conn, addr = self._s.accept()
self._conns.append(conn)
print "Connections: ", len(self._conns)
except socket.error:
pass
|