diff options
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | python/ContextKit/CTypesHelpers.py (renamed from python/CTypesHelpers.py) | 0 | ||||
-rw-r--r-- | python/ContextKit/ContextProvider.py (renamed from python/ContextProvider.py) | 0 | ||||
-rw-r--r-- | python/ContextKit/__init__.py | 0 | ||||
-rw-r--r-- | python/ContextKit/flexiprovider.py (renamed from tools/flexiprovider/flexiprovider.py) | 7 | ||||
-rw-r--r-- | python/Makefile.am | 11 | ||||
-rw-r--r-- | python/README (renamed from tools/flexiprovider/README) | 19 | ||||
-rwxr-xr-x | python/complex.py (renamed from tools/flexiprovider/complex.py) | 2 | ||||
-rwxr-xr-x | python/context-provide (renamed from tools/flexiprovider/provide.py) | 8 | ||||
-rwxr-xr-x | python/context-rlwrap (renamed from tools/flexiprovider/rl.py) | 4 | ||||
-rwxr-xr-x | python/simple.py (renamed from tools/flexiprovider/simple.py) | 2 |
12 files changed, 42 insertions, 16 deletions
diff --git a/Makefile.am b/Makefile.am index 4e63bbb5..ffc4f352 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,6 +14,7 @@ SUBDIRS = \ tools \ fake-provider \ vapi \ + python \ $(NULL) pkgconfigdir = $(libdir)/pkgconfig diff --git a/configure.ac b/configure.ac index 1a4eaf4d..d06a0789 100644 --- a/configure.ac +++ b/configure.ac @@ -105,6 +105,9 @@ AC_SUBST(LOCATION_LIBS) AM_CONDITIONAL(HAVE_LOCATION, test x$have_location = xyes) +AC_CONFIG_SUBDIRS([libcontextsubscriber]) +AM_PATH_PYTHON(,, [:]) + AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([libcontextprovider/Makefile]) AC_CONFIG_FILES([contextd/Makefile]) @@ -118,6 +121,7 @@ AC_CONFIG_FILES([doc/Makefile]) AC_CONFIG_FILES([doc/reference/Makefile]) AC_CONFIG_FILES([doc/reference/libcontextprovider/Makefile]) AC_CONFIG_FILES([tools/Makefile]) +AC_CONFIG_FILES([python/Makefile]) AC_CONFIG_FILES([contextprovider-1.0.pc]) AC_CONFIG_FILES([contextd/org.freedesktop.ContextKit.contextd.service]) AC_CONFIG_FILES([fake-provider/Makefile]) diff --git a/python/CTypesHelpers.py b/python/ContextKit/CTypesHelpers.py index bada4e0d..bada4e0d 100644 --- a/python/CTypesHelpers.py +++ b/python/ContextKit/CTypesHelpers.py diff --git a/python/ContextProvider.py b/python/ContextKit/ContextProvider.py index 6e8f61fd..6e8f61fd 100644 --- a/python/ContextProvider.py +++ b/python/ContextKit/ContextProvider.py diff --git a/python/ContextKit/__init__.py b/python/ContextKit/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/python/ContextKit/__init__.py diff --git a/tools/flexiprovider/flexiprovider.py b/python/ContextKit/flexiprovider.py index b57ef941..fd9a56ec 100644 --- a/tools/flexiprovider/flexiprovider.py +++ b/python/ContextKit/flexiprovider.py @@ -29,11 +29,16 @@ if pkgconfig('--uninstalled', 'contextprovider-1.0').returncode == 0: sys.path.append(pkgconfig('--variable=pythondir', 'contextprovider-1.0').output) try: import ContextProvider as CP +except ImportError: + raise except: # Failed, probably because LD_LIBRARY_PATH is not right. Set it and - # re-exec ourselves. + # re-exec ourselves. To avoid an infinite loop, we try this only + # when LD_LIBRARY_PATH doesn't yet contain what we want to add. libdir = pkgconfig('--variable=libdir', 'contextprovider-1.0').output ldpath = [d for d in os.environ.get('LD_LIBRARY_PATH', '').split(':') if d != ''] + if libdir in ldpath: + raise ldpath += [libdir, libdir + '/.libs'] env = dict(os.environ) env.update(LD_LIBRARY_PATH=':'.join(ldpath)) diff --git a/python/Makefile.am b/python/Makefile.am new file mode 100644 index 00000000..c716a0b0 --- /dev/null +++ b/python/Makefile.am @@ -0,0 +1,11 @@ +dist_bin_SCRIPTS = context-provide \ + context-rlwrap + +pkgpython_PYTHON = ContextKit/flexiprovider.py \ + ContextKit/ContextProvider.py \ + ContextKit/CTypesHelpers.py \ + ContextKit/__init__.py + +EXTRA_DIST = README \ + simple.py \ + complex.py
\ No newline at end of file diff --git a/tools/flexiprovider/README b/python/README index 35132a70..64d0ddc9 100644 --- a/tools/flexiprovider/README +++ b/python/README @@ -1,22 +1,29 @@ +These directories contain a simple Python binding for the +libcontextprovider library and a test provider tool. + Flexiprovider is a Python module/tool for testing Context Framework clients. It allows to define properties and provides means to change their values during runtime. There are two examples: `simple.py' and `complex.py', which you may use -to get a clue how to write your own provider, and a third one, -`provide.py', which allows you to start up a provider from the command -line, without writing any Python code. +to get a clue how to write your own provider. The `context-provide' +script allows you to start up a provider from the command line, without +writing any Python code. The interactive mode supports the following commands on the standard input (note that this is Python syntax, and it gets eval()ed): + set(property, value): sets the given property get(property): prints the value of the property reset(property): resets the property - add(propertydesc): adds a new property + add(propertydesc): adds a new property, see simple.py for + examples of propertydesc info(): prints properties and their values quit(): stops the whole thing The provider will stop also if stdin is closed. -You may use ./rl.py to enjoy readline interface: - ./rl.py ./provide.py my.fake.provider +You may use `context-rlwrap' as illustrated below to enjoy a more +friendlier readline interface: + + context-rlwrap ./provide.py my.fake.provider diff --git a/tools/flexiprovider/complex.py b/python/complex.py index 13c542f3..2adf166e 100755 --- a/tools/flexiprovider/complex.py +++ b/python/complex.py @@ -1,7 +1,7 @@ #!/usr/bin/python """A more complex provider with a horroristic theme.""" -from flexiprovider import * +from ContextKit.flexiprovider import * import glib count = 0 diff --git a/tools/flexiprovider/provide.py b/python/context-provide index 6d652a78..4a3b5610 100755 --- a/tools/flexiprovider/provide.py +++ b/python/context-provide @@ -1,9 +1,7 @@ #!/usr/bin/python -"""provide.py -- start up a provider from the command line +"""context-provide -- start up a provider from the command line -SYNOPSIS - -./provide [BUSTYPE:]PROVIDERNAME [TYPE NAME INITVALUE ...] +Usage: context-provide [BUSTYPE:]PROVIDERNAME [TYPE NAME INITVALUE ...] Starts up a Flexiprovider with the given PROVIDERNAME, serving properties specified in the arguments. TYPE is one of 'int', 'string', @@ -12,7 +10,7 @@ defaulting to the latter). """ import sys -from flexiprovider import * +from ContextKit.flexiprovider import * types = dict(int=(INT, int), truth=(TRUTH, bool), diff --git a/tools/flexiprovider/rl.py b/python/context-rlwrap index 50143cb8..96702559 100755 --- a/tools/flexiprovider/rl.py +++ b/python/context-rlwrap @@ -1,7 +1,7 @@ #!/usr/bin/python -"""rl.py -- a simple readline wrapper +"""context-rlwrap -- a simple readline wrapper -Usage: ./rl.py [some other program and args] +Usage: context-rlwrap [some other program and args] Wraps the plain stdin-based input mechanism of the given program into a convenient readline-based one. diff --git a/tools/flexiprovider/simple.py b/python/simple.py index c710bd43..a74cecdf 100755 --- a/tools/flexiprovider/simple.py +++ b/python/simple.py @@ -4,7 +4,7 @@ A very simple example of the Flexiprovider. Exports three properties initially. """ -from flexiprovider import * +from ContextKit.flexiprovider import * Flexiprovider([INT('location.altitude'), STRING('my.name', 'flexi'), |