summaryrefslogtreecommitdiff
path: root/py/demo/Manual
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2015-03-18 12:58:16 -0230
committerMatthew Newhook <matthew@zeroc.com>2015-03-18 12:58:16 -0230
commit9b7668c7c92cf9cb311fe444cdddb489cd2a219d (patch)
tree5016567c58c81f5654e9d01935e199c6bf4761d2 /py/demo/Manual
parentVS add-in & build updates: (diff)
downloadice-9b7668c7c92cf9cb311fe444cdddb489cd2a219d.tar.bz2
ice-9b7668c7c92cf9cb311fe444cdddb489cd2a219d.tar.xz
ice-9b7668c7c92cf9cb311fe444cdddb489cd2a219d.zip
Removed demos.
Moved demoscript to distribution.
Diffstat (limited to 'py/demo/Manual')
-rw-r--r--py/demo/Manual/README11
-rwxr-xr-xpy/demo/Manual/printer/Client.py38
-rw-r--r--py/demo/Manual/printer/Printer.ice20
-rw-r--r--py/demo/Manual/printer/README8
-rwxr-xr-xpy/demo/Manual/printer/Server.py41
-rwxr-xr-xpy/demo/Manual/printer/expect.py33
-rwxr-xr-xpy/demo/Manual/simple_filesystem/Client.py74
-rw-r--r--py/demo/Manual/simple_filesystem/Filesystem.ice38
-rw-r--r--py/demo/Manual/simple_filesystem/README10
-rwxr-xr-xpy/demo/Manual/simple_filesystem/Server.py147
-rwxr-xr-xpy/demo/Manual/simple_filesystem/expect.py33
11 files changed, 0 insertions, 453 deletions
diff --git a/py/demo/Manual/README b/py/demo/Manual/README
deleted file mode 100644
index 6226ad7d8a3..00000000000
--- a/py/demo/Manual/README
+++ /dev/null
@@ -1,11 +0,0 @@
-Demos in this directory:
-
-- printer
-
- An implementation of the simple printer example at the beginning of
- the manual.
-
-- simple_filesystem
-
- An implementation of the simple (non-persistent, non-life-cycle)
- version of the filesystem example.
diff --git a/py/demo/Manual/printer/Client.py b/py/demo/Manual/printer/Client.py
deleted file mode 100755
index 668baf4a61c..00000000000
--- a/py/demo/Manual/printer/Client.py
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-#
-# This copy of Ice is licensed to you under the terms described in the
-# ICE_LICENSE file included in this distribution.
-#
-# **********************************************************************
-
-import sys, traceback, Ice
-
-Ice.loadSlice('Printer.ice')
-import Demo
-
-status = 0
-ice = None
-try:
- ic = Ice.initialize(sys.argv)
- base = ic.stringToProxy("SimplePrinter:default -h localhost -p 10000")
- printer = Demo.PrinterPrx.checkedCast(base)
- if not printer:
- raise RuntimeError("Invalid proxy")
-
- printer.printString("Hello World!")
-except:
- traceback.print_exc()
- status = 1
-
-if ic:
- # Clean up
- try:
- ic.destroy()
- except:
- traceback.print_exc()
- status = 1
-
-sys.exit(status)
diff --git a/py/demo/Manual/printer/Printer.ice b/py/demo/Manual/printer/Printer.ice
deleted file mode 100644
index faa2238ac80..00000000000
--- a/py/demo/Manual/printer/Printer.ice
+++ /dev/null
@@ -1,20 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-#pragma once
-
-module Demo
-{
-
- interface Printer
- {
- void printString(string s);
- };
-
-};
diff --git a/py/demo/Manual/printer/README b/py/demo/Manual/printer/README
deleted file mode 100644
index 9c3ae7969af..00000000000
--- a/py/demo/Manual/printer/README
+++ /dev/null
@@ -1,8 +0,0 @@
-This demo implements the printer example in chapter 3 of the
-documentation. To run it, start the server in a window:
-
-$ python Server.py
-
-In a separate window, run the client:
-
-$ python Client.py
diff --git a/py/demo/Manual/printer/Server.py b/py/demo/Manual/printer/Server.py
deleted file mode 100755
index c72e3c83660..00000000000
--- a/py/demo/Manual/printer/Server.py
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-#
-# This copy of Ice is licensed to you under the terms described in the
-# ICE_LICENSE file included in this distribution.
-#
-# **********************************************************************
-
-import sys, traceback, Ice
-
-Ice.loadSlice('Printer.ice')
-import Demo
-
-class PrinterI(Demo.Printer):
- def printString(self, s, current=None):
- print(s)
-
-status = 0
-ice = None
-try:
- ic = Ice.initialize(sys.argv)
- adapter = ic.createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -h localhost -p 10000")
- object = PrinterI()
- adapter.add(object, ic.stringToIdentity("SimplePrinter"))
- adapter.activate()
- ic.waitForShutdown()
-except:
- traceback.print_exc()
- status = 1
-
-if ic:
- # Clean up
- try:
- ic.destroy()
- except:
- traceback.print_exec()
- status = 1
-
-sys.exit(status)
diff --git a/py/demo/Manual/printer/expect.py b/py/demo/Manual/printer/expect.py
deleted file mode 100755
index 5cf3c156c22..00000000000
--- a/py/demo/Manual/printer/expect.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-#
-# This copy of Ice is licensed to you under the terms described in the
-# ICE_LICENSE file included in this distribution.
-#
-# **********************************************************************
-
-import sys, os, signal
-
-path = [ ".", "..", "../..", "../../..", "../../../.." ]
-head = os.path.dirname(sys.argv[0])
-if len(head) > 0:
- path = [os.path.join(head, p) for p in path]
-path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ]
-if len(path) == 0:
- raise RuntimeError("can't find toplevel directory!")
-sys.path.append(path[0])
-from demoscript import Util
-
-server = Util.spawn('Server.py --Ice.PrintAdapterReady')
-server.expect('.* ready')
-
-sys.stdout.write("testing... ")
-sys.stdout.flush()
-client = Util.spawn('Client.py')
-client.waitTestSuccess()
-server.expect('Hello World!')
-server.kill(signal.SIGTERM)
-server.waitTestSuccess(-signal.SIGTERM)
-print("ok")
diff --git a/py/demo/Manual/simple_filesystem/Client.py b/py/demo/Manual/simple_filesystem/Client.py
deleted file mode 100755
index a718e797289..00000000000
--- a/py/demo/Manual/simple_filesystem/Client.py
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-#
-# This copy of Ice is licensed to you under the terms described in the
-# ICE_LICENSE file included in this distribution.
-#
-# **********************************************************************
-
-import sys, traceback, Ice
-
-Ice.loadSlice('Filesystem.ice')
-import Filesystem
-
-# Recursively display the contents of directory "dir"
-# in tree fashion. For files, show the contents of
-# each file. The "depth" parameter is the current
-# nesting level (for indentation).
-
-def listRecursive(dir, depth):
- indent = ''
- depth = depth + 1
- for i in range(depth):
- indent = indent + '\t'
-
- contents = dir.list()
-
- for node in contents:
- subdir = Filesystem.DirectoryPrx.checkedCast(node)
- file = Filesystem.FilePrx.uncheckedCast(node)
- sys.stdout.write(indent + node.name() + " ")
- if subdir:
- print("(directory):")
- listRecursive(subdir, depth)
- else:
- print("(file):")
- text = file.read()
- for line in text:
- print(indent + "\t" + line)
-
-status = 0
-ic = None
-try:
- # Create a communicator
- #
- ice = Ice.initialize(sys.argv)
-
- # Create a proxy to the root directory
- #
- obj = ice.stringToProxy("RootDir:default -h localhost -p 10000")
-
- # Downcast the proxy to a Directory proxy
- #
- rootDir = Filesystem.DirectoryPrx.checkedCast(obj)
-
- # Recursively list the contents of the root directory
- #
- print("Contents of root directory:")
- listRecursive(rootDir, 0)
-except:
- traceback.print_exc()
- status = 1
-
-if ic:
- # Clean up
- #
- try:
- ic.destroy()
- except:
- traceback.print_exc()
- status = 1
-
-sys.exit(status)
diff --git a/py/demo/Manual/simple_filesystem/Filesystem.ice b/py/demo/Manual/simple_filesystem/Filesystem.ice
deleted file mode 100644
index 6331f9b1fdd..00000000000
--- a/py/demo/Manual/simple_filesystem/Filesystem.ice
+++ /dev/null
@@ -1,38 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-#pragma once
-
-module Filesystem
-{
- exception GenericError
- {
- string reason;
- };
-
- interface Node
- {
- idempotent string name();
- };
-
- sequence<string> Lines;
-
- interface File extends Node
- {
- idempotent Lines read();
- idempotent void write(Lines text) throws GenericError;
- };
-
- sequence<Node*> NodeSeq;
-
- interface Directory extends Node
- {
- idempotent NodeSeq list();
- };
-};
diff --git a/py/demo/Manual/simple_filesystem/README b/py/demo/Manual/simple_filesystem/README
deleted file mode 100644
index 45194f48b4f..00000000000
--- a/py/demo/Manual/simple_filesystem/README
+++ /dev/null
@@ -1,10 +0,0 @@
-This demo implements the simple filesystem application shown at the
-end of the client and server Python mapping chapter.
-
-To run it, start the server in a window:
-
-$ python Server.py
-
-Then run the client in a separate window:
-
-$ python Client.py
diff --git a/py/demo/Manual/simple_filesystem/Server.py b/py/demo/Manual/simple_filesystem/Server.py
deleted file mode 100755
index 83297f3ab48..00000000000
--- a/py/demo/Manual/simple_filesystem/Server.py
+++ /dev/null
@@ -1,147 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-#
-# This copy of Ice is licensed to you under the terms described in the
-# ICE_LICENSE file included in this distribution.
-#
-# **********************************************************************
-
-import sys, threading, Ice
-
-Ice.loadSlice('Filesystem.ice')
-import Filesystem
-
-class DirectoryI(Filesystem.Directory):
- def __init__(self, communicator, name, parent):
- self._name = name
- self._parent = parent
- self._contents = []
-
- # Create an identity. The root directory has the fixed identity "RootDir"
- #
- self._id = Ice.Identity()
- if self._parent:
- self._id.name = Ice.generateUUID()
- else:
- self._id.name = "RootDir"
-
- # Slice Node::name() operation
-
- def name(self, current=None):
- return self._name
-
- # Slice Directory::list() operation
-
- def list(self, current=None):
- return self._contents
-
- # addChild is called by the child in order to add
- # itself to the _contents member of the parent
-
- def addChild(self, child):
- self._contents.append(child)
-
- # Add servant to ASM and Parent's _contents map.
-
- def activate(self, a):
- thisNode = Filesystem.DirectoryPrx.uncheckedCast(a.add(self, self._id))
- if self._parent:
- self._parent.addChild(thisNode)
-
-class FileI(Filesystem.File):
- def __init__(self, communicator, name, parent):
- self._name = name
- self._parent = parent
- self.lines = []
-
- assert(self._parent != None)
-
- # Create an identity
- #
- self._id = Ice.Identity()
- self._id.name = Ice.generateUUID()
-
- # Slice Node::name() operation
-
- def name(self, current=None):
- return self._name
-
- # Slice File::read() operation
-
- def read(self, current=None):
- return self._lines
-
- # Slice File::write() operation
-
- def write(self, text, current=None):
- self._lines = text
-
- # Add servant to ASM and Parent's _contents map.
-
- def activate(self, a):
- thisNode = Filesystem.FilePrx.uncheckedCast(a.add(self, self._id))
- self._parent.addChild(thisNode)
-
-
-class Server(Ice.Application):
- def run(self, args):
- # Terminate cleanly on receipt of a signal
- #
- self.shutdownOnInterrupt()
-
- # Create an object adapter
- #
- adapter = self.communicator().createObjectAdapterWithEndpoints(
- "SimpleFileSystem", "default -h localhost -p 10000")
-
- # Create the root directory (with name "/" and no parent)
- #
- root = DirectoryI(self.communicator(), "/", None)
- root.activate(adapter)
-
- # Create a file called "README" in the root directory
- #
- file = FileI(self.communicator(), "README", root)
- text = [ "This file system contains a collection of poetry." ]
- try:
- file.write(text)
- except Filesystem.GenericError as e:
- print(e.reason)
- file.activate(adapter)
-
- # Create a directory called "Coleridge" in the root directory
- #
- coleridge = DirectoryI(self.communicator(), "Coleridge", root)
- coleridge.activate(adapter)
-
- # Create a file called "Kubla_Khan" in the Coleridge directory
- #
- file = FileI(self.communicator(), "Kubla_Khan", coleridge)
- text = [ "In Xanadu did Kubla Khan",
- "A stately pleasure-dome decree:",
- "Where Alph, the sacred river, ran",
- "Through caverns measureless to man",
- "Down to a sunless sea." ]
- try:
- file.write(text)
- except Filesystem.GenericError as e:
- print(e.reason)
- file.activate(adapter)
-
- # All objects are created, allow client requests now
- #
- adapter.activate()
-
- # Wait until we are done
- #
- self.communicator().waitForShutdown()
-
- if self.interrupted():
- print(self.appName() + ": terminating")
-
- return 0
-
-app = Server()
-sys.exit(app.main(sys.argv))
diff --git a/py/demo/Manual/simple_filesystem/expect.py b/py/demo/Manual/simple_filesystem/expect.py
deleted file mode 100755
index 32419a4da26..00000000000
--- a/py/demo/Manual/simple_filesystem/expect.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
-#
-# This copy of Ice is licensed to you under the terms described in the
-# ICE_LICENSE file included in this distribution.
-#
-# **********************************************************************
-
-import sys, os, signal
-
-path = [ ".", "..", "../..", "../../..", "../../../.." ]
-head = os.path.dirname(sys.argv[0])
-if len(head) > 0:
- path = [os.path.join(head, p) for p in path]
-path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ]
-if len(path) == 0:
- raise RuntimeError("can't find toplevel directory!")
-sys.path.append(path[0])
-from demoscript import Util
-
-server = Util.spawn('Server.py --Ice.PrintAdapterReady')
-server.expect('.* ready')
-
-sys.stdout.write("testing... ")
-sys.stdout.flush()
-client = Util.spawn('Client.py')
-client.expect('Contents of root directory:\n.*Down to a sunless sea.')
-client.waitTestSuccess()
-server.kill(signal.SIGINT)
-server.waitTestSuccess()
-print("ok")