Permalink
Browse files

Included magnet modules into ion.core packages and removed dependency…

… on magnet; start with twistd -n cc
  • Loading branch information...
1 parent 85098db commit aabfe74ce460cc7654d72cbb75c11cdfe3f2c2cc Michael Meisinger committed Sep 21, 2010
Showing with 10,995 additions and 237 deletions.
  1. +1 −1 .gitignore
  2. +17 −10 README.txt
  3. +2 −2 ion/agents/instrumentagents/test/test_SBE49.py
  4. +157 −0 ion/core/_version.py
  5. +5 −5 ion/core/base_process.py
  6. +3 −3 ion/core/bootstrap.py
  7. +84 −0 ion/core/cc/ashell.py
  8. +6 −7 ion/core/cc/cc_agent.py
  9. +323 −10 ion/core/cc/container.py
  10. +18 −0 ion/core/cc/container_api.py
  11. +1 −1 ion/core/cc/interceptor.py
  12. +148 −0 ion/core/cc/service.py
  13. +132 −0 ion/core/cc/shell.py
  14. +443 −0 ion/core/cc/spawnable.py
  15. +54 −0 ion/core/cc/store.py
  16. +2 −5 ion/core/ionconst.py
  17. +1 −13 ion/core/ioninit.py
  18. +4 −0 ion/core/messaging/__init__.py
  19. +263 −0 ion/core/messaging/messaging.py
  20. +1 −1 ion/core/supervisor.py
  21. +5 −5 ion/core/test/test_baseprocess.py
  22. +5 −5 ion/core/test/test_bootstrap.py
  23. +2 −2 ion/core/test/test_worker.py
  24. +2 −2 ion/core/worker.py
  25. +1 −1 ion/data/datastore/datastore_service.py
  26. +1 −1 ion/data/datastore/test/test_registry.py
  27. +1 −1 ion/data/test/test_dataobject.py
  28. +1 −1 ion/demo/lca/javaint_service.py
  29. +1 −1 ion/play/hello_process.py
  30. +1 −1 ion/play/hello_service.py
  31. +44 −44 ion/play/identclient.py
  32. +2 −2 ion/play/identservice.py
  33. +1 −1 ion/play/regclient.py
  34. +53 −55 ion/play/test/test_identity_web_ui.py
  35. +1 −1 ion/resources/coi_resource_descriptions.py
  36. +3 −3 ion/services/base_service.py
  37. +2 −2 ion/services/base_svcproc.py
  38. +1 −1 ion/services/cei/epu_controller.py
  39. +1 −1 ion/services/cei/sensor_aggregator.py
  40. +1 −1 ion/services/cei/sleeper/epu_work_producer.py
  41. +1 −1 ion/services/cei/sleeper/epu_worker.py
  42. +2 −2 ion/services/cei/test/mockloop/mockloop.py
  43. +1 −1 ion/services/cei/test/mockloop/provisioner.py
  44. +1 −1 ion/services/cei/test/test_sensors.py
  45. +1 −1 ion/services/coi/authorization.py
  46. +1 −1 ion/services/coi/exchange_registry.py
  47. +1 −1 ion/services/coi/resource_registry.py
  48. +1 −1 ion/services/coi/service_registry.py
  49. +1 −1 ion/services/coi/state_repository.py
  50. +5 −5 ion/services/dm/distribution/base_consumer.py
  51. +3 −3 ion/services/dm/distribution/test/test_baseconsumer.py
  52. +1 −1 ion/services/dm/ingestion/ingestion_registry.py
  53. +1 −1 ion/services/dm/inventory/data_registry.py
  54. +1 −1 ion/services/dm/presentation/presentation_service.py
  55. +1 −1 ion/services/dm/preservation/preservation_registry.py
  56. +1 −1 ion/services/dm/preservation/preservation_service.py
  57. +1 −1 ion/services/dm/transformation/transformation_service.py
  58. +3 −3 ion/services/dm/util/dap_grid_timeseries_producer.py
  59. +3 −3 ion/services/dm/util/data_stream_producer.py
  60. +3 −3 ion/services/dm/util/test/test_dsp.py
  61. +1 −1 ion/services/sa/data_acquisition.py
  62. +1 −1 ion/services/sa/data_processing.py
  63. +1 −1 ion/services/sa/data_product_registry.py
  64. +1 −1 ion/services/sa/instrument_registry.py
  65. +2 −2 ion/test/iontest.py
  66. +2 −2 ion/util/procutils.py
  67. +3,908 −0 res/spec/amqp0-8.xml
  68. +5,185 −0 res/spec/amqp0-9.xml
  69. +9 −7 setup.py
  70. +8 −0 twisted/plugins/cc.py
  71. +50 −0 twisted/plugins/dropin.cache
View
@@ -12,6 +12,6 @@ res/config/ionlocal.config
res/logging/loglevelslocal.cfg
build
dist
-lcaarch.egg-info
+*.egg-info
.pydevproject
.project
View
@@ -1,9 +1,10 @@
==================================================
Ocean Observatories Initiative Cyberinfrastructure
-LCAarch - OOI Release 1 LCA architecture prototype
+Integrated Observatory Network (ION)
+ioncore-python - Capability Container and Core Modules
==================================================
-April 2010 - August 2010 (C) UCSD Regents
+April 2010 - September 2010 (C) UCSD Regents
This project provides a service framework with auxilliary functions for running
architecturally complete versions of all the services of the OOI release 1
@@ -56,7 +57,7 @@ Check the trace output that there are no substantial errors. You are now ready
to run.
Current dependencies include:
- twisted, numpy, txamqp, msgpack-python, httplib2, pycassa, simplejson,
+ twisted, carrot, numpy, txamqp, msgpack-python, httplib2, pycassa, simplejson,
pydap, pydap.handlers.netcdf, pydap.responses.netcdf, pydap.handlers.nca,
gviz_api.py, nimboss, txrabbitmq
@@ -69,12 +70,12 @@ Usage
(all subsequent steps assume you are in the lcaarch/ root dir)
-Start empty CC ("Magnet" Python Capability Container) shell with:
+Start empty Python Capability Container shell with:
::
- twistd -n magnet -h amoeba.ucsd.edu
- twistd -n magnet # to run with localhost
+ twistd -n cc -h amoeba.ucsd.edu
+ twistd -n cc # to run with localhost
-(to end a magnet container shell, press Ctrl-D Ctrl-C)
+(to end a capability container shell, press Ctrl-D Ctrl-C)
Start system by executing within the CC shell:
><>
@@ -83,9 +84,9 @@ Start system by executing within the CC shell:
Alternatively (better) from UNIX shell executing a script:
::
- twistd -n magnet -h amoeba.ucsd.edu res/scripts/bootstrap.py
- twistd -n magnet -h amoeba.ucsd.edu res/scripts/newcc.py
- twistd -n magnet -h amoeba.ucsd.edu -a nproducers=25 res/scripts/pubsub.py
+ twistd -n cc -h amoeba.ucsd.edu res/scripts/bootstrap.py
+ twistd -n cc -h amoeba.ucsd.edu res/scripts/newcc.py
+ twistd -n cc -h amoeba.ucsd.edu -a nproducers=25 res/scripts/pubsub.py
Testing
@@ -130,6 +131,12 @@ To compile all code to see if there are Python compile errors anywhere:
Change log:
===========
+2010-09-20:
+- Removed dependency on magnet. Included all relevant magnet code in ion.core
+ packages cc and messaging.
+ Start with: twistd -n cc
+- Included all CEI services and base classes in code base
+
2010-08-29:
- Changed all logging instances for loggers to log, to avoid name clashes.
@@ -18,8 +18,8 @@
from ion.agents.instrumentagents.simulators.sim_SBE49 import Simulator
from ion.core import bootstrap
-from magnet.spawnable import Receiver
-from magnet.spawnable import spawn
+from ion.core.cc.spawnable import Receiver
+from ion.core.cc.spawnable import spawn
from ion.core.base_process import BaseProcess, ProcessDesc
from ion.services.dm.distribution.pubsub_service import DataPubsubClient
from ion.services.base_service import BaseServiceClient
View
@@ -0,0 +1,157 @@
+#!/usr/bin/env python
+
+"""
+@file ion/core/_version.py
+@author Dorian Raymer
+@author Michael Meisinger
+@brief sets the version for ION classes
+"""
+
+import os
+import sys
+
+class Version(object):
+ """look for git commit to include in the version number.
+
+ An object that represents a three-part version number.
+ @note Taken from twisted python (twisted.python.versions)
+ """
+
+ def __init__(self, package, major, minor, micro, prerelease=None):
+ """
+ @param package: Name of the package that this is a version of.
+ @type package: C{str}
+ @param major: The major version number.
+ @type major: C{int}
+ @param minor: The minor version number.
+ @type minor: C{int}
+ @param micro: The micro version number.
+ @type micro: C{int}
+ @param prerelease: The prerelease number.
+ @type prerelease: C{int}
+ """
+ self.package = package
+ self.major = major
+ self.minor = minor
+ self.micro = micro
+ self.prerelease = prerelease
+
+ def short(self):
+ """
+ Return a string in canonical short version format,
+ <major>.<minor>.<micro>[+rSVNVer].
+ """
+ s = self.base()
+ gitcommit = self._getGitCommit()
+ if gitcommit:
+ s += '+git:' + str(gitcommit)
+ return s
+
+ def base(self):
+ """
+ Like L{short}, but without the +git.
+ """
+ if self.prerelease is None:
+ pre = ""
+ else:
+ pre = "pre%s" % (self.prerelease,)
+ return '%d.%d.%d%s' % (self.major,
+ self.minor,
+ self.micro,
+ pre)
+
+ def __repr__(self):
+ gitcommit = self._formatGitCommit()
+ if gitcommit:
+ gitcommit = ' #' + gitcommit
+ if self.prerelease is None:
+ prerelease = ""
+ else:
+ prerelease = ", prerelease=%r" % (self.prerelease,)
+ return '%s(%r, %d, %d, %d%s)%s' % (
+ self.__class__.__name__,
+ self.package,
+ self.major,
+ self.minor,
+ self.micro,
+ prerelease,
+ gitcommit)
+
+ def __str__(self):
+ return '[%s, version %s]' % (
+ self.package,
+ self.short())
+
+ def __cmp__(self, other):
+ """
+ Compare two versions, considering major versions, minor versions, micro
+ versions, then prereleases.
+
+ A version with a prerelease is always less than a version without a
+ prerelease. If both versions have prereleases, they will be included in
+ the comparison.
+
+ @param other: Another version.
+ @type other: L{Version}
+
+ @return: NotImplemented when the other object is not a Version, or one
+ of -1, 0, or 1.
+
+ @raise IncomparableVersions: when the package names of the versions
+ differ.
+ """
+ if not isinstance(other, self.__class__):
+ return NotImplemented
+ if self.package != other.package:
+ raise IncomparableVersions("%r != %r"
+ % (self.package, other.package))
+
+ if self.prerelease is None:
+ prerelease = _inf
+ else:
+ prerelease = self.prerelease
+
+ if other.prerelease is None:
+ otherpre = _inf
+ else:
+ otherpre = other.prerelease
+
+ x = cmp((self.major,
+ self.minor,
+ self.micro,
+ prerelease),
+ (other.major,
+ other.minor,
+ other.micro,
+ otherpre))
+ return x
+
+ def _getGitCommit(self):
+ mod = sys.modules.get(self.package)
+ if mod:
+ git = os.path.join(os.path.dirname(mod.__file__), '..', '.git')
+ if not os.path.exists(git):
+ # It's not an git working copy
+ return None
+
+ headFile = os.path.join(git, 'HEAD')
+ if os.path.exists(headFile):
+ head = file(headFile).read().strip()
+ headRef = head.split(':')[1].strip()
+ refFile = os.path.join(git, headRef)
+ if os.path.exists(refFile):
+ commit = file(refFile).read().strip()
+ return commit
+ else:
+ return 'Unknown'
+ else:
+ return 'Unknown'
+
+ def _formatGitCommit(self):
+ commit = self._getGitCommit()
+ if commit is None:
+ return ''
+ return ' (Git:%s)' % commit
+
+# VERSION !!! This is the main version !!!
+version = Version('ion', 0, 3, 0)
View
@@ -10,10 +10,10 @@
log = ion.util.ionlog.getLogger(__name__)
from twisted.internet import defer
-from magnet.container import Container
-from magnet.spawnable import Receiver
-from magnet.spawnable import ProtocolFactory
-from magnet.spawnable import spawn
+from ion.core.cc.container import Container
+from ion.core.cc.spawnable import Receiver
+from ion.core.cc.spawnable import ProtocolFactory
+from ion.core.cc.spawnable import spawn
from ion.data.store import Store
from ion.core import ioninit
@@ -108,7 +108,7 @@ def spawn(self):
"""
Spawns this process using the process' receiver and initializes it in
the same call. Self spawn can only be called once per instance.
- @note this method is not called when spawned through magnet. This makes
+ @note this method is not called when spawned through CC. This makes
it tricky to do consistent initialization on spawn.
"""
assert not self.receiver.spawned, "Process already spawned"
View
@@ -11,9 +11,9 @@
log = ion.util.ionlog.getLogger(__name__)
from twisted.internet import defer
-from magnet import spawnable
-from magnet.container import Container
-from magnet.spawnable import spawn
+from ion.core.cc import spawnable
+from ion.core.cc.container import Container
+from ion.core.cc.spawnable import spawn
from ion.data.store import Store
from ion.core import ioninit, base_process
View
@@ -0,0 +1,84 @@
+import os, sys, tty, termios
+
+from twisted.internet import reactor
+from twisted.internet import stdio
+from twisted.conch import insults
+from twisted.conch import manhole
+
+from ion.core import ionconst
+
+def get_virtualenv():
+ if 'VIRTUAL_ENV' in os.environ:
+ virtual_env = os.path.join(os.environ.get('VIRTUAL_ENV'),
+ 'lib',
+ 'python%d.%d' % sys.version_info[:2],
+ 'site-packages')
+ return "[env: %s]" % virtual_env
+ return "[env: system]"
+
+class ConsoleManhole(manhole.ColoredManhole):
+ ps = ('><> ', '... ')
+
+ def initializeScreen(self):
+ """@todo This should show relevant and useful development info:
+ - python version
+ - dependencies
+ o versions
+ o install path
+ o
+ - virtualenv (if used)
+
+ @todo Dependency info will be listed in the setup file
+ """
+ # self.terminal.reset()
+ self.terminal.write('OOI CI COI Capability Container Prototype \r\n')
+ self.terminal.write('AyP ><> (Asynchronous Python Shell)\r\n')
+ self.terminal.write('%s \r\n' % ionconst.version)
+ self.terminal.write('%s \r\n' % get_virtualenv())
+ self.terminal.write('[container: %s@%s.%d] \r\n' % (os.getlogin(), os.uname()[1], os.getpid()))
+ self.terminal.write('\r\n')
+ self.terminal.write(self.ps[self.pn])
+ self.setInsertMode()
+
+ def Xhandle_TAB(self):
+ completer = rlcompleter.Completer(self.namespace)
+ input_string = ''.join(self.lineBuffer)
+ reName = "([a-zA-Z_][a-zA-Z_0-9]*)$"
+ reAttribute = "([a-zA-Z_][a-zA-Z_0-9]*[.]+[a-zA-Z_.0-9]*)$"
+ nameMatch = re.match(reName, input_string)
+ attMatch = re.match(reAttribute, input_string)
+ if nameMatch:
+ matches = completer.global_matches(input_string)
+ if attMatch:
+ matches = completer.attr_matches(input_string)
+ # print matches
+
+ # def handle_INT(self):
+
+ def connectionLost(self, reason):
+ reactor.stop()
+
+
+def main(namespace=locals()):
+ try:
+ fd = sys.__stdin__.fileno()
+ oldSettings = termios.tcgetattr(fd)
+ tty.setraw(fd)
+ p = insults.insults.ServerProtocol(ConsoleManhole, namespace)
+ namespace.update({'__ashell': p})
+ stdio.StandardIO(p)
+ from twisted.python import log
+ # log.startLogging(sys.stdout)
+ reactor.run()
+ finally:
+ termios.tcsetattr(fd, termios.TCSANOW, oldSettings)
+ os.write(fd, "\r\x1bc\r")
+
+if __name__ == '__main__':
+ from twisted.python.rebuild import rebuild, updateInstance, latestFunction, latestClass
+ from ion.core.cc.spawnable import send, ps, ms, spawn, kill
+ from ion.core.cc.container import Container
+ from ion.core.cc import container
+ from twisted.python import log
+ reactor.callWhenRunning(container.test)
+ main(locals())
Oops, something went wrong.

0 comments on commit aabfe74

Please sign in to comment.