Welcome to JasperReports Tools’s documentation!

Contents:

JasperReports Tools

https://img.shields.io/pypi/v/jr_tools.svg https://img.shields.io/travis/erickgnavar/jr_tools.svg Documentation Status Updates

A collection of tools to handle Jasper Reports with python

Tested with JasperServer CE 6.4

Features

  • Client to get reports in API available formats(PDF, xls, etc)
  • CLI: run jr_tools --help to get the list of available commands
  • CLI: load resources from yaml file jr_tools load path_to_yaml_file

Development

For development there is a docker-compose based configuration to start jasper server and mysql.

Use the below commands to handle the docker setup:

  • make docker_up: this will launch docker-compose services, it’s going to take a few minutes to download the required images and setup everything.
  • make docker_down: this will shutdown the launched containers.
  • make mysql_shell: this will launch a mysql console to interact with the database, by default it connects to demo database.
  • make mysql_shell_root: the same as above but use the root user.

Credentials:

Jasper Server:

  • username: jasperadmin
  • password: jasperadmin

MySQL:

  • username: demo
  • password: demo
  • root password: root
  • default database: demo

After the setup is complete you can enter to http://localhost:8080 and login using the credentials from above.

TODO

  • Django helper to consume reports and converto to Django responses

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Installation

Stable release

To install JasperReports Tools, run this command in your terminal:

$ pip install jr_tools

This is the preferred method to install JasperReports Tools, as it will always install the most recent stable release.

If you don’t have pip installed, this Python installation guide can guide you through the process.

From sources

The sources for JasperReports Tools can be downloaded from the Github repo.

You can either clone the public repository:

$ git clone git://github.com/erickgnavar/jr_tools

Or download the tarball:

$ curl  -OL https://github.com/erickgnavar/jr_tools/tarball/master

Once you have a copy of the source, you can install it with:

$ python setup.py install

Usage

From python code

Run a report and get the binary result

from jr_tools.client import Client

client = Client(url='http://localhost:8080/jasperserver', username='jasperadmin', password='secret')
result = client.run_report('/path/to/report', {'id': 1}, 'pdf')

From command line

Get all available commands

$ jr_tools --help

Run and save a report

$ jr_tools run_report /path/to/report result_file.pdf --format pdf

To get more info about the optional arguments run:

$ jr_tools run_report --help

Load resources from yaml file

$ jr_tools load resources.yml

Resources sample yml file

files:
- uri: /Files/report.jrxml
  path: /path/to/jrxml/file/on/disk
  type: jrxml

reports:
- uri: /Reports/report
  params:
    - label: param_id
      type: text
      mandatory: true
  jrxml_uri: /Files/report.jrxml
  data_source_uri: /DataSources/demo

The datasource must be configured previously

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions

Report Bugs

Report bugs at https://github.com/erickgnavar/jr_tools/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your local setup that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.

Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.

Implement Features

Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.

Write Documentation

JasperReports Tools could always use more documentation, whether as part of the official JasperReports Tools docs, in docstrings, or even on the web in blog posts, articles, and such.

Submit Feedback

The best way to send feedback is to file an issue at https://github.com/erickgnavar/jr_tools/issues.

If you are proposing a feature:

  • Explain in detail how it would work.
  • Keep the scope as narrow as possible, to make it easier to implement.
  • Remember that this is a volunteer-driven project, and that contributions are welcome :)

Get Started!

Ready to contribute? Here’s how to set up jr_tools for local development.

  1. Fork the jr_tools repo on GitHub.

  2. Clone your fork locally:

    $ git clone git@github.com:your_name_here/jr_tools.git
    
  3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:

    $ mkvirtualenv jr_tools
    $ cd jr_tools/
    $ python setup.py develop
    
  4. Create a branch for local development:

    $ git checkout -b name-of-your-bugfix-or-feature
    

    Now you can make your changes locally.

  5. When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:

    $ flake8 jr_tools tests
    $ python setup.py test or py.test
    $ tox
    

    To get flake8 and tox, just pip install them into your virtualenv.

  6. Commit your changes and push your branch to GitHub:

    $ git add .
    $ git commit -m "Your detailed description of your changes."
    $ git push origin name-of-your-bugfix-or-feature
    
  7. Submit a pull request through the GitHub website.

Pull Request Guidelines

Before you submit a pull request, check that it meets these guidelines:

  1. The pull request should include tests.
  2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
  3. The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check https://travis-ci.org/erickgnavar/jr_tools/pull_requests and make sure that the tests pass for all supported Python versions.

Tips

To run a subset of tests:

$ python -m unittest tests.test_jr_tools

Credits

Development Lead

Contributors

None yet. Why not be the first?

History

0.3.1 (2018-10-24)

  • Pin Click version to 6.X to use underscore command names

0.3.0 (2017-11-06)

  • Add option to choose if a parameters must be mandatory

0.2.0 (2017-10-31)

  • Add suport to upload and configure files and reports to JasperServer using a yml file

0.1.0 (2017-07-30)

  • First release on PyPI.

Indices and tables