예제 #1
0
            socket.sendall(direct_message)

            logging.info("Processing Connect Request finished: " +
                         message.file_name)

        else:
            self.request.sendall("Unrecognised message:\n" + self.data)

    def get_file_server_by_file_name(self, file_name):
        for file_server in self.file_servers:
            if file_server.check_file_on_server(file_name):
                return file_server
        return None


if __name__ == "__main__":
    logging.basicConfig(filename='directory-log.log', level=logging.DEBUG)

    root = logging.getLogger()
    root.setLevel(logging.DEBUG)

    ch = logging.StreamHandler(sys.stdout)
    ch.setLevel(logging.DEBUG)
    formatter = logging.Formatter(
        '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    ch.setFormatter(formatter)
    root.addHandler(ch)

    run_server(DirectoryHandler)
예제 #2
0
        abs_file_path = os.path.join(abs_directory_path, file_id)

        f = open(abs_file_path, 'w+')

        f.write(file_contents)

        bytes_size = os.path.getsize(abs_file_path)

        local_file = LocalFile(f, file_id, abs_file_path, bytes_size)

        local_file.close()

        logging.info("Storing file finished: " + file_id)


if __name__ == "__main__":
    logging.basicConfig(filename='file-log.log', level=logging.DEBUG)

    root = logging.getLogger()
    root.setLevel(logging.DEBUG)

    ch = logging.StreamHandler(sys.stdout)
    ch.setLevel(logging.DEBUG)
    formatter = logging.Formatter(
            '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    ch.setFormatter(formatter)
    root.addHandler(ch)

    run_server(FileHandler)
예제 #3
0
        abs_file_path = os.path.join(abs_directory_path, file_id)

        f = open(abs_file_path, 'w+')

        f.write(file_contents)

        bytes_size = os.path.getsize(abs_file_path)

        local_file = LocalFile(f, file_id, abs_file_path, bytes_size)

        local_file.close()

        logging.info("Storing file finished: " + file_id)


if __name__ == "__main__":
    logging.basicConfig(filename='file-log.log', level=logging.DEBUG)

    root = logging.getLogger()
    root.setLevel(logging.DEBUG)

    ch = logging.StreamHandler(sys.stdout)
    ch.setLevel(logging.DEBUG)
    formatter = logging.Formatter(
        '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    ch.setFormatter(formatter)
    root.addHandler(ch)

    run_server(FileHandler)
            socket.sendall(direct_message)

            logging.info("Processing Connect Request finished: " +
                         message.file_name)

        else:
            self.request.sendall("Unrecognised message:\n" + self.data)

    def get_file_server_by_file_name(self, file_name):
        for file_server in self.file_servers:
            if file_server.check_file_on_server(file_name):
                return file_server
        return None


if __name__ == "__main__":
    logging.basicConfig(filename='directory-log.log', level=logging.DEBUG)

    root = logging.getLogger()
    root.setLevel(logging.DEBUG)

    ch = logging.StreamHandler(sys.stdout)
    ch.setLevel(logging.DEBUG)
    formatter = logging.Formatter(
            '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    ch.setFormatter(formatter)
    root.addHandler(ch)

    run_server(DirectoryHandler)