PyDIM has been developed using the v16rXX, v17rXX and v18r0 DIM versions and works with any. It has not been tested with older versions but I believe it has good chances to work. It does not depend on the DIM internals but only on DIM's API. This is why it should be compatible with a wide range of DIM versions.
Note: The package has been developed on both 32 and 64 bits architectures.
The source code is hosted in the CERN Central Subversion Service. There are several ways for accessing it:
/usr/local/lib
and /usr/local/include
respectively. Please make the necessary changes so that the run-time linker finds libdim.so (basically add an entry in /etc/ld.so.conf that points to the DIM library directory). Make sure that the DIM library is built using the same compiler and architecture as the Python installation you want to use.In the general case this should take care of building the library.
If the DIM libraries are not installed in the usual locations, the install script will look for an environment variable with the actual location. The variables that can be used are:
Remember to point that variable to the main DIM installation directory, i.e. the one that contains the sub-directories dim
and the specific one for your operating system, e.g. linux
.
For building on Windows you will need the same compiler (the same cl version) as the one used to build DIM. At this point, the default DIM C compiler is included in the Microsoft .Net 2003 framework. Ideally the Python interpreter should be build using the same compiler (any Python version > 2.3 should do the job).
Windows does not come by default with any SVN or CVS clients so you might want to install the Cygwin linux like environment for convenience. In this case make sure that the .Net paths are still correctly set.
/afs/cern.ch/lhcb/project/web/online/online-rpm-repo/
The RPMs are for both i386 and x86_64 architectures and are compiled gcc 3.4.X against Python 2.3 (these are the standard Python, gcc versions for SLC 4.6).
There are two dependencies for building the package: python-devel and dim-devel. Those packages contains the header files for Python and DIM respectively.
RPMs packages are build using the distutils module, this can be done by running the setup script with command bdist_rpm
:
$ python setup.py bdist_rpm
The bdist_rpm
command will create binary and source packages in the dist
directory. The command provides options for the process, such as creating only the .spec
file:
$ python setup.py bdist_rpm --spec-only
Or building only the RPM source package:
$ python setup.py bdist_rpm --source-only
The full list of the options can be displayed with the help command:
$ python setup.py --help bdist_rpm
The setup/setup.sh is provided for bash shells as an environment setup template. It tries to set up the DIM_DNS_NODE, adds the PyDIM/python directory to your PYTHONPATH, LD_LIBRARY_PATH.
You can execute some tests/examples from the 'tests' directory. Those scripts can be used as examples of the package's functionality.
import sys, time import pydim def service_callback(tag): """ Service callbacks are functions (in general, Python callable objects) that take one argument: the DIM tag used when the service was added, and returns a tuple with the values that corresponds to the service parameters definition in DIM. """ # Calculate the value of the server # ... val1 = 3.11 val2 = 42 return (val1, val2) def callback2(tag): # Calculate the value # ... # Remember, the callback function must return a tuple return ( "hello world", ) # The function dis_add_service is used to register the service in DIM svc = pydim.dis_add_service('test service 1', "F:1;I:1;", service_callback, 1) # Register another service svc2 = pydim.dis_add_service('another service', "C", callback2, 2) # The return value is the service identifier. It can be used to check # if the service was registered correctly. if not svc2: sys.stderr.write("An error occurred while registering the service\n") sys.exit(1) # A service must be updated before using it. pydim.dis_update_service(svc) pydim.dis_update_service(svc2) # Start the DIM server pydim.dis_start_serving('server-name') while True: # Update the service periodically pydim.dis_update_service(svc) time.sleep(5)
Now it's maintained by Niko Neufeld and Juan Manuel Caicedo.
Feel free to send your questions and bugfixes.