Giter VIP home page Giter VIP logo

python-fedora's Introduction

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.

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

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.

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.

  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
    

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

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: [email protected] 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()

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.)

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"

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.

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

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

yum install python-sphinx

Then run this command:

python setup.py build_sphinx

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

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.

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).

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

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.

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.

  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.

python-fedora's People

Contributors

abadger avatar abompard avatar adamwill avatar bkabrda avatar bowlofeggs avatar cverna avatar fabaff avatar girish946 avatar laxathom avatar lbazan avatar lmacken avatar mprahl avatar nbebout avatar nirik avatar puiterwijk avatar pypingou avatar ralphbean avatar rbuj avatar relrod avatar rickyz avatar rodrigc avatar scop avatar sebwoj avatar sgallagher avatar siddharthvipul avatar sontek avatar tflink avatar thekad avatar trishnaguha avatar vivekanand1101 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-fedora's Issues

The Bodhi2Client cannot handle expiring auth tokens

The bodhi client cannot work with expiring sessions. Once its session expires, it will never attempt to get a new session but will instead assume it can use the existing session. Thus, it does not matter if the user types the correct password or not.

This bug is basically the same as fedora-infra/bodhi#1474 except that it needs to also be fixed here for the bodhi-0.9 client.

This is also filed downstream: https://bugzilla.redhat.com/show_bug.cgi?id=1445294

flask-fas-openid tracebacks with flask>0.9

Traceback (most recent call last):
  File "/home/threebean/.virtualenvs/nuancier/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/threebean/.virtualenvs/nuancier/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/home/threebean/.virtualenvs/nuancier/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/threebean/.virtualenvs/nuancier/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/threebean/.virtualenvs/nuancier/lib/python2.7/site-packages/flask/app.py", line 1479, in full_dispatch_request
    response = self.process_response(response)
  File "/home/threebean/.virtualenvs/nuancier/lib/python2.7/site-packages/flask/app.py", line 1693, in process_response
    self.save_session(ctx.session, response)
  File "/home/threebean/.virtualenvs/nuancier/lib/python2.7/site-packages/flask/app.py", line 837, in save_session
    return self.session_interface.save_session(self, session, response)
  File "/home/threebean/.virtualenvs/nuancier/lib/python2.7/site-packages/flask/sessions.py", line 326, in save_session
    val = self.get_signing_serializer(app).dumps(dict(session))
  File "/home/threebean/.virtualenvs/nuancier/lib/python2.7/site-packages/itsdangerous.py", line 537, in dumps
    payload = want_bytes(self.dump_payload(obj))
  File "/home/threebean/.virtualenvs/nuancier/lib/python2.7/site-packages/itsdangerous.py", line 809, in dump_payload
    json = super(URLSafeSerializerMixin, self).dump_payload(obj)
  File "/home/threebean/.virtualenvs/nuancier/lib/python2.7/site-packages/itsdangerous.py", line 522, in dump_payload
    return want_bytes(self.serializer.dumps(obj))
  File "/home/threebean/.virtualenvs/nuancier/lib/python2.7/site-packages/flask/sessions.py", line 85, in dumps
    return json.dumps(_tag(value), separators=(',', ':'))
  File "/home/threebean/.virtualenvs/nuancier/lib/python2.7/site-packages/flask/json.py", line 126, in dumps
    rv = _json.dumps(obj, **kwargs)
  File "/usr/lib64/python2.7/json/__init__.py", line 250, in dumps
    sort_keys=sort_keys, **kw).encode(obj)
  File "/usr/lib64/python2.7/json/encoder.py", line 209, in encode
    chunks = list(chunks)
  File "/usr/lib64/python2.7/json/encoder.py", line 434, in _iterencode
    for chunk in _iterencode_dict(o, _current_indent_level):
  File "/usr/lib64/python2.7/json/encoder.py", line 408, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib64/python2.7/json/encoder.py", line 442, in _iterencode
    o = _default(o)
  File "/home/threebean/.virtualenvs/nuancier/lib/python2.7/site-packages/flask/json.py", line 83, in default
    return _json.JSONEncoder.default(self, o)
  File "/usr/lib64/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <openid.consumer.discover.OpenIDServiceEndpoint object at 0x7ff6240e2450> is not JSON serializable

Double hidden files are evil

I mean specifically ~/.fedora/.fedora_session. When I enter a hidden directory I don't expect (and you don't need to) another secrets hidden from me. Make the .fedora_session file unhidden please.

[RFE] Provide a set of default URL for Fedora apps

This RFE is based on the need to specify an alternative set of default URL for python-fedora based apps.

For example, using an alternative URL for an app (for staging/testing purpose, say "koji hub url" ), this URL would need to be overridden to every single python-fedora based apps and each app would grow an option to override the default URL.

Instead, I would suggest to make python-fedora read a config file describing the whole set of default staging/testing URL when the FEDORA_CLIENT_NAMESPACE=staging environment is set.

That way it would be possible to use any python-fedora enabled apps unmodified.

Retire wiki client?

I just happened to notice that python-fedora has a fairly limited wiki client. It doesn't look to have really been touched since 2009, and it's fairly incomplete. I've been doing some stuff with the wiki lately and I just used mwclient instead:

https://github.com/mwclient/mwclient

which is a much more complete and currently-maintained client, and there are several other choices at https://www.mediawiki.org/wiki/API:Client_code#Python . So I'm not sure there's a lot of point in python-fedora keeping an incomplete and apparently unmaintained one around? I don't see anything else inside python-fedora that really uses it, but I don't know if there are any external users.

traceback from dogencert

@dgonyeo got this traceback when trying to run fedora-packager-setup for the first time.

[derek@localhost ~]$ fedora-packager-setup
Setting up Fedora packager environment
You need a client certificate from the Fedora Account System, lets get one now
FAS Username: dgonyeo
FAS Password: 
Traceback (most recent call last):
  File "/usr/bin/fedora-packager-setup", line 108, in <module>
    main()
  File "/usr/bin/fedora-packager-setup", line 82, in main
    fedora_cert.create_user_cert()
  File "/usr/lib/python2.7/site-packages/fedora_cert/__init__.py", line 96, in create_user_cert
    cert = fas.user_gencert()
  File "/usr/lib/python2.7/site-packages/fedora/client/fas2.py", line 731, in user_gencert
    request = self.send_request('user/dogencert', auth=True)
  File "/usr/lib/python2.7/site-packages/fedora/client/baseclient.py", line 344, in send_request
    auth_params=auth_params, retries=retries)
  File "/usr/lib/python2.7/site-packages/fedora/client/proxyclient.py", line 394, in send_request
    if 'exc' in data:
TypeError: argument of type 'NoneType' is not iterable

Build docs on readthedocs

when you search for 'fedora fas api' https://www.google.pl/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=fedora%20fas%20api

The first hit is this page https://fedorahosted.org/python-fedora/browser/fas/doc/api.rst
The second hit is a deprecated wiki page.

which is totally broken.

We should build the docs on read the docs.

and then adjust those two pages to point there.

(or we could move this repo to pagure and build the docs there and point to them. it doesn't really matter where, just that we have something consistent and up to date)

We should not assume there is a previous session.

Look at line 69-70
cf

File "/usr/lib/python2.6/site-packages/flask_fas_openid.py", line 69, in _handle_openid_request
 return_url = flask.session['FLASK_FAS_OPENID_RETURN_URL']
 File "/usr/lib/python2.6/site-packages/werkzeug/local.py", line 363, in <lambda>
 __getitem__ = lambda x, i: x._get_current_object()[i]
KeyError: 'FLASK_FAS_OPENID_RETURN_URL'

please migrate to the new Fedora translation platform

Hello, the Fedora project migrates its translation platform to Weblate [1].

This tool directly interact with your git repository, and requires us to know:

  • [mandatory] which branch is your development branch?
  • [mandatory] have you merged latest translation from Zanata and locked the project?
  • [info] Weblate will handle updates when pot file changes, don't edit po files for this [2]
  • [optional] what is the license of translation? (please use a code from https://spdx.org/licenses/)
  • [optional] do you have any announcement/warning you would like to display to the translators? (it will be displayed in Weblate)
  • [optional] do you need us to activate any specific checks? (this is a setting per component [3])
  • [optional] do you need us to automatically detect new translation files? (typical usecase: website translation with one translation file per page)

Please note:

  • For github hosted projects, Weblate open pull request. For other project, you'll have to add a key to allow commits.
  • In Weblate's vocable, one project is a group of component. Each component is a translation file. You can have many projects or many components or both.
  • You can change your mind over time, just reach [email protected]

[1] https://communityblog.fedoraproject.org/fedora-localization-platform-migrates-to-weblate/
[2] https://docs.weblate.org/en/latest/admin/continuous.html#avoiding-merge-conflicts
[3] https://docs.weblate.org/en/latest/user/checks.html#translation-checks

Error encountered "no module named lockfile"

While setting up the environment encountered an error "no module named lockfile".
Since lockfile is a dependency, it should made present in requirements.txt to provide easy flow.

people_by_key only partly working

while FASCLIENT.people_by_key('username', 'pingou') works, neither FASCLIENT.people_by_key('id', 101433) nor FASCLIENT.people_by_key('email', 'pingou@...') do

We should fix this :)

please expose rhbz_email in flask_fas_openid

In BlockerBugs App we use flask_fas_openid.py for users to log into FAS. We'd need to receive rhbz_email value from the user profile, but currently flask_fas_openid doesn't forward that. Would it be possible to extend it so that it sends us also rhbz_email value?

PS: I know there's fasjson, and we could use it, but it's another service to integrate and depend on, while receiving the value through flask_fas_openid would be much simpler for us. That's why I'm asking if you'd would be willing to include it in there. Thanks!

Stop marking exception messages for translation

Talked with Shaiton and decided marking exception messages for translation is not a great idea:

  1. When you get an exception, you'd like to be able to google for it. translations hinder that.
  2. Translators often don't know what the exception messages mean so it's difficult for them to translate them accurately.
  3. Translations of exception messages aren't very helpful to the end user either.

We will have to be careful about how the exception messages leak out into error messages that the end user does see (and might possibly be able to correct/workaround) though.

We'll need to remove the () and b() from exception messages.

Add run-time environment to useragent

We should be aware/able to check where clients are communicating from (when dealing with
logs and such), by adding the run-time environment to useragent's string (such as, Development, Production or Staging)

Python 3 support

Hi,

is Python3 support planned? We would like to depend on the API but we want to support both Python3/2.

'NoneType' object has no attribute 'teams' exception in production

Original report: FedOAuth/FedOAuth#26

Running python-fedora-0.3.32.90-1.el6

[Tue Jun 11 19:38:08 2013] [error] Error attempting to use stored discovery information: <openid.consumer.consumer.TypeURIMismatch: Required type http://specs.openid.net/auth/2.0/signon not found in ['http://specs.openid.net/auth/2.
0/server', 'http://openid.net/server/1.0', 'http://fedoraproject.org/specs/open_id/cla', 'http://ns.launchpad.net/2007/openid-teams', 'http://openid.net/extensions/sreg/1.1', 'http://openid.net/sreg/1.0', 'http://schemas.openid.net/
pape/policies/2007/06/phishing-resistant', 'http://schemas.openid.net/pape/policies/2007/06/multi-factor', 'http://schemas.openid.net/pape/policies/2007/06/multi-factor-physical'] for endpoint <openid.consumer.discover.OpenIDService
Endpoint server_url='https://id.fedoraproject.org' claimed_id=None local_id=None canonicalID=None used_yadis=True >>
[Tue Jun 11 19:38:08 2013] [error] Attempting discovery to verify endpoint
[Tue Jun 11 19:38:08 2013] [error] Performing discovery on http://rjt.id.fedoraproject.org/
[Tue Jun 11 19:38:08 2013] [error] Received id_res response from https://id.fedoraproject.org using association {HMAC-SHA1}{…}
[Tue Jun 11 19:38:08 2013] [error] Using OpenID check_authentication
[Tue Jun 11 19:38:08 2013] [error] assoc_handle
[Tue Jun 11 19:38:08 2013] [error] cla.signed_cla
[Tue Jun 11 19:38:08 2013] [error] claimed_id
[Tue Jun 11 19:38:08 2013] [error] identity
[Tue Jun 11 19:38:08 2013] [error] mode
[Tue Jun 11 19:38:08 2013] [error] ns
[Tue Jun 11 19:38:08 2013] [error] ns.cla
[Tue Jun 11 19:38:08 2013] [error] ns.lp
[Tue Jun 11 19:38:08 2013] [error] ns.pape
[Tue Jun 11 19:38:08 2013] [error] ns.sreg
[Tue Jun 11 19:38:08 2013] [error] op_endpoint
[Tue Jun 11 19:38:08 2013] [error] pape.auth_level.nist
[Tue Jun 11 19:38:08 2013] [error] pape.auth_level.ns.nist
[Tue Jun 11 19:38:08 2013] [error] pape.auth_policies
[Tue Jun 11 19:38:08 2013] [error] pape.auth_time
[Tue Jun 11 19:38:08 2013] [error] response_nonce
[Tue Jun 11 19:38:08 2013] [error] return_to
[Tue Jun 11 19:38:08 2013] [error] signed
[Tue Jun 11 19:38:08 2013] [error] sreg.email
[Tue Jun 11 19:38:08 2013] [error] sreg.fullname
[Tue Jun 11 19:38:08 2013] [error] sreg.nickname
[Tue Jun 11 19:38:08 2013] [error] sreg.timezone
[Tue Jun 11 19:38:09 2013] [error] ERROR:fedoratagger:Exception on /_flask_fas_openid_handler/ [GET]
[Tue Jun 11 19:38:09 2013] [error] Traceback (most recent call last):
[Tue Jun 11 19:38:09 2013] [error]   File "/usr/lib/python2.6/site-packages/flask/app.py", line 1687, in wsgi_app
[Tue Jun 11 19:38:09 2013] [error]     response = self.full_dispatch_request()
[Tue Jun 11 19:38:09 2013] [error]   File "/usr/lib/python2.6/site-packages/flask/app.py", line 1360, in full_dispatch_request
[Tue Jun 11 19:38:09 2013] [error]     rv = self.handle_user_exception(e)
[Tue Jun 11 19:38:09 2013] [error]   File "/usr/lib/python2.6/site-packages/flask/app.py", line 1358, in full_dispatch_request
[Tue Jun 11 19:38:09 2013] [error]     rv = self.dispatch_request()
[Tue Jun 11 19:38:09 2013] [error]   File "/usr/lib/python2.6/site-packages/flask/app.py", line 1344, in dispatch_request
[Tue Jun 11 19:38:09 2013] [error]     return self.view_functions[rule.endpoint](**req.view_args)
[Tue Jun 11 19:38:09 2013] [error]   File "/usr/lib/python2.6/site-packages/flask_fas_openid.py", line 64, in flask_fas_openid_handler
[Tue Jun 11 19:38:09 2013] [error]     return self._handle_openid_request()
[Tue Jun 11 19:38:09 2013] [error]   File "/usr/lib/python2.6/site-packages/flask_fas_openid.py", line 94, in _handle_openid_request
[Tue Jun 11 19:38:09 2013] [error]     user['groups'] = teams_resp.teams   # The groups do not contain the cla_ groups
[Tue Jun 11 19:38:09 2013] [error] AttributeError: 'NoneType' object has no attribute 'teams

traceback from fedora-tagger

When trying to run fedora-tagger on in a virtualenv on F19 (with python-fedora installed from a git checkout of the develop branch), I get the following:

Traceback (most recent call last):
  File "runserver.py", line 7, in <module>
    from fedoratagger import APP
  File "/home/threebean/devel/fedora-tagger/fedoratagger/__init__.py", line 31, in <module>
    from flask_fas_openid import FAS
ImportError: No module named flask_fas_openid

Recommendations?

FAS authn fails in the current develop branch

>>> import getpass
>>> import fedora.client
>>> fedora.client.__file__
'fedora/client/__init__.pyc'
>>> # its checked out from the develop branch of git
>>> fas = fedora.client.AccountSystem(username="ralph", password=getpass.getpass())
Password: 
>>> fas.group_members('packager')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "fedora/client/fas2.py", line 369, in group_members
    urllib.quote(groupname), auth=True)
  File "fedora/client/baseclient.py", line 361, in send_request
    auth_params=auth_params, retries=retries, timeout=timeout)
  File "fedora/client/proxyclient.py", line 459, in send_request
    raise AuthError('Unable to log into server.  Invalid'
fedora.client.AuthError: Unable to log into server.  Invalid authentication tokens.  Send new username and password

I checked and the above code currently works in the latest release available to F19.

This may or may not be related to the code introduced in #20.

`pydoc fedora.accounts.fas2.AccountSystem` says no Python documentation found

The doc mentions the command, but it doesn't seem to work:

[asinha@ankur  ~]$ rpm -q python-fedora
python-fedora-0.8.0-2.fc25.noarch
[asinha@ankur  ~]$ pydoc fedora.accounts.fas2.AccountSystem
no Python documentation found for 'fedora.accounts.fas2.AccountSystem'

I get the same error on py3 too:

(housekeeping-virtualenv) [asinha@ankur  scripts(master %=)]$ which python
~/Documents/02_Code/00_repos/01_others/fedora-freemedia/prod/Housekeeping/housekeeping-virtualenv/bin/python
(housekeeping-virtualenv) [asinha@ankur  scripts(master %=)]$ python --version
Python 3.5.2
(housekeeping-virtualenv) [asinha@ankur  scripts(master %=)]$ pip install python-fedora
Requirement already satisfied: python-fedora in /home/asinha/Documents/02_Code/00_repos/01_others/fedora-freemedia/prod/Housekeeping/housekeeping-virtualenv/lib/python3.5/site-packages
Requirement already satisfied: munch in /home/asinha/Documents/02_Code/00_repos/01_others/fedora-freemedia/prod/Housekeeping/housekeeping-virtualenv/lib/python3.5/site-packages (from python-fedora)
Requirement already satisfied: six>=1.4.0 in /home/asinha/Documents/02_Code/00_repos/01_others/fedora-freemedia/prod/Housekeeping/housekeeping-virtualenv/lib/python3.5/site-packages (from python-fedora)
Requirement already satisfied: requests in /home/asinha/Documents/02_Code/00_repos/01_others/fedora-freemedia/prod/Housekeeping/housekeeping-virtualenv/lib/python3.5/site-packages (from python-fedora)
Requirement already satisfied: lockfile in /home/asinha/Documents/02_Code/00_repos/01_others/fedora-freemedia/prod/Housekeeping/housekeeping-virtualenv/lib/python3.5/site-packages (from python-fedora)
Requirement already satisfied: beautifulsoup4 in /home/asinha/Documents/02_Code/00_repos/01_others/fedora-freemedia/prod/Housekeeping/housekeeping-virtualenv/lib/python3.5/site-packages (from python-fedora)
Requirement already satisfied: urllib3 in /home/asinha/Documents/02_Code/00_repos/01_others/fedora-freemedia/prod/Housekeeping/housekeeping-virtualenv/lib/python3.5/site-packages (from python-fedora)
Requirement already satisfied: kitchen in /home/asinha/Documents/02_Code/00_repos/01_others/fedora-freemedia/prod/Housekeeping/housekeeping-virtualenv/lib/python3.5/site-packages (from python-fedora)
(housekeeping-virtualenv) [asinha@ankur  scripts(master %=)]$ pydoc fedora.accounts.fas2.AccountSystem
No Python documentation found for 'fedora.accounts.fas2.AccountSystem'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.

make openid login API friendly

Afaics, if a web app uses the flask openid plugin to allow logging in via openid (see pkgdb2), then the client needs to parse HTML to identify that a login is required and to perform a login. it would be nicer to be able to return proper JSON to keep the API clean.

Status of flask-fas-openid?

I'm setting up the new fedora-tagger on packages01.stg and am running into the following python-fedora related traceback:

mod_wsgi (pid=19377): Exception occurred processing WSGI script '/usr/share/fedoratagger/fedoratagger.wsgi'.
Traceback (most recent call last):
  File "/usr/share/fedoratagger/fedoratagger.wsgi", line 8, in <module>
    import fedoratagger
  File "/usr/lib/python2.6/site-packages/fedoratagger/__init__.py", line 31, in <module>
    from flask_fas_openid import FAS
ImportError: No module named flask_fas_openid

It's not so much a bug. I just want to start a discussion here about what the status of that module is. Pushing fedora-tagger forwards isn't necessarily a priority and it can definitely wait. At the time I ran into this, the relevant persons seemed to be either very busy or offline, so I decided to file this instead of asking in channel.

Support setuptools 18.0.0.1

Traceback on install:

building path(s) ‘/nix/store/f06j9bflm7sylhcmsfi39mbr230lrypn-python2.7-python-fedora-0.5.5’
unpacking sources
unpacking source archive /nix/store/hpyfnh9qy72mf8svn6ig3h8iyy842x21-python-fedora-0.5.5.tar.gz
source root is python-fedora-0.5.5
patching sources
configuring
building
Traceback (most recent call last):
  File "setup.py", line 19, in <module>
    from setuptools import find_packages, setup
  File "/nix/store/fpjrbn8jr6nvfijz32vy147mpar7qc72-python2.7-setuptools-18.0.1/lib/python2.7/site-packages/setuptools-18.0.1-py2.7.egg/setuptools/__init__.py", line 11, in <module>
    from setuptools.extension import Extension
  File "/nix/store/fpjrbn8jr6nvfijz32vy147mpar7qc72-python2.7-setuptools-18.0.1/lib/python2.7/site-packages/setuptools-18.0.1-py2.7.egg/setuptools/extension.py", line 8, in <module>
    from .dist import _get_unpatched
  File "/nix/store/fpjrbn8jr6nvfijz32vy147mpar7qc72-python2.7-setuptools-18.0.1/lib/python2.7/site-packages/setuptools-18.0.1-py2.7.egg/setuptools/dist.py", line 19, in <module>
    import pkg_resources
  File "/nix/store/fpjrbn8jr6nvfijz32vy147mpar7qc72-python2.7-setuptools-18.0.1/lib/python2.7/site-packages/setuptools-18.0.1-py2.7.egg/pkg_resources/__init__.py", line 90, in <module>
    packaging = pkg_resources._vendor.packaging
AttributeError: 'module' object has no attribute '_vendor'
builder for ‘/nix/store/c0ns8crsv0amkjnwav7lz33ry1srizkl-python2.7-python-fedora-0.5.5.drv’ failed with exit code 1
error: build of ‘/nix/store/c0ns8crsv0amkjnwav7lz33ry1srizkl-python2.7-python-fedora-0.5.5.drv’ failed

Bodhi2Client doesn't support retries

Bodhi1Client support retries: it tries several times (user specified) and after last unsuccessful try it raises an exception. This unfortunately doesn't work when Bodhi2Client is used.

When you try to run code bellow, you can see that when Bodhi1Client is used it actually tries 10 times before raising. Bodhi2Client fails that respond cannot be parsed as JSON.

from fedora.client.bodhi import Bodhi1Client, Bodhi2Client
import sys
import logging


logging.basicConfig()
logging.getLogger().setLevel(level=logging.DEBUG)

if int(sys.argv[1]) == 1:
    client = Bodhi1Client(base_url='http://httpstat.us/', retries=10, debug=True)
    client.send_request('500')
else:
    client = Bodhi2Client(base_url='http://httpstat.us/', retries=10, debug=True)
    client.send_request('500')

I check the code and it seems that Bodhi2Client's parent class OpenIdBaseClient overrides method send_request from its parent class OpenIdProxyClient, in which the retry code is present.

AuthError not raised on 403 errors

I noticed today that the fedora.client.openidbaseclient.requires_login decorator does not handle 403 return codes though it looks like it's intended to. The issue is that the output variable (a requests.models.Response) does two weird things:

  1. It casts to False:
ipdb> bool(output)
False
  1. "anding" a Response with a bool does not return a bool:
ipdb> print (output and output.status_code)                                                                           
<Response [403]>

We probably want to do this instead:

elif hasattr(output, 'status_code') and output.status_code == 403:

fedpkg update fails with traceback

% fedpkg update
/usr/lib/python2.7/site-packages/fedpkg/cli.py:169: DeprecationWarning: Commands._hash_file is deprecated and will be removed eventually.
    Please use Commands.lookasidecache.hash_file instead.
  hash = self.cmd._hash_file('bodhi.template', 'sha1')
Creating a new update for  ansible-1.9.4-1.fc23 
Password: 
Traceback (most recent call last):
  File "/usr/bin/bodhi", line 537, in <module>
    main()
  File "/usr/bin/bodhi", line 225, in main
    data = bodhi.save(**update_args)
  File "/usr/lib/python2.7/site-packages/fedora/client/bodhi.py", line 80, in wrapper
    result = method(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/fedora/client/bodhi.py", line 155, in save
    kwargs['csrf_token'] = self.csrf()
  File "/usr/lib/python2.7/site-packages/fedora/client/bodhi.py", line 80, in wrapper
    result = method(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/fedora/client/bodhi.py", line 308, in csrf
    'csrf', verb='GET', auth=True)['csrf_token']
KeyError: 'csrf_token'
Could not generate update request: Command 'bodhi --new --release f23 --file bodhi.template ansible-1.9.4-1.fc23 --username kevin' returned non-zero exit status 1

python-fedora-0.6.0-1.fc24.noarch

python3 incompatibility

Under python3

  File "./bz-sponsors.py", line 21, in <module>
    sponsors = client.group_members("packager")
  File "/usr/lib/python3.4/site-packages/fedora/client/fas2.py", line 401, in group_members
    urllib.quote(groupname), auth=True)
AttributeError: 'module' object has no attribute 'quote'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.