Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
47873a3
Updated Readme
madhawav Aug 9, 2017
5e57fcd
Added PySiddhi4 Sources
madhawav Aug 10, 2017
9c1bf13
Commented ComplexEvent and Event. Added install scripts. Modified loc…
madhawav Aug 10, 2017
668980d
Updated setup script author details abd Readme.
madhawav Aug 10, 2017
faa01de
Update README.md
madhawav Aug 10, 2017
6a1c254
Added deployment wheel generation support
madhawav Aug 10, 2017
2187574
Added Windows Compatibility
Aug 11, 2017
2015ba0
Added missing file PyThreadFixCaller.java
Aug 11, 2017
427762c
Added deployment support to Windows
Aug 11, 2017
4c75405
Update README.md
madhawav Aug 11, 2017
71c194e
Made shell=True applied only for check_call in Windows
madhawav Aug 11, 2017
7522031
Minor improvement to Readme
madhawav Aug 12, 2017
f7dd797
Added Copyright Notice to Python Files
madhawav Aug 15, 2017
00c14b8
Added Copyright to Java files
madhawav Aug 15, 2017
fdcbccb
Line length correction on BasicTest.py
madhawav Aug 17, 2017
15bcb72
Updated Copyright Notice to 2017.
madhawav Aug 17, 2017
5a0821d
Added Copyright Notice to C Files.
madhawav Aug 17, 2017
515c782
Added Copyright Notice to C Files.
madhawav Aug 17, 2017
e32cbd6
Merge remote-tracking branch 'origin/master'
madhawav Aug 17, 2017
e703f5b
Upgraded to 4.0.0-M43-SNAPSHOT
madhawav Aug 17, 2017
e1bd31e
Added Contributor Details
madhawav Aug 17, 2017
c6dcefb
Fixed dependency issues in installation.
madhawav Aug 19, 2017
f8ea511
Added developer mail to README
madhawav Aug 19, 2017
17ae55d
Update README.md
madhawav Aug 22, 2017
464eea4
Update README.md
madhawav Aug 22, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 83 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,89 @@
# Compiled class file
*.class
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Log file
# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# BlueJ files
*.ctxt
# dotenv
.env

# Mobile Tools for Java (J2ME)
.mtj.tmp/
# virtualenv
venv/
ENV/

# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar
# Spyder project settings
.spyderproject

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
# Rope project settings
.ropeproject
128 changes: 128 additions & 0 deletions PySiddhi4/DataTypes/DataWrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# WSO2 Inc. 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 PySiddhi4 import SiddhiLoader
from PySiddhi4.DataTypes.DoubleType import DoubleType
from PySiddhi4.DataTypes.LongType import LongType

'''
Data Wrapping is used because python 3 doesn't distinctly support long and double data types
'''


def unwrapDataItem(d):
'''
Unwraps a data item (String, float, int, long) sent from Java Proxy Classes
:param d:
:return:
'''
if d.isNull():
return None
elif d.isLong():
return LongType(d.getData())
elif d.isDouble():
return DoubleType(d.getData())
return d.getData()


def unwrapDataList(d):
'''
Unwraps a list of data sent from Java Proxy Classes
:param d:
:return:
'''
results = []
for r in d:
results.append(unwrapDataItem(r))
return results


def unwrapData(data):
'''
Unwraps a data object sent from Java Proxy Classes
:param data:
:return:
'''
if isinstance(data, list):
return unwrapDataList(data)
else:
return unwrapDataItem(data)


def wrapDataItem(d):
'''
Wraps a data item (int, long, string or float) , making it suitable to be transfered to Java Proxy
:param d:
:return:
'''
wrapped_data_proxy = SiddhiLoader._loadType("org.wso2.siddhi.pythonapi.DataWrapProxy")
wrapped_data = None
if d is None:
# Constructor for null type
wrapped_data = wrapped_data_proxy(0, False, True)
elif type(d) is LongType:
# Consutrctor for Long Type
wrapped_data = wrapped_data_proxy(d, True)
elif type(d) is DoubleType:
wrapped_data = wrapped_data_proxy(d, False, False, True)
else:
wrapped_data = wrapped_data_proxy(d)
return wrapped_data


def wrapDataList(data):
'''
Wraps a list of data, making it suitable for transfer to java proxy classes
:param data:
:return:
'''
results = []
for d in data:
results.append(wrapData(d))
return results


def wrapData(data):
'''
Wraps a data object (List or item) to suite transmission to Java proxy classes
:param data:
:return:
'''
if isinstance(data, list):
return wrapDataList(data)
else:
return wrapDataItem(data)


def unwrapHashMap(map):
'''
Obtains a copy of a Java HashMap as a Dictionary
:param map:
:return:
'''
if (not isinstance(map, SiddhiLoader._JavaClass)) or (
map.__javaclass__ != "java/util/Map" and map.__javaclass__ != "java/util/HashMap"):
return map
# TODO: Should prevent exposure of subtypes of ComplexEvent
results = {}
entry_set = map.entrySet().toArray()
for v in entry_set:
if v.value is None:
results[v.key] = None
else:
results[v.key] = unwrapHashMap(v.value)
return results
24 changes: 24 additions & 0 deletions PySiddhi4/DataTypes/DoubleType.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# WSO2 Inc. 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.

class DoubleType(float):
'''
Siddhi Double Data Type.
Use DoubleType(int_value) to create DoubleType variables.
'''

def __new__(cls, *args, **kwargs):
return super(DoubleType, cls).__new__(cls, args[0])
25 changes: 25 additions & 0 deletions PySiddhi4/DataTypes/LongType.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# WSO2 Inc. 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.


class LongType(int):
'''
Siddhi Long Data Type.
Use LongType(int_value) to create LongType variables.
'''

def __new__(cls, *args, **kwargs):
return super(LongType, cls).__new__(cls, args[0])
15 changes: 15 additions & 0 deletions PySiddhi4/DataTypes/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# WSO2 Inc. 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.
Loading