From b535c699af8cb0dada006470fe9cb4cb749585ff Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Wed, 17 May 2017 15:02:14 -0700 Subject: ICE-7442 - reorganizing Python installation --- cpp/src/Slice/Preprocessor.cpp | 6 + cpp/src/Slice/Preprocessor.h | 1 + cpp/src/Slice/Python.cpp | 209 ++- cpp/src/Slice/PythonUtil.cpp | 81 +- cpp/src/Slice/PythonUtil.h | 11 + python/BuildInstructionsWindows.md | 2 +- python/config/Make.rules | 10 +- python/config/install_dir | 2 +- python/config/zeroc-ice.pth | 1 - python/python/.gitignore | 1 - python/python/Glacier2.py | 231 --- python/python/Glacier2/__init__.py | 231 +++ python/python/Ice.py | 1923 -------------------- python/python/Ice/IceFuture.py | 48 + python/python/Ice/__init__.py | 1924 +++++++++++++++++++++ python/python/IceFuture.py | 48 - python/python/Makefile | 20 +- python/test/Slice/escape/Client.py | 2 +- python/test/Slice/import/Client.py | 2 +- python/test/Slice/macros/Client.py | 2 +- python/test/Slice/structure/Client.py | 2 +- slice/Glacier2/Metrics.ice | 2 +- slice/Glacier2/PermissionsVerifier.ice | 2 +- slice/Glacier2/PermissionsVerifierF.ice | 2 +- slice/Glacier2/Router.ice | 2 +- slice/Glacier2/RouterF.ice | 2 +- slice/Glacier2/SSLInfo.ice | 2 +- slice/Glacier2/Session.ice | 2 +- slice/Ice/BuiltinSequences.ice | 2 +- slice/Ice/Communicator.ice | 2 +- slice/Ice/CommunicatorF.ice | 2 +- slice/Ice/Connection.ice | 2 +- slice/Ice/ConnectionF.ice | 2 +- slice/Ice/Current.ice | 2 +- slice/Ice/Endpoint.ice | 2 +- slice/Ice/EndpointF.ice | 2 +- slice/Ice/EndpointTypes.ice | 2 +- slice/Ice/FacetMap.ice | 2 +- slice/Ice/Identity.ice | 2 +- slice/Ice/ImplicitContext.ice | 2 +- slice/Ice/ImplicitContextF.ice | 2 +- slice/Ice/Instrumentation.ice | 2 +- slice/Ice/InstrumentationF.ice | 2 +- slice/Ice/LocalException.ice | 2 +- slice/Ice/Locator.ice | 2 +- slice/Ice/LocatorF.ice | 2 +- slice/Ice/Logger.ice | 2 +- slice/Ice/LoggerF.ice | 2 +- slice/Ice/Metrics.ice | 2 +- slice/Ice/ObjectAdapter.ice | 2 +- slice/Ice/ObjectAdapterF.ice | 2 +- slice/Ice/ObjectFactory.ice | 2 +- slice/Ice/Plugin.ice | 2 +- slice/Ice/PluginF.ice | 2 +- slice/Ice/Process.ice | 2 +- slice/Ice/ProcessF.ice | 2 +- slice/Ice/Properties.ice | 2 +- slice/Ice/PropertiesAdmin.ice | 2 +- slice/Ice/PropertiesF.ice | 2 +- slice/Ice/RemoteLogger.ice | 2 +- slice/Ice/Router.ice | 2 +- slice/Ice/RouterF.ice | 2 +- slice/Ice/ServantLocator.ice | 2 +- slice/Ice/ServantLocatorF.ice | 2 +- slice/Ice/SliceChecksumDict.ice | 2 +- slice/Ice/ValueFactory.ice | 2 +- slice/Ice/Version.ice | 2 +- slice/IceBT/ConnectionInfo.ice | 2 +- slice/IceBT/EndpointInfo.ice | 2 +- slice/IceBT/Types.ice | 2 +- slice/IceBox/IceBox.ice | 2 +- slice/IceDiscovery/IceDiscovery.ice | 2 +- slice/IceGrid/Admin.ice | 2 +- slice/IceGrid/Descriptor.ice | 2 +- slice/IceGrid/Exception.ice | 2 +- slice/IceGrid/FileParser.ice | 2 +- slice/IceGrid/PluginFacade.ice | 2 +- slice/IceGrid/Registry.ice | 2 +- slice/IceGrid/Session.ice | 2 +- slice/IceGrid/UserAccountMapper.ice | 2 +- slice/IceLocatorDiscovery/IceLocatorDiscovery.ice | 2 +- slice/IcePatch2/FileInfo.ice | 2 +- slice/IcePatch2/FileServer.ice | 2 +- slice/IceSSL/ConnectionInfo.ice | 2 +- slice/IceSSL/ConnectionInfoF.ice | 2 +- slice/IceSSL/EndpointInfo.ice | 2 +- slice/IceStorm/IceStorm.ice | 2 +- slice/IceStorm/Metrics.ice | 2 +- 88 files changed, 2550 insertions(+), 2341 deletions(-) delete mode 100644 python/config/zeroc-ice.pth delete mode 100644 python/python/Glacier2.py create mode 100644 python/python/Glacier2/__init__.py delete mode 100644 python/python/Ice.py create mode 100644 python/python/Ice/IceFuture.py create mode 100644 python/python/Ice/__init__.py delete mode 100644 python/python/IceFuture.py diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index e275bcd3024..568bc075cf7 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -67,6 +67,12 @@ Slice::Preprocessor::~Preprocessor() close(); } +string +Slice::Preprocessor::getFileName() +{ + return _fileName; +} + string Slice::Preprocessor::getBaseName() { diff --git a/cpp/src/Slice/Preprocessor.h b/cpp/src/Slice/Preprocessor.h index 3e017723756..70ef5c2dc5b 100644 --- a/cpp/src/Slice/Preprocessor.h +++ b/cpp/src/Slice/Preprocessor.h @@ -40,6 +40,7 @@ public: const std::vector&, const std::string& = "cpp", const std::string& = ""); + std::string getFileName(); std::string getBaseName(); static std::string addQuotes(const std::string&); diff --git a/cpp/src/Slice/Python.cpp b/cpp/src/Slice/Python.cpp index d50a84059cd..4a46afd9fdb 100644 --- a/cpp/src/Slice/Python.cpp +++ b/cpp/src/Slice/Python.cpp @@ -73,6 +73,100 @@ interruptedCallback(int /*signal*/) interrupted = true; } +void +createDirectory(const string& dir) +{ + IceUtilInternal::structstat st; + if(!IceUtilInternal::stat(dir, &st)) + { + if(!(st.st_mode & S_IFDIR)) + { + ostringstream os; + os << "failed to create directory '" << dir + << "': file already exists and is not a directory"; + throw FileException(__FILE__, __LINE__, os.str()); + } + return; + } + + if(IceUtilInternal::mkdir(dir, 0777) != 0) + { + ostringstream os; + os << "cannot create directory '" << dir << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); + } +} + +// +// Starting in the directory given by output (can be empty for the CWD), create all necessary subdirectories +// in the path given by pkgdir. +// +void +createPackageDirectory(const string& output, const string& pkgdir) +{ + assert(output.empty() || IceUtilInternal::directoryExists(output)); + assert(!pkgdir.empty()); + + vector elements; + if(!IceUtilInternal::splitString(pkgdir, "/", elements)) + { + throw FileException(__FILE__, __LINE__, "invalid path in '" + pkgdir + "'"); + } + + assert(!elements.empty()); + + // + // Create all necessary subdirectories. + // + string path = output; + for(vector::iterator p = elements.begin(); p != elements.end(); ++p) + { + if(!path.empty()) + { + path += "/"; + } + path += *p; + IceUtilInternal::structstat st; + if(IceUtilInternal::stat(path, &st) < 0) + { + if(IceUtilInternal::mkdir(path, 0777) != 0) + { + ostringstream os; + os << "cannot create directory '" << path << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); + } + FileTracker::instance()->addDirectory(path); + } + else if(!(st.st_mode & S_IFDIR)) + { + ostringstream os; + os << "failed to create directory '" << path << "': file already exists and is not a directory"; + throw FileException(__FILE__, __LINE__, os.str()); + } + + // + // It's possible that the pkgdir metadata specified a directory that won't be visited by our + // PackageVisitor. We need every intermediate subdirectory to have an __init__.py file, which + // can be empty. + // + const string init = path + "/__init__.py"; + if(!IceUtilInternal::fileExists(init)) + { + // + // Create an empty file. + // + IceUtilInternal::Output out; + out.open(init.c_str()); + if(!out) + { + ostringstream os; + os << "cannot open '" << init << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); + } + FileTracker::instance()->addFile(init); + } + } +} // // For each Slice file Foo.ice we generate Foo_ice.py containing the Python @@ -114,8 +208,6 @@ private: static const char* _moduleTag; static const char* _submoduleTag; - static void createDirectory(const string&); - static void addModule(const string&, const string&, const string&); static void addSubmodule(const string&, const string&, const string&); @@ -186,32 +278,6 @@ PackageVisitor::visitModuleEnd(const ModulePtr& p) } } -void -PackageVisitor::createDirectory(const string& dir) -{ - IceUtilInternal::structstat st; - if(!IceUtilInternal::stat(dir, &st)) - { - if(!(st.st_mode & S_IFDIR)) - { - ostringstream os; - os << "failed to create package directory `" << dir - << "': file already exists and is not a directory"; - throw FileException(__FILE__, __LINE__, os.str()); - } - return; - } - - if(IceUtilInternal::mkdir(dir, 0777) != 0) - { - ostringstream os; - os << "cannot create directory `" << dir << "': " << strerror(errno); - throw FileException(__FILE__, __LINE__, os.str()); - } - - FileTracker::instance()->addDirectory(dir); -} - void PackageVisitor::addModule(const string& dir, const string& module, const string& name) { @@ -256,7 +322,7 @@ PackageVisitor::readInit(const string& dir, StringList& modules, StringList& sub if(!in) { ostringstream os; - os << "cannot open file `" << initPath << "': " << strerror(errno); + os << "cannot open file '" << initPath << "': " << strerror(errno); throw FileException(__FILE__, __LINE__, os.str()); } @@ -291,7 +357,7 @@ PackageVisitor::readInit(const string& dir, StringList& modules, StringList& sub if(s.size() < 8) { ostringstream os; - os << "invalid line `" << s << "' in `" << initPath << "'"; + os << "invalid line '" << s << "' in '" << initPath << "'"; throw os.str(); } @@ -323,14 +389,14 @@ PackageVisitor::readInit(const string& dir, StringList& modules, StringList& sub if(state != InSubmodules) { ostringstream os; - os << "invalid line `" << s << "' in `" << initPath << "'"; + os << "invalid line '" << s << "' in '" << initPath << "'"; throw os.str(); } if(s.size() < 15) { ostringstream os; - os << "invalid line `" << s << "' in `" << initPath << "'"; + os << "invalid line '" << s << "' in '" << initPath << "'"; throw os.str(); } @@ -338,10 +404,10 @@ PackageVisitor::readInit(const string& dir, StringList& modules, StringList& sub } } - if(state != InSubmodules) + if(state == InModules) { ostringstream os; - os << "invalid format in `" << initPath << "'" << endl; + os << "invalid format in '" << initPath << "'" << endl; throw os.str(); } } @@ -357,7 +423,7 @@ PackageVisitor::writeInit(const string& dir, const string& name, const StringLis if(!os) { ostringstream os; - os << "cannot open file `" << initPath << "': " << strerror(errno); + os << "cannot open file '" << initPath << "': " << strerror(errno); throw FileException(__FILE__, __LINE__, os.str()); } FileTracker::instance()->addFile(initPath); @@ -521,6 +587,12 @@ Slice::Python::compile(const vector& argv) return EXIT_FAILURE; } + if(!output.empty() && !IceUtilInternal::directoryExists(output)) + { + consoleErr << argv[0] << ": error: argument for --output-dir does not exist or is not a directory" << endl; + return EXIT_FAILURE; + } + int status = EXIT_SUCCESS; IceUtil::CtrlCHandler ctrlCHandler; @@ -626,33 +698,71 @@ Slice::Python::compile(const vector& argv) base.erase(0, pos + 1); } + // + // Check if the file contains the python:pkgdir global metadata. + // + const string pkgdir = getPackageDirectory(icecpp->getFileName(), u); + // // If --build-package is specified, we don't generate any code and simply // update the __init__.py files. // if(!buildPackage) { + string path; + if(!output.empty()) + { + path = output + '/'; // The output directory must already exist. + } + + if(!pkgdir.empty()) + { + // + // The metadata is present. It should have the form + // + // python:pkgdir:A/B/C + // + // We open the output file in the specified directory, prefixed by the + // output directory (if any). + // + createPackageDirectory(output, pkgdir); + path += pkgdir; + if(path[path.size() - 1] != '/') + { + path += "/"; // Append a separator if necessary. + } + } + else + { + // + // The file doesn't contain the python:pkgdir metadata, so we use the + // value of the --prefix option (if any). + // + path += prefix; + } + + // + // Add the file name (without the .ice extension). + // + path += base; + // // Append the suffix "_ice" to the filename in order to avoid any conflicts - // with Slice module names. For example, if the file Test.ice defines a + // with Slice module or type names. For example, if the file Test.ice defines a // Slice module named "Test", then we couldn't create a Python package named // "Test" and also call the generated file "Test.py". // - string file = prefix + base + "_ice.py"; - if(!output.empty()) - { - file = output + '/' + file; - } + path += "_ice.py"; IceUtilInternal::Output out; - out.open(file.c_str()); + out.open(path.c_str()); if(!out) { ostringstream os; - os << "cannot open`" << file << "': " << strerror(errno); + os << "cannot open '" << path << "': " << strerror(errno); throw FileException(__FILE__, __LINE__, os.str()); } - FileTracker::instance()->addFile(file); + FileTracker::instance()->addFile(path); // // Emit a Python magic comment to set the file encoding. @@ -675,7 +785,16 @@ Slice::Python::compile(const vector& argv) // if(!noPackage) { - PackageVisitor::createModules(u, prefix + base + "_ice", output); + string name; + if(!pkgdir.empty()) + { + name = getImportFileName(icecpp->getFileName(), u, vector()); + } + else + { + name = prefix + base + "_ice"; + } + PackageVisitor::createModules(u, name, output); } } catch(const Slice::FileException& ex) diff --git a/cpp/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp index ace5a9db9b1..92560601189 100644 --- a/cpp/src/Slice/PythonUtil.cpp +++ b/cpp/src/Slice/PythonUtil.cpp @@ -2850,6 +2850,78 @@ Slice::Python::CodeVisitor::writeDocstring(const OperationPtr& op, DocstringMode _out << nl << "\"\"\""; } +string +Slice::Python::getPackageDirectory(const string& file, const UnitPtr& unit) +{ + // + // file must be a fully-qualified path name. + // + + // + // Check if the file contains the python:pkgdir global metadata. + // + DefinitionContextPtr dc = unit->findDefinitionContext(file); + assert(dc); + const string prefix = "python:pkgdir:"; + string pkgdir = dc->findMetaData(prefix); + if(!pkgdir.empty()) + { + // + // The metadata is present, so the generated file was placed in the specified directory. + // + pkgdir = pkgdir.substr(prefix.size()); + assert(!pkgdir.empty()); // This situation should have been caught by MetaDataVisitor. + } + return pkgdir; +} + +string +Slice::Python::getImportFileName(const string& file, const UnitPtr& unit, const vector& includePaths) +{ + // + // The file and includePaths arguments must be fully-qualified path names. + // + + // + // Check if the file contains the python:pkgdir global metadata. + // + string pkgdir = getPackageDirectory(file, unit); + if(!pkgdir.empty()) + { + // + // The metadata is present, so the generated file was placed in the specified directory. + // + vector names; + IceUtilInternal::splitString(pkgdir, "/", names); + assert(!names.empty()); + pkgdir = ""; + for(vector::iterator p = names.begin(); p != names.end(); ++p) + { + if(p != names.begin()) + { + pkgdir += "."; + } + pkgdir += fixIdent(*p); + } + string::size_type pos = file.rfind('/'); + assert(pos != string::npos); + string name = file.substr(pos + 1); // Get the name of the file without the leading path. + assert(!name.empty()); + replace(name.begin(), name.end(), '.', '_'); // Convert .ice to _ice + return pkgdir + "." + name; + } + else + { + // + // The metadata is not present, so we transform the file name using the include paths (-I) + // given to the compiler. + // + string name = changeInclude(file, includePaths); + replace(name.begin(), name.end(), '/', '_'); + return name + "_ice"; + } +} + void Slice::Python::generate(const UnitPtr& un, bool all, bool checksum, const vector& includePaths, Output& out) @@ -2871,9 +2943,7 @@ Slice::Python::generate(const UnitPtr& un, bool all, bool checksum, const vector StringList includes = un->includeFiles(); for(StringList::const_iterator q = includes.begin(); q != includes.end(); ++q) { - string file = changeInclude(*q, paths); - replace(file.begin(), file.end(), '/', '_'); - out << nl << "import " << file << "_ice"; + out << nl << "import " << getImportFileName(*q, un, paths); } } @@ -3028,6 +3098,11 @@ Slice::Python::MetaDataVisitor::visitUnitStart(const UnitPtr& p) { continue; } + static const string pkgdirPrefix = "python:pkgdir:"; + if(s.find(pkgdirPrefix) == 0 && s.size() > pkgdirPrefix.size()) + { + continue; + } dc->warning(InvalidMetaData, file, "", "ignoring invalid global metadata `" + s + "'"); globalMetaData.remove(s); diff --git a/cpp/src/Slice/PythonUtil.h b/cpp/src/Slice/PythonUtil.h index 0b26d696e3b..d0967fce529 100644 --- a/cpp/src/Slice/PythonUtil.h +++ b/cpp/src/Slice/PythonUtil.h @@ -18,6 +18,17 @@ namespace Slice namespace Python { +// +// Get the package directory from metadata (if any). +// +std::string getPackageDirectory(const std::string&, const Slice::UnitPtr&); + +// +// Determine the name of a Python source file for use in an import statement. +// The return value does not include the .py extension. +// +std::string getImportFileName(const std::string&, const Slice::UnitPtr&, const std::vector&); + // // Generate Python code for a translation unit. // diff --git a/python/BuildInstructionsWindows.md b/python/BuildInstructionsWindows.md index e4c100ed60d..a41d1a5a091 100644 --- a/python/BuildInstructionsWindows.md +++ b/python/BuildInstructionsWindows.md @@ -36,7 +36,7 @@ can open one of: - VS2015 x64 Native Tools Command Prompt Using the first Command Prompt produces `Win32` binaries by default, while -the second Command Promt produces `x64` binaries by default. +the second Command Prompt produces `x64` binaries by default. In the Command Prompt, change to the `python` subdirectory: diff --git a/python/config/Make.rules b/python/config/Make.rules index 549a0d6f2cc..140c64e4590 100644 --- a/python/config/Make.rules +++ b/python/config/Make.rules @@ -75,11 +75,11 @@ distclean clean:: $(E) "Cleaning package $3" $(Q)$(RM) -r $2/$3/.depend $(Q)$(if $(findstring --no-package,$4),,$(RM) $2/$3/__init__.py) - $(Q)$(RM) $(patsubst $1/$3/%.ice,$2/$3_%_ice.py,$(wildcard $1/$3/*.ice)) + $(Q)$(RM) $(patsubst $1/$3/%.ice,$2/$3/%_ice.py,$(wildcard $1/$3/*.ice)) -generate-srcs srcs all:: $(patsubst $1/$3/%.ice,$2/$3_%_ice.py,$(wildcard $1/$3/*.ice)) +generate-srcs srcs all:: $(patsubst $1/$3/%.ice,$2/$3/%_ice.py,$(wildcard $1/$3/*.ice)) -$$(eval $$(call install-data-files,$(patsubst $1/$3/%.ice,$2/$3_%_ice.py,$(wildcard $1/$3/*.ice)),$2,$(install_pythondir),install)) +$$(eval $$(call install-data-files,$(patsubst $1/$3/%.ice,$2/$3/%_ice.py,$(wildcard $1/$3/*.ice)),$2,$(install_pythondir),install)) # If we also generate a package directory with an __init__.py, install it. ifeq ($(findstring --no-package,$4),) @@ -93,9 +93,9 @@ endef # define make-python-slice -$2/$3_$(or $4,%)_ice.py: $1/$3/$(or $4,%).ice $2/$3/.depend/$(or $4,%).ice.d $(slice2py_path) +$2/$3/$(or $4,%)_ice.py: $1/$3/$(or $4,%).ice $2/$3/.depend/$(or $4,%).ice.d $(slice2py_path) $(E) "Compiling $$<" $(Q)$(slice2py_path) -I$1 --output-dir $2 $5 --depend $$< > $2/$3/.depend/$(or $4,$$(*F)).ice.d - $(Q)$(slice2py_path) -I$1 --output-dir $2 --prefix $3_ --checksum $5 $$< + $(Q)$(slice2py_path) -I$1 --output-dir $2 --checksum $5 $$< endef diff --git a/python/config/install_dir b/python/config/install_dir index 30da8f10749..435ffd62ab4 100644 --- a/python/config/install_dir +++ b/python/config/install_dir @@ -33,4 +33,4 @@ except distutils.errors.DistutilsError: pass # Place the source files and the extension in a subdirectory of the installation directory. -print(os.path.join(e.install_dir, "zeroc-ice")) +print(e.install_dir) diff --git a/python/config/zeroc-ice.pth b/python/config/zeroc-ice.pth deleted file mode 100644 index 78c57de7dca..00000000000 --- a/python/config/zeroc-ice.pth +++ /dev/null @@ -1 +0,0 @@ -zeroc-ice diff --git a/python/python/.gitignore b/python/python/.gitignore index 3e3f00b9453..685ea725586 100644 --- a/python/python/.gitignore +++ b/python/python/.gitignore @@ -1,4 +1,3 @@ -Glacier2/* IceBox/* IceGrid/* IceMX/* diff --git a/python/python/Glacier2.py b/python/python/Glacier2.py deleted file mode 100644 index 3b04a4cfd75..00000000000 --- a/python/python/Glacier2.py +++ /dev/null @@ -1,231 +0,0 @@ -# ********************************************************************** -# -# Copyright (c) 2003-2017 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. -# -# ********************************************************************** - -""" -Glacier2 module -""" - -import threading, traceback, copy - -# -# Import the Python extension. -# -import Ice -Ice.updateModule("Glacier2") - -import Glacier2_Router_ice -import Glacier2_Session_ice -import Glacier2_PermissionsVerifier_ice -import Glacier2_SSLInfo_ice -import Glacier2_Metrics_ice - -class SessionNotExistException(Exception): - def __init__(self): - pass - -class RestartSessionException(Exception): - def __init__(self): - pass - -class Application(Ice.Application): - - def __init__(self, signalPolicy=0): # HandleSignals=0 - '''The constructor accepts an optional argument indicating -whether to handle signals. The value should be either -Application.HandleSignals (the default) or -Application.NoSignalHandling. -''' - - if type(self) == Application: - raise RuntimeError("Glacier2.Application is an abstract class") - - Ice.Application.__init__(self, signalPolicy) - - Application._adapter = None - Application._router = None - Application._session = None - Application._category = None - - def run(self, args): - raise RuntimeError('run should not be called on Glacier2.Application - call runWithSession instead') - - def createSession(self, args): - raise RuntimeError('createSession() not implemented') - - def runWithSession(self, args): - raise RuntimeError('runWithSession() not implemented') - - def sessionDestroyed(self): - pass - - def restart(self): - raise RestartSessionException() - restart = classmethod(restart) - - def router(self): - return Application._router - router = classmethod(router) - - def session(self): - return Application._session - session = classmethod(session) - - def categoryForClient(self): - if Application._router == None: - raise SessionNotExistException() - return Application._category - categoryForClient = classmethod(categoryForClient) - - def createCallbackIdentity(self, name): - return Ice.Identity(name, self.categoryForClient()) - createCallbackIdentity = classmethod(createCallbackIdentity) - - def addWithUUID(self, servant): - return self.objectAdapter().add(servant, self.createCallbackIdentity(Ice.generateUUID())) - addWithUUID = classmethod(addWithUUID) - - def objectAdapter(self): - if Application._router == None: - raise SessionNotExistException() - if Application._adapter == None: - Application._adapter = self.communicator().createObjectAdapterWithRouter("", Application._router) - Application._adapter.activate() - return Application._adapter - objectAdapter = classmethod(objectAdapter) - - def doMainInternal(self, args, initData): - # Reset internal state variables from Ice.Application. The - # remainder are reset at the end of this method. - Ice.Application._callbackInProgress = False - Ice.Application._destroyed = False - Ice.Application._interrupted = False - - restart = False - status = 0 - sessionCreated = False - try: - Ice.Application._communicator = Ice.initialize(args, initData) - - Application._router = RouterPrx.uncheckedCast(Ice.Application.communicator().getDefaultRouter()) - if Application._router == None: - Ice.getProcessLogger().error("no glacier2 router configured") - status = 1 - else: - # - # The default is to destroy when a signal is received. - # - if Ice.Application._signalPolicy == Ice.Application.HandleSignals: - Ice.Application.destroyOnInterrupt() - - # If createSession throws, we're done. - try: - Application._session = self.createSession() - sessionCreated = True - except Ice.LocalException: - Ice.getProcessLogger().error(traceback.format_exc()) - status = 1 - - if sessionCreated: - acmTimeout = 0 - try: - acmTimeout = Application._router.getACMTimeout() - except(Ice.OperationNotExistException): - pass - if acmTimeout <= 0: - acmTimeout = Application._router.getSessionTimeout() - if acmTimeout > 0: - connection = Application._router.ice_getCachedConnection() - assert(connection) - connection.setACM(acmTimeout, Ice.Unset, Ice.ACMHeartbeat.HeartbeatAlways) - connection.setCloseCallback(lambda conn: self.sessionDestroyed()) - Application._category = Application._router.getCategoryForClient() - status = self.runWithSession(args) - - # We want to restart on those exceptions which indicate a - # break down in communications, but not those exceptions that - # indicate a programming logic error (ie: marshal, protocol - # failure, etc). - except(RestartSessionException): - restart = True - except(Ice.ConnectionRefusedException, Ice.ConnectionLostException, Ice.UnknownLocalException, \ - Ice.RequestFailedException, Ice.TimeoutException): - Ice.getProcessLogger().error(traceback.format_exc()) - restart = True - except: - Ice.getProcessLogger().error(traceback.format_exc()) - status = 1 - - # - # Don't want any new interrupt and at this point (post-run), - # it would not make sense to release a held signal to run - # shutdown or destroy. - # - if Ice.Application._signalPolicy == Ice.Application.HandleSignals: - Ice.Application.ignoreInterrupt() - - Ice.Application._condVar.acquire() - while Ice.Application._callbackInProgress: - Ice.Application._condVar.wait() - if Ice.Application._destroyed: - Ice.Application._communicator = None - else: - Ice.Application._destroyed = True - # - # And _communicator != None, meaning will be destroyed - # next, _destroyed = True also ensures that any - # remaining callback won't do anything - # - Ice.Application._condVar.release() - - if sessionCreated and Application._router: - try: - Application._router.destroySession() - except (Ice.ConnectionLostException, SessionNotExistException): - pass - except: - Ice.getProcessLogger().error("unexpected exception when destroying the session " + \ - traceback.format_exc()) - Application._router = None - - if Ice.Application._communicator: - try: - Ice.Application._communicator.destroy() - except: - getProcessLogger().error(traceback.format_exc()) - status = 1 - - Ice.Application._communicator = None - - # Reset internal state. We cannot reset the Application state - # here, since _destroyed must remain true until we re-run - # this method. - Application._adapter = None - Application._router = None - Application._session = None - sessionCreated = False - Application._category = None - - return (restart, status) - - def doMain(self, args, initData): - # Set the default properties for all Glacier2 applications. - initData.properties.setProperty("Ice.RetryIntervals", "-1") - - restart = True - ret = 0 - while restart: - # A copy of the initialization data and the string seq - # needs to be passed to doMainInternal, as these can be - # changed by the application. - id = copy.copy(initData) - if id.properties: - id.properties = id.properties.clone() - argsCopy = args[:] - (restart, ret) = self.doMainInternal(argsCopy, initData) - return ret diff --git a/python/python/Glacier2/__init__.py b/python/python/Glacier2/__init__.py new file mode 100644 index 00000000000..6958b89a7d0 --- /dev/null +++ b/python/python/Glacier2/__init__.py @@ -0,0 +1,231 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2017 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. +# +# ********************************************************************** + +""" +Glacier2 module +""" + +import threading, traceback, copy + +# +# Import the Python extension. +# +import Ice +Ice.updateModule("Glacier2") + +import Glacier2.Router_ice +import Glacier2.Session_ice +import Glacier2.PermissionsVerifier_ice +import Glacier2.SSLInfo_ice +import Glacier2.Metrics_ice + +class SessionNotExistException(Exception): + def __init__(self): + pass + +class RestartSessionException(Exception): + def __init__(self): + pass + +class Application(Ice.Application): + + def __init__(self, signalPolicy=0): # HandleSignals=0 + '''The constructor accepts an optional argument indicating +whether to handle signals. The value should be either +Application.HandleSignals (the default) or +Application.NoSignalHandling. +''' + + if type(self) == Application: + raise RuntimeError("Glacier2.Application is an abstract class") + + Ice.Application.__init__(self, signalPolicy) + + Application._adapter = None + Application._router = None + Application._session = None + Application._category = None + + def run(self, args): + raise RuntimeError('run should not be called on Glacier2.Application - call runWithSession instead') + + def createSession(self, args): + raise RuntimeError('createSession() not implemented') + + def runWithSession(self, args): + raise RuntimeError('runWithSession() not implemented') + + def sessionDestroyed(self): + pass + + def restart(self): + raise RestartSessionException() + restart = classmethod(restart) + + def router(self): + return Application._router + router = classmethod(router) + + def session(self): + return Application._session + session = classmethod(session) + + def categoryForClient(self): + if Application._router == None: + raise SessionNotExistException() + return Application._category + categoryForClient = classmethod(categoryForClient) + + def createCallbackIdentity(self, name): + return Ice.Identity(name, self.categoryForClient()) + createCallbackIdentity = classmethod(createCallbackIdentity) + + def addWithUUID(self, servant): + return self.objectAdapter().add(servant, self.createCallbackIdentity(Ice.generateUUID())) + addWithUUID = classmethod(addWithUUID) + + def objectAdapter(self): + if Application._router == None: + raise SessionNotExistException() + if Application._adapter == None: + Application._adapter = self.communicator().createObjectAdapterWithRouter("", Application._router) + Application._adapter.activate() + return Application._adapter + objectAdapter = classmethod(objectAdapter) + + def doMainInternal(self, args, initData): + # Reset internal state variables from Ice.Application. The + # remainder are reset at the end of this method. + Ice.Application._callbackInProgress = False + Ice.Application._destroyed = False + Ice.Application._interrupted = False + + restart = False + status = 0 + sessionCreated = False + try: + Ice.Application._communicator = Ice.initialize(args, initData) + + Application._router = RouterPrx.uncheckedCast(Ice.Application.communicator().getDefaultRouter()) + if Application._router == None: + Ice.getProcessLogger().error("no glacier2 router configured") + status = 1 + else: + # + # The default is to destroy when a signal is received. + # + if Ice.Application._signalPolicy == Ice.Application.HandleSignals: + Ice.Application.destroyOnInterrupt() + + # If createSession throws, we're done. + try: + Application._session = self.createSession() + sessionCreated = True + except Ice.LocalException: + Ice.getProcessLogger().error(traceback.format_exc()) + status = 1 + + if sessionCreated: + acmTimeout = 0 + try: + acmTimeout = Application._router.getACMTimeout() + except(Ice.OperationNotExistException): + pass + if acmTimeout <= 0: + acmTimeout = Application._router.getSessionTimeout() + if acmTimeout > 0: + connection = Application._router.ice_getCachedConnection() + assert(connection) + connection.setACM(acmTimeout, Ice.Unset, Ice.ACMHeartbeat.HeartbeatAlways) + connection.setCloseCallback(lambda conn: self.sessionDestroyed()) + Application._category = Application._router.getCategoryForClient() + status = self.runWithSession(args) + + # We want to restart on those exceptions which indicate a + # break down in communications, but not those exceptions that + # indicate a programming logic error (ie: marshal, protocol + # failure, etc). + except(RestartSessionException): + restart = True + except(Ice.ConnectionRefusedException, Ice.ConnectionLostException, Ice.UnknownLocalException, \ + Ice.RequestFailedException, Ice.TimeoutException): + Ice.getProcessLogger().error(traceback.format_exc()) + restart = True + except: + Ice.getProcessLogger().error(traceback.format_exc()) + status = 1 + + # + # Don't want any new interrupt and at this point (post-run), + # it would not make sense to release a held signal to run + # shutdown or destroy. + # + if Ice.Application._signalPolicy == Ice.Application.HandleSignals: + Ice.Application.ignoreInterrupt() + + Ice.Application._condVar.acquire() + while Ice.Application._callbackInProgress: + Ice.Application._condVar.wait() + if Ice.Application._destroyed: + Ice.Application._communicator = None + else: + Ice.Application._destroyed = True + # + # And _communicator != None, meaning will be destroyed + # next, _destroyed = True also ensures that any + # remaining callback won't do anything + # + Ice.Application._condVar.release() + + if sessionCreated and Application._router: + try: + Application._router.destroySession() + except (Ice.ConnectionLostException, SessionNotExistException): + pass + except: + Ice.getProcessLogger().error("unexpected exception when destroying the session " + \ + traceback.format_exc()) + Application._router = None + + if Ice.Application._communicator: + try: + Ice.Application._communicator.destroy() + except: + getProcessLogger().error(traceback.format_exc()) + status = 1 + + Ice.Application._communicator = None + + # Reset internal state. We cannot reset the Application state + # here, since _destroyed must remain true until we re-run + # this method. + Application._adapter = None + Application._router = None + Application._session = None + sessionCreated = False + Application._category = None + + return (restart, status) + + def doMain(self, args, initData): + # Set the default properties for all Glacier2 applications. + initData.properties.setProperty("Ice.RetryIntervals", "-1") + + restart = True + ret = 0 + while restart: + # A copy of the initialization data and the string seq + # needs to be passed to doMainInternal, as these can be + # changed by the application. + id = copy.copy(initData) + if id.properties: + id.properties = id.properties.clone() + argsCopy = args[:] + (restart, ret) = self.doMainInternal(argsCopy, initData) + return ret diff --git a/python/python/Ice.py b/python/python/Ice.py deleted file mode 100644 index 96654a8fcc0..00000000000 --- a/python/python/Ice.py +++ /dev/null @@ -1,1923 +0,0 @@ -# ********************************************************************** -# -# Copyright (c) 2003-2017 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. -# -# ********************************************************************** - -""" -Ice module -""" - -import sys, string, imp, os, threading, warnings, datetime, logging, time, inspect - -# -# RTTI problems can occur in C++ code unless we modify Python's dlopen flags. -# Note that changing these flags might cause problems for other extensions -# loaded by the application (see bug 3660), so we restore the original settings -# after loading IcePy. -# -_dlopenflags = -1 -try: - _dlopenflags = sys.getdlopenflags() - - try: - import dl - sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL) - except ImportError: - # - # If the dl module is not available and we're running on a Linux - # platform, use the hard coded value of RTLD_NOW|RTLD_GLOBAL. - # - if sys.platform.startswith("linux"): - sys.setdlopenflags(258) - pass - -except AttributeError: - # - # sys.getdlopenflags() is not supported (we're probably running on Windows). - # - pass - -# -# Import the Python extension. -# -import IcePy - -# -# Restore the dlopen flags. -# -if _dlopenflags >= 0: - sys.setdlopenflags(_dlopenflags) - -# -# Give the extension an opportunity to clean up before a graceful exit. -# -import atexit -atexit.register(IcePy.cleanup) - -# -# Add some symbols to the Ice module. -# -ObjectPrx = IcePy.ObjectPrx -stringVersion = IcePy.stringVersion -intVersion = IcePy.intVersion -currentProtocol = IcePy.currentProtocol -currentProtocolEncoding = IcePy.currentProtocolEncoding -currentEncoding = IcePy.currentEncoding -stringToProtocolVersion = IcePy.stringToProtocolVersion -protocolVersionToString = IcePy.protocolVersionToString -stringToEncodingVersion = IcePy.stringToEncodingVersion -encodingVersionToString = IcePy.encodingVersionToString -generateUUID = IcePy.generateUUID -loadSlice = IcePy.loadSlice -AsyncResult = IcePy.AsyncResult -Unset = IcePy.Unset - -def Python35(): - return sys.version_info[:2] >= (3, 5) - -if Python35(): - from IceFuture import FutureBase, wrap_future -else: - FutureBase = object - -class Future(FutureBase): - def __init__(self): - self._result = None - self._exception = None - self._condition = threading.Condition() - self._doneCallbacks = [] - self._state = Future.StateRunning - - def cancel(self): - callbacks = [] - with self._condition: - if self._state == Future.StateDone: - return False - - if self._state == Future.StateCancelled: - return True - - self._state = Future.StateCancelled - callbacks = self._doneCallbacks - self._doneCallbacks = [] - self._condition.notify_all() - - self._callCallbacks(callbacks) - - return True - - def cancelled(self): - with self._condition: - return self._state == Future.StateCancelled - - def running(self): - with self._condition: - return self._state == Future.StateRunning - - def done(self): - with self._condition: - return self._state in [Future.StateCancelled, Future.StateDone] - - def add_done_callback(self, fn): - with self._condition: - if self._state == Future.StateRunning: - self._doneCallbacks.append(fn) - return - fn(self) - - def result(self, timeout=None): - with self._condition: - if not self._wait(timeout, lambda: self._state == Future.StateRunning): - raise TimeoutException() - if self._state == Future.StateCancelled: - raise InvocationCanceledException() - elif self._exception: - raise self._exception - else: - return self._result - - def exception(self, timeout=None): - with self._condition: - if not self._wait(timeout, lambda: self._state == Future.StateRunning): - raise TimeoutException() - if self._state == Future.StateCancelled: - raise InvocationCanceledException() - else: - return self._exception - - def set_result(self, result): - callbacks = [] - with self._condition: - if self._state != Future.StateRunning: - return - self._result = result - self._state = Future.StateDone - callbacks = self._doneCallbacks - self._doneCallbacks = [] - self._condition.notify_all() - - self._callCallbacks(callbacks) - - def set_exception(self, ex): - callbacks = [] - with self._condition: - if self._state != Future.StateRunning: - return - self._exception = ex - self._state = Future.StateDone - callbacks = self._doneCallbacks - self._doneCallbacks = [] - self._condition.notify_all() - - self._callCallbacks(callbacks) - - @staticmethod - def completed(result): - f = Future() - f.set_result(result) - return f - - def _wait(self, timeout, testFn=None): - # Must be called with _condition acquired - - while testFn(): - if timeout: - start = time.time() - self._condition.wait(timeout) - # Subtract the elapsed time so far from the timeout - timeout -= (time.time() - start) - if timeout <= 0: - return False - else: - self._condition.wait() - - return True - - def _callCallbacks(self, callbacks): - for callback in callbacks: - try: - callback(self) - except: - logging.getLogger("Ice.Future").exception('callback raised exception') - - StateRunning = 'running' - StateCancelled = 'cancelled' - StateDone = 'done' - -class InvocationFuture(Future): - def __init__(self, operation, asyncResult): - Future.__init__(self) - self._operation = operation - self._asyncResult = asyncResult # May be None for a batch invocation. - self._sent = False - self._sentSynchronously = False - self._sentCallbacks = [] - - def cancel(self): - if self._asyncResult: - self._asyncResult.cancel() - return Future.cancel(self) - - def add_done_callback_async(self, fn): - with self._condition: - if self._state == Future.StateRunning: - self._doneCallbacks.append(fn) - return - if self._asyncResult: - self._asyncResult.callLater(lambda: fn(self)) - else: - fn(self) - - def is_sent(self): - with self._condition: - return self._sent - - def is_sent_synchronously(self): - with self._condition: - return self._sentSynchronously - - def add_sent_callback(self, fn): - with self._condition: - if not self._sent: - self._sentCallbacks.append(fn) - return - if self._sentSynchronously or not self._asyncResult: - fn(self, self._sentSynchronously) - else: - self._asyncResult.callLater(lambda: fn(self, self._sentSynchronously)) - - def sent(self, timeout=None): - with self._condition: - if not self._wait(timeout, lambda: not self._sent): - raise TimeoutException() - if self._state == Future.StateCancelled: - raise InvocationCanceledException() - elif self._exception: - raise self._exception - else: - return self._sentSynchronously - - def set_sent(self, sentSynchronously): - callbacks = [] - with self._condition: - if self._sent: - return - - self._sent = True - self._sentSynchronously = sentSynchronously - callbacks = self._sentCallbacks - self._sentCallbacks = [] - self._condition.notify_all() - - for callback in callbacks: - try: - callback(self, sentSynchronously) - except Exception: - logging.getLogger("Ice.Future").exception('callback raised exception') - - def operation(self): - return self._operation - - def proxy(self): - return None if not self._asyncResult else self._asyncResult.getProxy() - - def connection(self): - return None if not self._asyncResult else self._asyncResult.getConnection() - - def communicator(self): - return None if not self._asyncResult else self._asyncResult.getCommunicator() - -# -# This value is used as the default value for struct types in the constructors -# of user-defined types. It allows us to determine whether the application has -# supplied a value. (See bug 3676) -# -_struct_marker = object() - -# -# Core Ice types. -# -class Value(object): - def ice_id(): - '''Obtains the type id corresponding to the most-derived Slice -interface supported by the target object. -Returns: - The type id. -''' - return '::Ice::Object' - - @staticmethod - def ice_staticId(): - '''Obtains the type id of this Slice class or interface. -Returns: - The type id. -''' - return '::Ice::Object' - - # - # Do not define these here. They will be invoked if defined by a subclass. - # - #def ice_preMarshal(self): - # pass - # - #def ice_postUnmarshal(self): - # pass - -class InterfaceByValue(Value): - - def __init__(self, id): - self.id = id - - def ice_id(self): - return self.id - -class Object(object): - def ice_isA(self, id, current=None): - '''Determines whether the target object supports the interface denoted -by the given Slice type id. -Arguments: - id The Slice type id -Returns: - True if the target object supports the interface, or false otherwise. -''' - return id in self.ice_ids(current) - - def ice_ping(self, current=None): - '''A reachability test for the target object.''' - pass - - def ice_ids(self, current=None): - '''Obtains the type ids corresponding to the Slice interface -that are supported by the target object. -Returns: - A list of type ids. -''' - return [ self.ice_id(current) ] - - def ice_id(self, current=None): - '''Obtains the type id corresponding to the most-derived Slice -interface supported by the target object. -Returns: - The type id. -''' - return '::Ice::Object' - - @staticmethod - def ice_staticId(): - '''Obtains the type id of this Slice class or interface. -Returns: - The type id. -''' - return '::Ice::Object' - - def _iceDispatch(self, cb, method, args): - # Invoke the given servant method. Exceptions can propagate to the caller. - result = method(*args) - - # Check for a future. - if isinstance(result, Future) or callable(getattr(result, "add_done_callback", None)): - def handler(future): - try: - cb.response(future.result()) - except: - cb.exception(sys.exc_info()[1]) - result.add_done_callback(handler) - elif Python35() and inspect.iscoroutine(result): # The iscoroutine() function was added in Python 3.5. - self._iceDispatchCoroutine(cb, result) - else: - cb.response(result) - - def _iceDispatchCoroutine(self, cb, coro, value=None, exception=None): - try: - if exception: - result = coro.throw(exception) - else: - result = coro.send(value) - - # Calling 'await ' will return the future. Check if we've received a future. - if isinstance(result, Future) or callable(getattr(result, "add_done_callback", None)): - def handler(future): - try: - self._iceDispatchCoroutine(cb, coro, value=future.result()) - except: - self._iceDispatchCoroutine(cb, coro, exception=sys.exc_info()[1]) - result.add_done_callback(handler) - else: - raise RuntimeError('unexpected value of type ' + str(type(result)) + ' provided by coroutine') - except StopIteration as ex: - # StopIteration is raised when the coroutine completes. - cb.response(ex.value) - except: - cb.exception(sys.exc_info()[1]) - -class Blobject(Object): - '''Special-purpose servant base class that allows a subclass to -handle synchronous Ice invocations as "blobs" of bytes.''' - - def ice_invoke(self, bytes, current): - '''Dispatch a synchronous Ice invocation. The operation's -arguments are encoded in the bytes argument. The return -value must be a tuple of two values: the first is a -boolean indicating whether the operation succeeded (True) -or raised a user exception (False), and the second is -the encoded form of the operation's results or the user -exception. -''' - pass - -class BlobjectAsync(Object): - '''Special-purpose servant base class that allows a subclass to -handle asynchronous Ice invocations as "blobs" of bytes.''' - - def ice_invoke_async(self, cb, bytes, current): - '''Dispatch an asynchronous Ice invocation. The operation's -arguments are encoded in the bytes argument. When the -dispatch is complete, the subclass can invoke either -ice_response or ice_exception on the supplied callback -object. -''' - pass - -# -# Exceptions. -# -class Exception(Exception): # Derives from built-in base 'Exception' class. - '''The base class for all Ice exceptions.''' - def __str__(self): - return self.__class__.__name__ - - def ice_name(self): - '''Returns the type name of this exception.''' - return self.ice_id()[2:] - - def ice_id(self): - '''Returns the type id of this exception.''' - return self._ice_id - -class LocalException(Exception): - '''The base class for all Ice run-time exceptions.''' - def __init__(self, args=''): - self.args = args - -class UserException(Exception): - '''The base class for all user-defined exceptions.''' - pass - -class EnumBase(object): - def __init__(self, _n, _v): - self._name = _n - self._value = _v - - def __str__(self): - return self._name - - __repr__ = __str__ - - def __hash__(self): - return self._value - - def __lt__(self, other): - if isinstance(other, self.__class__): - return self._value < other._value; - elif other == None: - return False - return NotImplemented - - def __le__(self, other): - if isinstance(other, self.__class__): - return self._value <= other._value; - elif other == None: - return False - return NotImplemented - - def __eq__(self, other): - if isinstance(other, self.__class__): - return self._value == other._value; - elif other == None: - return False - return NotImplemented - - def __ne__(self, other): - if isinstance(other, self.__class__): - return self._value != other._value; - elif other == None: - return False - return NotImplemented - - def __gt__(self, other): - if isinstance(other, self.__class__): - return self._value > other._value; - elif other == None: - return False - return NotImplemented - - def __ge__(self, other): - if isinstance(other, self.__class__): - return self._value >= other._value; - elif other == None: - return False - return NotImplemented - - def _getName(self): - return self._name - - def _getValue(self): - return self._value - - name = property(_getName) - value = property(_getValue) - -class SlicedData(object): - # - # Members: - # - # slices - tuple of SliceInfo - # - pass - -class SliceInfo(object): - # - # Members: - # - # typeId - string - # compactId - int - # bytes - string - # objects - tuple of Ice.Value - pass - -# -# Native PropertiesAdmin admin facet. -# -NativePropertiesAdmin = IcePy.NativePropertiesAdmin - -class PropertiesAdminUpdateCallback(object): - '''Callback class to get notifications of property updates passed - through the Properties admin facet''' - - def updated(self, props): - pass - -class UnknownSlicedValue(Value): - # - # Members: - # - # unknownTypeId - string - pass - -def getSliceDir(): - '''Convenience function for locating the directory containing the Slice files.''' - - # - # Detect setup.py installation in site-packages. The slice - # files live along side Ice.py - # - dir = os.path.join(os.path.dirname(__file__), "slice") - if os.path.isdir(dir): - return dir - - # - # Get the parent of the directory containing this file (Ice.py). - # - pyHome = os.path.join(os.path.dirname(__file__), "..") - - # - # For an installation from a source distribution, a binary tarball, or a - # Windows installer, the "slice" directory is a sibling of the "python" - # directory. - # - dir = os.path.join(pyHome, "slice") - if os.path.exists(dir): - return os.path.normpath(dir) - - # - # In a source distribution, the "slice" directory is one level higher. - # - dir = os.path.join(pyHome, "..", "slice") - if os.path.exists(dir): - return os.path.normpath(dir) - - if sys.platform[:5] == "linux": - # - # Check the default Linux location. - # - dir = os.path.join("/", "usr", "share", "ice", "slice") - if os.path.exists(dir): - return dir - - elif sys.platform == "darwin": - # - # Check the default macOS homebrew location. - # - dir = os.path.join("/", "usr", "local", "share", "ice", "slice") - if os.path.exists(dir): - return dir - - return None - -# -# Utilities for use by generated code. -# - -_pendingModules = {} - -def openModule(name): - global _pendingModules - if name in sys.modules: - result = sys.modules[name] - elif name in _pendingModules: - result = _pendingModules[name] - else: - result = createModule(name) - - return result - -def createModule(name): - global _pendingModules - l = name.split(".") - curr = '' - mod = None - - for s in l: - curr = curr + s - - if curr in sys.modules: - mod = sys.modules[curr] - elif curr in _pendingModules: - mod = _pendingModules[curr] - else: - nmod = imp.new_module(curr) - _pendingModules[curr] = nmod - mod = nmod - - curr = curr + "." - - return mod - -def updateModule(name): - global _pendingModules - if name in _pendingModules: - pendingModule = _pendingModules[name] - mod = sys.modules[name] - mod.__dict__.update(pendingModule.__dict__) - del _pendingModules[name] - -def updateModules(): - global _pendingModules - for name in _pendingModules.keys(): - if name in sys.modules: - sys.modules[name].__dict__.update(_pendingModules[name].__dict__) - else: - sys.modules[name] = _pendingModules[name] - _pendingModules = {} - -def createTempClass(): - class __temp: pass - return __temp - -class FormatType(object): - def __init__(self, val): - assert(val >= 0 and val < 3) - self.value = val - -FormatType.DefaultFormat = FormatType(0) -FormatType.CompactFormat = FormatType(1) -FormatType.SlicedFormat = FormatType(2) - -# -# Forward declarations. -# -IcePy._t_Object = IcePy.declareClass('::Ice::Object') -IcePy._t_Value = IcePy.declareValue('::Ice::Object') -IcePy._t_ObjectPrx = IcePy.declareProxy('::Ice::Object') -IcePy._t_LocalObject = IcePy.declareClass('::Ice::LocalObject') - -# -# Sequence mappings. -# -IcePy.SEQ_DEFAULT = 0 -IcePy.SEQ_TUPLE = 1 -IcePy.SEQ_LIST = 2 -#IcePy.SEQ_ARRAY = 3 - -# -# Slice checksum dictionary. -# -sliceChecksums = {} - -# -# Import generated Ice modules. -# -import Ice_BuiltinSequences_ice -import Ice_Current_ice -import Ice_Communicator_ice -import Ice_ImplicitContext_ice -import Ice_Endpoint_ice -import Ice_EndpointTypes_ice -import Ice_Identity_ice -import Ice_LocalException_ice -import Ice_Locator_ice -import Ice_Logger_ice -import Ice_ObjectAdapter_ice -import Ice_ObjectFactory_ice -import Ice_ValueFactory_ice -import Ice_Process_ice -import Ice_Properties_ice -import Ice_RemoteLogger_ice -import Ice_Router_ice -import Ice_ServantLocator_ice -import Ice_Connection_ice -import Ice_Version_ice -import Ice_Instrumentation_ice -import Ice_Metrics_ice - -# -# Replace EndpointInfo with our implementation. -# -del EndpointInfo -EndpointInfo = IcePy.EndpointInfo -del IPEndpointInfo -IPEndpointInfo = IcePy.IPEndpointInfo -del TCPEndpointInfo -TCPEndpointInfo = IcePy.TCPEndpointInfo -del UDPEndpointInfo -UDPEndpointInfo = IcePy.UDPEndpointInfo -del WSEndpointInfo -WSEndpointInfo = IcePy.WSEndpointInfo -del OpaqueEndpointInfo -OpaqueEndpointInfo = IcePy.OpaqueEndpointInfo - -SSLEndpointInfo = IcePy.SSLEndpointInfo - -# -# Replace ConnectionInfo with our implementation. -# -del ConnectionInfo -ConnectionInfo = IcePy.ConnectionInfo -del IPConnectionInfo -IPConnectionInfo = IcePy.IPConnectionInfo -del TCPConnectionInfo -TCPConnectionInfo = IcePy.TCPConnectionInfo -del UDPConnectionInfo -UDPConnectionInfo = IcePy.UDPConnectionInfo -del WSConnectionInfo -WSConnectionInfo = IcePy.WSConnectionInfo - -SSLConnectionInfo = IcePy.SSLConnectionInfo - -class ThreadNotification(object): - '''Base class for thread notification callbacks. A subclass must -define the start and stop methods.''' - - def __init__(self): - pass - - def start(): - '''Invoked in the context of a thread created by the Ice run time.''' - pass - - def stop(): - '''Invoked in the context of an Ice run-time thread that is about -to terminate.''' - pass - -class BatchRequest(object): - '''Base class for batch request interceptor. A subclass must -define the enqueue method.''' - def __init__(self, size, operation, proxy): - self._size = size - self._operation = operation - self._proxy = proxy - - def getSize(): - return self._size - - def getOperation(): - return self._operation - - def getProxy(): - return self._proxy - - def enqueue(): - '''Call enqueue from the batch request interceptor enqueue -implementation to confirm the batching a this request.''' - pass - -class BatchRequestInterceptor(object): - '''Base class for batch request interceptor. A subclass must -define the enqueue method.''' - - def __init__(self): - pass - - def enqueue(request, queueCount, queueSize): - '''Invoked when a request is batched.''' - pass - -# -# Initialization data. -# -class InitializationData(object): - '''The attributes of this class are used to initialize a new -communicator instance. The supported attributes are as follows: - -properties: An instance of Ice.Properties. You can use the - Ice.createProperties function to create a new property set. - -logger: An instance of Ice.Logger. - -threadStart: A callable that is invoked for each new Ice thread that is started. - -threadStop: A callable that is invoked when an Ice thread is stopped. - -dispatcher: A callable that is invoked when Ice needs to dispatch an activity. The callable - receives two arguments: a callable and an Ice.Connection object. The dispatcher must - eventually invoke the callable with no arguments. - -batchRequestInterceptor: A callable that will be invoked when a batch request is queued. - The callable receives three arguments: a BatchRequest object, an integer representing - the number of requests in the queue, and an integer representing the number of bytes - consumed by the requests in the queue. The interceptor must eventually invoke the - enqueue method on the BatchRequest object. - -valueFactoryManager: An object that implements ValueFactoryManager. -''' - def __init__(self): - self.properties = None - self.logger = None - self.threadHook = None # Deprecated. - self.threadStart = None - self.threadStop = None - self.dispatcher = None - self.batchRequestInterceptor = None - self.valueFactoryManager = None - -# -# Communicator wrapper. -# -class CommunicatorI(Communicator): - def __init__(self, impl): - self._impl = impl - impl._setWrapper(self) - - def __enter__(self): - return self - - def __exit__(self, type, value, traceback): - self._impl.destroy() - - def getImpl(self): - return self._impl - - def destroy(self): - self._impl.destroy() - - def shutdown(self): - self._impl.shutdown() - - def waitForShutdown(self): - # - # If invoked by the main thread, waitForShutdown only blocks for - # the specified timeout in order to give us a chance to handle - # signals. - # - while not self._impl.waitForShutdown(500): - pass - - def isShutdown(self): - return self._impl.isShutdown() - - def stringToProxy(self, str): - return self._impl.stringToProxy(str) - - def proxyToString(self, obj): - return self._impl.proxyToString(obj) - - def propertyToProxy(self, str): - return self._impl.propertyToProxy(str) - - def proxyToProperty(self, obj, str): - return self._impl.proxyToProperty(obj, str) - - def stringToIdentity(self, str): - return self._impl.stringToIdentity(str) - - def identityToString(self, ident): - return self._impl.identityToString(ident) - - def createObjectAdapter(self, name): - adapter = self._impl.createObjectAdapter(name) - return ObjectAdapterI(adapter) - - def createObjectAdapterWithEndpoints(self, name, endpoints): - adapter = self._impl.createObjectAdapterWithEndpoints(name, endpoints) - return ObjectAdapterI(adapter) - - def createObjectAdapterWithRouter(self, name, router): - adapter = self._impl.createObjectAdapterWithRouter(name, router) - return ObjectAdapterI(adapter) - - def addObjectFactory(self, factory, id): - # The extension implementation requires an extra argument that is a value factory - self._impl.addObjectFactory(factory, id, lambda s, factory=factory: factory.create(s)) - - def findObjectFactory(self, id): - return self._impl.findObjectFactory(id) - - def getValueFactoryManager(self): - return self._impl.getValueFactoryManager() - - def getImplicitContext(self): - context = self._impl.getImplicitContext() - if context == None: - return None; - else: - return ImplicitContextI(context) - - def getProperties(self): - properties = self._impl.getProperties() - return PropertiesI(properties) - - def getLogger(self): - logger = self._impl.getLogger() - if isinstance(logger, Logger): - return logger - else: - return LoggerI(logger) - - def getStats(self): - raise RuntimeError("operation `getStats' not implemented") - - def getDefaultRouter(self): - return self._impl.getDefaultRouter() - - def setDefaultRouter(self, rtr): - self._impl.setDefaultRouter(rtr) - - def getDefaultLocator(self): - return self._impl.getDefaultLocator() - - def setDefaultLocator(self, loc): - self._impl.setDefaultLocator(loc) - - def getPluginManager(self): - raise RuntimeError("operation `getPluginManager' not implemented") - - def flushBatchRequests(self, compress): - self._impl.flushBatchRequests(compress) - - def flushBatchRequestsAsync(self, compress): - return self._impl.flushBatchRequestsAsync(compress) - - def begin_flushBatchRequests(self, compress, _ex=None, _sent=None): - return self._impl.begin_flushBatchRequests(compress, _ex, _sent) - - def end_flushBatchRequests(self, r): - return self._impl.end_flushBatchRequests(r) - - def createAdmin(self, adminAdapter, adminIdentity): - return self._impl.createAdmin(adminAdapter, adminIdentity) - - def getAdmin(self): - return self._impl.getAdmin() - - def addAdminFacet(self, servant, facet): - self._impl.addAdminFacet(servant, facet) - - def findAdminFacet(self, facet): - return self._impl.findAdminFacet(facet) - - def findAllAdminFacets(self): - return self._impl.findAllAdminFacets() - - def removeAdminFacet(self, facet): - return self._impl.removeAdminFacet(facet) - -# -# Ice.initialize() -# -def initialize(args=None, data=None): - '''Initializes a new communicator. The optional arguments represent -an argument list (such as sys.argv) and an instance of InitializationData. -You can invoke this function as follows: - -Ice.initialize() -Ice.initialize(args) -Ice.initialize(data) -Ice.initialize(args, data) - -If you supply an argument list, the function removes those arguments from -the list that were recognized by the Ice run time. -''' - communicator = IcePy.Communicator(args, data) - return CommunicatorI(communicator) - -# -# Ice.identityToString -# -def identityToString(id, toStringMode=None): - return IcePy.identityToString(id, toStringMode) - -# -# Ice.stringToIdentity -# -def stringToIdentity(str): - return IcePy.stringToIdentity(str) - -# -# ObjectAdapter wrapper. -# -class ObjectAdapterI(ObjectAdapter): - def __init__(self, impl): - self._impl = impl - - def getName(self): - return self._impl.getName() - - def getCommunicator(self): - communicator = self._impl.getCommunicator() - return communicator._getWrapper() - - def activate(self): - self._impl.activate() - - def hold(self): - self._impl.hold() - - def waitForHold(self): - # - # If invoked by the main thread, waitForHold only blocks for - # the specified timeout in order to give us a chance to handle - # signals. - # - while not self._impl.waitForHold(1000): - pass - - def deactivate(self): - self._impl.deactivate() - - def waitForDeactivate(self): - # - # If invoked by the main thread, waitForDeactivate only blocks for - # the specified timeout in order to give us a chance to handle - # signals. - # - while not self._impl.waitForDeactivate(1000): - pass - - def isDeactivated(self): - self._impl.isDeactivated() - - def destroy(self): - self._impl.destroy() - - def add(self, servant, id): - return self._impl.add(servant, id) - - def addFacet(self, servant, id, facet): - return self._impl.addFacet(servant, id, facet) - - def addWithUUID(self, servant): - return self._impl.addWithUUID(servant) - - def addFacetWithUUID(self, servant, facet): - return self._impl.addFacetWIthUUID(servant, facet) - - def addDefaultServant(self, servant, category): - self._impl.addDefaultServant(servant, category) - - def remove(self, id): - return self._impl.remove(id) - - def removeFacet(self, id, facet): - return self._impl.removeFacet(id, facet) - - def removeAllFacets(self, id): - return self._impl.removeAllFacets(id) - - def removeDefaultServant(self, category): - return self._impl.removeDefaultServant(category) - - def find(self, id): - return self._impl.find(id) - - def findFacet(self, id, facet): - return self._impl.findFacet(id, facet) - - def findAllFacets(self, id): - return self._impl.findAllFacets(id) - - def findByProxy(self, proxy): - return self._impl.findByProxy(proxy) - - def findDefaultServant(self, category): - return self._impl.findDefaultServant(category) - - def addServantLocator(self, locator, category): - self._impl.addServantLocator(locator, category) - - def removeServantLocator(self, category): - return self._impl.removeServantLocator(category) - - def findServantLocator(self, category): - return self._impl.findServantLocator(category) - - def createProxy(self, id): - return self._impl.createProxy(id) - - def createDirectProxy(self, id): - return self._impl.createDirectProxy(id) - - def createIndirectProxy(self, id): - return self._impl.createIndirectProxy(id) - - def createReverseProxy(self, id): - return self._impl.createReverseProxy(id) - - def setLocator(self, loc): - self._impl.setLocator(loc) - - def getLocator(self): - return self._impl.getLocator() - - def getEndpoints(self): - return self._impl.getEndpoints() - - def refreshPublishedEndpoints(self): - self._impl.refreshPublishedEndpoints() - - def getPublishedEndpoints(self): - return self._impl.getPublishedEndpoints() - - def setPublishedEndpoints(self, newEndpoints): - self._impl.setPublishedEndpoints(newEndpoints) - -# -# Logger wrapper. -# -class LoggerI(Logger): - def __init__(self, impl): - self._impl = impl - - def _print(self, message): - return self._impl._print(message) - - def trace(self, category, message): - return self._impl.trace(category, message) - - def warning(self, message): - return self._impl.warning(message) - - def error(self, message): - return self._impl.error(message) - - def getPrefix(self): - return self._impl.getPrefix() - - def cloneWithPrefix(self, prefix): - logger = self._impl.cloneWithPrefix(prefix) - return LoggerI(logger) - -# -# Properties wrapper. -# -class PropertiesI(Properties): - def __init__(self, impl): - self._impl = impl - - def getProperty(self, key): - return self._impl.getProperty(key) - - def getPropertyWithDefault(self, key, value): - return self._impl.getPropertyWithDefault(key, value) - - def getPropertyAsInt(self, key): - return self._impl.getPropertyAsInt(key) - - def getPropertyAsIntWithDefault(self, key, value): - return self._impl.getPropertyAsIntWithDefault(key, value) - - def getPropertyAsList(self, key): - return self._impl.getPropertyAsList(key) - - def getPropertyAsListWithDefault(self, key, value): - return self._impl.getPropertyAsListWithDefault(key, value) - - def getPropertiesForPrefix(self, prefix): - return self._impl.getPropertiesForPrefix(prefix) - - def setProperty(self, key, value): - self._impl.setProperty(key, value) - - def getCommandLineOptions(self): - return self._impl.getCommandLineOptions() - - def parseCommandLineOptions(self, prefix, options): - return self._impl.parseCommandLineOptions(prefix, options) - - def parseIceCommandLineOptions(self, options): - return self._impl.parseIceCommandLineOptions(options) - - def load(self, file): - self._impl.load(file) - - def clone(self): - properties = self._impl.clone() - return PropertiesI(properties) - - def __iter__(self): - dict = self._impl.getPropertiesForPrefix('') - return iter(dict) - - def __str__(self): - return str(self._impl) - -# -# Ice.createProperties() -# -def createProperties(args=None, defaults=None): - '''Creates a new property set. The optional arguments represent -an argument list (such as sys.argv) and a property set that supplies -default values. You can invoke this function as follows: - -Ice.createProperties() -Ice.createProperties(args) -Ice.createProperties(defaults) -Ice.createProperties(args, defaults) - -If you supply an argument list, the function removes those arguments -from the list that were recognized by the Ice run time. -''' - - properties = IcePy.createProperties(args, defaults) - return PropertiesI(properties) - -# -# Ice.getProcessLogger() -# Ice.setProcessLogger() -# -def getProcessLogger(): - '''Returns the default logger object.''' - logger = IcePy.getProcessLogger() - if isinstance(logger, Logger): - return logger - else: - return LoggerI(logger) - -def setProcessLogger(logger): - '''Sets the default logger object.''' - IcePy.setProcessLogger(logger) - -# -# ImplicitContext wrapper -# -class ImplicitContextI(ImplicitContext): - def __init__(self, impl): - self._impl = impl - - def setContext(self, ctx): - self._impl.setContext(ctx) - - def getContext(self): - return self._impl.getContext() - - def containsKey(self, key): - return self._impl.containsKey(key) - - def get(self, key): - return self._impl.get(key) - - def put(self, key, value): - return self._impl.put(key, value) - - def remove(self, key): - return self._impl.remove(key) - - -# -# Its not possible to block in a python signal handler since this -# blocks the main thread from doing further work. As such we queue the -# signal with a worker thread which then "dispatches" the signal to -# the registered callback object. -# -# Note the interface is the same as the C++ CtrlCHandler -# implementation, however, the implementation is different. -# -class CtrlCHandler(threading.Thread): - # Class variable referring to the one and only handler for use - # from the signal handling callback. - _self = None - - def __init__(self): - threading.Thread.__init__(self) - - if CtrlCHandler._self != None: - raise RuntimeError("Only a single instance of a CtrlCHandler can be instantiated.") - CtrlCHandler._self = self - - # State variables. These are not class static variables. - self._condVar = threading.Condition() - self._queue = [] - self._done = False - self._callback = None - - # - # Setup and install signal handlers - # - if 'SIGHUP' in signal.__dict__: - signal.signal(signal.SIGHUP, CtrlCHandler.signalHandler) - if 'SIGBREAK' in signal.__dict__: - signal.signal(signal.SIGBREAK, CtrlCHandler.signalHandler) - signal.signal(signal.SIGINT, CtrlCHandler.signalHandler) - signal.signal(signal.SIGTERM, CtrlCHandler.signalHandler) - - # Start the thread once everything else is done. - self.start() - - # Dequeue and dispatch signals. - def run(self): - while True: - self._condVar.acquire() - while len(self._queue) == 0 and not self._done: - self._condVar.wait() - if self._done: - self._condVar.release() - break - sig, callback = self._queue.pop() - self._condVar.release() - if callback: - callback(sig) - - # Destroy the object. Wait for the thread to terminate and cleanup - # the internal state. - def destroy(self): - self._condVar.acquire() - self._done = True - self._condVar.notify() - self._condVar.release() - - # Wait for the thread to terminate - self.join() - # - # Cleanup any state set by the CtrlCHandler. - # - if 'SIGHUP' in signal.__dict__: - signal.signal(signal.SIGHUP, signal.SIG_DFL) - if 'SIGBREAK' in signal.__dict__: - signal.signal(signal.SIGBREAK, signal.SIG_DFL) - signal.signal(signal.SIGINT, signal.SIG_DFL) - signal.signal(signal.SIGTERM, signal.SIG_DFL) - CtrlCHandler._self = None - - def setCallback(self, callback): - self._condVar.acquire() - self._callback = callback - self._condVar.release() - - def getCallback(self): - self._condVar.acquire() - callback = self._callback - self._condVar.release() - return callback - - # Private. Only called by the signal handling mechanism. - def signalHandler(self, sig, frame): - self._self._condVar.acquire() - # - # The signal AND the current callback are queued together. - # - self._self._queue.append([sig, self._self._callback]) - self._self._condVar.notify() - self._self._condVar.release() - signalHandler = classmethod(signalHandler) - -# -# Application logger. -# -class _ApplicationLoggerI(Logger): - def __init__(self, prefix): - if len(prefix) > 0: - self._prefix = prefix + ": " - else: - self._prefix = "" - self._outputMutex = threading.Lock() - - def _print(self, message): - s = "[ " + str(datetime.datetime.now()) + " " + self._prefix - self._outputMutex.acquire() - sys.stderr.write(message + "\n") - self._outputMutex.release() - - def trace(self, category, message): - s = "[ " + str(datetime.datetime.now()) + " " + self._prefix - if len(category) > 0: - s += category + ": " - s += message + " ]" - - s = s.replace("\n", "\n ") - - self._outputMutex.acquire() - sys.stderr.write(s + "\n") - self._outputMutex.release() - - def warning(self, message): - self._outputMutex.acquire() - sys.stderr.write(str(datetime.datetime.now()) + " " + self._prefix + "warning: " + message + "\n") - self._outputMutex.release() - - def error(self, message): - self._outputMutex.acquire() - sys.stderr.write(str(datetime.datetime.now()) + " " + self._prefix + "error: " + message + "\n") - self._outputMutex.release() - -# -# Application class. -# -import signal, traceback -class Application(object): - '''Convenience class that initializes a communicator and reacts -gracefully to signals. An application must define a subclass -of this class and supply an implementation of the run method. -''' - - def __init__(self, signalPolicy=0): # HandleSignals=0 - '''The constructor accepts an optional argument indicating -whether to handle signals. The value should be either -Application.HandleSignals (the default) or -Application.NoSignalHandling. -''' - if type(self) == Application: - raise RuntimeError("Ice.Application is an abstract class") - Application._signalPolicy = signalPolicy - - def main(self, args, configFile=None, initData=None): - '''The main entry point for the Application class. The arguments -are an argument list (such as sys.argv), the name of an Ice -configuration file (optional), and an instance of -InitializationData (optional). This method does not return -until after the completion of the run method. The return -value is an integer representing the exit status. -''' - - if Application._communicator: - getProcessLogger().error(args[0] + ": only one instance of the Application class can be used") - return 1 - - # - # We parse the properties here to extract Ice.ProgramName. - # - if not initData: - initData = InitializationData() - if configFile: - try: - initData.properties = createProperties(None, initData.properties) - initData.properties.load(configFile) - except: - getProcessLogger().error(traceback.format_exc()) - return 1 - initData.properties = createProperties(args, initData.properties) - - # - # If the process logger is the default logger, we replace it with a - # a logger which is using the program name for the prefix. - # - if isinstance(getProcessLogger(), LoggerI): - setProcessLogger(_ApplicationLoggerI(initData.properties.getProperty("Ice.ProgramName"))) - - # - # Install our handler for the signals we are interested in. We assume main() - # is called from the main thread. - # - if Application._signalPolicy == Application.HandleSignals: - Application._ctrlCHandler = CtrlCHandler() - - try: - Application._interrupted = False - Application._appName = initData.properties.getPropertyWithDefault("Ice.ProgramName", args[0]) - Application._application = self - - # - # Used by _destroyOnInterruptCallback and _shutdownOnInterruptCallback. - # - Application._nohup = initData.properties.getPropertyAsInt("Ice.Nohup") > 0 - - # - # The default is to destroy when a signal is received. - # - if Application._signalPolicy == Application.HandleSignals: - Application.destroyOnInterrupt() - - status = self.doMain(args, initData) - except: - getProcessLogger().error(traceback.format_exc()) - status = 1 - # - # Set _ctrlCHandler to 0 only once communicator.destroy() has - # completed. - # - if Application._signalPolicy == Application.HandleSignals: - Application._ctrlCHandler.destroy() - Application._ctrlCHandler = None - - return status - - def doMain(self, args, initData): - try: - Application._communicator = initialize(args, initData) - Application._destroyed = False - status = self.run(args) - - except: - getProcessLogger().error(traceback.format_exc()) - status = 1 - - # - # Don't want any new interrupt and at this point (post-run), - # it would not make sense to release a held signal to run - # shutdown or destroy. - # - if Application._signalPolicy == Application.HandleSignals: - Application.ignoreInterrupt() - - Application._condVar.acquire() - while Application._callbackInProgress: - Application._condVar.wait() - if Application._destroyed: - Application._communicator = None - else: - Application._destroyed = True - # - # And _communicator != 0, meaning will be destroyed - # next, _destroyed = true also ensures that any - # remaining callback won't do anything - # - Application._application = None - Application._condVar.release() - - if Application._communicator: - try: - Application._communicator.destroy() - except: - getProcessLogger().error(traceback.format_exc()) - status = 1 - Application._communicator = None - return status - - def run(self, args): - '''This method must be overridden in a subclass. The base -class supplies an argument list from which all Ice arguments -have already been removed. The method returns an integer -exit status (0 is success, non-zero is failure). -''' - raise RuntimeError('run() not implemented') - - def interruptCallback(self, sig): - '''Subclass hook to intercept an interrupt.''' - pass - - def appName(self): - '''Returns the application name (the first element of -the argument list).''' - return self._appName - appName = classmethod(appName) - - def communicator(self): - '''Returns the communicator that was initialized for -the application.''' - return self._communicator - communicator = classmethod(communicator) - - def destroyOnInterrupt(self): - '''Configures the application to destroy its communicator -when interrupted by a signal.''' - if Application._signalPolicy == Application.HandleSignals: - self._condVar.acquire() - if self._ctrlCHandler.getCallback() == self._holdInterruptCallback: - self._released = True - self._condVar.notify() - self._ctrlCHandler.setCallback(self._destroyOnInterruptCallback) - self._condVar.release() - else: - getProcessLogger().error(Application._appName + \ - ": warning: interrupt method called on Application configured to not handle interrupts.") - destroyOnInterrupt = classmethod(destroyOnInterrupt) - - def shutdownOnInterrupt(self): - '''Configures the application to shutdown its communicator -when interrupted by a signal.''' - if Application._signalPolicy == Application.HandleSignals: - self._condVar.acquire() - if self._ctrlCHandler.getCallback() == self._holdInterruptCallback: - self._released = True - self._condVar.notify() - self._ctrlCHandler.setCallback(self._shutdownOnInterruptCallback) - self._condVar.release() - else: - getProcessLogger().error(Application._appName + \ - ": warning: interrupt method called on Application configured to not handle interrupts.") - shutdownOnInterrupt = classmethod(shutdownOnInterrupt) - - def ignoreInterrupt(self): - '''Configures the application to ignore signals.''' - if Application._signalPolicy == Application.HandleSignals: - self._condVar.acquire() - if self._ctrlCHandler.getCallback() == self._holdInterruptCallback: - self._released = True - self._condVar.notify() - self._ctrlCHandler.setCallback(None) - self._condVar.release() - else: - getProcessLogger().error(Application._appName + \ - ": warning: interrupt method called on Application configured to not handle interrupts.") - ignoreInterrupt = classmethod(ignoreInterrupt) - - def callbackOnInterrupt(self): - '''Configures the application to invoke interruptCallback -when interrupted by a signal.''' - if Application._signalPolicy == Application.HandleSignals: - self._condVar.acquire() - if self._ctrlCHandler.getCallback() == self._holdInterruptCallback: - self._released = True - self._condVar.notify() - self._ctrlCHandler.setCallback(self._callbackOnInterruptCallback) - self._condVar.release() - else: - getProcessLogger().error(Application._appName + \ - ": warning: interrupt method called on Application configured to not handle interrupts.") - callbackOnInterrupt = classmethod(callbackOnInterrupt) - - def holdInterrupt(self): - '''Configures the application to queue an interrupt for -later processing.''' - if Application._signalPolicy == Application.HandleSignals: - self._condVar.acquire() - if self._ctrlCHandler.getCallback() != self._holdInterruptCallback: - self._previousCallback = self._ctrlCHandler.getCallback() - self._released = False - self._ctrlCHandler.setCallback(self._holdInterruptCallback) - # else, we were already holding signals - self._condVar.release() - else: - getProcessLogger().error(Application._appName + \ - ": warning: interrupt method called on Application configured to not handle interrupts.") - holdInterrupt = classmethod(holdInterrupt) - - def releaseInterrupt(self): - '''Instructs the application to process any queued interrupt.''' - if Application._signalPolicy == Application.HandleSignals: - self._condVar.acquire() - if self._ctrlCHandler.getCallback() == self._holdInterruptCallback: - # - # Note that it's very possible no signal is held; - # in this case the callback is just replaced and - # setting _released to true and signalling _condVar - # do no harm. - # - self._released = True - self._ctrlCHandler.setCallback(self._previousCallback) - self._condVar.notify() - # Else nothing to release. - self._condVar.release() - else: - getProcessLogger().error(Application._appName + \ - ": warning: interrupt method called on Application configured to not handle interrupts.") - releaseInterrupt = classmethod(releaseInterrupt) - - def interrupted(self): - '''Returns True if the application was interrupted by a -signal, or False otherwise.''' - self._condVar.acquire() - result = self._interrupted - self._condVar.release() - return result - interrupted = classmethod(interrupted) - - def _holdInterruptCallback(self, sig): - self._condVar.acquire() - while not self._released: - self._condVar.wait() - if self._destroyed: - # - # Being destroyed by main thread - # - self._condVar.release() - return - callback = self._ctrlCHandler.getCallback() - self._condVar.release() - if callback: - callback(sig) - _holdInterruptCallback = classmethod(_holdInterruptCallback) - - def _destroyOnInterruptCallback(self, sig): - self._condVar.acquire() - if self._destroyed or self._nohup and sig == signal.SIGHUP: - # - # Being destroyed by main thread, or nohup. - # - self._condVar.release() - return - - self._callbackInProcess = True - self._interrupted = True - self._destroyed = True - self._condVar.release() - - try: - self._communicator.destroy() - except: - getProcessLogger().error(self._appName + " (while destroying in response to signal " + str(sig) + "):" + \ - traceback.format_exc()) - - self._condVar.acquire() - self._callbackInProcess = False - self._condVar.notify() - self._condVar.release() - _destroyOnInterruptCallback = classmethod(_destroyOnInterruptCallback) - - def _shutdownOnInterruptCallback(self, sig): - self._condVar.acquire() - if self._destroyed or self._nohup and sig == signal.SIGHUP: - # - # Being destroyed by main thread, or nohup. - # - self._condVar.release() - return - - self._callbackInProcess = True - self._interrupted = True - self._condVar.release() - - try: - self._communicator.shutdown() - except: - getProcessLogger().error(self._appName + " (while shutting down in response to signal " + str(sig) + \ - "):" + traceback.format_exc()) - - self._condVar.acquire() - self._callbackInProcess = False - self._condVar.notify() - self._condVar.release() - _shutdownOnInterruptCallback = classmethod(_shutdownOnInterruptCallback) - - def _callbackOnInterruptCallback(self, sig): - self._condVar.acquire() - if self._destroyed: - # - # Being destroyed by main thread. - # - self._condVar.release() - return - # For SIGHUP the user callback is always called. It can decide - # what to do. - - self._callbackInProcess = True - self._interrupted = True - self._condVar.release() - - try: - self._application.interruptCallback(sig) - except: - getProcessLogger().error(self._appName + " (while interrupting in response to signal " + str(sig) + \ - "):" + traceback.format_exc()) - - self._condVar.acquire() - self._callbackInProcess = False - self._condVar.notify() - self._condVar.release() - - _callbackOnInterruptCallback = classmethod(_callbackOnInterruptCallback) - - HandleSignals = 0 - NoSignalHandling = 1 - - _appName = None - _communicator = None - _application = None - _ctrlCHandler = None - _previousCallback = None - _interrupted = False - _released = False - _destroyed = False - _callbackInProgress = False - _condVar = threading.Condition() - _signalPolicy = HandleSignals - -# -# Define Ice::Object and Ice::ObjectPrx. -# -IcePy._t_Object = IcePy.defineClass('::Ice::Object', Object, (), None, ()) -IcePy._t_Value = IcePy.defineValue('::Ice::Object', Value, -1, (), False, False, None, ()) -IcePy._t_ObjectPrx = IcePy.defineProxy('::Ice::Object', ObjectPrx) -Object._ice_type = IcePy._t_Object - -Object._op_ice_isA = IcePy.Operation('ice_isA', OperationMode.Idempotent, OperationMode.Nonmutating, False, None, (), (((), IcePy._t_string, False, 0),), (), ((), IcePy._t_bool, False, 0), ()) -Object._op_ice_ping = IcePy.Operation('ice_ping', OperationMode.Idempotent, OperationMode.Nonmutating, False, None, (), (), (), None, ()) -Object._op_ice_ids = IcePy.Operation('ice_ids', OperationMode.Idempotent, OperationMode.Nonmutating, False, None, (), (), (), ((), _t_StringSeq, False, 0), ()) -Object._op_ice_id = IcePy.Operation('ice_id', OperationMode.Idempotent, OperationMode.Nonmutating, False, None, (), (), (), ((), IcePy._t_string, False, 0), ()) - -IcePy._t_LocalObject = IcePy.defineValue('::Ice::LocalObject', object, -1, (), False, False, None, ()) - -IcePy._t_UnknownSlicedValue = IcePy.defineValue('::Ice::UnknownSlicedValue', UnknownSlicedValue, -1, (), True, False, None, ()) -UnknownSlicedValue._ice_type = IcePy._t_UnknownSlicedValue - -# -# Annotate some exceptions. -# -def SyscallException__str__(self): - return "Ice.SyscallException:\n" + os.strerror(self.error) -SyscallException.__str__ = SyscallException__str__ -del SyscallException__str__ - -def SocketException__str__(self): - return "Ice.SocketException:\n" + os.strerror(self.error) -SocketException.__str__ = SocketException__str__ -del SocketException__str__ - -def ConnectFailedException__str__(self): - return "Ice.ConnectFailedException:\n" + os.strerror(self.error) -ConnectFailedException.__str__ = ConnectFailedException__str__ -del ConnectFailedException__str__ - -def ConnectionRefusedException__str__(self): - return "Ice.ConnectionRefusedException:\n" + os.strerror(self.error) -ConnectionRefusedException.__str__ = ConnectionRefusedException__str__ -del ConnectionRefusedException__str__ - -def ConnectionLostException__str__(self): - if self.error == 0: - return "Ice.ConnectionLostException:\nrecv() returned zero" - else: - return "Ice.ConnectionLostException:\n" + os.strerror(self.error) -ConnectionLostException.__str__ = ConnectionLostException__str__ -del ConnectionLostException__str__ - -# -# Proxy comparison functions. -# -def proxyIdentityEqual(lhs, rhs): - '''Determines whether the identities of two proxies are equal.''' - return proxyIdentityCompare(lhs, rhs) == 0 - -def proxyIdentityCompare(lhs, rhs): - '''Compares the identities of two proxies.''' - if (lhs and not isinstance(lhs, ObjectPrx)) or (rhs and not isinstance(rhs, ObjectPrx)): - raise ValueError('argument is not a proxy') - if not lhs and not rhs: - return 0 - elif not lhs and rhs: - return -1 - elif lhs and not rhs: - return 1 - else: - lid = lhs.ice_getIdentity() - rid = rhs.ice_getIdentity() - return (lid > rid) - (lid < rid) - -def proxyIdentityAndFacetEqual(lhs, rhs): - '''Determines whether the identities and facets of two -proxies are equal.''' - return proxyIdentityAndFacetCompare(lhs, rhs) == 0 - -def proxyIdentityAndFacetCompare(lhs, rhs): - '''Compares the identities and facets of two proxies.''' - if (lhs and not isinstance(lhs, ObjectPrx)) or (rhs and not isinstance(rhs, ObjectPrx)): - raise ValueError('argument is not a proxy') - if not lhs and not rhs: - return 0 - elif not lhs and rhs: - return -1 - elif lhs and not rhs: - return 1 - elif lhs.ice_getIdentity() != rhs.ice_getIdentity(): - lid = lhs.ice_getIdentity() - rid = rhs.ice_getIdentity() - return (lid > rid) - (lid < rid) - else: - lf = lhs.ice_getFacet() - rf = rhs.ice_getFacet() - return (lf > rf) - (lf < rf) - -# -# Used by generated code. Defining these in the Ice module means the generated code -# can avoid the need to qualify the type() and hash() functions with their module -# names. Since the functions are in the __builtin__ module (for Python 2.x) and the -# builtins module (for Python 3.x), it's easier to define them here. -# -def getType(o): - return type(o) - -# -# Used by generated code. Defining this in the Ice module means the generated code -# can avoid the need to qualify the hash() function with its module name. Since -# the function is in the __builtin__ module (for Python 2.x) and the builtins -# module (for Python 3.x), it's easier to define it here. -# -def getHash(o): - return hash(o) - -Protocol_1_0 = ProtocolVersion(1, 0) -Encoding_1_0 = EncodingVersion(1, 0) -Encoding_1_1 = EncodingVersion(1, 1) diff --git a/python/python/Ice/IceFuture.py b/python/python/Ice/IceFuture.py new file mode 100644 index 00000000000..df5eff76c83 --- /dev/null +++ b/python/python/Ice/IceFuture.py @@ -0,0 +1,48 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2017 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. +# +# ********************************************************************** + +# +# This file should only be used in Python >= 3.5. +# + +import asyncio + +# +# This class defines an __await__ method so that coroutines can call 'await '. +# +# Python 2.x rejects this code with a syntax error because a return statement is not allowed in a generator. +# +class FutureBase(object): + def __await__(self): + if not self.done(): + yield self + return self.result() + +def wrap_future(future, *, loop=None): + '''Wrap Ice.Future object into an asyncio.Future.''' + if isinstance(future, asyncio.Future): + return future + + assert isinstance(future, FutureBase), 'Ice.Future is expected, got {!r}'.format(future) + + if loop is None: + loop = asyncio.get_event_loop() + + af = loop.create_future() + + def callback(): + if future.cancelled(): + af.cancel() + elif future.exception(): + af.set_exception(future.exception()) + else: + af.set_result(future.result()) + + future.add_done_callback(lambda f: loop.call_soon_threadsafe(callback)) + return af diff --git a/python/python/Ice/__init__.py b/python/python/Ice/__init__.py new file mode 100644 index 00000000000..a167f54dde5 --- /dev/null +++ b/python/python/Ice/__init__.py @@ -0,0 +1,1924 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2017 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. +# +# ********************************************************************** + +""" +Ice module +""" + +import sys, string, imp, os, threading, warnings, datetime, logging, time, inspect + +# +# RTTI problems can occur in C++ code unless we modify Python's dlopen flags. +# Note that changing these flags might cause problems for other extensions +# loaded by the application (see bug 3660), so we restore the original settings +# after loading IcePy. +# +_dlopenflags = -1 +try: + _dlopenflags = sys.getdlopenflags() + + try: + import dl + sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL) + except ImportError: + # + # If the dl module is not available and we're running on a Linux + # platform, use the hard coded value of RTLD_NOW|RTLD_GLOBAL. + # + if sys.platform.startswith("linux"): + sys.setdlopenflags(258) + pass + +except AttributeError: + # + # sys.getdlopenflags() is not supported (we're probably running on Windows). + # + pass + +# +# Import the Python extension. +# +import IcePy + +# +# Restore the dlopen flags. +# +if _dlopenflags >= 0: + sys.setdlopenflags(_dlopenflags) + +# +# Give the extension an opportunity to clean up before a graceful exit. +# +import atexit +atexit.register(IcePy.cleanup) + +# +# Add some symbols to the Ice module. +# +ObjectPrx = IcePy.ObjectPrx +stringVersion = IcePy.stringVersion +intVersion = IcePy.intVersion +currentProtocol = IcePy.currentProtocol +currentProtocolEncoding = IcePy.currentProtocolEncoding +currentEncoding = IcePy.currentEncoding +stringToProtocolVersion = IcePy.stringToProtocolVersion +protocolVersionToString = IcePy.protocolVersionToString +stringToEncodingVersion = IcePy.stringToEncodingVersion +encodingVersionToString = IcePy.encodingVersionToString +generateUUID = IcePy.generateUUID +loadSlice = IcePy.loadSlice +AsyncResult = IcePy.AsyncResult +Unset = IcePy.Unset + +def Python35(): + return sys.version_info[:2] >= (3, 5) + +if Python35(): + from Ice.IceFuture import FutureBase, wrap_future +else: + FutureBase = object + +class Future(FutureBase): + def __init__(self): + self._result = None + self._exception = None + self._condition = threading.Condition() + self._doneCallbacks = [] + self._state = Future.StateRunning + + def cancel(self): + callbacks = [] + with self._condition: + if self._state == Future.StateDone: + return False + + if self._state == Future.StateCancelled: + return True + + self._state = Future.StateCancelled + callbacks = self._doneCallbacks + self._doneCallbacks = [] + self._condition.notify_all() + + self._callCallbacks(callbacks) + + return True + + def cancelled(self): + with self._condition: + return self._state == Future.StateCancelled + + def running(self): + with self._condition: + return self._state == Future.StateRunning + + def done(self): + with self._condition: + return self._state in [Future.StateCancelled, Future.StateDone] + + def add_done_callback(self, fn): + with self._condition: + if self._state == Future.StateRunning: + self._doneCallbacks.append(fn) + return + fn(self) + + def result(self, timeout=None): + with self._condition: + if not self._wait(timeout, lambda: self._state == Future.StateRunning): + raise TimeoutException() + if self._state == Future.StateCancelled: + raise InvocationCanceledException() + elif self._exception: + raise self._exception + else: + return self._result + + def exception(self, timeout=None): + with self._condition: + if not self._wait(timeout, lambda: self._state == Future.StateRunning): + raise TimeoutException() + if self._state == Future.StateCancelled: + raise InvocationCanceledException() + else: + return self._exception + + def set_result(self, result): + callbacks = [] + with self._condition: + if self._state != Future.StateRunning: + return + self._result = result + self._state = Future.StateDone + callbacks = self._doneCallbacks + self._doneCallbacks = [] + self._condition.notify_all() + + self._callCallbacks(callbacks) + + def set_exception(self, ex): + callbacks = [] + with self._condition: + if self._state != Future.StateRunning: + return + self._exception = ex + self._state = Future.StateDone + callbacks = self._doneCallbacks + self._doneCallbacks = [] + self._condition.notify_all() + + self._callCallbacks(callbacks) + + @staticmethod + def completed(result): + f = Future() + f.set_result(result) + return f + + def _wait(self, timeout, testFn=None): + # Must be called with _condition acquired + + while testFn(): + if timeout: + start = time.time() + self._condition.wait(timeout) + # Subtract the elapsed time so far from the timeout + timeout -= (time.time() - start) + if timeout <= 0: + return False + else: + self._condition.wait() + + return True + + def _callCallbacks(self, callbacks): + for callback in callbacks: + try: + callback(self) + except: + logging.getLogger("Ice.Future").exception('callback raised exception') + + StateRunning = 'running' + StateCancelled = 'cancelled' + StateDone = 'done' + +class InvocationFuture(Future): + def __init__(self, operation, asyncResult): + Future.__init__(self) + self._operation = operation + self._asyncResult = asyncResult # May be None for a batch invocation. + self._sent = False + self._sentSynchronously = False + self._sentCallbacks = [] + + def cancel(self): + if self._asyncResult: + self._asyncResult.cancel() + return Future.cancel(self) + + def add_done_callback_async(self, fn): + with self._condition: + if self._state == Future.StateRunning: + self._doneCallbacks.append(fn) + return + if self._asyncResult: + self._asyncResult.callLater(lambda: fn(self)) + else: + fn(self) + + def is_sent(self): + with self._condition: + return self._sent + + def is_sent_synchronously(self): + with self._condition: + return self._sentSynchronously + + def add_sent_callback(self, fn): + with self._condition: + if not self._sent: + self._sentCallbacks.append(fn) + return + if self._sentSynchronously or not self._asyncResult: + fn(self, self._sentSynchronously) + else: + self._asyncResult.callLater(lambda: fn(self, self._sentSynchronously)) + + def sent(self, timeout=None): + with self._condition: + if not self._wait(timeout, lambda: not self._sent): + raise TimeoutException() + if self._state == Future.StateCancelled: + raise InvocationCanceledException() + elif self._exception: + raise self._exception + else: + return self._sentSynchronously + + def set_sent(self, sentSynchronously): + callbacks = [] + with self._condition: + if self._sent: + return + + self._sent = True + self._sentSynchronously = sentSynchronously + callbacks = self._sentCallbacks + self._sentCallbacks = [] + self._condition.notify_all() + + for callback in callbacks: + try: + callback(self, sentSynchronously) + except Exception: + logging.getLogger("Ice.Future").exception('callback raised exception') + + def operation(self): + return self._operation + + def proxy(self): + return None if not self._asyncResult else self._asyncResult.getProxy() + + def connection(self): + return None if not self._asyncResult else self._asyncResult.getConnection() + + def communicator(self): + return None if not self._asyncResult else self._asyncResult.getCommunicator() + +# +# This value is used as the default value for struct types in the constructors +# of user-defined types. It allows us to determine whether the application has +# supplied a value. (See bug 3676) +# +_struct_marker = object() + +# +# Core Ice types. +# +class Value(object): + def ice_id(): + '''Obtains the type id corresponding to the most-derived Slice +interface supported by the target object. +Returns: + The type id. +''' + return '::Ice::Object' + + @staticmethod + def ice_staticId(): + '''Obtains the type id of this Slice class or interface. +Returns: + The type id. +''' + return '::Ice::Object' + + # + # Do not define these here. They will be invoked if defined by a subclass. + # + #def ice_preMarshal(self): + # pass + # + #def ice_postUnmarshal(self): + # pass + +class InterfaceByValue(Value): + + def __init__(self, id): + self.id = id + + def ice_id(self): + return self.id + +class Object(object): + def ice_isA(self, id, current=None): + '''Determines whether the target object supports the interface denoted +by the given Slice type id. +Arguments: + id The Slice type id +Returns: + True if the target object supports the interface, or false otherwise. +''' + return id in self.ice_ids(current) + + def ice_ping(self, current=None): + '''A reachability test for the target object.''' + pass + + def ice_ids(self, current=None): + '''Obtains the type ids corresponding to the Slice interface +that are supported by the target object. +Returns: + A list of type ids. +''' + return [ self.ice_id(current) ] + + def ice_id(self, current=None): + '''Obtains the type id corresponding to the most-derived Slice +interface supported by the target object. +Returns: + The type id. +''' + return '::Ice::Object' + + @staticmethod + def ice_staticId(): + '''Obtains the type id of this Slice class or interface. +Returns: + The type id. +''' + return '::Ice::Object' + + def _iceDispatch(self, cb, method, args): + # Invoke the given servant method. Exceptions can propagate to the caller. + result = method(*args) + + # Check for a future. + if isinstance(result, Future) or callable(getattr(result, "add_done_callback", None)): + def handler(future): + try: + cb.response(future.result()) + except: + cb.exception(sys.exc_info()[1]) + result.add_done_callback(handler) + elif Python35() and inspect.iscoroutine(result): # The iscoroutine() function was added in Python 3.5. + self._iceDispatchCoroutine(cb, result) + else: + cb.response(result) + + def _iceDispatchCoroutine(self, cb, coro, value=None, exception=None): + try: + if exception: + result = coro.throw(exception) + else: + result = coro.send(value) + + # Calling 'await ' will return the future. Check if we've received a future. + if isinstance(result, Future) or callable(getattr(result, "add_done_callback", None)): + def handler(future): + try: + self._iceDispatchCoroutine(cb, coro, value=future.result()) + except: + self._iceDispatchCoroutine(cb, coro, exception=sys.exc_info()[1]) + result.add_done_callback(handler) + else: + raise RuntimeError('unexpected value of type ' + str(type(result)) + ' provided by coroutine') + except StopIteration as ex: + # StopIteration is raised when the coroutine completes. + cb.response(ex.value) + except: + cb.exception(sys.exc_info()[1]) + +class Blobject(Object): + '''Special-purpose servant base class that allows a subclass to +handle synchronous Ice invocations as "blobs" of bytes.''' + + def ice_invoke(self, bytes, current): + '''Dispatch a synchronous Ice invocation. The operation's +arguments are encoded in the bytes argument. The return +value must be a tuple of two values: the first is a +boolean indicating whether the operation succeeded (True) +or raised a user exception (False), and the second is +the encoded form of the operation's results or the user +exception. +''' + pass + +class BlobjectAsync(Object): + '''Special-purpose servant base class that allows a subclass to +handle asynchronous Ice invocations as "blobs" of bytes.''' + + def ice_invoke_async(self, cb, bytes, current): + '''Dispatch an asynchronous Ice invocation. The operation's +arguments are encoded in the bytes argument. When the +dispatch is complete, the subclass can invoke either +ice_response or ice_exception on the supplied callback +object. +''' + pass + +# +# Exceptions. +# +class Exception(Exception): # Derives from built-in base 'Exception' class. + '''The base class for all Ice exceptions.''' + def __str__(self): + return self.__class__.__name__ + + def ice_name(self): + '''Returns the type name of this exception.''' + return self.ice_id()[2:] + + def ice_id(self): + '''Returns the type id of this exception.''' + return self._ice_id + +class LocalException(Exception): + '''The base class for all Ice run-time exceptions.''' + def __init__(self, args=''): + self.args = args + +class UserException(Exception): + '''The base class for all user-defined exceptions.''' + pass + +class EnumBase(object): + def __init__(self, _n, _v): + self._name = _n + self._value = _v + + def __str__(self): + return self._name + + __repr__ = __str__ + + def __hash__(self): + return self._value + + def __lt__(self, other): + if isinstance(other, self.__class__): + return self._value < other._value; + elif other == None: + return False + return NotImplemented + + def __le__(self, other): + if isinstance(other, self.__class__): + return self._value <= other._value; + elif other == None: + return False + return NotImplemented + + def __eq__(self, other): + if isinstance(other, self.__class__): + return self._value == other._value; + elif other == None: + return False + return NotImplemented + + def __ne__(self, other): + if isinstance(other, self.__class__): + return self._value != other._value; + elif other == None: + return False + return NotImplemented + + def __gt__(self, other): + if isinstance(other, self.__class__): + return self._value > other._value; + elif other == None: + return False + return NotImplemented + + def __ge__(self, other): + if isinstance(other, self.__class__): + return self._value >= other._value; + elif other == None: + return False + return NotImplemented + + def _getName(self): + return self._name + + def _getValue(self): + return self._value + + name = property(_getName) + value = property(_getValue) + +class SlicedData(object): + # + # Members: + # + # slices - tuple of SliceInfo + # + pass + +class SliceInfo(object): + # + # Members: + # + # typeId - string + # compactId - int + # bytes - string + # objects - tuple of Ice.Value + pass + +# +# Native PropertiesAdmin admin facet. +# +NativePropertiesAdmin = IcePy.NativePropertiesAdmin + +class PropertiesAdminUpdateCallback(object): + '''Callback class to get notifications of property updates passed + through the Properties admin facet''' + + def updated(self, props): + pass + +class UnknownSlicedValue(Value): + # + # Members: + # + # unknownTypeId - string + pass + +def getSliceDir(): + '''Convenience function for locating the directory containing the Slice files.''' + + # + # Get the parent of the directory containing this file (__init__.py). + # + pyHome = os.path.join(os.path.dirname(__file__), "..") + + # + # Detect setup.py installation in site-packages. The slice + # files live one level above this file. + # + dir = os.path.join(pyHome, "slice") + if os.path.isdir(dir): + return dir + + # + # For an installation from a source distribution, a binary tarball, or a + # Windows installer, the "slice" directory is a sibling of the "python" + # directory. + # + dir = os.path.join(pyHome, "..", "slice") + if os.path.exists(dir): + return os.path.normpath(dir) + + # + # In a source distribution, the "slice" directory is an extra level higher. + # directory. + # + dir = os.path.join(pyHome, "..", "..", "slice") + if os.path.exists(dir): + return os.path.normpath(dir) + + if sys.platform[:5] == "linux": + # + # Check the default Linux location. + # + dir = os.path.join("/", "usr", "share", "ice", "slice") + if os.path.exists(dir): + return dir + + elif sys.platform == "darwin": + # + # Check the default macOS homebrew location. + # + dir = os.path.join("/", "usr", "local", "share", "ice", "slice") + if os.path.exists(dir): + return dir + + return None + +# +# Utilities for use by generated code. +# + +_pendingModules = {} + +def openModule(name): + global _pendingModules + if name in sys.modules: + result = sys.modules[name] + elif name in _pendingModules: + result = _pendingModules[name] + else: + result = createModule(name) + + return result + +def createModule(name): + global _pendingModules + l = name.split(".") + curr = '' + mod = None + + for s in l: + curr = curr + s + + if curr in sys.modules: + mod = sys.modules[curr] + elif curr in _pendingModules: + mod = _pendingModules[curr] + else: + nmod = imp.new_module(curr) + _pendingModules[curr] = nmod + mod = nmod + + curr = curr + "." + + return mod + +def updateModule(name): + global _pendingModules + if name in _pendingModules: + pendingModule = _pendingModules[name] + mod = sys.modules[name] + mod.__dict__.update(pendingModule.__dict__) + del _pendingModules[name] + +def updateModules(): + global _pendingModules + for name in _pendingModules.keys(): + if name in sys.modules: + sys.modules[name].__dict__.update(_pendingModules[name].__dict__) + else: + sys.modules[name] = _pendingModules[name] + _pendingModules = {} + +def createTempClass(): + class __temp: pass + return __temp + +class FormatType(object): + def __init__(self, val): + assert(val >= 0 and val < 3) + self.value = val + +FormatType.DefaultFormat = FormatType(0) +FormatType.CompactFormat = FormatType(1) +FormatType.SlicedFormat = FormatType(2) + +# +# Forward declarations. +# +IcePy._t_Object = IcePy.declareClass('::Ice::Object') +IcePy._t_Value = IcePy.declareValue('::Ice::Object') +IcePy._t_ObjectPrx = IcePy.declareProxy('::Ice::Object') +IcePy._t_LocalObject = IcePy.declareClass('::Ice::LocalObject') + +# +# Sequence mappings. +# +IcePy.SEQ_DEFAULT = 0 +IcePy.SEQ_TUPLE = 1 +IcePy.SEQ_LIST = 2 +#IcePy.SEQ_ARRAY = 3 + +# +# Slice checksum dictionary. +# +sliceChecksums = {} + +# +# Import generated Ice modules. +# +import Ice.BuiltinSequences_ice +import Ice.Current_ice +import Ice.Communicator_ice +import Ice.ImplicitContext_ice +import Ice.Endpoint_ice +import Ice.EndpointTypes_ice +import Ice.Identity_ice +import Ice.LocalException_ice +import Ice.Locator_ice +import Ice.Logger_ice +import Ice.ObjectAdapter_ice +import Ice.ObjectFactory_ice +import Ice.ValueFactory_ice +import Ice.Process_ice +import Ice.Properties_ice +import Ice.RemoteLogger_ice +import Ice.Router_ice +import Ice.ServantLocator_ice +import Ice.Connection_ice +import Ice.Version_ice +import Ice.Instrumentation_ice +import Ice.Metrics_ice + +# +# Replace EndpointInfo with our implementation. +# +del EndpointInfo +EndpointInfo = IcePy.EndpointInfo +del IPEndpointInfo +IPEndpointInfo = IcePy.IPEndpointInfo +del TCPEndpointInfo +TCPEndpointInfo = IcePy.TCPEndpointInfo +del UDPEndpointInfo +UDPEndpointInfo = IcePy.UDPEndpointInfo +del WSEndpointInfo +WSEndpointInfo = IcePy.WSEndpointInfo +del OpaqueEndpointInfo +OpaqueEndpointInfo = IcePy.OpaqueEndpointInfo + +SSLEndpointInfo = IcePy.SSLEndpointInfo + +# +# Replace ConnectionInfo with our implementation. +# +del ConnectionInfo +ConnectionInfo = IcePy.ConnectionInfo +del IPConnectionInfo +IPConnectionInfo = IcePy.IPConnectionInfo +del TCPConnectionInfo +TCPConnectionInfo = IcePy.TCPConnectionInfo +del UDPConnectionInfo +UDPConnectionInfo = IcePy.UDPConnectionInfo +del WSConnectionInfo +WSConnectionInfo = IcePy.WSConnectionInfo + +SSLConnectionInfo = IcePy.SSLConnectionInfo + +class ThreadNotification(object): + '''Base class for thread notification callbacks. A subclass must +define the start and stop methods.''' + + def __init__(self): + pass + + def start(): + '''Invoked in the context of a thread created by the Ice run time.''' + pass + + def stop(): + '''Invoked in the context of an Ice run-time thread that is about +to terminate.''' + pass + +class BatchRequest(object): + '''Base class for batch request interceptor. A subclass must +define the enqueue method.''' + def __init__(self, size, operation, proxy): + self._size = size + self._operation = operation + self._proxy = proxy + + def getSize(): + return self._size + + def getOperation(): + return self._operation + + def getProxy(): + return self._proxy + + def enqueue(): + '''Call enqueue from the batch request interceptor enqueue +implementation to confirm the batching a this request.''' + pass + +class BatchRequestInterceptor(object): + '''Base class for batch request interceptor. A subclass must +define the enqueue method.''' + + def __init__(self): + pass + + def enqueue(request, queueCount, queueSize): + '''Invoked when a request is batched.''' + pass + +# +# Initialization data. +# +class InitializationData(object): + '''The attributes of this class are used to initialize a new +communicator instance. The supported attributes are as follows: + +properties: An instance of Ice.Properties. You can use the + Ice.createProperties function to create a new property set. + +logger: An instance of Ice.Logger. + +threadStart: A callable that is invoked for each new Ice thread that is started. + +threadStop: A callable that is invoked when an Ice thread is stopped. + +dispatcher: A callable that is invoked when Ice needs to dispatch an activity. The callable + receives two arguments: a callable and an Ice.Connection object. The dispatcher must + eventually invoke the callable with no arguments. + +batchRequestInterceptor: A callable that will be invoked when a batch request is queued. + The callable receives three arguments: a BatchRequest object, an integer representing + the number of requests in the queue, and an integer representing the number of bytes + consumed by the requests in the queue. The interceptor must eventually invoke the + enqueue method on the BatchRequest object. + +valueFactoryManager: An object that implements ValueFactoryManager. +''' + def __init__(self): + self.properties = None + self.logger = None + self.threadHook = None # Deprecated. + self.threadStart = None + self.threadStop = None + self.dispatcher = None + self.batchRequestInterceptor = None + self.valueFactoryManager = None + +# +# Communicator wrapper. +# +class CommunicatorI(Communicator): + def __init__(self, impl): + self._impl = impl + impl._setWrapper(self) + + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + self._impl.destroy() + + def getImpl(self): + return self._impl + + def destroy(self): + self._impl.destroy() + + def shutdown(self): + self._impl.shutdown() + + def waitForShutdown(self): + # + # If invoked by the main thread, waitForShutdown only blocks for + # the specified timeout in order to give us a chance to handle + # signals. + # + while not self._impl.waitForShutdown(500): + pass + + def isShutdown(self): + return self._impl.isShutdown() + + def stringToProxy(self, str): + return self._impl.stringToProxy(str) + + def proxyToString(self, obj): + return self._impl.proxyToString(obj) + + def propertyToProxy(self, str): + return self._impl.propertyToProxy(str) + + def proxyToProperty(self, obj, str): + return self._impl.proxyToProperty(obj, str) + + def stringToIdentity(self, str): + return self._impl.stringToIdentity(str) + + def identityToString(self, ident): + return self._impl.identityToString(ident) + + def createObjectAdapter(self, name): + adapter = self._impl.createObjectAdapter(name) + return ObjectAdapterI(adapter) + + def createObjectAdapterWithEndpoints(self, name, endpoints): + adapter = self._impl.createObjectAdapterWithEndpoints(name, endpoints) + return ObjectAdapterI(adapter) + + def createObjectAdapterWithRouter(self, name, router): + adapter = self._impl.createObjectAdapterWithRouter(name, router) + return ObjectAdapterI(adapter) + + def addObjectFactory(self, factory, id): + # The extension implementation requires an extra argument that is a value factory + self._impl.addObjectFactory(factory, id, lambda s, factory=factory: factory.create(s)) + + def findObjectFactory(self, id): + return self._impl.findObjectFactory(id) + + def getValueFactoryManager(self): + return self._impl.getValueFactoryManager() + + def getImplicitContext(self): + context = self._impl.getImplicitContext() + if context == None: + return None; + else: + return ImplicitContextI(context) + + def getProperties(self): + properties = self._impl.getProperties() + return PropertiesI(properties) + + def getLogger(self): + logger = self._impl.getLogger() + if isinstance(logger, Logger): + return logger + else: + return LoggerI(logger) + + def getStats(self): + raise RuntimeError("operation `getStats' not implemented") + + def getDefaultRouter(self): + return self._impl.getDefaultRouter() + + def setDefaultRouter(self, rtr): + self._impl.setDefaultRouter(rtr) + + def getDefaultLocator(self): + return self._impl.getDefaultLocator() + + def setDefaultLocator(self, loc): + self._impl.setDefaultLocator(loc) + + def getPluginManager(self): + raise RuntimeError("operation `getPluginManager' not implemented") + + def flushBatchRequests(self, compress): + self._impl.flushBatchRequests(compress) + + def flushBatchRequestsAsync(self, compress): + return self._impl.flushBatchRequestsAsync(compress) + + def begin_flushBatchRequests(self, compress, _ex=None, _sent=None): + return self._impl.begin_flushBatchRequests(compress, _ex, _sent) + + def end_flushBatchRequests(self, r): + return self._impl.end_flushBatchRequests(r) + + def createAdmin(self, adminAdapter, adminIdentity): + return self._impl.createAdmin(adminAdapter, adminIdentity) + + def getAdmin(self): + return self._impl.getAdmin() + + def addAdminFacet(self, servant, facet): + self._impl.addAdminFacet(servant, facet) + + def findAdminFacet(self, facet): + return self._impl.findAdminFacet(facet) + + def findAllAdminFacets(self): + return self._impl.findAllAdminFacets() + + def removeAdminFacet(self, facet): + return self._impl.removeAdminFacet(facet) + +# +# Ice.initialize() +# +def initialize(args=None, data=None): + '''Initializes a new communicator. The optional arguments represent +an argument list (such as sys.argv) and an instance of InitializationData. +You can invoke this function as follows: + +Ice.initialize() +Ice.initialize(args) +Ice.initialize(data) +Ice.initialize(args, data) + +If you supply an argument list, the function removes those arguments from +the list that were recognized by the Ice run time. +''' + communicator = IcePy.Communicator(args, data) + return CommunicatorI(communicator) + +# +# Ice.identityToString +# +def identityToString(id, toStringMode=None): + return IcePy.identityToString(id, toStringMode) + +# +# Ice.stringToIdentity +# +def stringToIdentity(str): + return IcePy.stringToIdentity(str) + +# +# ObjectAdapter wrapper. +# +class ObjectAdapterI(ObjectAdapter): + def __init__(self, impl): + self._impl = impl + + def getName(self): + return self._impl.getName() + + def getCommunicator(self): + communicator = self._impl.getCommunicator() + return communicator._getWrapper() + + def activate(self): + self._impl.activate() + + def hold(self): + self._impl.hold() + + def waitForHold(self): + # + # If invoked by the main thread, waitForHold only blocks for + # the specified timeout in order to give us a chance to handle + # signals. + # + while not self._impl.waitForHold(1000): + pass + + def deactivate(self): + self._impl.deactivate() + + def waitForDeactivate(self): + # + # If invoked by the main thread, waitForDeactivate only blocks for + # the specified timeout in order to give us a chance to handle + # signals. + # + while not self._impl.waitForDeactivate(1000): + pass + + def isDeactivated(self): + self._impl.isDeactivated() + + def destroy(self): + self._impl.destroy() + + def add(self, servant, id): + return self._impl.add(servant, id) + + def addFacet(self, servant, id, facet): + return self._impl.addFacet(servant, id, facet) + + def addWithUUID(self, servant): + return self._impl.addWithUUID(servant) + + def addFacetWithUUID(self, servant, facet): + return self._impl.addFacetWIthUUID(servant, facet) + + def addDefaultServant(self, servant, category): + self._impl.addDefaultServant(servant, category) + + def remove(self, id): + return self._impl.remove(id) + + def removeFacet(self, id, facet): + return self._impl.removeFacet(id, facet) + + def removeAllFacets(self, id): + return self._impl.removeAllFacets(id) + + def removeDefaultServant(self, category): + return self._impl.removeDefaultServant(category) + + def find(self, id): + return self._impl.find(id) + + def findFacet(self, id, facet): + return self._impl.findFacet(id, facet) + + def findAllFacets(self, id): + return self._impl.findAllFacets(id) + + def findByProxy(self, proxy): + return self._impl.findByProxy(proxy) + + def findDefaultServant(self, category): + return self._impl.findDefaultServant(category) + + def addServantLocator(self, locator, category): + self._impl.addServantLocator(locator, category) + + def removeServantLocator(self, category): + return self._impl.removeServantLocator(category) + + def findServantLocator(self, category): + return self._impl.findServantLocator(category) + + def createProxy(self, id): + return self._impl.createProxy(id) + + def createDirectProxy(self, id): + return self._impl.createDirectProxy(id) + + def createIndirectProxy(self, id): + return self._impl.createIndirectProxy(id) + + def createReverseProxy(self, id): + return self._impl.createReverseProxy(id) + + def setLocator(self, loc): + self._impl.setLocator(loc) + + def getLocator(self): + return self._impl.getLocator() + + def getEndpoints(self): + return self._impl.getEndpoints() + + def refreshPublishedEndpoints(self): + self._impl.refreshPublishedEndpoints() + + def getPublishedEndpoints(self): + return self._impl.getPublishedEndpoints() + + def setPublishedEndpoints(self, newEndpoints): + self._impl.setPublishedEndpoints(newEndpoints) + +# +# Logger wrapper. +# +class LoggerI(Logger): + def __init__(self, impl): + self._impl = impl + + def _print(self, message): + return self._impl._print(message) + + def trace(self, category, message): + return self._impl.trace(category, message) + + def warning(self, message): + return self._impl.warning(message) + + def error(self, message): + return self._impl.error(message) + + def getPrefix(self): + return self._impl.getPrefix() + + def cloneWithPrefix(self, prefix): + logger = self._impl.cloneWithPrefix(prefix) + return LoggerI(logger) + +# +# Properties wrapper. +# +class PropertiesI(Properties): + def __init__(self, impl): + self._impl = impl + + def getProperty(self, key): + return self._impl.getProperty(key) + + def getPropertyWithDefault(self, key, value): + return self._impl.getPropertyWithDefault(key, value) + + def getPropertyAsInt(self, key): + return self._impl.getPropertyAsInt(key) + + def getPropertyAsIntWithDefault(self, key, value): + return self._impl.getPropertyAsIntWithDefault(key, value) + + def getPropertyAsList(self, key): + return self._impl.getPropertyAsList(key) + + def getPropertyAsListWithDefault(self, key, value): + return self._impl.getPropertyAsListWithDefault(key, value) + + def getPropertiesForPrefix(self, prefix): + return self._impl.getPropertiesForPrefix(prefix) + + def setProperty(self, key, value): + self._impl.setProperty(key, value) + + def getCommandLineOptions(self): + return self._impl.getCommandLineOptions() + + def parseCommandLineOptions(self, prefix, options): + return self._impl.parseCommandLineOptions(prefix, options) + + def parseIceCommandLineOptions(self, options): + return self._impl.parseIceCommandLineOptions(options) + + def load(self, file): + self._impl.load(file) + + def clone(self): + properties = self._impl.clone() + return PropertiesI(properties) + + def __iter__(self): + dict = self._impl.getPropertiesForPrefix('') + return iter(dict) + + def __str__(self): + return str(self._impl) + +# +# Ice.createProperties() +# +def createProperties(args=None, defaults=None): + '''Creates a new property set. The optional arguments represent +an argument list (such as sys.argv) and a property set that supplies +default values. You can invoke this function as follows: + +Ice.createProperties() +Ice.createProperties(args) +Ice.createProperties(defaults) +Ice.createProperties(args, defaults) + +If you supply an argument list, the function removes those arguments +from the list that were recognized by the Ice run time. +''' + + properties = IcePy.createProperties(args, defaults) + return PropertiesI(properties) + +# +# Ice.getProcessLogger() +# Ice.setProcessLogger() +# +def getProcessLogger(): + '''Returns the default logger object.''' + logger = IcePy.getProcessLogger() + if isinstance(logger, Logger): + return logger + else: + return LoggerI(logger) + +def setProcessLogger(logger): + '''Sets the default logger object.''' + IcePy.setProcessLogger(logger) + +# +# ImplicitContext wrapper +# +class ImplicitContextI(ImplicitContext): + def __init__(self, impl): + self._impl = impl + + def setContext(self, ctx): + self._impl.setContext(ctx) + + def getContext(self): + return self._impl.getContext() + + def containsKey(self, key): + return self._impl.containsKey(key) + + def get(self, key): + return self._impl.get(key) + + def put(self, key, value): + return self._impl.put(key, value) + + def remove(self, key): + return self._impl.remove(key) + + +# +# Its not possible to block in a python signal handler since this +# blocks the main thread from doing further work. As such we queue the +# signal with a worker thread which then "dispatches" the signal to +# the registered callback object. +# +# Note the interface is the same as the C++ CtrlCHandler +# implementation, however, the implementation is different. +# +class CtrlCHandler(threading.Thread): + # Class variable referring to the one and only handler for use + # from the signal handling callback. + _self = None + + def __init__(self): + threading.Thread.__init__(self) + + if CtrlCHandler._self != None: + raise RuntimeError("Only a single instance of a CtrlCHandler can be instantiated.") + CtrlCHandler._self = self + + # State variables. These are not class static variables. + self._condVar = threading.Condition() + self._queue = [] + self._done = False + self._callback = None + + # + # Setup and install signal handlers + # + if 'SIGHUP' in signal.__dict__: + signal.signal(signal.SIGHUP, CtrlCHandler.signalHandler) + if 'SIGBREAK' in signal.__dict__: + signal.signal(signal.SIGBREAK, CtrlCHandler.signalHandler) + signal.signal(signal.SIGINT, CtrlCHandler.signalHandler) + signal.signal(signal.SIGTERM, CtrlCHandler.signalHandler) + + # Start the thread once everything else is done. + self.start() + + # Dequeue and dispatch signals. + def run(self): + while True: + self._condVar.acquire() + while len(self._queue) == 0 and not self._done: + self._condVar.wait() + if self._done: + self._condVar.release() + break + sig, callback = self._queue.pop() + self._condVar.release() + if callback: + callback(sig) + + # Destroy the object. Wait for the thread to terminate and cleanup + # the internal state. + def destroy(self): + self._condVar.acquire() + self._done = True + self._condVar.notify() + self._condVar.release() + + # Wait for the thread to terminate + self.join() + # + # Cleanup any state set by the CtrlCHandler. + # + if 'SIGHUP' in signal.__dict__: + signal.signal(signal.SIGHUP, signal.SIG_DFL) + if 'SIGBREAK' in signal.__dict__: + signal.signal(signal.SIGBREAK, signal.SIG_DFL) + signal.signal(signal.SIGINT, signal.SIG_DFL) + signal.signal(signal.SIGTERM, signal.SIG_DFL) + CtrlCHandler._self = None + + def setCallback(self, callback): + self._condVar.acquire() + self._callback = callback + self._condVar.release() + + def getCallback(self): + self._condVar.acquire() + callback = self._callback + self._condVar.release() + return callback + + # Private. Only called by the signal handling mechanism. + def signalHandler(self, sig, frame): + self._self._condVar.acquire() + # + # The signal AND the current callback are queued together. + # + self._self._queue.append([sig, self._self._callback]) + self._self._condVar.notify() + self._self._condVar.release() + signalHandler = classmethod(signalHandler) + +# +# Application logger. +# +class _ApplicationLoggerI(Logger): + def __init__(self, prefix): + if len(prefix) > 0: + self._prefix = prefix + ": " + else: + self._prefix = "" + self._outputMutex = threading.Lock() + + def _print(self, message): + s = "[ " + str(datetime.datetime.now()) + " " + self._prefix + self._outputMutex.acquire() + sys.stderr.write(message + "\n") + self._outputMutex.release() + + def trace(self, category, message): + s = "[ " + str(datetime.datetime.now()) + " " + self._prefix + if len(category) > 0: + s += category + ": " + s += message + " ]" + + s = s.replace("\n", "\n ") + + self._outputMutex.acquire() + sys.stderr.write(s + "\n") + self._outputMutex.release() + + def warning(self, message): + self._outputMutex.acquire() + sys.stderr.write(str(datetime.datetime.now()) + " " + self._prefix + "warning: " + message + "\n") + self._outputMutex.release() + + def error(self, message): + self._outputMutex.acquire() + sys.stderr.write(str(datetime.datetime.now()) + " " + self._prefix + "error: " + message + "\n") + self._outputMutex.release() + +# +# Application class. +# +import signal, traceback +class Application(object): + '''Convenience class that initializes a communicator and reacts +gracefully to signals. An application must define a subclass +of this class and supply an implementation of the run method. +''' + + def __init__(self, signalPolicy=0): # HandleSignals=0 + '''The constructor accepts an optional argument indicating +whether to handle signals. The value should be either +Application.HandleSignals (the default) or +Application.NoSignalHandling. +''' + if type(self) == Application: + raise RuntimeError("Ice.Application is an abstract class") + Application._signalPolicy = signalPolicy + + def main(self, args, configFile=None, initData=None): + '''The main entry point for the Application class. The arguments +are an argument list (such as sys.argv), the name of an Ice +configuration file (optional), and an instance of +InitializationData (optional). This method does not return +until after the completion of the run method. The return +value is an integer representing the exit status. +''' + + if Application._communicator: + getProcessLogger().error(args[0] + ": only one instance of the Application class can be used") + return 1 + + # + # We parse the properties here to extract Ice.ProgramName. + # + if not initData: + initData = InitializationData() + if configFile: + try: + initData.properties = createProperties(None, initData.properties) + initData.properties.load(configFile) + except: + getProcessLogger().error(traceback.format_exc()) + return 1 + initData.properties = createProperties(args, initData.properties) + + # + # If the process logger is the default logger, we replace it with a + # a logger which is using the program name for the prefix. + # + if isinstance(getProcessLogger(), LoggerI): + setProcessLogger(_ApplicationLoggerI(initData.properties.getProperty("Ice.ProgramName"))) + + # + # Install our handler for the signals we are interested in. We assume main() + # is called from the main thread. + # + if Application._signalPolicy == Application.HandleSignals: + Application._ctrlCHandler = CtrlCHandler() + + try: + Application._interrupted = False + Application._appName = initData.properties.getPropertyWithDefault("Ice.ProgramName", args[0]) + Application._application = self + + # + # Used by _destroyOnInterruptCallback and _shutdownOnInterruptCallback. + # + Application._nohup = initData.properties.getPropertyAsInt("Ice.Nohup") > 0 + + # + # The default is to destroy when a signal is received. + # + if Application._signalPolicy == Application.HandleSignals: + Application.destroyOnInterrupt() + + status = self.doMain(args, initData) + except: + getProcessLogger().error(traceback.format_exc()) + status = 1 + # + # Set _ctrlCHandler to 0 only once communicator.destroy() has + # completed. + # + if Application._signalPolicy == Application.HandleSignals: + Application._ctrlCHandler.destroy() + Application._ctrlCHandler = None + + return status + + def doMain(self, args, initData): + try: + Application._communicator = initialize(args, initData) + Application._destroyed = False + status = self.run(args) + + except: + getProcessLogger().error(traceback.format_exc()) + status = 1 + + # + # Don't want any new interrupt and at this point (post-run), + # it would not make sense to release a held signal to run + # shutdown or destroy. + # + if Application._signalPolicy == Application.HandleSignals: + Application.ignoreInterrupt() + + Application._condVar.acquire() + while Application._callbackInProgress: + Application._condVar.wait() + if Application._destroyed: + Application._communicator = None + else: + Application._destroyed = True + # + # And _communicator != 0, meaning will be destroyed + # next, _destroyed = true also ensures that any + # remaining callback won't do anything + # + Application._application = None + Application._condVar.release() + + if Application._communicator: + try: + Application._communicator.destroy() + except: + getProcessLogger().error(traceback.format_exc()) + status = 1 + Application._communicator = None + return status + + def run(self, args): + '''This method must be overridden in a subclass. The base +class supplies an argument list from which all Ice arguments +have already been removed. The method returns an integer +exit status (0 is success, non-zero is failure). +''' + raise RuntimeError('run() not implemented') + + def interruptCallback(self, sig): + '''Subclass hook to intercept an interrupt.''' + pass + + def appName(self): + '''Returns the application name (the first element of +the argument list).''' + return self._appName + appName = classmethod(appName) + + def communicator(self): + '''Returns the communicator that was initialized for +the application.''' + return self._communicator + communicator = classmethod(communicator) + + def destroyOnInterrupt(self): + '''Configures the application to destroy its communicator +when interrupted by a signal.''' + if Application._signalPolicy == Application.HandleSignals: + self._condVar.acquire() + if self._ctrlCHandler.getCallback() == self._holdInterruptCallback: + self._released = True + self._condVar.notify() + self._ctrlCHandler.setCallback(self._destroyOnInterruptCallback) + self._condVar.release() + else: + getProcessLogger().error(Application._appName + \ + ": warning: interrupt method called on Application configured to not handle interrupts.") + destroyOnInterrupt = classmethod(destroyOnInterrupt) + + def shutdownOnInterrupt(self): + '''Configures the application to shutdown its communicator +when interrupted by a signal.''' + if Application._signalPolicy == Application.HandleSignals: + self._condVar.acquire() + if self._ctrlCHandler.getCallback() == self._holdInterruptCallback: + self._released = True + self._condVar.notify() + self._ctrlCHandler.setCallback(self._shutdownOnInterruptCallback) + self._condVar.release() + else: + getProcessLogger().error(Application._appName + \ + ": warning: interrupt method called on Application configured to not handle interrupts.") + shutdownOnInterrupt = classmethod(shutdownOnInterrupt) + + def ignoreInterrupt(self): + '''Configures the application to ignore signals.''' + if Application._signalPolicy == Application.HandleSignals: + self._condVar.acquire() + if self._ctrlCHandler.getCallback() == self._holdInterruptCallback: + self._released = True + self._condVar.notify() + self._ctrlCHandler.setCallback(None) + self._condVar.release() + else: + getProcessLogger().error(Application._appName + \ + ": warning: interrupt method called on Application configured to not handle interrupts.") + ignoreInterrupt = classmethod(ignoreInterrupt) + + def callbackOnInterrupt(self): + '''Configures the application to invoke interruptCallback +when interrupted by a signal.''' + if Application._signalPolicy == Application.HandleSignals: + self._condVar.acquire() + if self._ctrlCHandler.getCallback() == self._holdInterruptCallback: + self._released = True + self._condVar.notify() + self._ctrlCHandler.setCallback(self._callbackOnInterruptCallback) + self._condVar.release() + else: + getProcessLogger().error(Application._appName + \ + ": warning: interrupt method called on Application configured to not handle interrupts.") + callbackOnInterrupt = classmethod(callbackOnInterrupt) + + def holdInterrupt(self): + '''Configures the application to queue an interrupt for +later processing.''' + if Application._signalPolicy == Application.HandleSignals: + self._condVar.acquire() + if self._ctrlCHandler.getCallback() != self._holdInterruptCallback: + self._previousCallback = self._ctrlCHandler.getCallback() + self._released = False + self._ctrlCHandler.setCallback(self._holdInterruptCallback) + # else, we were already holding signals + self._condVar.release() + else: + getProcessLogger().error(Application._appName + \ + ": warning: interrupt method called on Application configured to not handle interrupts.") + holdInterrupt = classmethod(holdInterrupt) + + def releaseInterrupt(self): + '''Instructs the application to process any queued interrupt.''' + if Application._signalPolicy == Application.HandleSignals: + self._condVar.acquire() + if self._ctrlCHandler.getCallback() == self._holdInterruptCallback: + # + # Note that it's very possible no signal is held; + # in this case the callback is just replaced and + # setting _released to true and signalling _condVar + # do no harm. + # + self._released = True + self._ctrlCHandler.setCallback(self._previousCallback) + self._condVar.notify() + # Else nothing to release. + self._condVar.release() + else: + getProcessLogger().error(Application._appName + \ + ": warning: interrupt method called on Application configured to not handle interrupts.") + releaseInterrupt = classmethod(releaseInterrupt) + + def interrupted(self): + '''Returns True if the application was interrupted by a +signal, or False otherwise.''' + self._condVar.acquire() + result = self._interrupted + self._condVar.release() + return result + interrupted = classmethod(interrupted) + + def _holdInterruptCallback(self, sig): + self._condVar.acquire() + while not self._released: + self._condVar.wait() + if self._destroyed: + # + # Being destroyed by main thread + # + self._condVar.release() + return + callback = self._ctrlCHandler.getCallback() + self._condVar.release() + if callback: + callback(sig) + _holdInterruptCallback = classmethod(_holdInterruptCallback) + + def _destroyOnInterruptCallback(self, sig): + self._condVar.acquire() + if self._destroyed or self._nohup and sig == signal.SIGHUP: + # + # Being destroyed by main thread, or nohup. + # + self._condVar.release() + return + + self._callbackInProcess = True + self._interrupted = True + self._destroyed = True + self._condVar.release() + + try: + self._communicator.destroy() + except: + getProcessLogger().error(self._appName + " (while destroying in response to signal " + str(sig) + "):" + \ + traceback.format_exc()) + + self._condVar.acquire() + self._callbackInProcess = False + self._condVar.notify() + self._condVar.release() + _destroyOnInterruptCallback = classmethod(_destroyOnInterruptCallback) + + def _shutdownOnInterruptCallback(self, sig): + self._condVar.acquire() + if self._destroyed or self._nohup and sig == signal.SIGHUP: + # + # Being destroyed by main thread, or nohup. + # + self._condVar.release() + return + + self._callbackInProcess = True + self._interrupted = True + self._condVar.release() + + try: + self._communicator.shutdown() + except: + getProcessLogger().error(self._appName + " (while shutting down in response to signal " + str(sig) + \ + "):" + traceback.format_exc()) + + self._condVar.acquire() + self._callbackInProcess = False + self._condVar.notify() + self._condVar.release() + _shutdownOnInterruptCallback = classmethod(_shutdownOnInterruptCallback) + + def _callbackOnInterruptCallback(self, sig): + self._condVar.acquire() + if self._destroyed: + # + # Being destroyed by main thread. + # + self._condVar.release() + return + # For SIGHUP the user callback is always called. It can decide + # what to do. + + self._callbackInProcess = True + self._interrupted = True + self._condVar.release() + + try: + self._application.interruptCallback(sig) + except: + getProcessLogger().error(self._appName + " (while interrupting in response to signal " + str(sig) + \ + "):" + traceback.format_exc()) + + self._condVar.acquire() + self._callbackInProcess = False + self._condVar.notify() + self._condVar.release() + + _callbackOnInterruptCallback = classmethod(_callbackOnInterruptCallback) + + HandleSignals = 0 + NoSignalHandling = 1 + + _appName = None + _communicator = None + _application = None + _ctrlCHandler = None + _previousCallback = None + _interrupted = False + _released = False + _destroyed = False + _callbackInProgress = False + _condVar = threading.Condition() + _signalPolicy = HandleSignals + +# +# Define Ice::Object and Ice::ObjectPrx. +# +IcePy._t_Object = IcePy.defineClass('::Ice::Object', Object, (), None, ()) +IcePy._t_Value = IcePy.defineValue('::Ice::Object', Value, -1, (), False, False, None, ()) +IcePy._t_ObjectPrx = IcePy.defineProxy('::Ice::Object', ObjectPrx) +Object._ice_type = IcePy._t_Object + +Object._op_ice_isA = IcePy.Operation('ice_isA', OperationMode.Idempotent, OperationMode.Nonmutating, False, None, (), (((), IcePy._t_string, False, 0),), (), ((), IcePy._t_bool, False, 0), ()) +Object._op_ice_ping = IcePy.Operation('ice_ping', OperationMode.Idempotent, OperationMode.Nonmutating, False, None, (), (), (), None, ()) +Object._op_ice_ids = IcePy.Operation('ice_ids', OperationMode.Idempotent, OperationMode.Nonmutating, False, None, (), (), (), ((), _t_StringSeq, False, 0), ()) +Object._op_ice_id = IcePy.Operation('ice_id', OperationMode.Idempotent, OperationMode.Nonmutating, False, None, (), (), (), ((), IcePy._t_string, False, 0), ()) + +IcePy._t_LocalObject = IcePy.defineValue('::Ice::LocalObject', object, -1, (), False, False, None, ()) + +IcePy._t_UnknownSlicedValue = IcePy.defineValue('::Ice::UnknownSlicedValue', UnknownSlicedValue, -1, (), True, False, None, ()) +UnknownSlicedValue._ice_type = IcePy._t_UnknownSlicedValue + +# +# Annotate some exceptions. +# +def SyscallException__str__(self): + return "Ice.SyscallException:\n" + os.strerror(self.error) +SyscallException.__str__ = SyscallException__str__ +del SyscallException__str__ + +def SocketException__str__(self): + return "Ice.SocketException:\n" + os.strerror(self.error) +SocketException.__str__ = SocketException__str__ +del SocketException__str__ + +def ConnectFailedException__str__(self): + return "Ice.ConnectFailedException:\n" + os.strerror(self.error) +ConnectFailedException.__str__ = ConnectFailedException__str__ +del ConnectFailedException__str__ + +def ConnectionRefusedException__str__(self): + return "Ice.ConnectionRefusedException:\n" + os.strerror(self.error) +ConnectionRefusedException.__str__ = ConnectionRefusedException__str__ +del ConnectionRefusedException__str__ + +def ConnectionLostException__str__(self): + if self.error == 0: + return "Ice.ConnectionLostException:\nrecv() returned zero" + else: + return "Ice.ConnectionLostException:\n" + os.strerror(self.error) +ConnectionLostException.__str__ = ConnectionLostException__str__ +del ConnectionLostException__str__ + +# +# Proxy comparison functions. +# +def proxyIdentityEqual(lhs, rhs): + '''Determines whether the identities of two proxies are equal.''' + return proxyIdentityCompare(lhs, rhs) == 0 + +def proxyIdentityCompare(lhs, rhs): + '''Compares the identities of two proxies.''' + if (lhs and not isinstance(lhs, ObjectPrx)) or (rhs and not isinstance(rhs, ObjectPrx)): + raise ValueError('argument is not a proxy') + if not lhs and not rhs: + return 0 + elif not lhs and rhs: + return -1 + elif lhs and not rhs: + return 1 + else: + lid = lhs.ice_getIdentity() + rid = rhs.ice_getIdentity() + return (lid > rid) - (lid < rid) + +def proxyIdentityAndFacetEqual(lhs, rhs): + '''Determines whether the identities and facets of two +proxies are equal.''' + return proxyIdentityAndFacetCompare(lhs, rhs) == 0 + +def proxyIdentityAndFacetCompare(lhs, rhs): + '''Compares the identities and facets of two proxies.''' + if (lhs and not isinstance(lhs, ObjectPrx)) or (rhs and not isinstance(rhs, ObjectPrx)): + raise ValueError('argument is not a proxy') + if not lhs and not rhs: + return 0 + elif not lhs and rhs: + return -1 + elif lhs and not rhs: + return 1 + elif lhs.ice_getIdentity() != rhs.ice_getIdentity(): + lid = lhs.ice_getIdentity() + rid = rhs.ice_getIdentity() + return (lid > rid) - (lid < rid) + else: + lf = lhs.ice_getFacet() + rf = rhs.ice_getFacet() + return (lf > rf) - (lf < rf) + +# +# Used by generated code. Defining these in the Ice module means the generated code +# can avoid the need to qualify the type() and hash() functions with their module +# names. Since the functions are in the __builtin__ module (for Python 2.x) and the +# builtins module (for Python 3.x), it's easier to define them here. +# +def getType(o): + return type(o) + +# +# Used by generated code. Defining this in the Ice module means the generated code +# can avoid the need to qualify the hash() function with its module name. Since +# the function is in the __builtin__ module (for Python 2.x) and the builtins +# module (for Python 3.x), it's easier to define it here. +# +def getHash(o): + return hash(o) + +Protocol_1_0 = ProtocolVersion(1, 0) +Encoding_1_0 = EncodingVersion(1, 0) +Encoding_1_1 = EncodingVersion(1, 1) diff --git a/python/python/IceFuture.py b/python/python/IceFuture.py deleted file mode 100644 index df5eff76c83..00000000000 --- a/python/python/IceFuture.py +++ /dev/null @@ -1,48 +0,0 @@ -# ********************************************************************** -# -# Copyright (c) 2003-2017 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. -# -# ********************************************************************** - -# -# This file should only be used in Python >= 3.5. -# - -import asyncio - -# -# This class defines an __await__ method so that coroutines can call 'await '. -# -# Python 2.x rejects this code with a syntax error because a return statement is not allowed in a generator. -# -class FutureBase(object): - def __await__(self): - if not self.done(): - yield self - return self.result() - -def wrap_future(future, *, loop=None): - '''Wrap Ice.Future object into an asyncio.Future.''' - if isinstance(future, asyncio.Future): - return future - - assert isinstance(future, FutureBase), 'Ice.Future is expected, got {!r}'.format(future) - - if loop is None: - loop = asyncio.get_event_loop() - - af = loop.create_future() - - def callback(): - if future.cancelled(): - af.cancel() - elif future.exception(): - af.set_exception(future.exception()) - else: - af.set_result(future.result()) - - future.add_done_callback(lambda f: loop.call_soon_threadsafe(callback)) - return af diff --git a/python/python/Makefile b/python/python/Makefile index 53346ffef2f..bd5cd9b43dd 100644 --- a/python/python/Makefile +++ b/python/python/Makefile @@ -20,16 +20,6 @@ $(eval $(call load-translator-dependencies,$(top_srcdir)/cpp/src/slice2py)) .NOTPARALLEL: -install:: | $(DESTDIR)$(install_pythondir) - $(E) "Installing generated code" - $(Q)$(INSTALL) *.py $(DESTDIR)$(install_pythondir) - -ifneq ($(usr_dir_install),) -install:: | $(DESTDIR)$(install_pythondir) - $(E) "Installing .pth file" - $(Q)$(INSTALL) ../config/zeroc-ice.pth $(DESTDIR)$(install_pythondir)/.. -endif - $(eval $(call make-python-package,$(slicedir),$(lang_srcdir)/python,Ice,--no-package)) $(eval $(call make-python-package,$(slicedir),$(lang_srcdir)/python,Glacier2,--no-package)) $(eval $(call make-python-package,$(slicedir),$(lang_srcdir)/python,IceBox)) @@ -38,7 +28,15 @@ $(eval $(call make-python-package,$(slicedir),$(lang_srcdir)/python,IceGrid)) $(eval $(call make-python-package,$(slicedir),$(lang_srcdir)/python,IcePatch2)) $(eval $(call make-python-package,$(slicedir),$(lang_srcdir)/python,IceStorm)) -# Generate this two files individually without the --no-package option to ensure the +# Generate these two files individually without the --no-package option to ensure the # IceMX package is updated. $(eval $(call make-python-slice,$(slicedir),$(lang_srcdir)/python,Ice,Metrics)) $(eval $(call make-python-slice,$(slicedir),$(lang_srcdir)/python,Glacier2,Metrics)) + +install:: | $(DESTDIR)$(install_pythondir)/Ice + $(E) "Installing generated code" + $(Q)$(INSTALL) Ice/__init__.py $(DESTDIR)$(install_pythondir)/Ice + $(Q)$(INSTALL) Ice/IceFuture.py $(DESTDIR)$(install_pythondir)/Ice + +install:: | $(DESTDIR)$(install_pythondir)/Glacier2 + $(Q)$(INSTALL) Glacier2/__init__.py $(DESTDIR)$(install_pythondir)/Glacier2 diff --git a/python/test/Slice/escape/Client.py b/python/test/Slice/escape/Client.py index 126d2810482..1946d09fc94 100755 --- a/python/test/Slice/escape/Client.py +++ b/python/test/Slice/escape/Client.py @@ -12,7 +12,7 @@ import os, sys, traceback for toplevel in [".", "..", "../..", "../../..", "../../../.."]: toplevel = os.path.normpath(toplevel) - if os.path.exists(os.path.join(toplevel, "python", "Ice.py")): + if os.path.exists(os.path.join(toplevel, "python", "Ice", "__init__.py")): break else: raise RuntimeError("can't find toplevel directory!") diff --git a/python/test/Slice/import/Client.py b/python/test/Slice/import/Client.py index 94a35d45582..c27f67795ac 100755 --- a/python/test/Slice/import/Client.py +++ b/python/test/Slice/import/Client.py @@ -12,7 +12,7 @@ import os, sys, traceback for toplevel in [".", "..", "../..", "../../..", "../../../.."]: toplevel = os.path.normpath(toplevel) - if os.path.exists(os.path.join(toplevel, "python", "Ice.py")): + if os.path.exists(os.path.join(toplevel, "python", "Ice", "__init__.py")): break else: raise RuntimeError("can't find toplevel directory!") diff --git a/python/test/Slice/macros/Client.py b/python/test/Slice/macros/Client.py index ae60009a31b..5fa054dde5a 100755 --- a/python/test/Slice/macros/Client.py +++ b/python/test/Slice/macros/Client.py @@ -12,7 +12,7 @@ import os, sys, traceback for toplevel in [".", "..", "../..", "../../..", "../../../.."]: toplevel = os.path.normpath(toplevel) - if os.path.exists(os.path.join(toplevel, "python", "Ice.py")): + if os.path.exists(os.path.join(toplevel, "python", "Ice", "__init__.py")): break else: raise RuntimeError("can't find toplevel directory!") diff --git a/python/test/Slice/structure/Client.py b/python/test/Slice/structure/Client.py index 2a9e23246db..19fb2c8a98e 100755 --- a/python/test/Slice/structure/Client.py +++ b/python/test/Slice/structure/Client.py @@ -12,7 +12,7 @@ import os, sys, traceback for toplevel in [".", "..", "../..", "../../..", "../../../.."]: toplevel = os.path.normpath(toplevel) - if os.path.exists(os.path.join(toplevel, "python", "Ice.py")): + if os.path.exists(os.path.join(toplevel, "python", "Ice", "__init__.py")): break else: raise RuntimeError("can't find toplevel directory!") diff --git a/slice/Glacier2/Metrics.ice b/slice/Glacier2/Metrics.ice index 49947dee3af..62181d61076 100644 --- a/slice/Glacier2/Metrics.ice +++ b/slice/Glacier2/Metrics.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:GLACIER2_API", "objc:header-dir:objc", "objc:dll-export:GLACIER2_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:GLACIER2_API", "objc:header-dir:objc", "objc:dll-export:GLACIER2_API", "js:ice-build", "python:pkgdir:Glacier2"]] [["cpp:include:Glacier2/Config.h"]] #include diff --git a/slice/Glacier2/PermissionsVerifier.ice b/slice/Glacier2/PermissionsVerifier.ice index af16d0f40fa..23cb992322d 100644 --- a/slice/Glacier2/PermissionsVerifier.ice +++ b/slice/Glacier2/PermissionsVerifier.ice @@ -9,7 +9,7 @@ #pragma once -[["cpp:header-ext:h", "cpp:dll-export:GLACIER2_API", "objc:header-dir:objc", "objc:dll-export:GLACIER2_API", "js:ice-build"]] +[["cpp:header-ext:h", "cpp:dll-export:GLACIER2_API", "objc:header-dir:objc", "objc:dll-export:GLACIER2_API", "js:ice-build", "python:pkgdir:Glacier2"]] [["cpp:include:Glacier2/Config.h"]] #include diff --git a/slice/Glacier2/PermissionsVerifierF.ice b/slice/Glacier2/PermissionsVerifierF.ice index fba9eff9df4..dd7f05926c8 100644 --- a/slice/Glacier2/PermissionsVerifierF.ice +++ b/slice/Glacier2/PermissionsVerifierF.ice @@ -9,7 +9,7 @@ #pragma once -[["cpp:header-ext:h", "cpp:dll-export:GLACIER2_API", "objc:header-dir:objc", "objc:dll-export:GLACIER2_API", "js:ice-build"]] +[["cpp:header-ext:h", "cpp:dll-export:GLACIER2_API", "objc:header-dir:objc", "objc:dll-export:GLACIER2_API", "js:ice-build", "python:pkgdir:Glacier2"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Glacier2/Router.ice b/slice/Glacier2/Router.ice index 018f8247d48..7a945dc7158 100644 --- a/slice/Glacier2/Router.ice +++ b/slice/Glacier2/Router.ice @@ -9,7 +9,7 @@ #pragma once -[["cpp:header-ext:h", "cpp:dll-export:GLACIER2_API", "objc:header-dir:objc", "objc:dll-export:GLACIER2_API", "js:ice-build"]] +[["cpp:header-ext:h", "cpp:dll-export:GLACIER2_API", "objc:header-dir:objc", "objc:dll-export:GLACIER2_API", "js:ice-build", "python:pkgdir:Glacier2"]] [["cpp:include:Glacier2/Config.h"]] #include diff --git a/slice/Glacier2/RouterF.ice b/slice/Glacier2/RouterF.ice index b39bd711611..2d2898cb034 100644 --- a/slice/Glacier2/RouterF.ice +++ b/slice/Glacier2/RouterF.ice @@ -9,7 +9,7 @@ #pragma once -[["cpp:header-ext:h", "cpp:dll-export:GLACIER2_API", "objc:header-dir:objc", "objc:dll-export:GLACIER2_API", "js:ice-build"]] +[["cpp:header-ext:h", "cpp:dll-export:GLACIER2_API", "objc:header-dir:objc", "objc:dll-export:GLACIER2_API", "js:ice-build", "python:pkgdir:Glacier2"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Glacier2/SSLInfo.ice b/slice/Glacier2/SSLInfo.ice index fa11a9cc9b9..05cbe00e66d 100644 --- a/slice/Glacier2/SSLInfo.ice +++ b/slice/Glacier2/SSLInfo.ice @@ -9,7 +9,7 @@ #pragma once -[["cpp:header-ext:h", "cpp:dll-export:GLACIER2_API", "objc:header-dir:objc", "objc:dll-export:GLACIER2_API", "js:ice-build"]] +[["cpp:header-ext:h", "cpp:dll-export:GLACIER2_API", "objc:header-dir:objc", "objc:dll-export:GLACIER2_API", "js:ice-build", "python:pkgdir:Glacier2"]] [["cpp:include:Glacier2/Config.h"]] #include diff --git a/slice/Glacier2/Session.ice b/slice/Glacier2/Session.ice index 262bb9d8aff..9946541daf5 100644 --- a/slice/Glacier2/Session.ice +++ b/slice/Glacier2/Session.ice @@ -9,7 +9,7 @@ #pragma once -[["cpp:header-ext:h", "cpp:dll-export:GLACIER2_API", "objc:header-dir:objc", "objc:dll-export:GLACIER2_API", "js:ice-build"]] +[["cpp:header-ext:h", "cpp:dll-export:GLACIER2_API", "objc:header-dir:objc", "objc:dll-export:GLACIER2_API", "js:ice-build", "python:pkgdir:Glacier2"]] [["cpp:include:Glacier2/Config.h"]] #include diff --git a/slice/Ice/BuiltinSequences.ice b/slice/Ice/BuiltinSequences.ice index a2dd12ff23c..41c39c23647 100644 --- a/slice/Ice/BuiltinSequences.ice +++ b/slice/Ice/BuiltinSequences.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/Communicator.ice b/slice/Ice/Communicator.ice index 280458bbcd0..11a9de91739 100644 --- a/slice/Ice/Communicator.ice +++ b/slice/Ice/Communicator.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #include #include diff --git a/slice/Ice/CommunicatorF.ice b/slice/Ice/CommunicatorF.ice index 697558c8d16..0575c7be455 100644 --- a/slice/Ice/CommunicatorF.ice +++ b/slice/Ice/CommunicatorF.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/Connection.ice b/slice/Ice/Connection.ice index 3fdcc82f834..de937452277 100644 --- a/slice/Ice/Connection.ice +++ b/slice/Ice/Connection.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #include #include diff --git a/slice/Ice/ConnectionF.ice b/slice/Ice/ConnectionF.ice index d56e24618fd..9332deaf0d5 100644 --- a/slice/Ice/ConnectionF.ice +++ b/slice/Ice/ConnectionF.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/Current.ice b/slice/Ice/Current.ice index 219305ff1ba..74d59447e5b 100644 --- a/slice/Ice/Current.ice +++ b/slice/Ice/Current.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #include #include diff --git a/slice/Ice/Endpoint.ice b/slice/Ice/Endpoint.ice index f56703612f7..0c171fdc989 100644 --- a/slice/Ice/Endpoint.ice +++ b/slice/Ice/Endpoint.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #include #include diff --git a/slice/Ice/EndpointF.ice b/slice/Ice/EndpointF.ice index 1ee2db282e8..1b9b2f07347 100644 --- a/slice/Ice/EndpointF.ice +++ b/slice/Ice/EndpointF.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/EndpointTypes.ice b/slice/Ice/EndpointTypes.ice index 5bf6248cf39..35a0a1f8f01 100644 --- a/slice/Ice/EndpointTypes.ice +++ b/slice/Ice/EndpointTypes.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/FacetMap.ice b/slice/Ice/FacetMap.ice index aa433408391..664e14dedc1 100644 --- a/slice/Ice/FacetMap.ice +++ b/slice/Ice/FacetMap.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/Identity.ice b/slice/Ice/Identity.ice index e0e6c6d17e1..b650ad7c2db 100644 --- a/slice/Ice/Identity.ice +++ b/slice/Ice/Identity.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/ImplicitContext.ice b/slice/Ice/ImplicitContext.ice index fbbf671283d..2dabdda5e11 100644 --- a/slice/Ice/ImplicitContext.ice +++ b/slice/Ice/ImplicitContext.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #include #include diff --git a/slice/Ice/ImplicitContextF.ice b/slice/Ice/ImplicitContextF.ice index b87fb14246f..104cf34ef00 100644 --- a/slice/Ice/ImplicitContextF.ice +++ b/slice/Ice/ImplicitContextF.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/Instrumentation.ice b/slice/Ice/Instrumentation.ice index ff0063a7937..590cbd0243a 100644 --- a/slice/Ice/Instrumentation.ice +++ b/slice/Ice/Instrumentation.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #include #include diff --git a/slice/Ice/InstrumentationF.ice b/slice/Ice/InstrumentationF.ice index 18ad14e1a25..03bd355ea4d 100644 --- a/slice/Ice/InstrumentationF.ice +++ b/slice/Ice/InstrumentationF.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/LocalException.ice b/slice/Ice/LocalException.ice index f0b21b3324f..be9098b6b2b 100644 --- a/slice/Ice/LocalException.ice +++ b/slice/Ice/LocalException.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #include #include diff --git a/slice/Ice/Locator.ice b/slice/Ice/Locator.ice index 441ac5ab397..4d61ef569c4 100644 --- a/slice/Ice/Locator.ice +++ b/slice/Ice/Locator.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #include #include diff --git a/slice/Ice/LocatorF.ice b/slice/Ice/LocatorF.ice index 8d028c5a67d..b82ac90fa56 100644 --- a/slice/Ice/LocatorF.ice +++ b/slice/Ice/LocatorF.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/Logger.ice b/slice/Ice/Logger.ice index 376e99984b1..4ea8bae1114 100644 --- a/slice/Ice/Logger.ice +++ b/slice/Ice/Logger.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/LoggerF.ice b/slice/Ice/LoggerF.ice index c1b41f84ab4..a3ef1fec89b 100644 --- a/slice/Ice/LoggerF.ice +++ b/slice/Ice/LoggerF.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/Metrics.ice b/slice/Ice/Metrics.ice index 43ea05a2cbc..534dca93ca4 100644 --- a/slice/Ice/Metrics.ice +++ b/slice/Ice/Metrics.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #include diff --git a/slice/Ice/ObjectAdapter.ice b/slice/Ice/ObjectAdapter.ice index ae0f8a84f03..2baf7109a31 100644 --- a/slice/Ice/ObjectAdapter.ice +++ b/slice/Ice/ObjectAdapter.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #include #include diff --git a/slice/Ice/ObjectAdapterF.ice b/slice/Ice/ObjectAdapterF.ice index 097544e7bab..314bcf9f31c 100644 --- a/slice/Ice/ObjectAdapterF.ice +++ b/slice/Ice/ObjectAdapterF.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/ObjectFactory.ice b/slice/Ice/ObjectFactory.ice index 291dc3a2914..68028d63194 100644 --- a/slice/Ice/ObjectFactory.ice +++ b/slice/Ice/ObjectFactory.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/Plugin.ice b/slice/Ice/Plugin.ice index 63f5969a803..d143b0f71eb 100644 --- a/slice/Ice/Plugin.ice +++ b/slice/Ice/Plugin.ice @@ -10,7 +10,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #include #include diff --git a/slice/Ice/PluginF.ice b/slice/Ice/PluginF.ice index e3023a56d7f..1b69e102f53 100644 --- a/slice/Ice/PluginF.ice +++ b/slice/Ice/PluginF.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/Process.ice b/slice/Ice/Process.ice index b07f4c858da..ea6fc3cff71 100644 --- a/slice/Ice/Process.ice +++ b/slice/Ice/Process.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/ProcessF.ice b/slice/Ice/ProcessF.ice index c74ba6d2754..1f1f6804fe1 100644 --- a/slice/Ice/ProcessF.ice +++ b/slice/Ice/ProcessF.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/Properties.ice b/slice/Ice/Properties.ice index 66aa611d3b5..59cd7034c91 100644 --- a/slice/Ice/Properties.ice +++ b/slice/Ice/Properties.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #include diff --git a/slice/Ice/PropertiesAdmin.ice b/slice/Ice/PropertiesAdmin.ice index 350c4176105..77340cf9019 100644 --- a/slice/Ice/PropertiesAdmin.ice +++ b/slice/Ice/PropertiesAdmin.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #include diff --git a/slice/Ice/PropertiesF.ice b/slice/Ice/PropertiesF.ice index 9f5799191b5..dd97d0d8a3c 100644 --- a/slice/Ice/PropertiesF.ice +++ b/slice/Ice/PropertiesF.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/RemoteLogger.ice b/slice/Ice/RemoteLogger.ice index 69a41d000c3..43caa57f4b1 100644 --- a/slice/Ice/RemoteLogger.ice +++ b/slice/Ice/RemoteLogger.ice @@ -11,7 +11,7 @@ #include -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] [["cpp:include:list"]] #ifndef __SLICE2JAVA_COMPAT__ diff --git a/slice/Ice/Router.ice b/slice/Ice/Router.ice index a1c55e93e5b..4abf973ae0a 100644 --- a/slice/Ice/Router.ice +++ b/slice/Ice/Router.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #include diff --git a/slice/Ice/RouterF.ice b/slice/Ice/RouterF.ice index 224576b77dd..08efd92d449 100644 --- a/slice/Ice/RouterF.ice +++ b/slice/Ice/RouterF.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/ServantLocator.ice b/slice/Ice/ServantLocator.ice index 8f04f81f7a0..931a012c837 100644 --- a/slice/Ice/ServantLocator.ice +++ b/slice/Ice/ServantLocator.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #include #include diff --git a/slice/Ice/ServantLocatorF.ice b/slice/Ice/ServantLocatorF.ice index f6caa430554..a112a9797eb 100644 --- a/slice/Ice/ServantLocatorF.ice +++ b/slice/Ice/ServantLocatorF.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/SliceChecksumDict.ice b/slice/Ice/SliceChecksumDict.ice index 1788628194b..8061287b8b7 100644 --- a/slice/Ice/SliceChecksumDict.ice +++ b/slice/Ice/SliceChecksumDict.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/ValueFactory.ice b/slice/Ice/ValueFactory.ice index 0c83b6da694..54de5c213e4 100644 --- a/slice/Ice/ValueFactory.ice +++ b/slice/Ice/ValueFactory.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/Ice/Version.ice b/slice/Ice/Version.ice index 9458b6e6376..87bbcd974ba 100644 --- a/slice/Ice/Version.ice +++ b/slice/Ice/Version.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICE_API", "objc:header-dir:objc", "objc:dll-export:ICE_API", "js:ice-build", "python:pkgdir:Ice"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/IceBT/ConnectionInfo.ice b/slice/IceBT/ConnectionInfo.ice index 773b69200e8..64ae497d346 100644 --- a/slice/IceBT/ConnectionInfo.ice +++ b/slice/IceBT/ConnectionInfo.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEBT_API", "objc:header-dir:objc"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEBT_API", "objc:header-dir:objc", "python:pkgdir:IceBT"]] #include diff --git a/slice/IceBT/EndpointInfo.ice b/slice/IceBT/EndpointInfo.ice index 0791b55a81b..e519e5d064c 100644 --- a/slice/IceBT/EndpointInfo.ice +++ b/slice/IceBT/EndpointInfo.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEBT_API", "objc:header-dir:objc", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEBT_API", "objc:header-dir:objc", "js:ice-build", "python:pkgdir:IceBT"]] #include diff --git a/slice/IceBT/Types.ice b/slice/IceBT/Types.ice index 71f467e38b8..60d7c2d7edf 100644 --- a/slice/IceBT/Types.ice +++ b/slice/IceBT/Types.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEBT_API", "objc:header-dir:objc"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEBT_API", "objc:header-dir:objc", "python:pkgdir:IceBT"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/IceBox/IceBox.ice b/slice/IceBox/IceBox.ice index 22b85651a4f..13f3c9f6d73 100644 --- a/slice/IceBox/IceBox.ice +++ b/slice/IceBox/IceBox.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEBOX_API", "objc:header-dir:objc"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEBOX_API", "objc:header-dir:objc", "python:pkgdir:IceBox"]] [["cpp:include:IceBox/Config.h"]] #include diff --git a/slice/IceDiscovery/IceDiscovery.ice b/slice/IceDiscovery/IceDiscovery.ice index 451e6a421a8..4a82bfe48b3 100644 --- a/slice/IceDiscovery/IceDiscovery.ice +++ b/slice/IceDiscovery/IceDiscovery.ice @@ -8,7 +8,7 @@ // ********************************************************************** #pragma once -[["ice-prefix", "cpp:header-ext:h", "objc:header-dir:objc"]] +[["ice-prefix", "cpp:header-ext:h", "objc:header-dir:objc", "python:pkgdir:IceDiscovery"]] #include diff --git a/slice/IceGrid/Admin.ice b/slice/IceGrid/Admin.ice index ef1ccf7ad7a..6d62124a22a 100644 --- a/slice/IceGrid/Admin.ice +++ b/slice/IceGrid/Admin.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEGRID_API", "objc:header-dir:objc", "objc:dll-export:ICEGRID_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEGRID_API", "objc:header-dir:objc", "objc:dll-export:ICEGRID_API", "js:ice-build", "python:pkgdir:IceGrid"]] [["cpp:include:IceGrid/Config.h"]] #include diff --git a/slice/IceGrid/Descriptor.ice b/slice/IceGrid/Descriptor.ice index e40ecb4e261..dca76142306 100644 --- a/slice/IceGrid/Descriptor.ice +++ b/slice/IceGrid/Descriptor.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "objc:header-dir:objc", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "objc:header-dir:objc", "js:ice-build", "python:pkgdir:IceGrid"]] #ifndef ICE_BUILDING_ICEGRIDDB [["cpp:dll-export:ICEGRID_API", "objc:dll-export:ICEGRID_API"]] diff --git a/slice/IceGrid/Exception.ice b/slice/IceGrid/Exception.ice index 5cb78c4f169..f8271027971 100644 --- a/slice/IceGrid/Exception.ice +++ b/slice/IceGrid/Exception.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "objc:header-dir:objc", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "objc:header-dir:objc", "js:ice-build", "python:pkgdir:IceGrid"]] #ifndef ICE_BUILDING_ICEGRIDDB [["cpp:dll-export:ICEGRID_API", "objc:dll-export:ICEGRID_API"]] diff --git a/slice/IceGrid/FileParser.ice b/slice/IceGrid/FileParser.ice index 335379b8f50..e1b5caf90d6 100644 --- a/slice/IceGrid/FileParser.ice +++ b/slice/IceGrid/FileParser.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEGRID_API", "objc:header-dir:objc", "objc:dll-export:ICEGRID_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEGRID_API", "objc:header-dir:objc", "objc:dll-export:ICEGRID_API", "js:ice-build", "python:pkgdir:IceGrid"]] [["cpp:include:IceGrid/Config.h"]] #include diff --git a/slice/IceGrid/PluginFacade.ice b/slice/IceGrid/PluginFacade.ice index c80e7b6f40c..4ad1a164206 100644 --- a/slice/IceGrid/PluginFacade.ice +++ b/slice/IceGrid/PluginFacade.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEGRID_API", "objc:header-dir:objc", "objc:dll-export:ICEGRID_API"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEGRID_API", "objc:header-dir:objc", "objc:dll-export:ICEGRID_API", "python:pkgdir:IceGrid"]] [["cpp:include:IceGrid/Config.h"]] #include diff --git a/slice/IceGrid/Registry.ice b/slice/IceGrid/Registry.ice index 144af2d2d52..d6370dcba40 100644 --- a/slice/IceGrid/Registry.ice +++ b/slice/IceGrid/Registry.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEGRID_API", "objc:header-dir:objc", "objc:dll-export:ICEGRID_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEGRID_API", "objc:header-dir:objc", "objc:dll-export:ICEGRID_API", "js:ice-build", "python:pkgdir:IceGrid"]] [["cpp:include:IceGrid/Config.h"]] #include diff --git a/slice/IceGrid/Session.ice b/slice/IceGrid/Session.ice index e88c496997f..43f935d4778 100644 --- a/slice/IceGrid/Session.ice +++ b/slice/IceGrid/Session.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEGRID_API", "objc:header-dir:objc", "objc:dll-export:ICEGRID_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEGRID_API", "objc:header-dir:objc", "objc:dll-export:ICEGRID_API", "js:ice-build", "python:pkgdir:IceGrid"]] [["cpp:include:IceGrid/Config.h"]] #include diff --git a/slice/IceGrid/UserAccountMapper.ice b/slice/IceGrid/UserAccountMapper.ice index 051ec120116..e3ddc087c6f 100644 --- a/slice/IceGrid/UserAccountMapper.ice +++ b/slice/IceGrid/UserAccountMapper.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEGRID_API", "objc:header-dir:objc", "objc:dll-export:ICEGRID_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEGRID_API", "objc:header-dir:objc", "objc:dll-export:ICEGRID_API", "js:ice-build", "python:pkgdir:IceGrid"]] [["cpp:include:IceGrid/Config.h"]] #ifndef __SLICE2JAVA_COMPAT__ diff --git a/slice/IceLocatorDiscovery/IceLocatorDiscovery.ice b/slice/IceLocatorDiscovery/IceLocatorDiscovery.ice index 4c29617b1c4..89d3a20da30 100644 --- a/slice/IceLocatorDiscovery/IceLocatorDiscovery.ice +++ b/slice/IceLocatorDiscovery/IceLocatorDiscovery.ice @@ -8,7 +8,7 @@ // ********************************************************************** #pragma once -[["ice-prefix", "cpp:header-ext:h", "objc:header-dir:objc"]] +[["ice-prefix", "cpp:header-ext:h", "objc:header-dir:objc", "python:pkgdir:IceLocatorDiscovery"]] #include diff --git a/slice/IcePatch2/FileInfo.ice b/slice/IcePatch2/FileInfo.ice index 2eb9e6bb7ef..a07adf0378b 100644 --- a/slice/IcePatch2/FileInfo.ice +++ b/slice/IcePatch2/FileInfo.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEPATCH2_API", "objc:header-dir:objc"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEPATCH2_API", "objc:header-dir:objc", "python:pkgdir:IcePatch2"]] [["cpp:include:IcePatch2/Config.h"]] #include diff --git a/slice/IcePatch2/FileServer.ice b/slice/IcePatch2/FileServer.ice index 71e3a6b20ba..e4e5aa45489 100644 --- a/slice/IcePatch2/FileServer.ice +++ b/slice/IcePatch2/FileServer.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEPATCH2_API", "objc:header-dir:objc"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICEPATCH2_API", "objc:header-dir:objc", "python:pkgdir:IcePatch2"]] [["cpp:include:IcePatch2/Config.h"]] #include diff --git a/slice/IceSSL/ConnectionInfo.ice b/slice/IceSSL/ConnectionInfo.ice index 9cbce24c8b0..6152fd31437 100644 --- a/slice/IceSSL/ConnectionInfo.ice +++ b/slice/IceSSL/ConnectionInfo.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICESSL_API", "objc:header-dir:objc", "objc:dll-export:ICESSL_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICESSL_API", "objc:header-dir:objc", "objc:dll-export:ICESSL_API", "js:ice-build", "python:pkgdir:IceSSL"]] [["cpp:include:IceSSL/Plugin.h"]] diff --git a/slice/IceSSL/ConnectionInfoF.ice b/slice/IceSSL/ConnectionInfoF.ice index d415b7ce163..772e5f0d36a 100644 --- a/slice/IceSSL/ConnectionInfoF.ice +++ b/slice/IceSSL/ConnectionInfoF.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICESSL_API", "objc:header-dir:objc", "objc:dll-export:ICESSL_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICESSL_API", "objc:header-dir:objc", "objc:dll-export:ICESSL_API", "js:ice-build", "python:pkgdir:IceSSL"]] #ifndef __SLICE2JAVA_COMPAT__ [["java:package:com.zeroc"]] diff --git a/slice/IceSSL/EndpointInfo.ice b/slice/IceSSL/EndpointInfo.ice index f1378e62498..1456571e1d2 100644 --- a/slice/IceSSL/EndpointInfo.ice +++ b/slice/IceSSL/EndpointInfo.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICESSL_API", "objc:header-dir:objc", "objc:dll-export:ICESSL_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICESSL_API", "objc:header-dir:objc", "objc:dll-export:ICESSL_API", "js:ice-build", "python:pkgdir:IceSSL"]] #include diff --git a/slice/IceStorm/IceStorm.ice b/slice/IceStorm/IceStorm.ice index 72994e0f404..b28a3d94af5 100644 --- a/slice/IceStorm/IceStorm.ice +++ b/slice/IceStorm/IceStorm.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICESTORM_API", "objc:header-dir:objc", "objc:dll-export:ICESTORM_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICESTORM_API", "objc:header-dir:objc", "objc:dll-export:ICESTORM_API", "js:ice-build", "python:pkgdir:IceStorm"]] [["cpp:include:IceStorm/Config.h"]] #include diff --git a/slice/IceStorm/Metrics.ice b/slice/IceStorm/Metrics.ice index dae0f6d98d6..580b39f93f1 100644 --- a/slice/IceStorm/Metrics.ice +++ b/slice/IceStorm/Metrics.ice @@ -9,7 +9,7 @@ #pragma once -[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICESTORM_API", "objc:header-dir:objc", "objc:dll-export:ICESTORM_API", "js:ice-build"]] +[["ice-prefix", "cpp:header-ext:h", "cpp:dll-export:ICESTORM_API", "objc:header-dir:objc", "objc:dll-export:ICESTORM_API", "js:ice-build", "python:pkgdir:IceStorm"]] [["cpp:include:IceStorm/Config.h"]] #include -- cgit v1.2.3