Commit 422b146b authored by Damien Octeau's avatar Damien Octeau Committed by GitHub
Browse files

Merge pull request #1 from cedricbonhomme/master

Refactoring in order to isolate PRIMO to its own namespace.
parents b4b3ae56 d154ee86
# Created by https://www.gitignore.io/api/python
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
*.c
# 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
# dotenv
.env
# virtualenv
venv/
ENV/
# Spyder project settings
.spyderproject
# Rope project settings
.ropeproject
......@@ -15,13 +15,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#exclude linking/*.pyx
#exclude primo/linking/*.pyx
include *.txt
include primo.py
include make_plots_and_stats.py
include performance_experiments.py
include bin/primo
include bin/make_plots_and_stats
include bin/performance_experiments
include setup.py
include linking/*.c
include linking/*.pxd
include linking/*.pxi
include linking/*.py
include primo/linking/*.c
include primo/linking/*.pxd
include primo/linking/*.pxi
include primo/linking/*.py
The PRIMO tool for static Intent resolution and probabilistic value inference.
# Installation
```shell
$ sudo python setup.py build
$ sudo python setup.py install
```
The script can be run directly from the top-level directory afterwards.
For further instructions, please see http://siis.cse.psu.edu/primo
# Usage
## As an application
```shell
$ primo --protodir ic3-output/ --dumpintentlinks links.blp
$ mkdir stats
$ make_plots_and_stats --input links.blp --out stats/
2016-05-10 09:20:34,538 [root] [INFO ] Loading file links.blp.
2016-05-10 09:20:34,541 [root] [INFO ] Loaded 35375 Intent links.
2016-05-10 09:20:34,541 [root] [INFO ] Plotting probability distribution CDF.
2016-05-10 09:20:35,669 [root] [INFO ] Finished plotting probability distribution CDF.
2016-05-10 09:20:35,669 [root] [INFO ] Plotting probability distribution histogram.
2016-05-10 09:20:36,632 [root] [INFO ] Finished plotting probability distribution histogram.
2016-05-10 09:20:36,632 [root] [INFO ] Plotting probability distribution by inter/intra app Intent.
2016-05-10 09:20:41,133 [root] [INFO ] Finished plotting histograms.
2016-05-10 09:20:41,133 [root] [INFO ] Computing Intent connectivities.
2016-05-10 09:20:41,158 [root] [INFO ] Finished computing Intent connectivities from Intent links.
2016-05-10 09:20:41,159 [root] [INFO ] Computing connectivity CDFs.
2016-05-10 09:20:41,731 [root] [INFO ] Plotting link CDF.
2016-05-10 09:20:42,272 [root] [INFO ] Finished plotting link CDF.
```
## As a module
```python
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from primo.linking.fetch_data import FetchData
if __name__ == "__main__":
# Point of entry in execution mode
file_path = sys.argv[1:]
apps, components, intents, intent_filters = FetchData(file_path, "", True)
print("")
for app in apps:
print(app.name)
print("""\tSends external intent: {}
Has publicly accessible component: {}""". \
format(app.SendsExternalIntent(),
app.HasOpenComponent()))
```
To build:
python setup.py build
The script can be run directly from the top-level directory afterwards.
It can also be installed with python setup.py install
For further instructions, please see http://siis.cse.psu.edu/primo/
......@@ -25,7 +25,7 @@ import sys
import gflags
from linking.plots_and_stats import MakePlotsAndStats
from primo.linking.plots_and_stats import MakePlotsAndStats
FLAGS = gflags.FLAGS
......
......@@ -29,7 +29,7 @@ import time
import gflags
from linking.find_links import FindLinksAndLogExceptions
from primo.linking.find_links import FindLinksAndLogExceptions
LOGGER = logging.getLogger(__name__)
......
......@@ -36,7 +36,7 @@ import time
import gflags
from linking import find_links
from primo.linking import find_links
FLAGS = gflags.FLAGS
......
......@@ -15,12 +15,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Application class and factory."""
from linking.components cimport Component
from linking.components cimport MakeComponent
from linking.intents cimport ComponentIntent
from linking.attribute_matching cimport AttributeMap
from primo.linking.components cimport Component
from primo.linking.components cimport MakeComponent
from primo.linking.intents cimport ComponentIntent
from primo.linking.attribute_matching cimport AttributeMap
from linking import ic3_data_pb2
from primo.linking import ic3_data_pb2
cdef set SAMPLES = set()
......
......@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from linking.applications cimport Application
from primo.linking.applications cimport Application
cdef int GetSkippedFilterCount()
cdef Component MakeComponent(object component_pb, Application application,
......
......@@ -16,11 +16,11 @@
# limitations under the License.
"""A class and factory for Android application components."""
from linking.applications cimport Application
from linking.target_data cimport AddComponent
from linking.intent_filters cimport IntentFilter
from linking.intent_filters cimport MakeIntentFilter
from linking.intents cimport MakeComponentIntent
from primo.linking.applications cimport Application
from primo.linking.target_data cimport AddComponent
from primo.linking.intent_filters cimport IntentFilter
from primo.linking.intent_filters cimport MakeIntentFilter
from primo.linking.intents cimport MakeComponentIntent
cdef int _id = 0
......
......@@ -20,8 +20,8 @@ from google.protobuf import text_format
import logging
import os
from linking import applications
from linking import ic3_data_pb2
from primo.linking import applications
from primo.linking import ic3_data_pb2
LOGGER = logging.getLogger(__name__)
......
......@@ -16,8 +16,8 @@
# limitations under the License.
cimport numpy as np
from linking.components cimport Component
from linking.intents cimport Intent
from primo.linking.components cimport Component
from primo.linking.intents cimport Intent
ctypedef np.int8_t DTYPE_t
......
......@@ -24,15 +24,15 @@ import logging
import numpy as np
import time
from linking.applications cimport Application
from linking.components cimport Component
from linking.target_data cimport GetAppsMatching
from linking.target_data cimport GetComponentsOfApp
from linking.target_data cimport GetComponentsWithKind
from linking.target_data cimport GetComponentsWithName
from linking.target_data cimport GetExportedComponentCount
from linking.target_data cimport GetExportedComponents
from linking.intents cimport Intent
from primo.linking.applications cimport Application
from primo.linking.components cimport Component
from primo.linking.target_data cimport GetAppsMatching
from primo.linking.target_data cimport GetComponentsOfApp
from primo.linking.target_data cimport GetComponentsWithKind
from primo.linking.target_data cimport GetComponentsWithName
from primo.linking.target_data cimport GetExportedComponentCount
from primo.linking.target_data cimport GetExportedComponents
from primo.linking.intents cimport Intent
DTYPE = np.int8
......
......@@ -16,9 +16,9 @@
# limitations under the License.
cimport numpy as np
from linking.intent_filters cimport IntentFilter
from linking.intents cimport ComponentIntent
from linking.intents cimport Intent
from primo.linking.intent_filters cimport IntentFilter
from primo.linking.intents cimport ComponentIntent
from primo.linking.intents cimport Intent
ctypedef np.int8_t DTYPE_t
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment