forked from fedora-infra/python-fedora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
308 lines (233 loc) · 10.3 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
====================
Python Fedora Module
====================
:Author: Toshio Kuratomi
:Date: 10 April 2013
:Version: 0.3.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.
.. _`Fedora Services`: doc/service.html
.. _TurboGears: http://www.turbogears.org
.. contents::
-------
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 ``bunch``, ``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.
---------------------------
Fedora Accounts Integration
---------------------------
We provide several modules that make connecting to the `Fedora Account
System`_ easier.
.. _`Fedora Account System`: https://fedorahosted.org/fas
General Purpose API
===================
The ``fedora.accounts.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.accounts.fas2.AccountSystem
Here's an example of using the ``AccountSystem``::
from fedora.accounts.fas2 import AccountSystem
from fedora.client import AuthError,
x
# 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
.. _`client documentation`: doc/client.rst
-----------------
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 transifex-client to run these
commands::
yum install babel setuptools transifex-client
Much information about using transifex for translations can be found in the
`transifex user's guide`_. The information in this section is largely from
experimenting with the information in the `transifex client documentation`_
.. _`transifex user's guide`: http://help.transifex.net/user-guide/index.html
.. ~`transifex client documentation`: http://help.transifex.net/user-guide/client/index.html
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
tx push -s
Then commit your changes to source control.
Updating the PO Files
=====================
Transifex.net 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::
tx pull -a
Then commit the changes to source control
Note that if you see a status message from transifex like this::
Pulling new translations for resource python-fedora.python-fedorapot (source: translations/python-fedora.pot)
-> fr: translations/fr.po
it means that transifex has created a brand new po file for you. You need to
add the new file to source control before committing.
Creating a new PO File
======================
The easiest way to create a new po file for a new language is in transifex's
web UI.
* Visit this link:
https://www.transifex.net/projects/p/python-fedora/resource/python-fedorapot/
* Login with a transifex.net username and password
* Scroll down to the add translation button below the statistics on current
translations
* Select a language from the dropdown and hit the translate online button
This will start a translation for your language. In the future you can
continue to use the transifex online translation editor or you can download
the .po file, translate on your computer, and then reupload.
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
-------
0) Commit all features, hotfixes, etc that you want in the release into the
develop branch.
1) Checkout a copy of the repository and setup git flow::
git clone git@github.com:fedora-infra/python-fedora.git
cd python-fedora
git flow init
2) Create a release branch for all of our work
git flow release start $VERSION
3) Download new translations and verify they are valid by compiling them::
tx pull -a
python releaseutils.py build_catalogs
# If everything checks out
git commit -m 'Merge new translations from transifex.net'
4) Make sure that the NEWS file is accurate (use git log if needed).
5) Update python-fedora.spec and fedora/release.py with the new version
information.
# Make edits to python-fedora.spec and release.py
git commit
6) 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
7) Push the release branch to the server::
# Update files
git flow release publish $VERSION
8) Go to a temporary directory and checkout a copy of the release::
cd ..
git clone git@github.com:fedora-infra/python-fedora.git release
cd release
git checkout release/$VERSION
9) Create the tarball in this clean checkout::
python setup.py sdist
10) 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
11) Make sure the build completes. Run rpmlint on the results. Install and
test the new packages::
rpmlint *rpm
sudo rpm -Uvh *noarch.rpm
[test]
12) 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
13) 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
14) mark the release as finished in git::
cd ../python-fedora
git flow release finish $VERSION
git push --all
git push --tags
15) Finish building and pushing packages for Fedora.