You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2016/08/09 18:00:57 UTC
[17/32] airavata-sandbox git commit: adding jupyter note books for
Airavata
adding jupyter note books for Airavata
Project: http://git-wip-us.apache.org/repos/asf/airavata-sandbox/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-sandbox/commit/75eb96c2
Tree: http://git-wip-us.apache.org/repos/asf/airavata-sandbox/tree/75eb96c2
Diff: http://git-wip-us.apache.org/repos/asf/airavata-sandbox/diff/75eb96c2
Branch: refs/heads/master
Commit: 75eb96c24e15536c88439472fa04b1e68995090c
Parents: 4231ac3
Author: Pradyut Madhavaram <pr...@gmail.com>
Authored: Fri Aug 5 11:13:47 2016 -0400
Committer: Pradyut Madhavaram <pr...@gmail.com>
Committed: Fri Aug 5 11:13:47 2016 -0400
----------------------------------------------------------------------
.../Admin-User/appcatalog/__init__.py | 1 +
.../Admin-User/appcatalog/__init__.pyc | Bin 0 -> 142 bytes
.../Admin-User/appcatalog/appcatalog.py | 72 +
.../Admin-User/appcatalog/appcatalog.pyc | Bin 0 -> 3353 bytes
.../Admin-User/cli.properties | 19 +
.../Admin-User/expcatalog/__init__.py | 1 +
.../Admin-User/expcatalog/__init__.pyc | Bin 0 -> 142 bytes
.../__pycache__/__init__.cpython-35.pyc | Bin 0 -> 164 bytes
.../__pycache__/expcatalog.cpython-35.pyc | Bin 0 -> 7305 bytes
.../Admin-User/expcatalog/expcatalog.py | 187 +
.../Admin-User/expcatalog/expcatalog.pyc | Bin 0 -> 7932 bytes
.../Admin-User/thrift/TSCons.py | 35 +
.../Admin-User/thrift/TSerialization.py | 38 +
.../Admin-User/thrift/TTornado.py | 153 +
.../Admin-User/thrift/Thrift.py | 170 +
.../Admin-User/thrift/Thrift.pyc | Bin 0 -> 4886 bytes
.../Admin-User/thrift/__init__.py | 20 +
.../Admin-User/thrift/__init__.pyc | Bin 0 -> 151 bytes
.../Admin-User/thrift/protocol/TBase.py | 81 +
.../thrift/protocol/TBinaryProtocol.py | 261 +
.../thrift/protocol/TBinaryProtocol.pyc | Bin 0 -> 10448 bytes
.../thrift/protocol/TCompactProtocol.py | 405 +
.../Admin-User/thrift/protocol/TJSONProtocol.py | 552 +
.../Admin-User/thrift/protocol/TProtocol.py | 406 +
.../Admin-User/thrift/protocol/TProtocol.pyc | Bin 0 -> 13517 bytes
.../Admin-User/thrift/protocol/__init__.py | 20 +
.../Admin-User/thrift/protocol/__init__.pyc | Bin 0 -> 248 bytes
.../Admin-User/thrift/protocol/fastbinary.c | 1219 +
.../Admin-User/thrift/server/THttpServer.py | 87 +
.../thrift/server/TNonblockingServer.py | 346 +
.../thrift/server/TProcessPoolServer.py | 118 +
.../Admin-User/thrift/server/TServer.py | 269 +
.../Admin-User/thrift/server/__init__.py | 20 +
.../Admin-User/thrift/transport/THttpClient.py | 147 +
.../Admin-User/thrift/transport/TSSLSocket.py | 214 +
.../Admin-User/thrift/transport/TSSLSocket.pyc | Bin 0 -> 6546 bytes
.../Admin-User/thrift/transport/TSocket.py | 176 +
.../Admin-User/thrift/transport/TSocket.pyc | Bin 0 -> 5512 bytes
.../Admin-User/thrift/transport/TTransport.py | 330 +
.../Admin-User/thrift/transport/TTransport.pyc | Bin 0 -> 12858 bytes
.../Admin-User/thrift/transport/TTwisted.py | 221 +
.../thrift/transport/TZlibTransport.py | 249 +
.../Admin-User/thrift/transport/__init__.py | 20 +
.../Admin-User/thrift/transport/__init__.pyc | Bin 0 -> 207 bytes
.../create-experiment-checkpoint.ipynb | 449 +
.../create-experiment/__init__.py | 0
.../create-experiment/apache/__init__.py | 0
.../create-experiment/apache/__init__.pyc | Bin 0 -> 105 bytes
.../apache/airavata/__init__.py | 0
.../apache/airavata/__init__.pyc | Bin 0 -> 114 bytes
.../apache/airavata/api/Airavata-remote | 1130 +
.../apache/airavata/api/Airavata.py | 47815 +++++++++++++++++
.../apache/airavata/api/Airavata.pyc | Bin 0 -> 1517997 bytes
.../apache/airavata/api/__init__.py | 1 +
.../apache/airavata/api/__init__.pyc | Bin 0 -> 183 bytes
.../apache/airavata/api/constants.py | 12 +
.../apache/airavata/api/error/__init__.py | 1 +
.../apache/airavata/api/error/__init__.pyc | Bin 0 -> 173 bytes
.../apache/airavata/api/error/constants.py | 11 +
.../apache/airavata/api/error/ttypes.py | 940 +
.../apache/airavata/api/error/ttypes.pyc | Bin 0 -> 34089 bytes
.../apache/airavata/api/ttypes.py | 37 +
.../apache/airavata/api/ttypes.pyc | Bin 0 -> 1600 bytes
.../apache/airavata/model/__init__.py | 1 +
.../apache/airavata/model/__init__.pyc | Bin 0 -> 169 bytes
.../airavata/model/appcatalog/__init__.py | 0
.../airavata/model/appcatalog/__init__.pyc | Bin 0 -> 131 bytes
.../model/appcatalog/appdeployment/__init__.py | 1 +
.../model/appcatalog/appdeployment/__init__.pyc | Bin 0 -> 194 bytes
.../model/appcatalog/appdeployment/constants.py | 11 +
.../model/appcatalog/appdeployment/ttypes.py | 634 +
.../model/appcatalog/appdeployment/ttypes.pyc | Bin 0 -> 20381 bytes
.../model/appcatalog/appinterface/__init__.py | 1 +
.../model/appcatalog/appinterface/__init__.pyc | Bin 0 -> 193 bytes
.../model/appcatalog/appinterface/constants.py | 11 +
.../model/appcatalog/appinterface/ttypes.py | 219 +
.../model/appcatalog/appinterface/ttypes.pyc | Bin 0 -> 7414 bytes
.../appcatalog/computeresource/__init__.py | 1 +
.../appcatalog/computeresource/__init__.pyc | Bin 0 -> 196 bytes
.../appcatalog/computeresource/constants.py | 11 +
.../model/appcatalog/computeresource/ttypes.py | 1640 +
.../model/appcatalog/computeresource/ttypes.pyc | Bin 0 -> 50576 bytes
.../model/appcatalog/gatewayprofile/__init__.py | 1 +
.../appcatalog/gatewayprofile/__init__.pyc | Bin 0 -> 195 bytes
.../appcatalog/gatewayprofile/constants.py | 11 +
.../model/appcatalog/gatewayprofile/ttypes.py | 512 +
.../model/appcatalog/gatewayprofile/ttypes.pyc | Bin 0 -> 16903 bytes
.../model/appcatalog/parallelism/__init__.py | 1 +
.../model/appcatalog/parallelism/__init__.pyc | Bin 0 -> 192 bytes
.../model/appcatalog/parallelism/constants.py | 11 +
.../model/appcatalog/parallelism/ttypes.py | 60 +
.../model/appcatalog/parallelism/ttypes.pyc | Bin 0 -> 1372 bytes
.../appcatalog/storageresource/__init__.py | 1 +
.../appcatalog/storageresource/__init__.pyc | Bin 0 -> 196 bytes
.../appcatalog/storageresource/constants.py | 11 +
.../model/appcatalog/storageresource/ttypes.py | 167 +
.../model/appcatalog/storageresource/ttypes.pyc | Bin 0 -> 6028 bytes
.../airavata/model/application/__init__.py | 0
.../airavata/model/application/__init__.pyc | Bin 0 -> 132 bytes
.../airavata/model/application/io/__init__.py | 1 +
.../airavata/model/application/io/__init__.pyc | Bin 0 -> 184 bytes
.../airavata/model/application/io/constants.py | 11 +
.../airavata/model/application/io/ttypes.py | 510 +
.../airavata/model/application/io/ttypes.pyc | Bin 0 -> 14257 bytes
.../apache/airavata/model/commons/__init__.py | 1 +
.../apache/airavata/model/commons/__init__.pyc | Bin 0 -> 177 bytes
.../apache/airavata/model/commons/constants.py | 12 +
.../apache/airavata/model/commons/ttypes.py | 335 +
.../apache/airavata/model/commons/ttypes.pyc | Bin 0 -> 11641 bytes
.../apache/airavata/model/constants.py | 11 +
.../apache/airavata/model/data/__init__.py | 0
.../apache/airavata/model/data/__init__.pyc | Bin 0 -> 125 bytes
.../airavata/model/data/movement/__init__.py | 1 +
.../airavata/model/data/movement/__init__.pyc | Bin 0 -> 183 bytes
.../airavata/model/data/movement/constants.py | 11 +
.../airavata/model/data/movement/ttypes.py | 625 +
.../airavata/model/data/movement/ttypes.pyc | Bin 0 -> 20859 bytes
.../airavata/model/data/product/__init__.py | 1 +
.../airavata/model/data/product/constants.py | 11 +
.../airavata/model/data/product/ttypes.py | 549 +
.../airavata/model/data/replica/__init__.py | 1 +
.../airavata/model/data/replica/__init__.pyc | Bin 0 -> 182 bytes
.../airavata/model/data/replica/constants.py | 11 +
.../airavata/model/data/replica/ttypes.py | 511 +
.../airavata/model/data/replica/ttypes.pyc | Bin 0 -> 14489 bytes
.../airavata/model/data/resource/__init__.py | 1 +
.../airavata/model/data/resource/constants.py | 11 +
.../airavata/model/data/resource/ttypes.py | 535 +
.../airavata/model/experiment/__init__.py | 1 +
.../airavata/model/experiment/__init__.pyc | Bin 0 -> 180 bytes
.../airavata/model/experiment/constants.py | 11 +
.../apache/airavata/model/experiment/ttypes.py | 1111 +
.../apache/airavata/model/experiment/ttypes.pyc | Bin 0 -> 32151 bytes
.../apache/airavata/model/group/__init__.py | 1 +
.../apache/airavata/model/group/__init__.pyc | Bin 0 -> 175 bytes
.../apache/airavata/model/group/constants.py | 11 +
.../apache/airavata/model/group/ttypes.py | 179 +
.../apache/airavata/model/group/ttypes.pyc | Bin 0 -> 5482 bytes
.../apache/airavata/model/job/__init__.py | 1 +
.../apache/airavata/model/job/__init__.pyc | Bin 0 -> 173 bytes
.../apache/airavata/model/job/constants.py | 11 +
.../apache/airavata/model/job/ttypes.py | 237 +
.../apache/airavata/model/job/ttypes.pyc | Bin 0 -> 7071 bytes
.../apache/airavata/model/messaging/__init__.py | 0
.../airavata/model/messaging/__init__.pyc | Bin 0 -> 130 bytes
.../airavata/model/messaging/event/__init__.py | 1 +
.../airavata/model/messaging/event/__init__.pyc | Bin 0 -> 185 bytes
.../airavata/model/messaging/event/constants.py | 11 +
.../airavata/model/messaging/event/ttypes.py | 1426 +
.../airavata/model/messaging/event/ttypes.pyc | Bin 0 -> 48557 bytes
.../apache/airavata/model/process/__init__.py | 1 +
.../apache/airavata/model/process/__init__.pyc | Bin 0 -> 177 bytes
.../apache/airavata/model/process/constants.py | 11 +
.../apache/airavata/model/process/ttypes.py | 425 +
.../apache/airavata/model/process/ttypes.pyc | Bin 0 -> 12365 bytes
.../airavata/model/scheduling/__init__.py | 1 +
.../airavata/model/scheduling/__init__.pyc | Bin 0 -> 180 bytes
.../airavata/model/scheduling/constants.py | 11 +
.../apache/airavata/model/scheduling/ttypes.py | 230 +
.../apache/airavata/model/scheduling/ttypes.pyc | Bin 0 -> 6698 bytes
.../apache/airavata/model/security/__init__.py | 1 +
.../apache/airavata/model/security/__init__.pyc | Bin 0 -> 178 bytes
.../apache/airavata/model/security/constants.py | 11 +
.../apache/airavata/model/security/ttypes.py | 108 +
.../apache/airavata/model/security/ttypes.pyc | Bin 0 -> 4142 bytes
.../apache/airavata/model/status/__init__.py | 1 +
.../apache/airavata/model/status/__init__.pyc | Bin 0 -> 176 bytes
.../apache/airavata/model/status/constants.py | 11 +
.../apache/airavata/model/status/ttypes.py | 542 +
.../apache/airavata/model/status/ttypes.pyc | Bin 0 -> 15977 bytes
.../apache/airavata/model/task/__init__.py | 1 +
.../apache/airavata/model/task/__init__.pyc | Bin 0 -> 174 bytes
.../apache/airavata/model/task/constants.py | 11 +
.../apache/airavata/model/task/ttypes.py | 703 +
.../apache/airavata/model/task/ttypes.pyc | Bin 0 -> 22730 bytes
.../apache/airavata/model/ttypes.py | 34 +
.../apache/airavata/model/ttypes.pyc | Bin 0 -> 1350 bytes
.../apache/airavata/model/user/__init__.py | 1 +
.../apache/airavata/model/user/__init__.pyc | Bin 0 -> 174 bytes
.../apache/airavata/model/user/constants.py | 12 +
.../apache/airavata/model/user/ttypes.py | 721 +
.../apache/airavata/model/user/ttypes.pyc | Bin 0 -> 20353 bytes
.../apache/airavata/model/workflow/__init__.py | 1 +
.../apache/airavata/model/workflow/__init__.pyc | Bin 0 -> 178 bytes
.../apache/airavata/model/workflow/constants.py | 11 +
.../apache/airavata/model/workflow/ttypes.py | 822 +
.../apache/airavata/model/workflow/ttypes.pyc | Bin 0 -> 25348 bytes
.../apache/airavata/model/workspace/__init__.py | 1 +
.../airavata/model/workspace/__init__.pyc | Bin 0 -> 179 bytes
.../airavata/model/workspace/constants.py | 11 +
.../model/workspace/experiment/__init__.py | 1 +
.../model/workspace/experiment/constants.py | 14 +
.../model/workspace/experiment/ttypes.py | 3474 ++
.../apache/airavata/model/workspace/ttypes.py | 851 +
.../apache/airavata/model/workspace/ttypes.pyc | Bin 0 -> 25091 bytes
.../create-experiment/create-experiment.ipynb | 449 +
.../create-experiment/thrift/TSCons.py | 35 +
.../create-experiment/thrift/TSerialization.py | 38 +
.../create-experiment/thrift/TTornado.py | 153 +
.../create-experiment/thrift/Thrift.py | 170 +
.../create-experiment/thrift/Thrift.pyc | Bin 0 -> 4886 bytes
.../create-experiment/thrift/__init__.py | 20 +
.../create-experiment/thrift/__init__.pyc | Bin 0 -> 151 bytes
.../create-experiment/thrift/protocol/TBase.py | 81 +
.../thrift/protocol/TBinaryProtocol.py | 261 +
.../thrift/protocol/TBinaryProtocol.pyc | Bin 0 -> 10448 bytes
.../thrift/protocol/TCompactProtocol.py | 405 +
.../thrift/protocol/TJSONProtocol.py | 552 +
.../thrift/protocol/TProtocol.py | 406 +
.../thrift/protocol/TProtocol.pyc | Bin 0 -> 13517 bytes
.../thrift/protocol/__init__.py | 20 +
.../thrift/protocol/__init__.pyc | Bin 0 -> 248 bytes
.../thrift/protocol/fastbinary.c | 1219 +
.../thrift/server/THttpServer.py | 87 +
.../thrift/server/TNonblockingServer.py | 346 +
.../thrift/server/TProcessPoolServer.py | 118 +
.../create-experiment/thrift/server/TServer.py | 269 +
.../create-experiment/thrift/server/__init__.py | 20 +
.../thrift/transport/THttpClient.py | 147 +
.../thrift/transport/TSSLSocket.py | 214 +
.../thrift/transport/TSSLSocket.pyc | Bin 0 -> 6546 bytes
.../thrift/transport/TSocket.py | 176 +
.../thrift/transport/TSocket.pyc | Bin 0 -> 5512 bytes
.../thrift/transport/TTransport.py | 330 +
.../thrift/transport/TTransport.pyc | Bin 0 -> 12858 bytes
.../thrift/transport/TTwisted.py | 221 +
.../thrift/transport/TZlibTransport.py | 249 +
.../thrift/transport/__init__.py | 20 +
.../thrift/transport/__init__.pyc | Bin 0 -> 207 bytes
229 files changed, 79716 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/appcatalog/__init__.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/appcatalog/__init__.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/appcatalog/__init__.py
new file mode 100644
index 0000000..42e1d7d
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/appcatalog/__init__.py
@@ -0,0 +1 @@
+__author__ = 'syodage'
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/appcatalog/__init__.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/appcatalog/__init__.pyc b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/appcatalog/__init__.pyc
new file mode 100644
index 0000000..bf85e3f
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/appcatalog/__init__.pyc differ
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/appcatalog/appcatalog.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/appcatalog/appcatalog.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/appcatalog/appcatalog.py
new file mode 100644
index 0000000..dce34d6
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/appcatalog/appcatalog.py
@@ -0,0 +1,72 @@
+from apache.airavata.model.experiment.ttypes import ExperimentModel, UserConfigurationDataModel
+from apache.airavata.model.scheduling.ttypes import ComputationalResourceSchedulingModel
+from apache.airavata.model.workspace.ttypes import Project
+
+from oauthlib.oauth2 import LegacyApplicationClient
+from requests_oauthlib import OAuth2Session
+from oauthlib.oauth2 import BackendApplicationClient
+
+__author__ = 'syodage'
+import sys
+
+import random
+
+from thrift.protocol import TBinaryProtocol
+from thrift.transport import TSocket, TTransport ##, TSSLSocket
+
+from apache.airavata.api import Airavata
+from apache.airavata.model.security.ttypes import AuthzToken
+from apache.airavata.model.application.io.ttypes import InputDataObjectType, OutputDataObjectType
+
+class AppCatalog:
+ def __init__(self, hostName, port):
+ # Create a socket to the Airavata Server
+ transport = TSocket.TSocket(hostName,port)
+ # Use Buffered Protocol to speedup over raw sockets
+ transport = TTransport.TBufferedTransport(transport)
+
+ # Airavata currently uses Binary Protocol
+ protocol = TBinaryProtocol.TBinaryProtocol(transport)
+
+ # Create a Airavata client to use the protocol encoder
+ self.airavataClient = Airavata.Client(protocol)
+
+ transport.open()
+
+ client_id = r'XXXXXXXXXXXX'
+ client_secret = r'XXXXXXXX'
+
+ client = BackendApplicationClient(client_id=client_id)
+ oauth = OAuth2Session(client=client)
+ token = oauth.fetch_token(token_url='https://idp.scigap.org:9443/oauth2/token', client_id=client_id, client_secret=client_secret)
+ self.authzToken = AuthzToken(token["access_token"])
+
+ claimsMap = {"userName":"admin","gatewayID": "Ultrascan_Production"}
+ self.authzToken.claimsMap = claimsMap
+
+ self.gateWayId = "Ultrascan_Production"
+
+ print self.airavataClient.getAPIVersion(self.authzToken)
+
+ def computer_resources(self):
+ resources = self.airavataClient.getAllComputeResourceNames(self.authzToken)
+ return resources
+
+ def list_of_applications(self, gatewayId):
+ Applications= self.airavataClient.getAllApplicationInterfaces(self.authzToken,gatewayId)
+ return Applications
+
+ def application_deployments(self, applicationInterfaceId):
+ deployments= self.airavataClient.getApplicationDeployment(self.authzToken,applicationInterfaceId)
+ return deployments
+
+ def module_descriptions(self,gatewayId):
+ description = self.airavataClient.getAllAppModules(self.authzToken,gatewayId)
+ return description
+
+ def get_gatewaylist(self):
+ gateway_list= self.airavataClient.getAllGateways(self.authzToken)
+ return gateway_list
+
+
+
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/appcatalog/appcatalog.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/appcatalog/appcatalog.pyc b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/appcatalog/appcatalog.pyc
new file mode 100644
index 0000000..5774dbf
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/appcatalog/appcatalog.pyc differ
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/cli.properties
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/cli.properties b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/cli.properties
new file mode 100644
index 0000000..9327692
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/cli.properties
@@ -0,0 +1,19 @@
+[AiravataServer]
+host=gw154.iu.xsede.org
+port=8930
+#host=gw77.iu.xsede.org
+#port=9930
+#port=10930
+
+## Gateway Specific Properties
+[GatewayProperties]
+gateway_id=Ultrascan_Production
+cred_token_id=
+#gateway_id=seagrid
+#cred_token_id=47507a08-1579-4883-be03-3c8e3b7da061
+
+[Stampede]
+host=stampede.tacc.xsede.org
+hostDesc=TACC Stampede Cluster
+jobManagerType=SLURM
+
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/__init__.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/__init__.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/__init__.py
new file mode 100644
index 0000000..42e1d7d
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/__init__.py
@@ -0,0 +1 @@
+__author__ = 'syodage'
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/__init__.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/__init__.pyc b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/__init__.pyc
new file mode 100644
index 0000000..b2d149f
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/__init__.pyc differ
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/__pycache__/__init__.cpython-35.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/__pycache__/__init__.cpython-35.pyc b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/__pycache__/__init__.cpython-35.pyc
new file mode 100644
index 0000000..60df72b
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/__pycache__/__init__.cpython-35.pyc differ
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/__pycache__/expcatalog.cpython-35.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/__pycache__/expcatalog.cpython-35.pyc b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/__pycache__/expcatalog.cpython-35.pyc
new file mode 100644
index 0000000..2e8ba43
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/__pycache__/expcatalog.cpython-35.pyc differ
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/expcatalog.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/expcatalog.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/expcatalog.py
new file mode 100644
index 0000000..d49edf9
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/expcatalog.py
@@ -0,0 +1,187 @@
+from apache.airavata.model.experiment.ttypes import ExperimentModel, UserConfigurationDataModel
+from apache.airavata.model.scheduling.ttypes import ComputationalResourceSchedulingModel
+from apache.airavata.model.workspace.ttypes import Project
+
+from oauthlib.oauth2 import LegacyApplicationClient
+from requests_oauthlib import OAuth2Session
+from oauthlib.oauth2 import BackendApplicationClient
+
+import datetime
+from datetime import datetime
+import calendar
+
+
+__author__ = 'syodage'
+import sys
+
+import random
+
+from thrift.protocol import TBinaryProtocol
+from thrift.transport import TSocket, TTransport ##, TSSLSocket
+
+from apache.airavata.api import Airavata
+from apache.airavata.model.security.ttypes import AuthzToken
+from apache.airavata.model.application.io.ttypes import InputDataObjectType, OutputDataObjectType
+
+class ExpCatalog:
+ def __init__(self, hostName, port):
+ # Create a socket to the Airavata Server
+ transport = TSocket.TSocket(hostName,port)
+ # Use Buffered Protocol to speedup over raw sockets
+ transport = TTransport.TBufferedTransport(transport)
+
+ # Airavata currently uses Binary Protocol
+ protocol = TBinaryProtocol.TBinaryProtocol(transport)
+
+ # Create a Airavata client to use the protocol encoder
+ self.airavataClient = Airavata.Client(protocol)
+
+ transport.open()
+
+ client_id = r'XXXXXXXXX'
+ client_secret = r'XXXXXXXXX'
+
+ client = BackendApplicationClient(client_id=client_id)
+ oauth = OAuth2Session(client=client)
+ token = oauth.fetch_token(token_url='https://idp.scigap.org:9443/oauth2/token', client_id=client_id, client_secret=client_secret)
+ self.authzToken = AuthzToken(token["access_token"])
+
+ claimsMap = {"userName":"admin","gatewayID": "Ultrascan_Production"}
+ self.authzToken.claimsMap = claimsMap
+
+ self.gateWayId = "default"
+
+ print (self.airavataClient.getAPIVersion(self.authzToken))
+
+ def getExperiment(self, expId):
+ experiment = self.airavataClient.getExperiment(self.authzToken, expId)
+ # print experiment
+ return experiment
+
+ def getJobModel(self,expId):
+ jobM = self.airavataClient.getJobDetails(self.authzToken,expId)
+ return jobM
+
+ def getExperimentSummary(self, expId):
+ expSum = ExperimentSummary()
+ expSum.setExperimentModel(self.getExperiment(expId))
+ expSum.setJobModels(self.getJobModel(expId))
+ return expSum
+
+
+ def getExperimentName(self):
+ nameList = ["Darwin", "Faraday" , "Aristotle", "Tesla", "Edison", "Galileo", "Einstein", "Newton", "Dalton",
+ "Arthur" , "Clark", "Turing", "Hawking", "Maxwell", "Isaac", ""]
+ limit = nameList.__len__()
+ r = random.randint(0, limit-1)
+ return nameList[r]
+
+ def createExperiment(self, applicationName):
+ # experiment = ExperimentModel()
+ # experiment.experimentName(self.getExperimentName())
+ if applicationName == "Amber":
+ appInterface = self.getApplication(applicationName)
+ else:
+ print ("not yet support for application " + applicationName)
+
+ inputs = appInterface.applicationInputs
+ for input in inputs:
+ if input.name == "Heat-Restart-File":
+ input.value = "file://ogce@stampede.tacc.xsede.org:/scratch/01437/ogce/gta-work-dirs/PROCESS_e0610a6c-5778-4a69-a004-f440e29194af/02_Heat.rst"
+ elif input.name == "Production-Control-File":
+ input.value = "file://ogce@stampede.tacc.xsede.org:/scratch/01437/ogce/gta-work-dirs/PROCESS_e0610a6c-5778-4a69-a004-f440e29194af/03_Prod.in"
+ elif input.name == "Parameter-Topology-File":
+ input.value = "file://ogce@stampede.tacc.xsede.org:/scratch/01437/ogce/gta-work-dirs/PROCESS_e0610a6c-5778-4a69-a004-f440e29194af/prmtop"
+
+ outputs = appInterface.applicationOutputs
+
+ experiment = ExperimentModel()
+ experiment.experimentName = self.getExperimentName()
+ experiment.projectId = self.getDefaultProjectId()
+ experiment.gatewayId = self.gateWayId
+ experiment.userName = "admin"
+ experiment.description = "Test Amber experiment"
+ experiment.experimentInputs = inputs
+ experiment.experimentOutputs = outputs
+ experiment.executionId = appInterface.applicationInterfaceId
+
+ computeResources = self.airavataClient.getAvailableAppInterfaceComputeResources(
+ self.authzToken, appInterface.applicationInterfaceId)
+ t = {"a": "b", "c": "d"}
+ for computeResource in computeResources:
+ if computeResource.startswith("stampede.tacc.xsede.org"):
+ stampedCRId = computeResource
+ break
+
+ print (stampedCRId)
+ computationalRS = ComputationalResourceSchedulingModel()
+ computationalRS.resourceHostId = stampedCRId
+ computationalRS.totalCPUCount = 16
+ computationalRS.nodeCount = 1
+ computationalRS.numberOfThreads = 1
+ computationalRS.queueName = "normal"
+ computationalRS.wallTimeLimit = 10
+ computationalRS.totalPhysicalMemory = 1
+
+ userConfig = UserConfigurationDataModel()
+ userConfig.airavataAutoSchedule = True
+ userConfig.overrideManualScheduledParams = False
+ userConfig.computationalResourceScheduling = computationalRS
+
+
+ experiment.userConfigurationData = userConfig
+ expId = self.airavataClient.createExperiment(self.authzToken, self.gateWayId, experiment)
+ print ("Experiment Id is " + expId)
+ return expId
+
+ def launchExperiment(self, expId):
+ self.airavataClient.launchExperiment(self.authzToken, expId , self.gateWayId)
+
+
+ def cancelExperiment(self, expId):
+ self.airavataClient.terminateExperiment(self.authzToken, expId, self.gateWayId)
+
+ def getApplication(self, nameStartWith):
+ appNames = self.airavataClient.getAllApplicationInterfaceNames(self.authzToken,self.gateWayId )
+ appInterFaces = self.airavataClient.getAllApplicationInterfaces(self.authzToken, self.gateWayId)
+ for interface in appInterFaces:
+ if interface.applicationName.startswith(nameStartWith):
+ return interface
+ # for name in appNames:
+ # if name.startswith(nameStartWith):
+ # return name
+ # def createAndLaunchExperiment(self):
+
+ def getDefaultProjectId(self):
+ project = Project()
+ project.name = "default"
+ project.owner = "admin"
+ project.description = "test project"
+ projectId = self.airavataClient.createProject(self.authzToken, self.gateWayId,project)
+ project.projectID = projectId
+ return projectId
+
+ def experiment_statistics(self,gatewayID, fromTime, toTime):
+ statistics=self.airavataClient.getExperimentStatistics(self.authzToken, gatewayID,fromTime,toTime)
+ return statistics
+
+ def create_experiment(self,authzToken,gatewayId,experiment):
+ experiment=self.airavataClient.createExperiment(self.authzToken, gatewayID,experiment)
+ return experiment
+
+
+class ExperimentSummary:
+
+ def setExperimentModel(self, expModel):
+ self.name = expModel.experimentName
+ self.id = expModel.experimentId
+ self.status = expModel.experimentStatus
+
+
+ def setProcessModel(self, processModel):
+ print ("setProcessModel is not yet implemented")
+
+ def setJobModels(self, jobModel):
+ self.jobs = jobModel
+
+
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/expcatalog.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/expcatalog.pyc b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/expcatalog.pyc
new file mode 100644
index 0000000..d44337b
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/expcatalog/expcatalog.pyc differ
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/TSCons.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/TSCons.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/TSCons.py
new file mode 100644
index 0000000..da8d283
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/TSCons.py
@@ -0,0 +1,35 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+from os import path
+from SCons.Builder import Builder
+
+
+def scons_env(env, add=''):
+ opath = path.dirname(path.abspath('$TARGET'))
+ lstr = 'thrift --gen cpp -o ' + opath + ' ' + add + ' $SOURCE'
+ cppbuild = Builder(action=lstr)
+ env.Append(BUILDERS={'ThriftCpp': cppbuild})
+
+
+def gen_cpp(env, dir, file):
+ scons_env(env)
+ suffixes = ['_types.h', '_types.cpp']
+ targets = map(lambda s: 'gen-cpp/' + file + s, suffixes)
+ return env.ThriftCpp(targets, dir + file + '.thrift')
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/TSerialization.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/TSerialization.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/TSerialization.py
new file mode 100644
index 0000000..54f10e2
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/TSerialization.py
@@ -0,0 +1,38 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+from lib.thrift.protocol import TBinaryProtocol
+from lib.thrift.transport import TTransport
+
+
+def serialize(thrift_object,
+ protocol_factory=TBinaryProtocol.TBinaryProtocolFactory()):
+ transport = TTransport.TMemoryBuffer()
+ protocol = protocol_factory.getProtocol(transport)
+ thrift_object.write(protocol)
+ return transport.getvalue()
+
+
+def deserialize(base,
+ buf,
+ protocol_factory=TBinaryProtocol.TBinaryProtocolFactory()):
+ transport = TTransport.TMemoryBuffer(buf)
+ protocol = protocol_factory.getProtocol(transport)
+ base.read(protocol)
+ return base
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/TTornado.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/TTornado.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/TTornado.py
new file mode 100644
index 0000000..af309c3
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/TTornado.py
@@ -0,0 +1,153 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+from cStringIO import StringIO
+import logging
+import socket
+import struct
+
+from thrift.transport import TTransport
+from thrift.transport.TTransport import TTransportException
+
+from tornado import gen
+from tornado import iostream
+from tornado import netutil
+
+
+class TTornadoStreamTransport(TTransport.TTransportBase):
+ """a framed, buffered transport over a Tornado stream"""
+ def __init__(self, host, port, stream=None):
+ self.host = host
+ self.port = port
+ self.is_queuing_reads = False
+ self.read_queue = []
+ self.__wbuf = StringIO()
+
+ # servers provide a ready-to-go stream
+ self.stream = stream
+ if self.stream is not None:
+ self._set_close_callback()
+
+ # not the same number of parameters as TTransportBase.open
+ def open(self, callback):
+ logging.debug('socket connecting')
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
+ self.stream = iostream.IOStream(sock)
+
+ def on_close_in_connect(*_):
+ message = 'could not connect to {}:{}'.format(self.host, self.port)
+ raise TTransportException(
+ type=TTransportException.NOT_OPEN,
+ message=message)
+ self.stream.set_close_callback(on_close_in_connect)
+
+ def finish(*_):
+ self._set_close_callback()
+ callback()
+
+ self.stream.connect((self.host, self.port), callback=finish)
+
+ def _set_close_callback(self):
+ def on_close():
+ raise TTransportException(
+ type=TTransportException.END_OF_FILE,
+ message='socket closed')
+ self.stream.set_close_callback(self.close)
+
+ def close(self):
+ # don't raise if we intend to close
+ self.stream.set_close_callback(None)
+ self.stream.close()
+
+ def read(self, _):
+ # The generated code for Tornado shouldn't do individual reads -- only
+ # frames at a time
+ assert "you're doing it wrong" is True
+
+ @gen.engine
+ def readFrame(self, callback):
+ self.read_queue.append(callback)
+ logging.debug('read queue: %s', self.read_queue)
+
+ if self.is_queuing_reads:
+ # If a read is already in flight, then the while loop below should
+ # pull it from self.read_queue
+ return
+
+ self.is_queuing_reads = True
+ while self.read_queue:
+ next_callback = self.read_queue.pop()
+ result = yield gen.Task(self._readFrameFromStream)
+ next_callback(result)
+ self.is_queuing_reads = False
+
+ @gen.engine
+ def _readFrameFromStream(self, callback):
+ logging.debug('_readFrameFromStream')
+ frame_header = yield gen.Task(self.stream.read_bytes, 4)
+ frame_length, = struct.unpack('!i', frame_header)
+ logging.debug('received frame header, frame length = %i', frame_length)
+ frame = yield gen.Task(self.stream.read_bytes, frame_length)
+ logging.debug('received frame payload')
+ callback(frame)
+
+ def write(self, buf):
+ self.__wbuf.write(buf)
+
+ def flush(self, callback=None):
+ wout = self.__wbuf.getvalue()
+ wsz = len(wout)
+ # reset wbuf before write/flush to preserve state on underlying failure
+ self.__wbuf = StringIO()
+ # N.B.: Doing this string concatenation is WAY cheaper than making
+ # two separate calls to the underlying socket object. Socket writes in
+ # Python turn out to be REALLY expensive, but it seems to do a pretty
+ # good job of managing string buffer operations without excessive copies
+ buf = struct.pack("!i", wsz) + wout
+
+ logging.debug('writing frame length = %i', wsz)
+ self.stream.write(buf, callback)
+
+
+class TTornadoServer(netutil.TCPServer):
+ def __init__(self, processor, iprot_factory, oprot_factory=None,
+ *args, **kwargs):
+ super(TTornadoServer, self).__init__(*args, **kwargs)
+
+ self._processor = processor
+ self._iprot_factory = iprot_factory
+ self._oprot_factory = (oprot_factory if oprot_factory is not None
+ else iprot_factory)
+
+ def handle_stream(self, stream, address):
+ try:
+ host, port = address
+ trans = TTornadoStreamTransport(host=host, port=port, stream=stream)
+ oprot = self._oprot_factory.getProtocol(trans)
+
+ def next_pass():
+ if not trans.stream.closed():
+ self._processor.process(trans, self._iprot_factory, oprot,
+ callback=next_pass)
+
+ next_pass()
+
+ except Exception:
+ logging.exception('thrift exception in handle_stream')
+ trans.close()
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/Thrift.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/Thrift.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/Thrift.py
new file mode 100644
index 0000000..9890af7
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/Thrift.py
@@ -0,0 +1,170 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import sys
+
+
+class TType:
+ STOP = 0
+ VOID = 1
+ BOOL = 2
+ BYTE = 3
+ I08 = 3
+ DOUBLE = 4
+ I16 = 6
+ I32 = 8
+ I64 = 10
+ STRING = 11
+ UTF7 = 11
+ STRUCT = 12
+ MAP = 13
+ SET = 14
+ LIST = 15
+ UTF8 = 16
+ UTF16 = 17
+
+ _VALUES_TO_NAMES = ('STOP',
+ 'VOID',
+ 'BOOL',
+ 'BYTE',
+ 'DOUBLE',
+ None,
+ 'I16',
+ None,
+ 'I32',
+ None,
+ 'I64',
+ 'STRING',
+ 'STRUCT',
+ 'MAP',
+ 'SET',
+ 'LIST',
+ 'UTF8',
+ 'UTF16')
+
+
+class TMessageType:
+ CALL = 1
+ REPLY = 2
+ EXCEPTION = 3
+ ONEWAY = 4
+
+
+class TProcessor:
+ """Base class for procsessor, which works on two streams."""
+
+ def process(iprot, oprot):
+ pass
+
+
+class TException(Exception):
+ """Base class for all thrift exceptions."""
+
+ # BaseException.message is deprecated in Python v[2.6,3.0)
+ if (2, 6, 0) <= sys.version_info < (3, 0):
+ def _get_message(self):
+ return self._message
+
+ def _set_message(self, message):
+ self._message = message
+ message = property(_get_message, _set_message)
+
+ def __init__(self, message=None):
+ Exception.__init__(self, message)
+ self.message = message
+
+
+class TApplicationException(TException):
+ """Application level thrift exceptions."""
+
+ UNKNOWN = 0
+ UNKNOWN_METHOD = 1
+ INVALID_MESSAGE_TYPE = 2
+ WRONG_METHOD_NAME = 3
+ BAD_SEQUENCE_ID = 4
+ MISSING_RESULT = 5
+ INTERNAL_ERROR = 6
+ PROTOCOL_ERROR = 7
+ INVALID_TRANSFORM = 8
+ INVALID_PROTOCOL = 9
+ UNSUPPORTED_CLIENT_TYPE = 10
+
+ def __init__(self, type=UNKNOWN, message=None):
+ TException.__init__(self, message)
+ self.type = type
+
+ def __str__(self):
+ if self.message:
+ return self.message
+ elif self.type == self.UNKNOWN_METHOD:
+ return 'Unknown method'
+ elif self.type == self.INVALID_MESSAGE_TYPE:
+ return 'Invalid message type'
+ elif self.type == self.WRONG_METHOD_NAME:
+ return 'Wrong method name'
+ elif self.type == self.BAD_SEQUENCE_ID:
+ return 'Bad sequence ID'
+ elif self.type == self.MISSING_RESULT:
+ return 'Missing result'
+ elif self.type == self.INTERNAL_ERROR:
+ return 'Internal error'
+ elif self.type == self.PROTOCOL_ERROR:
+ return 'Protocol error'
+ elif self.type == self.INVALID_TRANSFORM:
+ return 'Invalid transform'
+ elif self.type == self.INVALID_PROTOCOL:
+ return 'Invalid protocol'
+ elif self.type == self.UNSUPPORTED_CLIENT_TYPE:
+ return 'Unsupported client type'
+ else:
+ return 'Default (unknown) TApplicationException'
+
+ def read(self, iprot):
+ iprot.readStructBegin()
+ while True:
+ (fname, ftype, fid) = iprot.readFieldBegin()
+ if ftype == TType.STOP:
+ break
+ if fid == 1:
+ if ftype == TType.STRING:
+ self.message = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 2:
+ if ftype == TType.I32:
+ self.type = iprot.readI32()
+ else:
+ iprot.skip(ftype)
+ else:
+ iprot.skip(ftype)
+ iprot.readFieldEnd()
+ iprot.readStructEnd()
+
+ def write(self, oprot):
+ oprot.writeStructBegin('TApplicationException')
+ if self.message is not None:
+ oprot.writeFieldBegin('message', TType.STRING, 1)
+ oprot.writeString(self.message)
+ oprot.writeFieldEnd()
+ if self.type is not None:
+ oprot.writeFieldBegin('type', TType.I32, 2)
+ oprot.writeI32(self.type)
+ oprot.writeFieldEnd()
+ oprot.writeFieldStop()
+ oprot.writeStructEnd()
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/Thrift.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/Thrift.pyc b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/Thrift.pyc
new file mode 100644
index 0000000..8b7f8b1
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/Thrift.pyc differ
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/__init__.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/__init__.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/__init__.py
new file mode 100644
index 0000000..48d659c
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/__init__.py
@@ -0,0 +1,20 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+__all__ = ['Thrift', 'TSCons']
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/__init__.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/__init__.pyc b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/__init__.pyc
new file mode 100644
index 0000000..42aabd6
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/__init__.pyc differ
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TBase.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TBase.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TBase.py
new file mode 100644
index 0000000..6cbd5f3
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TBase.py
@@ -0,0 +1,81 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+from thrift.Thrift import *
+from thrift.protocol import TBinaryProtocol
+from thrift.transport import TTransport
+
+try:
+ from thrift.protocol import fastbinary
+except:
+ fastbinary = None
+
+
+class TBase(object):
+ __slots__ = []
+
+ def __repr__(self):
+ L = ['%s=%r' % (key, getattr(self, key))
+ for key in self.__slots__]
+ return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
+
+ def __eq__(self, other):
+ if not isinstance(other, self.__class__):
+ return False
+ for attr in self.__slots__:
+ my_val = getattr(self, attr)
+ other_val = getattr(other, attr)
+ if my_val != other_val:
+ return False
+ return True
+
+ def __ne__(self, other):
+ return not (self == other)
+
+ def read(self, iprot):
+ if (iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and
+ isinstance(iprot.trans, TTransport.CReadableTransport) and
+ self.thrift_spec is not None and
+ fastbinary is not None):
+ fastbinary.decode_binary(self,
+ iprot.trans,
+ (self.__class__, self.thrift_spec))
+ return
+ iprot.readStruct(self, self.thrift_spec)
+
+ def write(self, oprot):
+ if (oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and
+ self.thrift_spec is not None and
+ fastbinary is not None):
+ oprot.trans.write(
+ fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+ return
+ oprot.writeStruct(self, self.thrift_spec)
+
+
+class TExceptionBase(Exception):
+ # old style class so python2.4 can raise exceptions derived from this
+ # This can't inherit from TBase because of that limitation.
+ __slots__ = []
+
+ __repr__ = TBase.__repr__.im_func
+ __eq__ = TBase.__eq__.im_func
+ __ne__ = TBase.__ne__.im_func
+ read = TBase.read.im_func
+ write = TBase.write.im_func
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TBinaryProtocol.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TBinaryProtocol.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TBinaryProtocol.py
new file mode 100644
index 0000000..17a600f
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TBinaryProtocol.py
@@ -0,0 +1,261 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+from struct import pack, unpack
+
+from thrift.protocol.TProtocol import *
+
+
+class TBinaryProtocol(TProtocolBase):
+ """Binary implementation of the Thrift protocol driver."""
+
+ # NastyHaxx. Python 2.4+ on 32-bit machines forces hex constants to be
+ # positive, converting this into a long. If we hardcode the int value
+ # instead it'll stay in 32 bit-land.
+
+ # VERSION_MASK = 0xffff0000
+ VERSION_MASK = -65536
+
+ # VERSION_1 = 0x80010000
+ VERSION_1 = -2147418112
+
+ TYPE_MASK = 0x000000ff
+
+ def __init__(self, trans, strictRead=False, strictWrite=True):
+ TProtocolBase.__init__(self, trans)
+ self.strictRead = strictRead
+ self.strictWrite = strictWrite
+
+ def writeMessageBegin(self, name, type, seqid):
+ if self.strictWrite:
+ self.writeI32(TBinaryProtocol.VERSION_1 | type)
+ self.writeString(name)
+ self.writeI32(seqid)
+ else:
+ self.writeString(name)
+ self.writeByte(type)
+ self.writeI32(seqid)
+
+ def writeMessageEnd(self):
+ pass
+
+ def writeStructBegin(self, name):
+ pass
+
+ def writeStructEnd(self):
+ pass
+
+ def writeFieldBegin(self, name, type, id):
+ self.writeByte(type)
+ self.writeI16(id)
+
+ def writeFieldEnd(self):
+ pass
+
+ def writeFieldStop(self):
+ self.writeByte(TType.STOP)
+
+ def writeMapBegin(self, ktype, vtype, size):
+ self.writeByte(ktype)
+ self.writeByte(vtype)
+ self.writeI32(size)
+
+ def writeMapEnd(self):
+ pass
+
+ def writeListBegin(self, etype, size):
+ self.writeByte(etype)
+ self.writeI32(size)
+
+ def writeListEnd(self):
+ pass
+
+ def writeSetBegin(self, etype, size):
+ self.writeByte(etype)
+ self.writeI32(size)
+
+ def writeSetEnd(self):
+ pass
+
+ def writeBool(self, bool):
+ if bool:
+ self.writeByte(1)
+ else:
+ self.writeByte(0)
+
+ def writeByte(self, byte):
+ buff = pack("!b", byte)
+ self.trans.write(buff)
+
+ def writeI16(self, i16):
+ buff = pack("!h", i16)
+ self.trans.write(buff)
+
+ def writeI32(self, i32):
+ buff = pack("!i", i32)
+ self.trans.write(buff)
+
+ def writeI64(self, i64):
+ buff = pack("!q", i64)
+ self.trans.write(buff)
+
+ def writeDouble(self, dub):
+ buff = pack("!d", dub)
+ self.trans.write(buff)
+
+ def writeString(self, str):
+ self.writeI32(len(str))
+ self.trans.write(str)
+
+ def readMessageBegin(self):
+ sz = self.readI32()
+ if sz < 0:
+ version = sz & TBinaryProtocol.VERSION_MASK
+ if version != TBinaryProtocol.VERSION_1:
+ raise TProtocolException(
+ type=TProtocolException.BAD_VERSION,
+ message='Bad version in readMessageBegin: %d' % (sz))
+ type = sz & TBinaryProtocol.TYPE_MASK
+ name = self.readString()
+ seqid = self.readI32()
+ else:
+ if self.strictRead:
+ raise TProtocolException(type=TProtocolException.BAD_VERSION,
+ message='No protocol version header')
+ name = self.trans.readAll(sz)
+ type = self.readByte()
+ seqid = self.readI32()
+ return (name, type, seqid)
+
+ def readMessageEnd(self):
+ pass
+
+ def readStructBegin(self):
+ pass
+
+ def readStructEnd(self):
+ pass
+
+ def readFieldBegin(self):
+ type = self.readByte()
+ if type == TType.STOP:
+ return (None, type, 0)
+ id = self.readI16()
+ return (None, type, id)
+
+ def readFieldEnd(self):
+ pass
+
+ def readMapBegin(self):
+ ktype = self.readByte()
+ vtype = self.readByte()
+ size = self.readI32()
+ return (ktype, vtype, size)
+
+ def readMapEnd(self):
+ pass
+
+ def readListBegin(self):
+ etype = self.readByte()
+ size = self.readI32()
+ return (etype, size)
+
+ def readListEnd(self):
+ pass
+
+ def readSetBegin(self):
+ etype = self.readByte()
+ size = self.readI32()
+ return (etype, size)
+
+ def readSetEnd(self):
+ pass
+
+ def readBool(self):
+ byte = self.readByte()
+ if byte == 0:
+ return False
+ return True
+
+ def readByte(self):
+ buff = self.trans.readAll(1)
+ val, = unpack('!b', buff)
+ return val
+
+ def readI16(self):
+ buff = self.trans.readAll(2)
+ val, = unpack('!h', buff)
+ return val
+
+ def readI32(self):
+ buff = self.trans.readAll(4)
+ val, = unpack('!i', buff)
+ return val
+
+ def readI64(self):
+ buff = self.trans.readAll(8)
+ val, = unpack('!q', buff)
+ return val
+
+ def readDouble(self):
+ buff = self.trans.readAll(8)
+ val, = unpack('!d', buff)
+ return val
+
+ def readString(self):
+ len = self.readI32()
+ str = self.trans.readAll(len)
+ return str
+
+
+class TBinaryProtocolFactory:
+ def __init__(self, strictRead=False, strictWrite=True):
+ self.strictRead = strictRead
+ self.strictWrite = strictWrite
+
+ def getProtocol(self, trans):
+ prot = TBinaryProtocol(trans, self.strictRead, self.strictWrite)
+ return prot
+
+
+class TBinaryProtocolAccelerated(TBinaryProtocol):
+ """C-Accelerated version of TBinaryProtocol.
+
+ This class does not override any of TBinaryProtocol's methods,
+ but the generated code recognizes it directly and will call into
+ our C module to do the encoding, bypassing this object entirely.
+ We inherit from TBinaryProtocol so that the normal TBinaryProtocol
+ encoding can happen if the fastbinary module doesn't work for some
+ reason. (TODO(dreiss): Make this happen sanely in more cases.)
+
+ In order to take advantage of the C module, just use
+ TBinaryProtocolAccelerated instead of TBinaryProtocol.
+
+ NOTE: This code was contributed by an external developer.
+ The internal Thrift team has reviewed and tested it,
+ but we cannot guarantee that it is production-ready.
+ Please feel free to report bugs and/or success stories
+ to the public mailing list.
+ """
+ pass
+
+
+class TBinaryProtocolAcceleratedFactory:
+ def getProtocol(self, trans):
+ return TBinaryProtocolAccelerated(trans)
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TBinaryProtocol.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TBinaryProtocol.pyc b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TBinaryProtocol.pyc
new file mode 100644
index 0000000..981be1c
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TBinaryProtocol.pyc differ
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TCompactProtocol.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TCompactProtocol.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TCompactProtocol.py
new file mode 100644
index 0000000..09ca6ad
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TCompactProtocol.py
@@ -0,0 +1,405 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+from struct import pack, unpack
+
+from lib.thrift.protocol.TProtocol import *
+
+
+__all__ = ['TCompactProtocol', 'TCompactProtocolFactory']
+
+CLEAR = 0
+FIELD_WRITE = 1
+VALUE_WRITE = 2
+CONTAINER_WRITE = 3
+BOOL_WRITE = 4
+FIELD_READ = 5
+CONTAINER_READ = 6
+VALUE_READ = 7
+BOOL_READ = 8
+
+
+def make_helper(v_from, container):
+ def helper(func):
+ def nested(self, *args, **kwargs):
+ assert self.state in (v_from, container), (self.state, v_from, container)
+ return func(self, *args, **kwargs)
+ return nested
+ return helper
+writer = make_helper(VALUE_WRITE, CONTAINER_WRITE)
+reader = make_helper(VALUE_READ, CONTAINER_READ)
+
+
+def makeZigZag(n, bits):
+ return (n << 1) ^ (n >> (bits - 1))
+
+
+def fromZigZag(n):
+ return (n >> 1) ^ -(n & 1)
+
+
+def writeVarint(trans, n):
+ out = []
+ while True:
+ if n & ~0x7f == 0:
+ out.append(n)
+ break
+ else:
+ out.append((n & 0xff) | 0x80)
+ n = n >> 7
+ trans.write(''.join(map(chr, out)))
+
+
+def readVarint(trans):
+ result = 0
+ shift = 0
+ while True:
+ x = trans.readAll(1)
+ byte = ord(x)
+ result |= (byte & 0x7f) << shift
+ if byte >> 7 == 0:
+ return result
+ shift += 7
+
+
+class CompactType:
+ STOP = 0x00
+ TRUE = 0x01
+ FALSE = 0x02
+ BYTE = 0x03
+ I16 = 0x04
+ I32 = 0x05
+ I64 = 0x06
+ DOUBLE = 0x07
+ BINARY = 0x08
+ LIST = 0x09
+ SET = 0x0A
+ MAP = 0x0B
+ STRUCT = 0x0C
+
+CTYPES = {TType.STOP: CompactType.STOP,
+ TType.BOOL: CompactType.TRUE, # used for collection
+ TType.BYTE: CompactType.BYTE,
+ TType.I16: CompactType.I16,
+ TType.I32: CompactType.I32,
+ TType.I64: CompactType.I64,
+ TType.DOUBLE: CompactType.DOUBLE,
+ TType.STRING: CompactType.BINARY,
+ TType.STRUCT: CompactType.STRUCT,
+ TType.LIST: CompactType.LIST,
+ TType.SET: CompactType.SET,
+ TType.MAP: CompactType.MAP
+ }
+
+TTYPES = {}
+for k, v in CTYPES.items():
+ TTYPES[v] = k
+TTYPES[CompactType.FALSE] = TType.BOOL
+del k
+del v
+
+
+class TCompactProtocol(TProtocolBase):
+ """Compact implementation of the Thrift protocol driver."""
+
+ PROTOCOL_ID = 0x82
+ VERSION = 1
+ VERSION_MASK = 0x1f
+ TYPE_MASK = 0xe0
+ TYPE_SHIFT_AMOUNT = 5
+
+ def __init__(self, trans):
+ TProtocolBase.__init__(self, trans)
+ self.state = CLEAR
+ self.__last_fid = 0
+ self.__bool_fid = None
+ self.__bool_value = None
+ self.__structs = []
+ self.__containers = []
+
+ def __writeVarint(self, n):
+ writeVarint(self.trans, n)
+
+ def writeMessageBegin(self, name, type, seqid):
+ assert self.state == CLEAR
+ self.__writeUByte(self.PROTOCOL_ID)
+ self.__writeUByte(self.VERSION | (type << self.TYPE_SHIFT_AMOUNT))
+ self.__writeVarint(seqid)
+ self.__writeString(name)
+ self.state = VALUE_WRITE
+
+ def writeMessageEnd(self):
+ assert self.state == VALUE_WRITE
+ self.state = CLEAR
+
+ def writeStructBegin(self, name):
+ assert self.state in (CLEAR, CONTAINER_WRITE, VALUE_WRITE), self.state
+ self.__structs.append((self.state, self.__last_fid))
+ self.state = FIELD_WRITE
+ self.__last_fid = 0
+
+ def writeStructEnd(self):
+ assert self.state == FIELD_WRITE
+ self.state, self.__last_fid = self.__structs.pop()
+
+ def writeFieldStop(self):
+ self.__writeByte(0)
+
+ def __writeFieldHeader(self, type, fid):
+ delta = fid - self.__last_fid
+ if 0 < delta <= 15:
+ self.__writeUByte(delta << 4 | type)
+ else:
+ self.__writeByte(type)
+ self.__writeI16(fid)
+ self.__last_fid = fid
+
+ def writeFieldBegin(self, name, type, fid):
+ assert self.state == FIELD_WRITE, self.state
+ if type == TType.BOOL:
+ self.state = BOOL_WRITE
+ self.__bool_fid = fid
+ else:
+ self.state = VALUE_WRITE
+ self.__writeFieldHeader(CTYPES[type], fid)
+
+ def writeFieldEnd(self):
+ assert self.state in (VALUE_WRITE, BOOL_WRITE), self.state
+ self.state = FIELD_WRITE
+
+ def __writeUByte(self, byte):
+ self.trans.write(pack('!B', byte))
+
+ def __writeByte(self, byte):
+ self.trans.write(pack('!b', byte))
+
+ def __writeI16(self, i16):
+ self.__writeVarint(makeZigZag(i16, 16))
+
+ def __writeSize(self, i32):
+ self.__writeVarint(i32)
+
+ def writeCollectionBegin(self, etype, size):
+ assert self.state in (VALUE_WRITE, CONTAINER_WRITE), self.state
+ if size <= 14:
+ self.__writeUByte(size << 4 | CTYPES[etype])
+ else:
+ self.__writeUByte(0xf0 | CTYPES[etype])
+ self.__writeSize(size)
+ self.__containers.append(self.state)
+ self.state = CONTAINER_WRITE
+ writeSetBegin = writeCollectionBegin
+ writeListBegin = writeCollectionBegin
+
+ def writeMapBegin(self, ktype, vtype, size):
+ assert self.state in (VALUE_WRITE, CONTAINER_WRITE), self.state
+ if size == 0:
+ self.__writeByte(0)
+ else:
+ self.__writeSize(size)
+ self.__writeUByte(CTYPES[ktype] << 4 | CTYPES[vtype])
+ self.__containers.append(self.state)
+ self.state = CONTAINER_WRITE
+
+ def writeCollectionEnd(self):
+ assert self.state == CONTAINER_WRITE, self.state
+ self.state = self.__containers.pop()
+ writeMapEnd = writeCollectionEnd
+ writeSetEnd = writeCollectionEnd
+ writeListEnd = writeCollectionEnd
+
+ def writeBool(self, bool):
+ if self.state == BOOL_WRITE:
+ if bool:
+ ctype = CompactType.TRUE
+ else:
+ ctype = CompactType.FALSE
+ self.__writeFieldHeader(ctype, self.__bool_fid)
+ elif self.state == CONTAINER_WRITE:
+ if bool:
+ self.__writeByte(CompactType.TRUE)
+ else:
+ self.__writeByte(CompactType.FALSE)
+ else:
+ raise AssertionError("Invalid state in compact protocol")
+
+ writeByte = writer(__writeByte)
+ writeI16 = writer(__writeI16)
+
+ @writer
+ def writeI32(self, i32):
+ self.__writeVarint(makeZigZag(i32, 32))
+
+ @writer
+ def writeI64(self, i64):
+ self.__writeVarint(makeZigZag(i64, 64))
+
+ @writer
+ def writeDouble(self, dub):
+ self.trans.write(pack('!d', dub))
+
+ def __writeString(self, s):
+ self.__writeSize(len(s))
+ self.trans.write(s)
+ writeString = writer(__writeString)
+
+ def readFieldBegin(self):
+ assert self.state == FIELD_READ, self.state
+ type = self.__readUByte()
+ if type & 0x0f == TType.STOP:
+ return (None, 0, 0)
+ delta = type >> 4
+ if delta == 0:
+ fid = self.__readI16()
+ else:
+ fid = self.__last_fid + delta
+ self.__last_fid = fid
+ type = type & 0x0f
+ if type == CompactType.TRUE:
+ self.state = BOOL_READ
+ self.__bool_value = True
+ elif type == CompactType.FALSE:
+ self.state = BOOL_READ
+ self.__bool_value = False
+ else:
+ self.state = VALUE_READ
+ return (None, self.__getTType(type), fid)
+
+ def readFieldEnd(self):
+ assert self.state in (VALUE_READ, BOOL_READ), self.state
+ self.state = FIELD_READ
+
+ def __readUByte(self):
+ result, = unpack('!B', self.trans.readAll(1))
+ return result
+
+ def __readByte(self):
+ result, = unpack('!b', self.trans.readAll(1))
+ return result
+
+ def __readVarint(self):
+ return readVarint(self.trans)
+
+ def __readZigZag(self):
+ return fromZigZag(self.__readVarint())
+
+ def __readSize(self):
+ result = self.__readVarint()
+ if result < 0:
+ raise TException("Length < 0")
+ return result
+
+ def readMessageBegin(self):
+ assert self.state == CLEAR
+ proto_id = self.__readUByte()
+ if proto_id != self.PROTOCOL_ID:
+ raise TProtocolException(TProtocolException.BAD_VERSION,
+ 'Bad protocol id in the message: %d' % proto_id)
+ ver_type = self.__readUByte()
+ type = (ver_type & self.TYPE_MASK) >> self.TYPE_SHIFT_AMOUNT
+ version = ver_type & self.VERSION_MASK
+ if version != self.VERSION:
+ raise TProtocolException(TProtocolException.BAD_VERSION,
+ 'Bad version: %d (expect %d)' % (version, self.VERSION))
+ seqid = self.__readVarint()
+ name = self.__readString()
+ return (name, type, seqid)
+
+ def readMessageEnd(self):
+ assert self.state == CLEAR
+ assert len(self.__structs) == 0
+
+ def readStructBegin(self):
+ assert self.state in (CLEAR, CONTAINER_READ, VALUE_READ), self.state
+ self.__structs.append((self.state, self.__last_fid))
+ self.state = FIELD_READ
+ self.__last_fid = 0
+
+ def readStructEnd(self):
+ assert self.state == FIELD_READ
+ self.state, self.__last_fid = self.__structs.pop()
+
+ def readCollectionBegin(self):
+ assert self.state in (VALUE_READ, CONTAINER_READ), self.state
+ size_type = self.__readUByte()
+ size = size_type >> 4
+ type = self.__getTType(size_type)
+ if size == 15:
+ size = self.__readSize()
+ self.__containers.append(self.state)
+ self.state = CONTAINER_READ
+ return type, size
+ readSetBegin = readCollectionBegin
+ readListBegin = readCollectionBegin
+
+ def readMapBegin(self):
+ assert self.state in (VALUE_READ, CONTAINER_READ), self.state
+ size = self.__readSize()
+ types = 0
+ if size > 0:
+ types = self.__readUByte()
+ vtype = self.__getTType(types)
+ ktype = self.__getTType(types >> 4)
+ self.__containers.append(self.state)
+ self.state = CONTAINER_READ
+ return (ktype, vtype, size)
+
+ def readCollectionEnd(self):
+ assert self.state == CONTAINER_READ, self.state
+ self.state = self.__containers.pop()
+ readSetEnd = readCollectionEnd
+ readListEnd = readCollectionEnd
+ readMapEnd = readCollectionEnd
+
+ def readBool(self):
+ if self.state == BOOL_READ:
+ return self.__bool_value == CompactType.TRUE
+ elif self.state == CONTAINER_READ:
+ return self.__readByte() == CompactType.TRUE
+ else:
+ raise AssertionError("Invalid state in compact protocol: %d" %
+ self.state)
+
+ readByte = reader(__readByte)
+ __readI16 = __readZigZag
+ readI16 = reader(__readZigZag)
+ readI32 = reader(__readZigZag)
+ readI64 = reader(__readZigZag)
+
+ @reader
+ def readDouble(self):
+ buff = self.trans.readAll(8)
+ val, = unpack('!d', buff)
+ return val
+
+ def __readString(self):
+ len = self.__readSize()
+ return self.trans.readAll(len)
+ readString = reader(__readString)
+
+ def __getTType(self, byte):
+ return TTYPES[byte & 0x0f]
+
+
+class TCompactProtocolFactory:
+ def __init__(self):
+ pass
+
+ def getProtocol(self, trans):
+ return TCompactProtocol(trans)
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TJSONProtocol.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TJSONProtocol.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TJSONProtocol.py
new file mode 100644
index 0000000..6f51523
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/protocol/TJSONProtocol.py
@@ -0,0 +1,552 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import base64
+import json
+import math
+
+from lib.thrift.protocol.TProtocol import TType, TProtocolBase, TProtocolException
+
+
+__all__ = ['TJSONProtocol',
+ 'TJSONProtocolFactory',
+ 'TSimpleJSONProtocol',
+ 'TSimpleJSONProtocolFactory']
+
+VERSION = 1
+
+COMMA = ','
+COLON = ':'
+LBRACE = '{'
+RBRACE = '}'
+LBRACKET = '['
+RBRACKET = ']'
+QUOTE = '"'
+BACKSLASH = '\\'
+ZERO = '0'
+
+ESCSEQ = '\\u00'
+ESCAPE_CHAR = '"\\bfnrt'
+ESCAPE_CHAR_VALS = ['"', '\\', '\b', '\f', '\n', '\r', '\t']
+NUMERIC_CHAR = '+-.0123456789Ee'
+
+CTYPES = {TType.BOOL: 'tf',
+ TType.BYTE: 'i8',
+ TType.I16: 'i16',
+ TType.I32: 'i32',
+ TType.I64: 'i64',
+ TType.DOUBLE: 'dbl',
+ TType.STRING: 'str',
+ TType.STRUCT: 'rec',
+ TType.LIST: 'lst',
+ TType.SET: 'set',
+ TType.MAP: 'map'}
+
+JTYPES = {}
+for key in CTYPES.keys():
+ JTYPES[CTYPES[key]] = key
+
+
+class JSONBaseContext(object):
+
+ def __init__(self, protocol):
+ self.protocol = protocol
+ self.first = True
+
+ def doIO(self, function):
+ pass
+
+ def write(self):
+ pass
+
+ def read(self):
+ pass
+
+ def escapeNum(self):
+ return False
+
+ def __str__(self):
+ return self.__class__.__name__
+
+
+class JSONListContext(JSONBaseContext):
+
+ def doIO(self, function):
+ if self.first is True:
+ self.first = False
+ else:
+ function(COMMA)
+
+ def write(self):
+ self.doIO(self.protocol.trans.write)
+
+ def read(self):
+ self.doIO(self.protocol.readJSONSyntaxChar)
+
+
+class JSONPairContext(JSONBaseContext):
+
+ def __init__(self, protocol):
+ super(JSONPairContext, self).__init__(protocol)
+ self.colon = True
+
+ def doIO(self, function):
+ if self.first:
+ self.first = False
+ self.colon = True
+ else:
+ function(COLON if self.colon else COMMA)
+ self.colon = not self.colon
+
+ def write(self):
+ self.doIO(self.protocol.trans.write)
+
+ def read(self):
+ self.doIO(self.protocol.readJSONSyntaxChar)
+
+ def escapeNum(self):
+ return self.colon
+
+ def __str__(self):
+ return '%s, colon=%s' % (self.__class__.__name__, self.colon)
+
+
+class LookaheadReader():
+ hasData = False
+ data = ''
+
+ def __init__(self, protocol):
+ self.protocol = protocol
+
+ def read(self):
+ if self.hasData is True:
+ self.hasData = False
+ else:
+ self.data = self.protocol.trans.read(1)
+ return self.data
+
+ def peek(self):
+ if self.hasData is False:
+ self.data = self.protocol.trans.read(1)
+ self.hasData = True
+ return self.data
+
+class TJSONProtocolBase(TProtocolBase):
+
+ def __init__(self, trans):
+ TProtocolBase.__init__(self, trans)
+ self.resetWriteContext()
+ self.resetReadContext()
+
+ def resetWriteContext(self):
+ self.context = JSONBaseContext(self)
+ self.contextStack = [self.context]
+
+ def resetReadContext(self):
+ self.resetWriteContext()
+ self.reader = LookaheadReader(self)
+
+ def pushContext(self, ctx):
+ self.contextStack.append(ctx)
+ self.context = ctx
+
+ def popContext(self):
+ self.contextStack.pop()
+ if self.contextStack:
+ self.context = self.contextStack[-1]
+ else:
+ self.context = JSONBaseContext(self)
+
+ def writeJSONString(self, string):
+ self.context.write()
+ self.trans.write(json.dumps(string))
+
+ def writeJSONNumber(self, number):
+ self.context.write()
+ jsNumber = str(number)
+ if self.context.escapeNum():
+ jsNumber = "%s%s%s" % (QUOTE, jsNumber, QUOTE)
+ self.trans.write(jsNumber)
+
+ def writeJSONBase64(self, binary):
+ self.context.write()
+ self.trans.write(QUOTE)
+ self.trans.write(base64.b64encode(binary))
+ self.trans.write(QUOTE)
+
+ def writeJSONObjectStart(self):
+ self.context.write()
+ self.trans.write(LBRACE)
+ self.pushContext(JSONPairContext(self))
+
+ def writeJSONObjectEnd(self):
+ self.popContext()
+ self.trans.write(RBRACE)
+
+ def writeJSONArrayStart(self):
+ self.context.write()
+ self.trans.write(LBRACKET)
+ self.pushContext(JSONListContext(self))
+
+ def writeJSONArrayEnd(self):
+ self.popContext()
+ self.trans.write(RBRACKET)
+
+ def readJSONSyntaxChar(self, character):
+ current = self.reader.read()
+ if character != current:
+ raise TProtocolException(TProtocolException.INVALID_DATA,
+ "Unexpected character: %s" % current)
+
+ def readJSONString(self, skipContext):
+ string = []
+ if skipContext is False:
+ self.context.read()
+ self.readJSONSyntaxChar(QUOTE)
+ while True:
+ character = self.reader.read()
+ if character == QUOTE:
+ break
+ if character == ESCSEQ[0]:
+ character = self.reader.read()
+ if character == ESCSEQ[1]:
+ self.readJSONSyntaxChar(ZERO)
+ self.readJSONSyntaxChar(ZERO)
+ character = json.JSONDecoder().decode('"\u00%s"' % self.trans.read(2))
+ else:
+ off = ESCAPE_CHAR.find(character)
+ if off == -1:
+ raise TProtocolException(TProtocolException.INVALID_DATA,
+ "Expected control char")
+ character = ESCAPE_CHAR_VALS[off]
+ string.append(character)
+ return ''.join(string)
+
+ def isJSONNumeric(self, character):
+ return (True if NUMERIC_CHAR.find(character) != - 1 else False)
+
+ def readJSONQuotes(self):
+ if (self.context.escapeNum()):
+ self.readJSONSyntaxChar(QUOTE)
+
+ def readJSONNumericChars(self):
+ numeric = []
+ while True:
+ character = self.reader.peek()
+ if self.isJSONNumeric(character) is False:
+ break
+ numeric.append(self.reader.read())
+ return ''.join(numeric)
+
+ def readJSONInteger(self):
+ self.context.read()
+ self.readJSONQuotes()
+ numeric = self.readJSONNumericChars()
+ self.readJSONQuotes()
+ try:
+ return int(numeric)
+ except ValueError:
+ raise TProtocolException(TProtocolException.INVALID_DATA,
+ "Bad data encounted in numeric data")
+
+ def readJSONDouble(self):
+ self.context.read()
+ if self.reader.peek() == QUOTE:
+ string = self.readJSONString(True)
+ try:
+ double = float(string)
+ if (self.context.escapeNum is False and
+ not math.isinf(double) and
+ not math.isnan(double)):
+ raise TProtocolException(TProtocolException.INVALID_DATA,
+ "Numeric data unexpectedly quoted")
+ return double
+ except ValueError:
+ raise TProtocolException(TProtocolException.INVALID_DATA,
+ "Bad data encounted in numeric data")
+ else:
+ if self.context.escapeNum() is True:
+ self.readJSONSyntaxChar(QUOTE)
+ try:
+ return float(self.readJSONNumericChars())
+ except ValueError:
+ raise TProtocolException(TProtocolException.INVALID_DATA,
+ "Bad data encounted in numeric data")
+
+ def readJSONBase64(self):
+ string = self.readJSONString(False)
+ return base64.b64decode(string)
+
+ def readJSONObjectStart(self):
+ self.context.read()
+ self.readJSONSyntaxChar(LBRACE)
+ self.pushContext(JSONPairContext(self))
+
+ def readJSONObjectEnd(self):
+ self.readJSONSyntaxChar(RBRACE)
+ self.popContext()
+
+ def readJSONArrayStart(self):
+ self.context.read()
+ self.readJSONSyntaxChar(LBRACKET)
+ self.pushContext(JSONListContext(self))
+
+ def readJSONArrayEnd(self):
+ self.readJSONSyntaxChar(RBRACKET)
+ self.popContext()
+
+
+class TJSONProtocol(TJSONProtocolBase):
+
+ def readMessageBegin(self):
+ self.resetReadContext()
+ self.readJSONArrayStart()
+ if self.readJSONInteger() != VERSION:
+ raise TProtocolException(TProtocolException.BAD_VERSION,
+ "Message contained bad version.")
+ name = self.readJSONString(False)
+ typen = self.readJSONInteger()
+ seqid = self.readJSONInteger()
+ return (name, typen, seqid)
+
+ def readMessageEnd(self):
+ self.readJSONArrayEnd()
+
+ def readStructBegin(self):
+ self.readJSONObjectStart()
+
+ def readStructEnd(self):
+ self.readJSONObjectEnd()
+
+ def readFieldBegin(self):
+ character = self.reader.peek()
+ ttype = 0
+ id = 0
+ if character == RBRACE:
+ ttype = TType.STOP
+ else:
+ id = self.readJSONInteger()
+ self.readJSONObjectStart()
+ ttype = JTYPES[self.readJSONString(False)]
+ return (None, ttype, id)
+
+ def readFieldEnd(self):
+ self.readJSONObjectEnd()
+
+ def readMapBegin(self):
+ self.readJSONArrayStart()
+ keyType = JTYPES[self.readJSONString(False)]
+ valueType = JTYPES[self.readJSONString(False)]
+ size = self.readJSONInteger()
+ self.readJSONObjectStart()
+ return (keyType, valueType, size)
+
+ def readMapEnd(self):
+ self.readJSONObjectEnd()
+ self.readJSONArrayEnd()
+
+ def readCollectionBegin(self):
+ self.readJSONArrayStart()
+ elemType = JTYPES[self.readJSONString(False)]
+ size = self.readJSONInteger()
+ return (elemType, size)
+ readListBegin = readCollectionBegin
+ readSetBegin = readCollectionBegin
+
+ def readCollectionEnd(self):
+ self.readJSONArrayEnd()
+ readSetEnd = readCollectionEnd
+ readListEnd = readCollectionEnd
+
+ def readBool(self):
+ return (False if self.readJSONInteger() == 0 else True)
+
+ def readNumber(self):
+ return self.readJSONInteger()
+ readByte = readNumber
+ readI16 = readNumber
+ readI32 = readNumber
+ readI64 = readNumber
+
+ def readDouble(self):
+ return self.readJSONDouble()
+
+ def readString(self):
+ return self.readJSONString(False)
+
+ def readBinary(self):
+ return self.readJSONBase64()
+
+ def writeMessageBegin(self, name, request_type, seqid):
+ self.resetWriteContext()
+ self.writeJSONArrayStart()
+ self.writeJSONNumber(VERSION)
+ self.writeJSONString(name)
+ self.writeJSONNumber(request_type)
+ self.writeJSONNumber(seqid)
+
+ def writeMessageEnd(self):
+ self.writeJSONArrayEnd()
+
+ def writeStructBegin(self, name):
+ self.writeJSONObjectStart()
+
+ def writeStructEnd(self):
+ self.writeJSONObjectEnd()
+
+ def writeFieldBegin(self, name, ttype, id):
+ self.writeJSONNumber(id)
+ self.writeJSONObjectStart()
+ self.writeJSONString(CTYPES[ttype])
+
+ def writeFieldEnd(self):
+ self.writeJSONObjectEnd()
+
+ def writeFieldStop(self):
+ pass
+
+ def writeMapBegin(self, ktype, vtype, size):
+ self.writeJSONArrayStart()
+ self.writeJSONString(CTYPES[ktype])
+ self.writeJSONString(CTYPES[vtype])
+ self.writeJSONNumber(size)
+ self.writeJSONObjectStart()
+
+ def writeMapEnd(self):
+ self.writeJSONObjectEnd()
+ self.writeJSONArrayEnd()
+
+ def writeListBegin(self, etype, size):
+ self.writeJSONArrayStart()
+ self.writeJSONString(CTYPES[etype])
+ self.writeJSONNumber(size)
+
+ def writeListEnd(self):
+ self.writeJSONArrayEnd()
+
+ def writeSetBegin(self, etype, size):
+ self.writeJSONArrayStart()
+ self.writeJSONString(CTYPES[etype])
+ self.writeJSONNumber(size)
+
+ def writeSetEnd(self):
+ self.writeJSONArrayEnd()
+
+ def writeBool(self, boolean):
+ self.writeJSONNumber(1 if boolean is True else 0)
+
+ def writeInteger(self, integer):
+ self.writeJSONNumber(integer)
+ writeByte = writeInteger
+ writeI16 = writeInteger
+ writeI32 = writeInteger
+ writeI64 = writeInteger
+
+ def writeDouble(self, dbl):
+ self.writeJSONNumber(dbl)
+
+ def writeString(self, string):
+ self.writeJSONString(string)
+
+ def writeBinary(self, binary):
+ self.writeJSONBase64(binary)
+
+
+class TJSONProtocolFactory:
+
+ def getProtocol(self, trans):
+ return TJSONProtocol(trans)
+
+
+class TSimpleJSONProtocol(TJSONProtocolBase):
+ """Simple, readable, write-only JSON protocol.
+
+ Useful for interacting with scripting languages.
+ """
+
+ def readMessageBegin(self):
+ raise NotImplementedError()
+
+ def readMessageEnd(self):
+ raise NotImplementedError()
+
+ def readStructBegin(self):
+ raise NotImplementedError()
+
+ def readStructEnd(self):
+ raise NotImplementedError()
+
+ def writeMessageBegin(self, name, request_type, seqid):
+ self.resetWriteContext()
+
+ def writeMessageEnd(self):
+ pass
+
+ def writeStructBegin(self, name):
+ self.writeJSONObjectStart()
+
+ def writeStructEnd(self):
+ self.writeJSONObjectEnd()
+
+ def writeFieldBegin(self, name, ttype, fid):
+ self.writeJSONString(name)
+
+ def writeFieldEnd(self):
+ pass
+
+ def writeMapBegin(self, ktype, vtype, size):
+ self.writeJSONObjectStart()
+
+ def writeMapEnd(self):
+ self.writeJSONObjectEnd()
+
+ def _writeCollectionBegin(self, etype, size):
+ self.writeJSONArrayStart()
+
+ def _writeCollectionEnd(self):
+ self.writeJSONArrayEnd()
+ writeListBegin = _writeCollectionBegin
+ writeListEnd = _writeCollectionEnd
+ writeSetBegin = _writeCollectionBegin
+ writeSetEnd = _writeCollectionEnd
+
+ def writeInteger(self, integer):
+ self.writeJSONNumber(integer)
+ writeByte = writeInteger
+ writeI16 = writeInteger
+ writeI32 = writeInteger
+ writeI64 = writeInteger
+
+ def writeBool(self, boolean):
+ self.writeJSONNumber(1 if boolean is True else 0)
+
+ def writeDouble(self, dbl):
+ self.writeJSONNumber(dbl)
+
+ def writeString(self, string):
+ self.writeJSONString(string)
+
+ def writeBinary(self, binary):
+ self.writeJSONBase64(binary)
+
+
+class TSimpleJSONProtocolFactory(object):
+
+ def getProtocol(self, trans):
+ return TSimpleJSONProtocol(trans)