asfpy 0.53__tar.gz → 0.55__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
asfpy-0.55/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
asfpy-0.55/PKG-INFO ADDED
@@ -0,0 +1,115 @@
1
+ Metadata-Version: 2.1
2
+ Name: asfpy
3
+ Version: 0.55
4
+ Summary: ASF Common Python Methods
5
+ Author: ASF Infrastructure
6
+ Author-email: users@infra.apache.org
7
+ Requires-Python: >=3.9.2,<4
8
+ Classifier: License :: OSI Approved :: Apache Software License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Provides-Extra: aioldap
14
+ Provides-Extra: ldap
15
+ Requires-Dist: aiohttp (>=3.10.5,<4.0.0)
16
+ Requires-Dist: bonsai (>=1.5.3,<2.0.0) ; extra == "aioldap"
17
+ Requires-Dist: cffi (>=1.17.1,<2.0.0)
18
+ Requires-Dist: cryptography (>=44.0.2,<45.0.0)
19
+ Requires-Dist: easydict (>=1.13,<2.0)
20
+ Requires-Dist: ezt (>=1.1,<2.0)
21
+ Requires-Dist: python-ldap (>=3.4.4,<4.0.0) ; extra == "ldap"
22
+ Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
23
+ Requires-Dist: requests (>=2.32.3,<3.0.0)
24
+ Requires-Dist: watchfiles (>=1.0.0,<2.0.0)
25
+ Description-Content-Type: text/markdown
26
+
27
+ # asfpy - ASF Infrastructure Common Library for Python functions
28
+ <a href="https://pypi.org/project/asfpy"><img alt="PyPI" src="https://img.shields.io/pypi/v/asfpy.svg?color=blue&maxAge=600" /></a>
29
+ <a href="https://pypi.org/project/asfpy"><img alt="PyPI - Python Versions" src="https://img.shields.io/pypi/pyversions/asfpy.svg?maxAge=600" /></a>
30
+ <a href="https://github.com/apache/infrastructure-asfpy/actions/workflows/unittest.yml?query=branch%3Amain"><img alt="Unit Tests" src="https://github.com/apache/infrastructure-asfpy/actions/workflows/unittest.yml/badge.svg?branch=main" /></a>
31
+ <a href="https://github.com/apache/infrastructure-asfpy/blob/main/LICENSE"><img alt="Apache License" src="https://img.shields.io/github/license/apache/infrastructure-asfpy" /></a>
32
+
33
+ This Python library contains features commonly used at the Apache Software Foundation.
34
+
35
+ (For asfpy 0.37 and below, look at our old [Subversion repository](https://svn.apache.org/repos/infra/infrastructure/trunk/projects/asfpy/))
36
+
37
+
38
+ ## Building asfpy package
39
+
40
+ Prerequisites:
41
+
42
+ - `poetry`: install e.g. with pipx `pipx install poetry`
43
+
44
+ Building the package:
45
+
46
+ ```console
47
+ $ poetry build
48
+ ```
49
+
50
+ Running the tests:
51
+
52
+ ```console
53
+ $ poetry run pytest
54
+ ```
55
+
56
+ ## Installation
57
+
58
+ Create and activate a virtual environment and then install `asfpy` using [pip](https://pip.pypa.io):
59
+
60
+ ```console
61
+ $ pip install "asfpy"
62
+ ```
63
+
64
+ Note: Adding `[ldap]` or `[aioldap]` extras will install optional dependencies for LDAP support that will
65
+ require additional [system dependencies](https://github.com/noirello/bonsai?tab=readme-ov-file#requirements-for-building):
66
+
67
+ ```console
68
+ $ pip install "asfpy[aioldap]"
69
+ ```
70
+
71
+ ## Publishing a new asfpy package
72
+
73
+ Create an account on https://pypi.org/, then add a token with an "all projects" scope.
74
+
75
+ Configure your credentials for the `pypi` repository:
76
+
77
+ ```console
78
+ $ poetry config pypi-token.pypi <your-token>
79
+ ```
80
+
81
+ Finally publish to `pypi.org`:
82
+
83
+ ```console
84
+ $ make publish
85
+ ```
86
+
87
+ See [this guide](https://realpython.com/pypi-publish-python-package/#publish-your-package-to-pypi) for more details on working with PyPi.
88
+
89
+ Please also create a tag for the release.
90
+
91
+ ### Publishing to test.pypi.org
92
+
93
+ Create an account on https://test.pypi.org/, then add a token with an
94
+ "all projects" scope.
95
+
96
+ Add a `testpypi` repository to your poetry config:
97
+
98
+ ```console
99
+ $ poetry config repositories.testpypi https://test.pypi.org/legacy/
100
+ ```
101
+
102
+ Configure your credentials for the `testpypi` repository:
103
+
104
+ ```console
105
+ $ poetry config pypi-token.testpypi <your-token>
106
+ ```
107
+
108
+ Finally publish to `test.pypi.org`:
109
+
110
+ ```console
111
+ $ make publish-test
112
+ ```
113
+
114
+ The package should upload to the test.pypi.org service.
115
+
asfpy-0.55/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # asfpy - ASF Infrastructure Common Library for Python functions
2
+ <a href="https://pypi.org/project/asfpy"><img alt="PyPI" src="https://img.shields.io/pypi/v/asfpy.svg?color=blue&maxAge=600" /></a>
3
+ <a href="https://pypi.org/project/asfpy"><img alt="PyPI - Python Versions" src="https://img.shields.io/pypi/pyversions/asfpy.svg?maxAge=600" /></a>
4
+ <a href="https://github.com/apache/infrastructure-asfpy/actions/workflows/unittest.yml?query=branch%3Amain"><img alt="Unit Tests" src="https://github.com/apache/infrastructure-asfpy/actions/workflows/unittest.yml/badge.svg?branch=main" /></a>
5
+ <a href="https://github.com/apache/infrastructure-asfpy/blob/main/LICENSE"><img alt="Apache License" src="https://img.shields.io/github/license/apache/infrastructure-asfpy" /></a>
6
+
7
+ This Python library contains features commonly used at the Apache Software Foundation.
8
+
9
+ (For asfpy 0.37 and below, look at our old [Subversion repository](https://svn.apache.org/repos/infra/infrastructure/trunk/projects/asfpy/))
10
+
11
+
12
+ ## Building asfpy package
13
+
14
+ Prerequisites:
15
+
16
+ - `poetry`: install e.g. with pipx `pipx install poetry`
17
+
18
+ Building the package:
19
+
20
+ ```console
21
+ $ poetry build
22
+ ```
23
+
24
+ Running the tests:
25
+
26
+ ```console
27
+ $ poetry run pytest
28
+ ```
29
+
30
+ ## Installation
31
+
32
+ Create and activate a virtual environment and then install `asfpy` using [pip](https://pip.pypa.io):
33
+
34
+ ```console
35
+ $ pip install "asfpy"
36
+ ```
37
+
38
+ Note: Adding `[ldap]` or `[aioldap]` extras will install optional dependencies for LDAP support that will
39
+ require additional [system dependencies](https://github.com/noirello/bonsai?tab=readme-ov-file#requirements-for-building):
40
+
41
+ ```console
42
+ $ pip install "asfpy[aioldap]"
43
+ ```
44
+
45
+ ## Publishing a new asfpy package
46
+
47
+ Create an account on https://pypi.org/, then add a token with an "all projects" scope.
48
+
49
+ Configure your credentials for the `pypi` repository:
50
+
51
+ ```console
52
+ $ poetry config pypi-token.pypi <your-token>
53
+ ```
54
+
55
+ Finally publish to `pypi.org`:
56
+
57
+ ```console
58
+ $ make publish
59
+ ```
60
+
61
+ See [this guide](https://realpython.com/pypi-publish-python-package/#publish-your-package-to-pypi) for more details on working with PyPi.
62
+
63
+ Please also create a tag for the release.
64
+
65
+ ### Publishing to test.pypi.org
66
+
67
+ Create an account on https://test.pypi.org/, then add a token with an
68
+ "all projects" scope.
69
+
70
+ Add a `testpypi` repository to your poetry config:
71
+
72
+ ```console
73
+ $ poetry config repositories.testpypi https://test.pypi.org/legacy/
74
+ ```
75
+
76
+ Configure your credentials for the `testpypi` repository:
77
+
78
+ ```console
79
+ $ poetry config pypi-token.testpypi <your-token>
80
+ ```
81
+
82
+ Finally publish to `test.pypi.org`:
83
+
84
+ ```console
85
+ $ make publish-test
86
+ ```
87
+
88
+ The package should upload to the test.pypi.org service.
@@ -66,7 +66,7 @@ class TemplateWatcher:
66
66
  return t
67
67
 
68
68
  @staticmethod
69
- def watch_filter(change: watchfiles.Change, path: str) -> bool:
69
+ def watch_filter(change: watchfiles.Change, _: str) -> bool:
70
70
  return change in {watchfiles.Change.added, watchfiles.Change.modified}
71
71
 
72
72
  async def watch_forever(self):
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "asfpy"
3
- version = "0.53"
3
+ version = "0.55"
4
4
  description='ASF Common Python Methods'
5
5
  authors = ["ASF Infrastructure <users@infra.apache.org>"]
6
6
  readme = "README.md"
@@ -10,19 +10,18 @@ classifiers = [
10
10
  ]
11
11
 
12
12
  [tool.poetry.dependencies]
13
- python = ">=3.9,<4"
13
+ python = ">=3.9.2,<4"
14
14
  aiohttp = "^3.10.5"
15
- bonsai = "^1.5.3"
15
+ bonsai = { version = "^1.5.3", optional = true }
16
16
  ezt = "^1.1"
17
- python-ldap = "^3.4.4"
17
+ python-ldap = { version = "^3.4.4", optional = true }
18
18
  requests = "^2.32.3"
19
19
  easydict = "^1.13"
20
20
  pyyaml = "^6.0.2"
21
- cryptography = "^43.0.1"
21
+ cryptography = "^44.0.2"
22
22
  cffi = "^1.17.1"
23
23
  watchfiles = "^1.0.0"
24
24
 
25
-
26
25
  [build-system]
27
26
  requires = ["poetry-core"]
28
27
  build-backend = "poetry.core.masonry.api"
@@ -31,14 +30,10 @@ build-backend = "poetry.core.masonry.api"
31
30
  pytest = "*"
32
31
  pylint = "*"
33
32
 
34
- [tool.poetry.group.ldap]
35
- optional = true
36
-
37
- [tool.poetry.group.ldap.dependencies]
38
- python-ldap = "*"
39
-
40
- [tool.poetry.group.aioldap]
41
- optional = true
33
+ [tool.poetry.extras]
34
+ ldap = ["python-ldap"]
35
+ aioldap = ["bonsai"]
42
36
 
43
- [tool.poetry.group.aioldap.dependencies]
44
- bonsai = "*"
37
+ [tool.pytest.ini_options]
38
+ testpaths = ["test"]
39
+ pythonpath = ["asfpy"]
asfpy-0.53/PKG-INFO DELETED
@@ -1,72 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: asfpy
3
- Version: 0.53
4
- Summary: ASF Common Python Methods
5
- Author: ASF Infrastructure
6
- Author-email: users@infra.apache.org
7
- Requires-Python: >=3.9,<4
8
- Classifier: License :: OSI Approved :: Apache Software License
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Programming Language :: Python :: 3.9
11
- Classifier: Programming Language :: Python :: 3.10
12
- Classifier: Programming Language :: Python :: 3.11
13
- Classifier: Programming Language :: Python :: 3.12
14
- Requires-Dist: aiohttp (>=3.10.5,<4.0.0)
15
- Requires-Dist: bonsai (>=1.5.3,<2.0.0)
16
- Requires-Dist: cffi (>=1.17.1,<2.0.0)
17
- Requires-Dist: cryptography (>=43.0.1,<44.0.0)
18
- Requires-Dist: easydict (>=1.13,<2.0)
19
- Requires-Dist: ezt (>=1.1,<2.0)
20
- Requires-Dist: python-ldap (>=3.4.4,<4.0.0)
21
- Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
22
- Requires-Dist: requests (>=2.32.3,<3.0.0)
23
- Requires-Dist: watchfiles (>=1.0.0,<2.0.0)
24
- Description-Content-Type: text/markdown
25
-
26
- # asfpy - ASF Infrastructure Common Library for Python functions
27
-
28
- This Python library contains features commonly used at the Apache Software Foundation.
29
-
30
- (For asfpy 0.37 and below, look at our old [Subversion repository](https://svn.apache.org/repos/infra/infrastructure/trunk/projects/asfpy/))
31
-
32
-
33
- ## Building asfpy package
34
-
35
- Preparation
36
-
37
- * `apt install python3.10-venv`
38
- * `pip3 install build twine`
39
-
40
- Bump the version number in `setup.py` and run:
41
- `python3 -m build`
42
-
43
-
44
- ## Publishing a new asfpy package
45
-
46
- After building the asfpy package, run the following command, where $version is the new version to publish:
47
-
48
- `python3 -m twine upload dist/asfpy-$version*` (for instance `dist/asfpy-0.38*`)
49
-
50
- The above command will upload the `.whl` and the `.tar.gz` (the glob-asterisk is important!)
51
-
52
- See [this guide](https://realpython.com/pypi-publish-python-package/#publish-your-package-to-pypi) for more details on working with PyPi.
53
-
54
- Please also create a tag for the release.
55
-
56
- ### for testing
57
-
58
- Create an account on https://test.pypi.org/, then add a token with an
59
- "all projects" scope. Place that into your `.pypirc` like so:
60
-
61
- ```
62
- [testpypi]
63
- repository = https://test.pypi.org/legacy/
64
- username = __token__
65
- password = pypi-tokenstringgoeshere
66
- ```
67
-
68
- Then you can test an upload with:
69
- `python3 -m twine upload -r testpypi dist/asf-py$version*`
70
-
71
- The package should upload to the test.pypi.org service.
72
-
asfpy-0.53/README.md DELETED
@@ -1,46 +0,0 @@
1
- # asfpy - ASF Infrastructure Common Library for Python functions
2
-
3
- This Python library contains features commonly used at the Apache Software Foundation.
4
-
5
- (For asfpy 0.37 and below, look at our old [Subversion repository](https://svn.apache.org/repos/infra/infrastructure/trunk/projects/asfpy/))
6
-
7
-
8
- ## Building asfpy package
9
-
10
- Preparation
11
-
12
- * `apt install python3.10-venv`
13
- * `pip3 install build twine`
14
-
15
- Bump the version number in `setup.py` and run:
16
- `python3 -m build`
17
-
18
-
19
- ## Publishing a new asfpy package
20
-
21
- After building the asfpy package, run the following command, where $version is the new version to publish:
22
-
23
- `python3 -m twine upload dist/asfpy-$version*` (for instance `dist/asfpy-0.38*`)
24
-
25
- The above command will upload the `.whl` and the `.tar.gz` (the glob-asterisk is important!)
26
-
27
- See [this guide](https://realpython.com/pypi-publish-python-package/#publish-your-package-to-pypi) for more details on working with PyPi.
28
-
29
- Please also create a tag for the release.
30
-
31
- ### for testing
32
-
33
- Create an account on https://test.pypi.org/, then add a token with an
34
- "all projects" scope. Place that into your `.pypirc` like so:
35
-
36
- ```
37
- [testpypi]
38
- repository = https://test.pypi.org/legacy/
39
- username = __token__
40
- password = pypi-tokenstringgoeshere
41
- ```
42
-
43
- Then you can test an upload with:
44
- `python3 -m twine upload -r testpypi dist/asf-py$version*`
45
-
46
- The package should upload to the test.pypi.org service.
asfpy-0.53/asfpy/NOTES DELETED
@@ -1,129 +0,0 @@
1
- host = "mail-relay.apache.org",
2
- recipient = email,
3
- subject = "Welcome to the Apache Software Foundation!",
4
- sender = '<root@apache.org>',
5
- message = messageBody,
6
-
7
- host = "mail-relay.apache.org",
8
- recipient = ["private@"+project+".apache.org","root@apache.org"],
9
- subject = "[NOTICE] Account created: "+fullName+" ("+uid+")",
10
- sender = '<root@apache.org>',
11
- message = messageBody,
12
-
13
- host = "mail-relay.apache.org",
14
- recipient = 'root@apache.org',
15
- subject = "[NOTICE] Account created: "+fullName+" ("+uid+")",
16
- sender = '<root@apache.org>',
17
- message = messageBody,
18
-
19
- host="mail-relay.apache.org",
20
- recipient=recip,
21
- subject=subj,
22
- sender='<root@apache.org>',
23
- message=messageBody,
24
-
25
- asfyaml.py:
26
- asfpy.messaging.mail(
27
- sender='GitBox <gitbox@apache.org>',
28
- recipients=['private@%s.apache.org' % pname],
29
- subject=subject,
30
- message=message)
31
-
32
- download-integrity-checker:
33
- sender="ASF Infrastructure <root@apache.org>",
34
- subject=f"Verification of download artifacts on dist.apache.org FAILED for {project}!",
35
- recipients=recipients,
36
- message=EMAIL_TEMPLATE.format(**locals())
37
-
38
- kif.py:
39
- asfpy.messaging.mail(sender=ecfg['from'], recipient=ecfg['rcpt'], subject=subject, message=msg)
40
-
41
- boxer:
42
- asfpy.messaging.mail(
43
- sender="GitBox <gitbox@apache.org>",
44
- recipients=[NEW_REPO_NOTIFY, f"private@{pmc}.apache.org"],
45
- subject=f"New GitBox/GitHub repository set up: {reponame}",
46
- message=NEW_REPO_NOTIFY_MSG % locals()
47
- )
48
-
49
- gitbox_syncer/github_sync.py
50
- asfpy.messaging.mail(
51
- recipient = '<team@infra.apache.org>',
52
- subject = "gitbox repository %s: push from unknown github user!" % reponame,
53
- sender = '<gitbox@apache.org>',
54
- message = tmpl_unknown_user % locals(),
55
- )
56
-
57
- sscommon.py:
58
- asfpy.messaging.mail(
59
- sender = sender,
60
- recipients = receivers,
61
- subject = subject,
62
- message = msg
63
- )
64
-
65
-
66
- https://github.com/apache/infrastructure-github-event-notifier/blob/e036b4728fa5d3b69794c268601034eabe95f9d5/notifier.py
67
- asfpy.messaging.mail(
68
- sender="GitBox <git@apache.org>",
69
- recipient=recipient,
70
- subject=real_subject,
71
- message=real_text,
72
- messageid=msgid,
73
- headers=msg_headers,
74
- )
75
-
76
- https://github.com/apache/infrastructure-p6/blob/bbe6148c2d3a6efff50ccfe4845aa65c110bf84a/modules/gitbox/files/asfgit/hooks/post-receive.d/03-check-rel.py
77
- asfpy.messaging.mail(
78
- sender="<gitbox@apache.org>",
79
- subject = subject,
80
- recipient = "<notifications@infra.apache.org>",
81
- message=msg
82
- )
83
-
84
- https://github.com/apache/infrastructure-github-discussions-notifier/blob/1e03320894298135a4e3f9f3518de7a4abb712a4/ghd-notifier.py
85
- asfpy.messaging.mail(
86
- sender="GitBox <git@apache.org>", recipient=recipient, subject=subject, message=text, messageid=msgid, headers=msg_headers
87
- )
88
-
89
- https://github.com/apache/infrastructure-gha-notifier/blob/43c7748f697b85d345bb63393da255fddf363a4c/ghactions.py
90
- asfpy.messaging.mail(
91
- sender="GitBox <git@apache.org>", recipient=recipient, subject=subject, message=text
92
- )
93
-
94
- https://github.com/apache/infrastructure-github-code-syncer/blob/614826674907e265c77f42c9b259d7f786a1dd30/payloadparser.py
95
- asfpy.messaging.mail(
96
- recipient="<private@infra.apache.org>",
97
- subject="[REVIEW NEEDED] github repository %s: push from unknown github user!" % reponame,
98
- sender="<gitbox@apache.org>",
99
- message=tmpl_unknown_user % locals(),
100
- )
101
- asfpy.messaging.mail(
102
- recipient="<notifications@infra.apache.org>",
103
- subject="gitbox repository %s: sqlite operational error!" % reponame,
104
- sender="<gitbox@apache.org>",
105
- message="gitbox.db could not be written to: %s" % txt,
106
- )
107
- asfpy.messaging.mail(
108
- recipient="<notifications@infra.apache.org>",
109
- subject="gitbox repository %s: missed event/push!" % reponame,
110
- sender="<gitbox@apache.org>",
111
- message=tmpl_missed_webhook % locals(),
112
- )
113
-
114
- https://github.com/apache/infrastructure-p6/blob/4692b7ede4f819b9075f241f57354a0a72fb6911/modules/gitbox/files/asfgit/hooks/post-receive.d/05-asfyaml.py
115
- asfpy.messaging.mail(recipients = [blamemail, main_contact], subject = "Failed to parse .asf.yaml in %s.git!" % cfg.repo_name, message = str(e))
116
- asfpy.messaging.mail(recipients = [blamemail, main_contact], subject = subject, message = errors)
117
- asfpy.messaging.mail(recipients = [blamemail, main_contact], subject = subject, message = msg)
118
-
119
- https://github.com/apache/infrastructure-webmod/blob/db9cec85690573d7307307ffd1f7f1b0e024c0d8/scripts/modreq.py
120
- asfpy.messaging.mail(
121
- sender = "ASF WebMod <root@apache.org>",
122
- recipient = f"private@{domain}",
123
- subject = f"Mailing list moderators for {mlist} updated by {session['uid']}",
124
- message = f"The following changes to the moderator list have been made by {session['uid']}:\n{message}\n",
125
- host = state.config["smtp"],
126
- )
127
-
128
- https://github.com/apache/infrastructure-occ/blob/163f8292019e38af935e27a157732464bd13a7d0/occ.py
129
- asfpy.messaging.mail(recipient=blamelist, subject=blamesubject, message=TMPL_FAILURE % (e.exitcode, e.reason))
asfpy-0.53/asfpy/ldap.py DELETED
@@ -1,440 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # Licensed to the Apache Software Foundation (ASF) under one or more
4
- # contributor license agreements. See the NOTICE file distributed with
5
- # this work for additional information regarding copyright ownership.
6
- # The ASF licenses this file to You under the Apache License, Version 2.0
7
- # (the "License"); you may not use this file except in compliance with
8
- # the License. You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- """ ASF LDAP Account Manager """
19
-
20
- import sys
21
- assert sys.version_info >= (3, 2)
22
-
23
- import ldap
24
- import ldap.modlist
25
- import ldif
26
- import re
27
- import crypt
28
- import random
29
- import string
30
-
31
- LDAP_SANDBOX = "ldaps://ldap-sandbox.apache.org:636"
32
- LDAP_MASTER = "ldaps://ldap-us.apache.org:636"
33
- LDAP_SUFFIX = 'dc=apache,dc=org'
34
- LDAP_PEOPLE_BASE = 'ou=people,dc=apache,dc=org'
35
- LDAP_GROUPS_BASE = 'ou=groups,dc=apache,dc=org'
36
- LDAP_APLDAP_BASE = 'cn=apldap,ou=groups,ou=services,dc=apache,dc=org'
37
- LDAP_CHAIRS_BASE = 'cn=pmc-chairs,ou=groups,ou=services,dc=apache,dc=org'
38
- LDAP_PMCS_BASE = 'ou=project,ou=groups,dc=apache,dc=org'
39
- LDAP_ROLES_BASE = 'ou=role,ou=groups,dc=apache,dc=org'
40
- LDAP_DN = 'uid=%s,ou=people,dc=apache,dc=org'
41
- LDAP_CN = 'cn=%s,%s'
42
-
43
- # INFRA-21590 ApacheID cannot have dashes.
44
- LDAP_VALID_UID_RE = re.compile(r"^[a-z0-9][a-z0-9_]+$")
45
- # New user account UIDs will be larger than this value.
46
- # Conversely: service accounts will be less than this.
47
- # NOTE: this value was chosen to ensure enough lower-value
48
- # UIDs were available for service accounts, until we
49
- # reach the heat death of the universe.
50
- MINIMUM_USER_UID = 6000
51
-
52
- # New service account UIDs will be larger than this value,
53
- # but below that of MINIMUM_UID.
54
- # NOTE: since the GID is chosen to match the UID, we start
55
- # at 5010, to avoid collision with: "nacho" uid=1122 gid=5004
56
- MINIMUM_SVC_UID = 5010
57
-
58
- assert MINIMUM_USER_UID > MINIMUM_SVC_UID
59
-
60
- ASSERTION_FAILED = "Common backend assertions failed, LDAP corruption?"
61
- BACKEND_TIMEOUT = "The backend authentication server timed out, please retry later."
62
-
63
- def bytify(ldiff):
64
- """ Convert all values in a dict to byte-string """
65
- for k, v in ldiff.items():
66
- if type(v) is list:
67
- n = 0
68
- for xv in v:
69
- if type(v[n]) is str:
70
- v[n] = xv.encode('utf-8')
71
- n += 1
72
- else:
73
- if type(v) is str:
74
- v = [v.encode('utf-8')]
75
- ldiff[k] = v
76
- return ldiff
77
-
78
-
79
- def stringify(ldiff):
80
- """ Convert all values in a dict to string """
81
- for k, v in ldiff.items():
82
- # Convert single-list to string
83
- if type(v) is list and len(v) == 1:
84
- v = v[0]
85
-
86
- if type(v) is list:
87
- n = 0
88
- for xv in v:
89
- if type(v[n]) is bytes:
90
- v[n] = xv.decode('utf-8')
91
- n += 1
92
- else:
93
- if type(v) is bytes:
94
- v = v.decode('utf-8')
95
- ldiff[k] = v
96
- return ldiff
97
-
98
-
99
- class ConnectionException(Exception):
100
- """ Simple exception with a message and an optional origin exception (WIP) """
101
- def __init__(self, message, origin=None):
102
- super().__init__(message)
103
- self.origin = origin
104
-
105
-
106
- class ValidatorException(Exception):
107
- """ Simple validator exception with a message and an optional triggering attribute """
108
- def __init__(self, message, attrib=None):
109
- super().__init__(message)
110
- self.attribute = attrib
111
-
112
-
113
- class committer:
114
- """ Committer class, allows for munging data """
115
-
116
- def __init__(self, mgr, res):
117
- self.manager = mgr
118
- self.dn = res[0][0]
119
- self.dn_enc = self.dn.encode('ascii')
120
- self.attributes = stringify(res[0][1])
121
- self.uid = self.attributes['uid']
122
-
123
- def add_project(self, project):
124
- """ Add person to project (as committer) """
125
- dn = LDAP_CN % (project, LDAP_PMCS_BASE)
126
- self.manager.lc.modify_s(dn, [(ldap.MOD_ADD, 'member', self.dn_enc)])
127
-
128
- def add_pmc(self, project):
129
- """ Add person to project (as PMC member) """
130
- dn = LDAP_CN % (project, LDAP_PMCS_BASE)
131
- self.manager.lc.modify_s(dn, [(ldap.MOD_ADD, 'owner', self.dn_enc)])
132
-
133
- def add_basic_group(self, group):
134
- """ Add person to basic posixGroup entry """
135
- dn = LDAP_CN % (group, LDAP_GROUPS_BASE)
136
- self.manager.lc.modify_s(dn, [(ldap.MOD_ADD, 'memberUid', self.uid.encode('ascii'))])
137
-
138
- def add_role(self, role):
139
- """ Add person to basic posixGroup entry """
140
- dn = LDAP_CN % (role, LDAP_ROLES_BASE)
141
- self.manager.lc.modify_s(dn, [(ldap.MOD_ADD, 'member', self.dn_enc)])
142
-
143
- def remove_project(self, project):
144
- """ Remove person from project (as committer) """
145
- dn = LDAP_CN % (project, LDAP_PMCS_BASE)
146
- self.manager.lc.modify_s(dn, [(ldap.MOD_DELETE, 'member', self.dn_enc)])
147
-
148
- def remove_pmc(self, project):
149
- """ Remove person from PMC """
150
- dn = LDAP_CN % (project, LDAP_PMCS_BASE)
151
- self.manager.lc.modify_s(dn, [(ldap.MOD_DELETE, 'owner', self.dn_enc)])
152
-
153
- def remove_basic_group(self, group):
154
- """ Remove person from basic posixGroup entry """
155
- dn = LDAP_CN % (group, LDAP_GROUPS_BASE)
156
- self.manager.lc.modify_s(dn, [(ldap.MOD_DELETE, 'memberUid', self.uid.encode('ascii'))])
157
-
158
- def remove_role(self, role):
159
- """ Add person to basic posixGroup entry """
160
- dn = LDAP_CN % (role, LDAP_ROLES_BASE)
161
- self.manager.lc.modify_s(dn, [(ldap.MOD_DELETE, 'member', self.dn_enc)])
162
-
163
- def rename(self, newuid):
164
- """ Rename an account, fixing in all projects """
165
- xuid = newuid
166
- if type(newuid) is str:
167
- newuid = newuid.encode('ascii')
168
- else:
169
- xuid = newuid.decode('ascii')
170
- # Validate uid
171
- if not LDAP_VALID_UID_RE.match(xuid):
172
- raise ValidatorException("Invalid UID, must match ^[a-z0-9][a-z0-9_]+$")
173
-
174
- # Test if uid exists
175
- if self.manager.load_account(xuid):
176
- raise ConnectionException("An account with this uid already exists")
177
-
178
- # Test for clashing cn's
179
- res = self.manager.lc.search_s(LDAP_SUFFIX, ldap.SCOPE_SUBTREE, 'cn=%s' % xuid)
180
- if res:
181
- raise ValidatorException("availid clashes with project name %s!" % res[0][0], 'uid')
182
-
183
- # We'll need to assign a new uidNumber as well..
184
- uidnumber = self.manager.next_user_uid()
185
-
186
- # Switch email and home dir
187
- changeset = []
188
- o_email = self.attributes['asf-committer-email'].encode('ascii')
189
- n_email = b'%s@apache.org' % newuid
190
- o_homedir = self.attributes['homeDirectory'].encode('ascii')
191
- n_homedir = b'/home/%s' % newuid
192
- changeset.append((ldap.MOD_DELETE, 'asf-committer-email', o_email))
193
- changeset.append((ldap.MOD_ADD, 'asf-committer-email', n_email))
194
- changeset.append((ldap.MOD_DELETE, 'homeDirectory', o_homedir))
195
- changeset.append((ldap.MOD_ADD, 'homeDirectory', n_homedir))
196
-
197
- # Change UID Number - has to be done all in one atomic go.
198
- ouidn = self.attributes['uidNumber'].encode('ascii')
199
- nuidn = b'%u' % uidnumber
200
- print("Changing uidNumber/gidNumber to %s..." % uidnumber)
201
- changeset.append((ldap.MOD_DELETE, 'gidNumber', ouidn))
202
- changeset.append((ldap.MOD_ADD, 'gidNumber', nuidn))
203
- changeset.append((ldap.MOD_DELETE, 'uidNumber', ouidn))
204
- changeset.append((ldap.MOD_ADD, 'uidNumber', nuidn))
205
- self.manager.lc.modify_s(self.dn, changeset)
206
-
207
- # Change DN
208
- odn = self.dn_enc.decode('ascii')
209
- newdn = LDAP_DN % xuid
210
- newdn_enc = newdn.encode('ascii')
211
- print("Changing %s to %s" % (odn, newdn))
212
- self.manager.lc.modrdn_s(odn, 'uid=%s' % xuid)
213
- # Search and rename
214
-
215
- # Replace long refs: member + owner
216
- for role in ['member', 'owner']:
217
- res = self.manager.lc.search_s(LDAP_SUFFIX, ldap.SCOPE_SUBTREE, '%s=%s' % (role, self.dn_enc.decode('ascii')))
218
- for entry in res:
219
- cn = entry[0]
220
- myhash = entry[1]
221
- if self.dn_enc in myhash[role]:
222
- print("Modifying (long) %s attribute in %s ..." % (role, cn))
223
- self.manager.lc.modify_s(cn, [(ldap.MOD_DELETE, role, self.dn_enc)])
224
- self.manager.lc.modify_s(cn, [(ldap.MOD_ADD, role, newdn_enc)])
225
-
226
- # Replace short refs: memberUid
227
- ouid = self.uid.encode('ascii')
228
- for role in ['memberUid']:
229
- res = self.manager.lc.search_s(LDAP_SUFFIX, ldap.SCOPE_SUBTREE, '(&(objectClass=posixGroup)(%s=%s))' % (role, self.uid))
230
- for entry in res:
231
- cn = entry[0]
232
- myhash = entry[1]
233
- if ouid in myhash[role]:
234
- print("Modifying (short) %s attribute in %s ..." % (role, cn))
235
- self.manager.lc.modify_s(cn, [(ldap.MOD_DELETE, role, ouid)])
236
- self.manager.lc.modify_s(cn, [(ldap.MOD_ADD, role, newuid)])
237
-
238
- # Change in-object
239
- self.uid = xuid
240
- self.dn_enc = newdn_enc
241
-
242
-
243
- class manager:
244
-
245
- """ Top LDAP Manager class for whomever is using the script """
246
- def __init__(self, user, password, host=LDAP_SANDBOX):
247
- # Verify correct user ID syntax, construct DN
248
- if not re.match(r"^[-_a-z0-9]+$", user):
249
- raise ConnectionException("Invalid characters in User ID. Must be alphanumerical or dashes only.")
250
-
251
- # Init LDAP connection
252
- lc = ldap.initialize(host)
253
-
254
- lc.set_option(ldap.OPT_REFERRALS, 0)
255
- lc.set_option(ldap.OPT_TIMEOUT, 5)
256
-
257
- # Attempt to bind with user and pass provided
258
- try:
259
- lc.simple_bind_s(LDAP_DN % user, password)
260
- except ldap.INVALID_CREDENTIALS:
261
- raise ConnectionException("Invalid username or password supplied!")
262
- except ldap.TIMEOUT:
263
- raise ConnectionException(BACKEND_TIMEOUT)
264
-
265
- # So far so good, set uid
266
- self.uid = user
267
- self.dn = LDAP_DN % user
268
- self.lc = lc
269
-
270
- # Get full name etc
271
- try:
272
- res = lc.search_s(LDAP_DN % user, ldap.SCOPE_BASE)
273
- assert(len(res) == 1)
274
- assert(len(res[0]) == 2)
275
- fn = res[0][1].get('cn')
276
- assert(type(fn) is list and len(fn) == 1)
277
- self.fullname = str(fn[0], 'utf-8')
278
- self.email = '%s@apache.org' % user
279
- except ldap.TIMEOUT:
280
- raise ConnectionException(BACKEND_TIMEOUT)
281
- except AssertionError:
282
- raise ConnectionException(ASSERTION_FAILED)
283
-
284
- # Get apldap status
285
- try:
286
- res = lc.search_s(LDAP_APLDAP_BASE, ldap.SCOPE_BASE)
287
- assert(len(res) == 1)
288
- assert(len(res[0]) == 2)
289
- members = res[0][1].get('member')
290
- assert(type(members) is list and len(members) > 0)
291
- self.isAdmin = bytes(LDAP_DN % user, 'utf-8') in members
292
- except ldap.TIMEOUT:
293
- raise ConnectionException(BACKEND_TIMEOUT)
294
- except AssertionError:
295
- raise ConnectionException(ASSERTION_FAILED)
296
-
297
- def load_account(self, uid):
298
- if type(uid) is bytes:
299
- uid = uid.decode('ascii')
300
- # Check if account exists!
301
- res = self.lc.search_s(LDAP_PEOPLE_BASE, ldap.SCOPE_SUBTREE, 'uid=%s' % uid)
302
- if res:
303
- return committer(self, res)
304
- return None
305
-
306
- def _find_gaps(self, l):
307
- return [item for item in range(l[0], l[-1]+1) if item not in l]
308
-
309
- def next_user_uid(self):
310
- """ Find lowest available user account uid with a matching available gid """
311
-
312
- try:
313
- r = self.lc.search_s(LDAP_PEOPLE_BASE, ldap.SCOPE_SUBTREE, 'uid=*', ['uidNumber', 'gidNumber'])
314
- un_avail_uids = sorted([int(item[1]["uidNumber"][0].decode('utf8')) for item in r])
315
- un_avail_gids = sorted([int(item[1]["gidNumber"][0].decode('utf8')) for item in r])
316
- avail_uids = self._find_gaps(un_avail_uids)
317
- avail_gids = self._find_gaps(un_avail_gids)
318
-
319
- # In case there are no gaps, increment the last returned UID
320
- # If the new UID is not unavailable append it to the list of
321
- # available_uids.
322
- n_uid = int(un_avail_uids[-1]+1)
323
- while n_uid in un_avail_gids:
324
- n_uid+=1
325
-
326
- avail_uids.append(n_uid)
327
-
328
- # Ensure you got something
329
- assert(type(avail_uids) is list and len(avail_uids) > 0 and type(avail_gids) is list and len(avail_gids) > 0)
330
-
331
- for uid in avail_uids:
332
- if uid >= MINIMUM_USER_UID and uid in avail_gids:
333
- return(uid)
334
- continue
335
-
336
- except ldap.TIMEOUT:
337
- raise ConnectionException(BACKEND_TIMEOUT)
338
- except AssertionError:
339
- raise ConnectionException(ASSERTION_FAILED)
340
-
341
- def create_account(
342
- self,
343
- uid,
344
- email,
345
- fullname,
346
- forcePass=None,
347
- requireTwo=True,
348
- ):
349
- """ Attempts to create a committer account in LDAP """
350
- if not self.isAdmin:
351
- raise ConnectionException("You do not have sufficient access to create accounts")
352
-
353
- # Validate uid
354
- if not LDAP_VALID_UID_RE.match(uid):
355
- raise ValidatorException("Invalid UID, must match ^[a-z0-9][a-z0-9_]+$")
356
-
357
- # Test if uid exists
358
- if self.load_account(uid):
359
- raise ConnectionException("An account with this uid already exists")
360
-
361
- # Test for clashing cn's
362
- res = self.lc.search_s(LDAP_SUFFIX, ldap.SCOPE_SUBTREE, 'cn=%s' % uid)
363
- if res:
364
- raise ValidatorException("availid clashes with project name %s!" % res[0][0], 'uid')
365
-
366
- uidnumber = self.next_user_uid()
367
-
368
- # Get surname and given name, validate against spurious whitespace
369
- names = fullname.split(' ')
370
- if len(names) < 2 and requireTwo:
371
- raise ValidatorException("Full name needs at least two parts!", 'fullname')
372
- givenName = names[0]
373
- surName = names[-1]
374
- for n in names:
375
- if not n.strip():
376
- raise ValidatorException("Found part of name with too much spacing!", 'fullname')
377
-
378
- # Validate email
379
- if not re.match(r"^\S+@\S+?\.\S+$", email):
380
- raise ValidatorException("Invalid email address supplied!", 'email')
381
-
382
- # Set password, b64-encoded crypt of random string
383
- password = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(16))
384
- if forcePass:
385
- password = forcePass
386
- password_crypted = crypt.crypt(password, crypt.mksalt(method=crypt.METHOD_MD5))
387
-
388
- ldiff = {
389
- 'objectClass': ['person', 'top', 'posixAccount', 'organizationalPerson', 'inetOrgPerson', 'asf-committer', 'hostObject', 'ldapPublicKey'],
390
- 'loginShell': '/bin/bash',
391
- 'asf-sascore': '10',
392
- 'givenName': givenName,
393
- 'sn': surName,
394
- 'mail': email,
395
- 'gidNumber': '9000',
396
- 'uidNumber': str(uidnumber),
397
- 'asf-committer-email': '%s@apache.org' % uid,
398
- 'cn': fullname,
399
- 'homeDirectory': '/home/%s' % uid,
400
- 'userPassword': '{CRYPT}' + password_crypted,
401
- 'host': 'home.apache.org',
402
- }
403
-
404
- # Convert everything to bytestrings because ldap demands it...
405
- bytify(ldiff)
406
-
407
- # Run LDIF on server
408
- dn = LDAP_DN % uid
409
- am = ldap.modlist.addModlist(ldiff)
410
- self.lc.add_s(dn, am)
411
-
412
- return self.load_account(uid)
413
-
414
-
415
- class LDIFWriter_Sane(ldif.LDIFWriter):
416
- """
417
- LDIFWriter with b64 detection overridden to allow for use of utf-8 rather than bytes
418
- Also disables b64 encoding for the 'dn' attribute
419
- """
420
-
421
- def _needs_base64_encoding(self, attr_type, attr_value):
422
- """
423
- returns False if attr_type is 'dn'
424
- returns True if attr_value has to be base-64 encoded because
425
- of special chars or because attr_type is in self._base64_attrs
426
- """
427
- if attr_type.lower() == 'dn':
428
- # We must always exclude DN
429
- # as our own library makes this a str (utf-8)
430
- return False
431
- if type(attr_value) is bytes:
432
- return super()._needs_base64_encoding(attr_type, attr_value)
433
- # short-cut to avoid encoding unless necessary
434
- if attr_type.lower() in self._base64_attrs:
435
- return True
436
- try:
437
- return super()._needs_base64_encoding(attr_type, attr_value.encode('utf-8'))
438
- except UnicodeEncodeError:
439
- return False
440
-
asfpy-0.53/asfpy/t.py DELETED
@@ -1,8 +0,0 @@
1
- from messaging import mail
2
-
3
-
4
- mail(recipient='gstein@gmail.com',
5
- subject='testing',
6
- message='body\n',
7
- auth=('gstein', 'ApacheRules!!'),
8
- )
asfpy-0.53/asfpy/t2.py DELETED
@@ -1,7 +0,0 @@
1
- from messaging import mail
2
-
3
-
4
- mail(recipient='gstein@gmail.com',
5
- subject='testing 2',
6
- message='body 2\n',
7
- )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes