Esempio n. 1
0
    def init_connection(self):
        """Initialize variables that are local to a connection, (needed if the client automatically reconnect)"""
        self.ready_lock.acquire(
            False)  # reacquire the ready-lock in case of reconnection

        self.connected = PYMUMBLE_CONN_STATE_NOT_CONNECTED
        self.control_socket = None
        self.media_socket = None  # Not implemented - for UDP media

        self.bandwidth = PYMUMBLE_BANDWIDTH  # reset the outgoing bandwidth to it's default before connectiong
        self.server_max_bandwidth = None
        self.udp_active = False

        self.users = users.Users(
            self, self.callbacks
        )  # contain the server's connected users informations
        self.channels = channels.Channels(
            self, self.callbacks)  # contain the server's channels informations
        self.blobs = blobs.Blobs(self)  # manage the blob objects
        self.sound_output = soundoutput.SoundOutput(
            self, PYMUMBLE_AUDIO_PER_PACKET,
            self.bandwidth)  # manage the outgoing sounds
        self.commands = commands.Commands(
        )  # manage commands sent between the main and the mumble threads

        self.receive_buffer = ""  # initialize the control connection input buffer
Esempio n. 2
0
def run():
    '''
    Creates the Presenter and connects it to the config and pico_log models,
    the view interface and the interactor
    '''
    presenter.Presenter(channels.Channels(), view.MeTvFrame(),
                        interactor.Interactor())
Esempio n. 3
0
import sys
import threading

import channels
import util
'''
Main function of the coordinator server

Description:
The sequencer keeps a queue of messages received from each server and broadcasts the messages
'''
if __name__ == "__main__":

    # Makes sure that the user entered a config file
    if (len(sys.argv) < 2):
        print 'Usage: python coordinator.py config_file'
        sys.exit()

    # Read server name and config from CL arguments
    name = 'Seq'
    config = util.read_key_value_file(sys.argv[1])
    channels = channels.Channels(name)
    channels.make_connections(config)

    # Instatiates the message broacaster and receive threads
    broadcast_thread = threading.Thread(
        target=lambda: channels.broadcast_message())
    broadcast_thread.start()
    recv_thread = threading.Thread(target=lambda: channels.recv_message())
    recv_thread.start()
 def get_channels(self):
     request = channels.ChannelsRequest()
     xml_channels = self.get_data_(self.GET_CHANNELS_CMD_, request.to_xml())
     if xml_channels == None or len(xml_channels) == 0:
         raise DVBLinkError(DVBLinkStatus.STATUS_INVALID_DATA)
     return channels.Channels(xml_channels)
Esempio n. 5
0
    def execute(self):
        print(self.commands)

        if self.commands[1] == "channel":
            if self.commands[2] == "create":
                if len(self.commands) > 3:
                    n = channels.Channels()
                    s = n.createLogicalChannel(self.commands[3])
                    return io.BytesIO(s.encode("utf-8"))
            if self.commands[2] == "mv":
                if len(self.commands) > 3:
                    n = channels.Channels()
                    s = n.renameLogicalChannel(self.commands[3], self.commands[4])
                    return io.BytesIO(s.encode("utf-8"))
            if self.commands[2] == "rm":
                if len(self.commands) > 3:
                    n = channels.Channels()
                    s = n.removeLogicalChannel(self.commands[3])
                    return io.BytesIO(s.encode("utf-8"))
            if self.commands[2] == "ls":
                n = channels.Channels()
                s = n.listLogicalChannel()
                return io.BytesIO(s.encode("utf-8"))
            if self.commands[2] == "ptt":
                if len(self.commands) > 3:
                    unquoted = self.commands[3].replace("'", "").replace("\"", "")
               	    n = channels.Channels()
                    s = n.getPttStatus(unquoted)
                    return io.BytesIO(s.encode("utf-8"))
            if self.commands[2] == "stream":
                if self.inputstream != None and self.commands[3] == '-l':
                    unquoted = self.commands[4].replace("'", "").replace("\"", "")
                    jailed = self.chroot.translate(unquoted)

                    # We do a soft form of semaphore lock using a file. This isn't intended to
                    # be perfectly fair but it should be atomic.
                    f = None
                    try:
                        f = os.open(jailed + ".lock", os.O_CREAT | os.O_EXCL)
                    except:
                        raise Exception("The channel is already being streamed to.")
                    finally:
                        if f is not None:
                            os.close(f)

                    n = channels.Channels()
                    try:
                        if not n.acquire(unquoted):
                            raise Exception("There is no such channel to stream to.")

                        self.upload(jailed)
                    finally:
                        time.sleep(3)
                        os.remove(jailed + ".lock")
                        n.release(unquoted)

                    return None

                if self.inputstream == None and self.commands[3] == '-r':
                    unquoted = self.commands[4].replace("'", "").replace("\"", "")
                    jailed = self.chroot.translate(unquoted)

                    return self.download(jailed)

        return None
Esempio n. 6
0
        print("startListen error", e)

    print('exiting startListen')
    f.close()


def userListener():
    input("Press Enter to exit...\n")
    print('Enter pressed ')
    channels.stopListen = True
    stopFlag.set()


if __name__ == '__main__':
    f = open('./video.avi', 'wb')
    channels = channels.Channels()
    initComm()
    sendAllPackets()
    stopFlag = Event()
    cmd = ['ffplay', '-i', '-']
    process = Popen(cmd, stdin=PIPE)
    timer = timerThread.Timer(stopFlag, resetComm, channels, 10)
    timer.start()
    stopThread = Thread(target=userListener).start()
    startListen(channels.tcpSocketVideo2)

    timer.join()
    process.kill()
    f.close()
    closeComm()
    print('finished')
Esempio n. 7
0
import trunks
# from datetime import datetime
from tornado.concurrent import run_on_executor
import concurrent.futures
import channels as channels_
import datetime
import channel_events
import psycopg2 as pg2

define("port", default=18001, help="run on the given port", type=int)
smf = Semaphore()
clients = []
ws_queue = Queue()
events_queue = Queue()
devices = channels_.Devices()
channels = channels_.Channels(ws_queue)
"""
 {'channel_number': {'caller_id_number': 
                       {'<line>/0': {''
                                    }
                     'answered': 0,
                     'rejected': 0,
                     'incoming': 0,
                     'period': (from_datetime, last_datetime) }
"""

settings = {
    "cookie_secret":
    "r3S5j6jsRE9PQMHLkSnrRi9Dpiga/CArRRIBt/ahA/18zlovBJUku7A+6S2F+WZu0Mc=",
    "login_url": "/login",
    "xsrf_cookies": True,