#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys
import os
import binascii
import Ice
Ice.loadSlice('-I. --all trawlnet.ice')
import TrawlNet


class SenderI(TrawlNet.Sender):
    def __init__(self, path, fileName):
        self.path = path
        self.fileName = fileName
        self.file_ = open("./"+self.path+self.fileName, "rb")

    def receive(self, size, current=None):
        return str(binascii.b2a_base64(self.file_.read(size), newline=False))

    def close(self, current=None):
        print("Cerrando fichero " +self.fileName)
        self.file_.close()

    def destroy(self, current=None):
        try:
            print("Destruido adaptador del sender para el archivo "+self.fileName+".")
            current.adapter.remove(current.id)
        except Exception as e:
            print(e)

class SenderFactoryI(TrawlNet.SenderFactory):
    def __init__(self, path):
        self.path = path

    def create(self, fileName, current=None):
        try:
            prueba = open("./"+self.path+fileName, 'rb').readline()
        except IOError:
            print("El archivo \"" +fileName+ "\" no existe.")
            raise TrawlNet.FileDoesNotExistError("El archivo \"" +fileName+ "\" no existe.")
        else:
            servant = SenderI(self.path, fileName)
            proxy = current.adapter.addWithUUID(servant)
            return TrawlNet.SenderPrx.checkedCast(proxy)


class Server(Ice.Application):
    def run(self, argv):
        path = argv[1]
        broker = self.communicator()
        servant = SenderFactoryI(path)

        adapter = broker.createObjectAdapter("SenderFactoryAdapter")
        proxy = adapter.add(servant, broker.stringToIdentity("senderFactory1"))

        print("Servidor sender_factory desplegado.")
        adapter.activate()
        self.shutdownOnInterrupt()
        broker.waitForShutdown()

        print("Finalizado el servidor sender_factory.")

        return 0


server = Server()
sys.exit(server.main(sys.argv))

2a6ffa3810d16a6845ad903937efd40860b5e647
<mask token>


class SenderFactoryI(TrawlNet.SenderFactory):

    def __init__(self, path):
        self.path = path

    def create(self, fileName, current=None):
        try:
            prueba = open('./' + self.path + fileName, 'rb').readline()
        except IOError:
            print('El archivo "' + fileName + '" no existe.')
            raise TrawlNet.FileDoesNotExistError('El archivo "' + fileName +
                '" no existe.')
        else:
            servant = SenderI(self.path, fileName)
            proxy = current.adapter.addWithUUID(servant)
            return TrawlNet.SenderPrx.checkedCast(proxy)


class Server(Ice.Application):

    def run(self, argv):
        path = argv[1]
        broker = self.communicator()
        servant = SenderFactoryI(path)
        adapter = broker.createObjectAdapter('SenderFactoryAdapter')
        proxy = adapter.add(servant, broker.stringToIdentity('senderFactory1'))
        print('Servidor sender_factory desplegado.')
        adapter.activate()
        self.shutdownOnInterrupt()
        broker.waitForShutdown()
        print('Finalizado el servidor sender_factory.')
        return 0


<mask token>

<mask token>


class SenderI(TrawlNet.Sender):

    def __init__(self, path, fileName):
        self.path = path
        self.fileName = fileName
        self.file_ = open('./' + self.path + self.fileName, 'rb')
    <mask token>

    def close(self, current=None):
        print('Cerrando fichero ' + self.fileName)
        self.file_.close()

    def destroy(self, current=None):
        try:
            print('Destruido adaptador del sender para el archivo ' + self.
                fileName + '.')
            current.adapter.remove(current.id)
        except Exception as e:
            print(e)


class SenderFactoryI(TrawlNet.SenderFactory):

    def __init__(self, path):
        self.path = path

    def create(self, fileName, current=None):
        try:
            prueba = open('./' + self.path + fileName, 'rb').readline()
        except IOError:
            print('El archivo "' + fileName + '" no existe.')
            raise TrawlNet.FileDoesNotExistError('El archivo "' + fileName +
                '" no existe.')
        else:
            servant = SenderI(self.path, fileName)
            proxy = current.adapter.addWithUUID(servant)
            return TrawlNet.SenderPrx.checkedCast(proxy)


class Server(Ice.Application):

    def run(self, argv):
        path = argv[1]
        broker = self.communicator()
        servant = SenderFactoryI(path)
        adapter = broker.createObjectAdapter('SenderFactoryAdapter')
        proxy = adapter.add(servant, broker.stringToIdentity('senderFactory1'))
        print('Servidor sender_factory desplegado.')
        adapter.activate()
        self.shutdownOnInterrupt()
        broker.waitForShutdown()
        print('Finalizado el servidor sender_factory.')
        return 0


<mask token>

<mask token>
Ice.loadSlice('-I. --all trawlnet.ice')
<mask token>


class SenderI(TrawlNet.Sender):

    def __init__(self, path, fileName):
        self.path = path
        self.fileName = fileName
        self.file_ = open('./' + self.path + self.fileName, 'rb')

    def receive(self, size, current=None):
        return str(binascii.b2a_base64(self.file_.read(size), newline=False))

    def close(self, current=None):
        print('Cerrando fichero ' + self.fileName)
        self.file_.close()

    def destroy(self, current=None):
        try:
            print('Destruido adaptador del sender para el archivo ' + self.
                fileName + '.')
            current.adapter.remove(current.id)
        except Exception as e:
            print(e)


class SenderFactoryI(TrawlNet.SenderFactory):

    def __init__(self, path):
        self.path = path

    def create(self, fileName, current=None):
        try:
            prueba = open('./' + self.path + fileName, 'rb').readline()
        except IOError:
            print('El archivo "' + fileName + '" no existe.')
            raise TrawlNet.FileDoesNotExistError('El archivo "' + fileName +
                '" no existe.')
        else:
            servant = SenderI(self.path, fileName)
            proxy = current.adapter.addWithUUID(servant)
            return TrawlNet.SenderPrx.checkedCast(proxy)


class Server(Ice.Application):

    def run(self, argv):
        path = argv[1]
        broker = self.communicator()
        servant = SenderFactoryI(path)
        adapter = broker.createObjectAdapter('SenderFactoryAdapter')
        proxy = adapter.add(servant, broker.stringToIdentity('senderFactory1'))
        print('Servidor sender_factory desplegado.')
        adapter.activate()
        self.shutdownOnInterrupt()
        broker.waitForShutdown()
        print('Finalizado el servidor sender_factory.')
        return 0


<mask token>
sys.exit(server.main(sys.argv))

<mask token>
Ice.loadSlice('-I. --all trawlnet.ice')
<mask token>


class SenderI(TrawlNet.Sender):

    def __init__(self, path, fileName):
        self.path = path
        self.fileName = fileName
        self.file_ = open('./' + self.path + self.fileName, 'rb')

    def receive(self, size, current=None):
        return str(binascii.b2a_base64(self.file_.read(size), newline=False))

    def close(self, current=None):
        print('Cerrando fichero ' + self.fileName)
        self.file_.close()

    def destroy(self, current=None):
        try:
            print('Destruido adaptador del sender para el archivo ' + self.
                fileName + '.')
            current.adapter.remove(current.id)
        except Exception as e:
            print(e)


class SenderFactoryI(TrawlNet.SenderFactory):

    def __init__(self, path):
        self.path = path

    def create(self, fileName, current=None):
        try:
            prueba = open('./' + self.path + fileName, 'rb').readline()
        except IOError:
            print('El archivo "' + fileName + '" no existe.')
            raise TrawlNet.FileDoesNotExistError('El archivo "' + fileName +
                '" no existe.')
        else:
            servant = SenderI(self.path, fileName)
            proxy = current.adapter.addWithUUID(servant)
            return TrawlNet.SenderPrx.checkedCast(proxy)


class Server(Ice.Application):

    def run(self, argv):
        path = argv[1]
        broker = self.communicator()
        servant = SenderFactoryI(path)
        adapter = broker.createObjectAdapter('SenderFactoryAdapter')
        proxy = adapter.add(servant, broker.stringToIdentity('senderFactory1'))
        print('Servidor sender_factory desplegado.')
        adapter.activate()
        self.shutdownOnInterrupt()
        broker.waitForShutdown()
        print('Finalizado el servidor sender_factory.')
        return 0


server = Server()
sys.exit(server.main(sys.argv))

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys
import os
import binascii
import Ice
Ice.loadSlice('-I. --all trawlnet.ice')
import TrawlNet


class SenderI(TrawlNet.Sender):
    def __init__(self, path, fileName):
        self.path = path
        self.fileName = fileName
        self.file_ = open("./"+self.path+self.fileName, "rb")

    def receive(self, size, current=None):
        return str(binascii.b2a_base64(self.file_.read(size), newline=False))

    def close(self, current=None):
        print("Cerrando fichero " +self.fileName)
        self.file_.close()

    def destroy(self, current=None):
        try:
            print("Destruido adaptador del sender para el archivo "+self.fileName+".")
            current.adapter.remove(current.id)
        except Exception as e:
            print(e)

class SenderFactoryI(TrawlNet.SenderFactory):
    def __init__(self, path):
        self.path = path

    def create(self, fileName, current=None):
        try:
            prueba = open("./"+self.path+fileName, 'rb').readline()
        except IOError:
            print("El archivo \"" +fileName+ "\" no existe.")
            raise TrawlNet.FileDoesNotExistError("El archivo \"" +fileName+ "\" no existe.")
        else:
            servant = SenderI(self.path, fileName)
            proxy = current.adapter.addWithUUID(servant)
            return TrawlNet.SenderPrx.checkedCast(proxy)


class Server(Ice.Application):
    def run(self, argv):
        path = argv[1]
        broker = self.communicator()
        servant = SenderFactoryI(path)

        adapter = broker.createObjectAdapter("SenderFactoryAdapter")
        proxy = adapter.add(servant, broker.stringToIdentity("senderFactory1"))

        print("Servidor sender_factory desplegado.")
        adapter.activate()
        self.shutdownOnInterrupt()
        broker.waitForShutdown()

        print("Finalizado el servidor sender_factory.")

        return 0


server = Server()
sys.exit(server.main(sys.argv))
