A Python library for interacting with, and connecting to, Fedora services.
sebwoj and cverna Add missing blankline in ProxyClient docstring
Signed-off-by: Sebastian Wojciechowski <s.wojciechowski89@gmail.com>
Latest commit 895ccd7 Sep 18, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.tx Updated translations Dec 19, 2013
doc correction in doc. changed path for module 'AccountSystem' from 'fedo… Sep 10, 2018
fedora Add missing blankline in ProxyClient docstring Nov 28, 2018
tests Use assertEqual() instead of assertEquals() Dec 31, 2015
translations Update translations from Zanata Apr 22, 2016
.bzrignore Mark strings for translation. Mar 19, 2009
.gitignore Improved Readme and added *.rst~ in .gitignore Sep 10, 2015
AUTHORS First version of flask_fas_openid added Feb 11, 2013
COPYING Update FSF address Aug 10, 2011
COPYING.LESSER Relicense from GPLv2 to LGPLv2+. headers, COPYING.LESSER file, licens… Jul 30, 2009
MANIFEST.in Also ship README.rst Apr 24, 2016
NEWS Remove fedora.client.bodhi. Aug 16, 2018
README.rst correction in doc. changed path for module 'AccountSystem' from 'fedo… Sep 10, 2018
flask_fas_openid.py Make flask_fas_openid compatible with flask >= 1.0 Jul 31, 2018
releaseutils.py Use configparser from six.moves Jan 7, 2016
requirements.txt Use split out python-openidc-client Mar 30, 2017
setup.cfg Add another string that means we're marking a string for translation Aug 7, 2014
setup.py Use split out python-openidc-client Mar 30, 2017
test_requirements.txt Add a Development environment section to the Readme Jul 26, 2018
tox.ini Change tox test targets to match setup.py. Jan 7, 2016
zanata.xml Release 0.8.0 release notes and version bump Apr 21, 2016

README.rst

Python Fedora Module

Author: Patrick Uiterwijk
Date: 21 April 2016
Version: 0.8.x

The Fedora module provides a python API for building Fedora Services and clients that connect to them. It has functions and classes that help to build TurboGears applications and classes to make building clients of those services much easier.

License

This python module is distributed under the terms of the GNU Lesser General Public License Version 2 or later.

Dependencies

python-fedora requires the munch, kitchen, and requests python modules. It used to use pycurl, but was updated to use requests as of version 0.3.32. The flask_fas_openid module requires the python-openid and python-openid-teams modules.

Installing

python-fedora is found in rpm form in Fedora proper. Sometimes a new version will be placed in the Fedora Infrastructure yum repository for testing within Infrastructure before being released to the general public. Installing from the yum repository should be as easy as:

$ yum install python-fedora

If you want to install from a checkout of the development branch, follow these procedures:

$ git clone https://github.com/fedora-infra/python-fedora.git
$ cd python-fedora
$ ./setup.py install

See the configuration notes in each section for information on configuring your application after install.

Development Environment

  1. Create and Activate a virtual environment:

    python3 -m venv .venv
    source .venv/bin/activate
    
  2. Upgrade pip and install Dependencies:

    pip install --upgrade pip
    pip install -r requirements.txt
    pip install -r test_requirements.txt
    
  3. Run the unit tests:

    tox test
    

Fedora Accounts Integration

We provide several modules that make connecting to the Fedora Account System easier.

General Purpose API

The fedora.client.fas2 module allows code to integrate with the Fedora Account System. It uses the JSON interface provided by the Account System servre to retrieve information about users.

Note: This API is not feature complete. If you'd like to help add methods, document the existing methods, or otherwise aid in development of this API please contact us on the infrastructure list: infrastructure@lists.fedoraproject.org or on IRC: lmacken, abadger1999, and ricky in #fedora-admin, irc.freenode.net

Using the general API requires instantiating an AccountSystem object. You then use methods on the AccountSystem to get and set information on the people in the account system.

At the moment, there are only a few methods implemented. Full documentation on these methods is available from the AccountSystem's docstrings from the interpreter or, for instance, by running:

$ pydoc fedora.client.fas2.AccountSystem

Here's an example of using the AccountSystem:

from fedora.client.fas2 import AccountSystem
from fedora.client import AuthError

# Get an AccountSystem object.  All AccountSystem methods need to be
# authenticated so you might as well give username and password here.
fas = AccountSystem(username='foo', password='bar')

people = fas.people_by_id()

TurboGears Interface

The TurboGears interface also uses the JSON interface to the account system. It provides a TurboGears visit and identity plugin so a TurboGears application can authorize via FAS. Since the plugin operates over JSON, it is possible to use these plugins on hosts outside of Fedora Infrastructure as well as within. Remember, however, that entering your Fedora password on a third party website requires you to trust that website. So doing things this way is more useful for developers wanting to work on their apps outside of Fedora Infrastructure than a general purpose solution for allowing Fedora Users to access your web app. (SSL client certificates and OpenID are better solutions to this problem but they are still being implemented in the FAS2 server.)

Configuring

To configure your TurboGears application, you need to set the following variables in your pkgname/config/app.cfg file:

fas.url='https://admin.fedoraproject.org/accounts/'
visit.on=True
visit.manager="jsonfas"
identity.on="True"
identity.failure_url="/login"
identity.provider="jsonfas"

Fedora Services

python-fedora provides several helper classes and functions for building a TurboGears application that works well with other Fedora Services. the Fedora Services documentation is the best place to learn more about these.

TurboGears Client

There is a module to make writing a client for our TurboGears services very easy. Please see the client documentation for more details

Building the docs

You'll need to install python-sphinx for this:

yum install python-sphinx

Then run this command:

python setup.py build_sphinx

Translations

The strings in python-fedora has mainly error messages. These are translated so we should make sure that translators are able to translate them when necessary. You will need babel, setuptools, and zanata-client to run these commands:

yum install babel setuptools zanata-client

Much information about using zanata for translations can be found in the zanata user's guide. The information in this section is largely from experimenting with the information in the zanata client documentation

Updating the POT File

When you make changes that change the translatable strings in the package, you should update the POT file. Use the following distutils command (provided by python-babel) to do that:

./setup.py extract_messages -o translations/python-fedora.pot
zanata-cli push

Then commit your changes to source control.

Updating the PO Files

fedora.zanata.org will merge the strings inside the pot file with the already translated strings. To merge these, we just need to pull revised versions of the po files:

zanata-cli pull

Then commit the changes to source control (look for any brand new PO files that zanata may have created).

Creating a new PO File

The easiest way to create a new po file for a new language is in 's web UI.

Compiling Message Catalogs

Message catalogs can be compiled for testing and should always be compiled just prior to release. Do this with the following script:

python releaseutils.py build_catalogs

Compiled message catalogs should not be committed to source control.

Installing Message Catalogs

python releaseutils.py install_catalogs will install the catalogs. This command may be customized through the use of environment variables. See python releaseutils.py --help for details.

Release

  1. Commit all features, hotfixes, etc that you want in the release into the develop branch.

  2. Checkout a copy of the repository and setup git flow:

    git clone https://github.com/fedora-infra/python-fedora.git
    cd python-fedora
    git flow init
    
  3. Create a release branch for all of our work:

    git flow release start $VERSION
    
  4. Download new translations and verify they are valid by compiling them:

    zanata-cli pull
    python releaseutils.py build_catalogs
    # If everything checks out
    git commit -m 'Merge new translations from fedora.zanata.org'
    
  5. Make sure that the NEWS file is accurate (use git log if needed).

  6. Update python-fedora.spec and fedora/release.py with the new version information.:

    # Make edits to python-fedora.spec and release.py
    git commit
    
  7. Make sure the docs are proper and publish them:

    # Build docs and check for errors
    python setup.py build_sphinx
    # pypi
    python setup.py upload_docs
    
  8. Push the release branch to the server:

    # Update files
    git flow release publish $VERSION
    
  9. Go to a temporary directory and checkout a copy of the release:

    cd ..
    git clone https://github.com/fedora-infra/python-fedora.git release
    cd release
    git checkout release/$VERSION
    
  10. Create the tarball in this clean checkout:

    python setup.py sdist
    
  11. copy the dist/python-fedora-VERSION.tar.gz and python-fedora.spec files to where you build Fedora RPMS. Do a test build:

    cp dist/python-fedora-*.tar.gz python-fedora.spec /srv/git/python-fedora/
    pushd /srv/git/python-fedora/
    fedpkg switch-branch master
    make mockbuild
    
  12. Make sure the build completes. Run rpmlint on the results. Install and test the new packages:

    rpmlint *rpm
    sudo rpm -Uvh *noarch.rpm
    [test]
    
  13. When satisfied that the build works, create a fresh tarball and upload to pypi:

    popd   # Back to the release directory
    python setup.py sdist upload --sign
    
  14. copy the same tarball to fedorahosted. The directory to upload to is slightly different for fedorahosted admins vs normal fedorahosted users: Admin:

    scp dist/python-fedora*tar.gz* fedorahosted.org:/srv/web/releases/p/y/python-fedora/
    

    Normal contributor:

    scp dist/python-fedora*tar.gz* fedorahosted.org:python-fedora
    
  15. mark the release as finished in git:

    cd ../python-fedora
    git flow release finish $VERSION
    git push --all
    git push --tags
    
  16. Finish building and pushing packages for Fedora.