qfield-fetch 0.1.0__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.
- qfield_fetch-0.1.0/LICENSE +339 -0
- qfield_fetch-0.1.0/PKG-INFO +81 -0
- qfield_fetch-0.1.0/README.md +62 -0
- qfield_fetch-0.1.0/pyproject.toml +82 -0
- qfield_fetch-0.1.0/pyproject.toml.orig +81 -0
- qfield_fetch-0.1.0/src/qfield_fetch/__init__.py +57 -0
- qfield_fetch-0.1.0/src/qfield_fetch/__main__.py +21 -0
- qfield_fetch-0.1.0/src/qfield_fetch/cache.py +284 -0
- qfield_fetch-0.1.0/src/qfield_fetch/cli.py +119 -0
- qfield_fetch-0.1.0/src/qfield_fetch/py.typed +0 -0
- qfield_fetch-0.1.0/src/qfield_fetch/pytest_plugin.py +69 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
GNU GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 2, June 1991
|
|
3
|
+
|
|
4
|
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
|
5
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
6
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
7
|
+
of this license document, but changing it is not allowed.
|
|
8
|
+
|
|
9
|
+
Preamble
|
|
10
|
+
|
|
11
|
+
The licenses for most software are designed to take away your
|
|
12
|
+
freedom to share and change it. By contrast, the GNU General Public
|
|
13
|
+
License is intended to guarantee your freedom to share and change free
|
|
14
|
+
software--to make sure the software is free for all its users. This
|
|
15
|
+
General Public License applies to most of the Free Software
|
|
16
|
+
Foundation's software and to any other program whose authors commit to
|
|
17
|
+
using it. (Some other Free Software Foundation software is covered by
|
|
18
|
+
the GNU Lesser General Public License instead.) You can apply it to
|
|
19
|
+
your programs, too.
|
|
20
|
+
|
|
21
|
+
When we speak of free software, we are referring to freedom, not
|
|
22
|
+
price. Our General Public Licenses are designed to make sure that you
|
|
23
|
+
have the freedom to distribute copies of free software (and charge for
|
|
24
|
+
this service if you wish), that you receive source code or can get it
|
|
25
|
+
if you want it, that you can change the software or use pieces of it
|
|
26
|
+
in new free programs; and that you know you can do these things.
|
|
27
|
+
|
|
28
|
+
To protect your rights, we need to make restrictions that forbid
|
|
29
|
+
anyone to deny you these rights or to ask you to surrender the rights.
|
|
30
|
+
These restrictions translate to certain responsibilities for you if you
|
|
31
|
+
distribute copies of the software, or if you modify it.
|
|
32
|
+
|
|
33
|
+
For example, if you distribute copies of such a program, whether
|
|
34
|
+
gratis or for a fee, you must give the recipients all the rights that
|
|
35
|
+
you have. You must make sure that they, too, receive or can get the
|
|
36
|
+
source code. And you must show them these terms so they know their
|
|
37
|
+
rights.
|
|
38
|
+
|
|
39
|
+
We protect your rights with two steps: (1) copyright the software, and
|
|
40
|
+
(2) offer you this license which gives you legal permission to copy,
|
|
41
|
+
distribute and/or modify the software.
|
|
42
|
+
|
|
43
|
+
Also, for each author's protection and ours, we want to make certain
|
|
44
|
+
that everyone understands that there is no warranty for this free
|
|
45
|
+
software. If the software is modified by someone else and passed on, we
|
|
46
|
+
want its recipients to know that what they have is not the original, so
|
|
47
|
+
that any problems introduced by others will not reflect on the original
|
|
48
|
+
authors' reputations.
|
|
49
|
+
|
|
50
|
+
Finally, any free program is threatened constantly by software
|
|
51
|
+
patents. We wish to avoid the danger that redistributors of a free
|
|
52
|
+
program will individually obtain patent licenses, in effect making the
|
|
53
|
+
program proprietary. To prevent this, we have made it clear that any
|
|
54
|
+
patent must be licensed for everyone's free use or not licensed at all.
|
|
55
|
+
|
|
56
|
+
The precise terms and conditions for copying, distribution and
|
|
57
|
+
modification follow.
|
|
58
|
+
|
|
59
|
+
GNU GENERAL PUBLIC LICENSE
|
|
60
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
61
|
+
|
|
62
|
+
0. This License applies to any program or other work which contains
|
|
63
|
+
a notice placed by the copyright holder saying it may be distributed
|
|
64
|
+
under the terms of this General Public License. The "Program", below,
|
|
65
|
+
refers to any such program or work, and a "work based on the Program"
|
|
66
|
+
means either the Program or any derivative work under copyright law:
|
|
67
|
+
that is to say, a work containing the Program or a portion of it,
|
|
68
|
+
either verbatim or with modifications and/or translated into another
|
|
69
|
+
language. (Hereinafter, translation is included without limitation in
|
|
70
|
+
the term "modification".) Each licensee is addressed as "you".
|
|
71
|
+
|
|
72
|
+
Activities other than copying, distribution and modification are not
|
|
73
|
+
covered by this License; they are outside its scope. The act of
|
|
74
|
+
running the Program is not restricted, and the output from the Program
|
|
75
|
+
is covered only if its contents constitute a work based on the
|
|
76
|
+
Program (independent of having been made by running the Program).
|
|
77
|
+
Whether that is true depends on what the Program does.
|
|
78
|
+
|
|
79
|
+
1. You may copy and distribute verbatim copies of the Program's
|
|
80
|
+
source code as you receive it, in any medium, provided that you
|
|
81
|
+
conspicuously and appropriately publish on each copy an appropriate
|
|
82
|
+
copyright notice and disclaimer of warranty; keep intact all the
|
|
83
|
+
notices that refer to this License and to the absence of any warranty;
|
|
84
|
+
and give any other recipients of the Program a copy of this License
|
|
85
|
+
along with the Program.
|
|
86
|
+
|
|
87
|
+
You may charge a fee for the physical act of transferring a copy, and
|
|
88
|
+
you may at your option offer warranty protection in exchange for a fee.
|
|
89
|
+
|
|
90
|
+
2. You may modify your copy or copies of the Program or any portion
|
|
91
|
+
of it, thus forming a work based on the Program, and copy and
|
|
92
|
+
distribute such modifications or work under the terms of Section 1
|
|
93
|
+
above, provided that you also meet all of these conditions:
|
|
94
|
+
|
|
95
|
+
a) You must cause the modified files to carry prominent notices
|
|
96
|
+
stating that you changed the files and the date of any change.
|
|
97
|
+
|
|
98
|
+
b) You must cause any work that you distribute or publish, that in
|
|
99
|
+
whole or in part contains or is derived from the Program or any
|
|
100
|
+
part thereof, to be licensed as a whole at no charge to all third
|
|
101
|
+
parties under the terms of this License.
|
|
102
|
+
|
|
103
|
+
c) If the modified program normally reads commands interactively
|
|
104
|
+
when run, you must cause it, when started running for such
|
|
105
|
+
interactive use in the most ordinary way, to print or display an
|
|
106
|
+
announcement including an appropriate copyright notice and a
|
|
107
|
+
notice that there is no warranty (or else, saying that you provide
|
|
108
|
+
a warranty) and that users may redistribute the program under
|
|
109
|
+
these conditions, and telling the user how to view a copy of this
|
|
110
|
+
License. (Exception: if the Program itself is interactive but
|
|
111
|
+
does not normally print such an announcement, your work based on
|
|
112
|
+
the Program is not required to print an announcement.)
|
|
113
|
+
|
|
114
|
+
These requirements apply to the modified work as a whole. If
|
|
115
|
+
identifiable sections of that work are not derived from the Program,
|
|
116
|
+
and can be reasonably considered independent and separate works in
|
|
117
|
+
themselves, then this License, and its terms, do not apply to those
|
|
118
|
+
sections when you distribute them as separate works. But when you
|
|
119
|
+
distribute the same sections as part of a whole which is a work based
|
|
120
|
+
on the Program, the distribution of the whole must be on the terms of
|
|
121
|
+
this License, whose permissions for other licensees extend to the
|
|
122
|
+
entire whole, and thus to each and every part regardless of who wrote it.
|
|
123
|
+
|
|
124
|
+
Thus, it is not the intent of this section to claim rights or contest
|
|
125
|
+
your rights to work written entirely by you; rather, the intent is to
|
|
126
|
+
exercise the right to control the distribution of derivative or
|
|
127
|
+
collective works based on the Program.
|
|
128
|
+
|
|
129
|
+
In addition, mere aggregation of another work not based on the Program
|
|
130
|
+
with the Program (or with a work based on the Program) on a volume of
|
|
131
|
+
a storage or distribution medium does not bring the other work under
|
|
132
|
+
the scope of this License.
|
|
133
|
+
|
|
134
|
+
3. You may copy and distribute the Program (or a work based on it,
|
|
135
|
+
under Section 2) in object code or executable form under the terms of
|
|
136
|
+
Sections 1 and 2 above provided that you also do one of the following:
|
|
137
|
+
|
|
138
|
+
a) Accompany it with the complete corresponding machine-readable
|
|
139
|
+
source code, which must be distributed under the terms of Sections
|
|
140
|
+
1 and 2 above on a medium customarily used for software interchange; or,
|
|
141
|
+
|
|
142
|
+
b) Accompany it with a written offer, valid for at least three
|
|
143
|
+
years, to give any third party, for a charge no more than your
|
|
144
|
+
cost of physically performing source distribution, a complete
|
|
145
|
+
machine-readable copy of the corresponding source code, to be
|
|
146
|
+
distributed under the terms of Sections 1 and 2 above on a medium
|
|
147
|
+
customarily used for software interchange; or,
|
|
148
|
+
|
|
149
|
+
c) Accompany it with the information you received as to the offer
|
|
150
|
+
to distribute corresponding source code. (This alternative is
|
|
151
|
+
allowed only for noncommercial distribution and only if you
|
|
152
|
+
received the program in object code or executable form with such
|
|
153
|
+
an offer, in accord with Subsection b above.)
|
|
154
|
+
|
|
155
|
+
The source code for a work means the preferred form of the work for
|
|
156
|
+
making modifications to it. For an executable work, complete source
|
|
157
|
+
code means all the source code for all modules it contains, plus any
|
|
158
|
+
associated interface definition files, plus the scripts used to
|
|
159
|
+
control compilation and installation of the executable. However, as a
|
|
160
|
+
special exception, the source code distributed need not include
|
|
161
|
+
anything that is normally distributed (in either source or binary
|
|
162
|
+
form) with the major components (compiler, kernel, and so on) of the
|
|
163
|
+
operating system on which the executable runs, unless that component
|
|
164
|
+
itself accompanies the executable.
|
|
165
|
+
|
|
166
|
+
If distribution of executable or object code is made by offering
|
|
167
|
+
access to copy from a designated place, then offering equivalent
|
|
168
|
+
access to copy the source code from the same place counts as
|
|
169
|
+
distribution of the source code, even though third parties are not
|
|
170
|
+
compelled to copy the source along with the object code.
|
|
171
|
+
|
|
172
|
+
4. You may not copy, modify, sublicense, or distribute the Program
|
|
173
|
+
except as expressly provided under this License. Any attempt
|
|
174
|
+
otherwise to copy, modify, sublicense or distribute the Program is
|
|
175
|
+
void, and will automatically terminate your rights under this License.
|
|
176
|
+
However, parties who have received copies, or rights, from you under
|
|
177
|
+
this License will not have their licenses terminated so long as such
|
|
178
|
+
parties remain in full compliance.
|
|
179
|
+
|
|
180
|
+
5. You are not required to accept this License, since you have not
|
|
181
|
+
signed it. However, nothing else grants you permission to modify or
|
|
182
|
+
distribute the Program or its derivative works. These actions are
|
|
183
|
+
prohibited by law if you do not accept this License. Therefore, by
|
|
184
|
+
modifying or distributing the Program (or any work based on the
|
|
185
|
+
Program), you indicate your acceptance of this License to do so, and
|
|
186
|
+
all its terms and conditions for copying, distributing or modifying
|
|
187
|
+
the Program or works based on it.
|
|
188
|
+
|
|
189
|
+
6. Each time you redistribute the Program (or any work based on the
|
|
190
|
+
Program), the recipient automatically receives a license from the
|
|
191
|
+
original licensor to copy, distribute or modify the Program subject to
|
|
192
|
+
these terms and conditions. You may not impose any further
|
|
193
|
+
restrictions on the recipients' exercise of the rights granted herein.
|
|
194
|
+
You are not responsible for enforcing compliance by third parties to
|
|
195
|
+
this License.
|
|
196
|
+
|
|
197
|
+
7. If, as a consequence of a court judgment or allegation of patent
|
|
198
|
+
infringement or for any other reason (not limited to patent issues),
|
|
199
|
+
conditions are imposed on you (whether by court order, agreement or
|
|
200
|
+
otherwise) that contradict the conditions of this License, they do not
|
|
201
|
+
excuse you from the conditions of this License. If you cannot
|
|
202
|
+
distribute so as to satisfy simultaneously your obligations under this
|
|
203
|
+
License and any other pertinent obligations, then as a consequence you
|
|
204
|
+
may not distribute the Program at all. For example, if a patent
|
|
205
|
+
license would not permit royalty-free redistribution of the Program by
|
|
206
|
+
all those who receive copies directly or indirectly through you, then
|
|
207
|
+
the only way you could satisfy both it and this License would be to
|
|
208
|
+
refrain entirely from distribution of the Program.
|
|
209
|
+
|
|
210
|
+
If any portion of this section is held invalid or unenforceable under
|
|
211
|
+
any particular circumstance, the balance of the section is intended to
|
|
212
|
+
apply and the section as a whole is intended to apply in other
|
|
213
|
+
circumstances.
|
|
214
|
+
|
|
215
|
+
It is not the purpose of this section to induce you to infringe any
|
|
216
|
+
patents or other property right claims or to contest validity of any
|
|
217
|
+
such claims; this section has the sole purpose of protecting the
|
|
218
|
+
integrity of the free software distribution system, which is
|
|
219
|
+
implemented by public license practices. Many people have made
|
|
220
|
+
generous contributions to the wide range of software distributed
|
|
221
|
+
through that system in reliance on consistent application of that
|
|
222
|
+
system; it is up to the author/donor to decide if he or she is willing
|
|
223
|
+
to distribute software through any other system and a licensee cannot
|
|
224
|
+
impose that choice.
|
|
225
|
+
|
|
226
|
+
This section is intended to make thoroughly clear what is believed to
|
|
227
|
+
be a consequence of the rest of this License.
|
|
228
|
+
|
|
229
|
+
8. If the distribution and/or use of the Program is restricted in
|
|
230
|
+
certain countries either by patents or by copyrighted interfaces, the
|
|
231
|
+
original copyright holder who places the Program under this License
|
|
232
|
+
may add an explicit geographical distribution limitation excluding
|
|
233
|
+
those countries, so that distribution is permitted only in or among
|
|
234
|
+
countries not thus excluded. In such case, this License incorporates
|
|
235
|
+
the limitation as if written in the body of this License.
|
|
236
|
+
|
|
237
|
+
9. The Free Software Foundation may publish revised and/or new versions
|
|
238
|
+
of the General Public License from time to time. Such new versions will
|
|
239
|
+
be similar in spirit to the present version, but may differ in detail to
|
|
240
|
+
address new problems or concerns.
|
|
241
|
+
|
|
242
|
+
Each version is given a distinguishing version number. If the Program
|
|
243
|
+
specifies a version number of this License which applies to it and "any
|
|
244
|
+
later version", you have the option of following the terms and conditions
|
|
245
|
+
either of that version or of any later version published by the Free
|
|
246
|
+
Software Foundation. If the Program does not specify a version number of
|
|
247
|
+
this License, you may choose any version ever published by the Free Software
|
|
248
|
+
Foundation.
|
|
249
|
+
|
|
250
|
+
10. If you wish to incorporate parts of the Program into other free
|
|
251
|
+
programs whose distribution conditions are different, write to the author
|
|
252
|
+
to ask for permission. For software which is copyrighted by the Free
|
|
253
|
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
|
254
|
+
make exceptions for this. Our decision will be guided by the two goals
|
|
255
|
+
of preserving the free status of all derivatives of our free software and
|
|
256
|
+
of promoting the sharing and reuse of software generally.
|
|
257
|
+
|
|
258
|
+
NO WARRANTY
|
|
259
|
+
|
|
260
|
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
|
261
|
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
|
262
|
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
|
263
|
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
|
264
|
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
265
|
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
|
266
|
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
|
267
|
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
|
268
|
+
REPAIR OR CORRECTION.
|
|
269
|
+
|
|
270
|
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
271
|
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
|
272
|
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
|
273
|
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
|
274
|
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
|
275
|
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
|
276
|
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
|
277
|
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
|
278
|
+
POSSIBILITY OF SUCH DAMAGES.
|
|
279
|
+
|
|
280
|
+
END OF TERMS AND CONDITIONS
|
|
281
|
+
|
|
282
|
+
How to Apply These Terms to Your New Programs
|
|
283
|
+
|
|
284
|
+
If you develop a new program, and you want it to be of the greatest
|
|
285
|
+
possible use to the public, the best way to achieve this is to make it
|
|
286
|
+
free software which everyone can redistribute and change under these terms.
|
|
287
|
+
|
|
288
|
+
To do so, attach the following notices to the program. It is safest
|
|
289
|
+
to attach them to the start of each source file to most effectively
|
|
290
|
+
convey the exclusion of warranty; and each file should have at least
|
|
291
|
+
the "copyright" line and a pointer to where the full notice is found.
|
|
292
|
+
|
|
293
|
+
<one line to give the program's name and a brief idea of what it does.>
|
|
294
|
+
Copyright (C) <year> <name of author>
|
|
295
|
+
|
|
296
|
+
This program is free software; you can redistribute it and/or modify
|
|
297
|
+
it under the terms of the GNU General Public License as published by
|
|
298
|
+
the Free Software Foundation; either version 2 of the License, or
|
|
299
|
+
(at your option) any later version.
|
|
300
|
+
|
|
301
|
+
This program is distributed in the hope that it will be useful,
|
|
302
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
303
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
304
|
+
GNU General Public License for more details.
|
|
305
|
+
|
|
306
|
+
You should have received a copy of the GNU General Public License along
|
|
307
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
308
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
309
|
+
|
|
310
|
+
Also add information on how to contact you by electronic and paper mail.
|
|
311
|
+
|
|
312
|
+
If the program is interactive, make it output a short notice like this
|
|
313
|
+
when it starts in an interactive mode:
|
|
314
|
+
|
|
315
|
+
Gnomovision version 69, Copyright (C) year name of author
|
|
316
|
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
317
|
+
This is free software, and you are welcome to redistribute it
|
|
318
|
+
under certain conditions; type `show c' for details.
|
|
319
|
+
|
|
320
|
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
321
|
+
parts of the General Public License. Of course, the commands you use may
|
|
322
|
+
be called something other than `show w' and `show c'; they could even be
|
|
323
|
+
mouse-clicks or menu items--whatever suits your program.
|
|
324
|
+
|
|
325
|
+
You should also get your employer (if you work as a programmer) or your
|
|
326
|
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
|
327
|
+
necessary. Here is a sample; alter the names:
|
|
328
|
+
|
|
329
|
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
|
330
|
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
|
331
|
+
|
|
332
|
+
<signature of Ty Coon>, 1 April 1989
|
|
333
|
+
Ty Coon, President of Vice
|
|
334
|
+
|
|
335
|
+
This General Public License does not permit incorporating your program into
|
|
336
|
+
proprietary programs. If your program is a subroutine library, you may
|
|
337
|
+
consider it more useful to permit linking proprietary applications with the
|
|
338
|
+
library. If this is what you want to do, use the GNU Lesser General
|
|
339
|
+
Public License instead of this License.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qfield-fetch
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Download QField AppImages and QField and QFieldCloud sources into one cache
|
|
5
|
+
Keywords: QField,QFieldCloud,GIS,AppImage
|
|
6
|
+
License-Expression: GPL-2.0-or-later
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Framework :: Pytest
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Software Development :: Testing
|
|
11
|
+
Classifier: Programming Language :: Python
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Operating System :: POSIX
|
|
14
|
+
Requires-Dist: typer>=0.16
|
|
15
|
+
Requires-Python: >=3.12
|
|
16
|
+
Project-URL: homepage, https://github.com/Joonalai/qfield-dev-tools
|
|
17
|
+
Project-URL: repository, https://github.com/Joonalai/qfield-dev-tools
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# qfield-fetch
|
|
21
|
+
|
|
22
|
+
Downloads QField release AppImages, and QField and QFieldCloud sources, into one cache.
|
|
23
|
+
[pytest-qfield](https://github.com/Joonalai/qfield-dev-tools/tree/main/components/pytest-qfield) and [pytest-qfield-app](https://github.com/Joonalai/qfield-dev-tools/tree/main/components/pytest-qfield-app)
|
|
24
|
+
fetch through it, and the command line manages the same cache.
|
|
25
|
+
|
|
26
|
+
Each entry is fetched once, even by parallel processes such as pytest-xdist workers.
|
|
27
|
+
Sources are shallow clones of the one ref asked for (`git clone --depth=1 --branch=<ref>`).
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install qfield-fetch
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Fetching AppImages needs Linux. Cloning needs `git`.
|
|
36
|
+
|
|
37
|
+
## Command line
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
qfield-fetch appimage 4.2.9 # prints .../appimage/4.2.9/AppRun
|
|
41
|
+
qfield-fetch source 4.2.9 # tag v4.2.9, prints the checkout
|
|
42
|
+
qfield-fetch source master --update # a branch, cloned again after it moved
|
|
43
|
+
qfield-fetch qfieldcloud latest # newest QFieldCloud release
|
|
44
|
+
qfield-fetch list
|
|
45
|
+
qfield-fetch remove source v4.2.9
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Versions take an optional `v`, and `latest` is the newest release. `qff` is a short
|
|
49
|
+
alias of `qfield-fetch`.
|
|
50
|
+
|
|
51
|
+
## Cache
|
|
52
|
+
|
|
53
|
+
`~/.cache/qfield-fetch` (or `$XDG_CACHE_HOME/qfield-fetch`) by default. Set `QFIELD_FETCH_CACHE_DIR`,
|
|
54
|
+
or pass `--cache-dir`, to use another one.
|
|
55
|
+
|
|
56
|
+
```text
|
|
57
|
+
appimage/4.2.9/AppRun
|
|
58
|
+
source/v4.2.9/
|
|
59
|
+
qfieldcloud/v26.30/
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Python
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from qfield_fetch import appimage, qfield_source, qfieldcloud_source
|
|
66
|
+
|
|
67
|
+
app_run = appimage("4.2.9")
|
|
68
|
+
checkout = qfield_source("release-4_3", update=True)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Pytest options
|
|
72
|
+
|
|
73
|
+
The package registers options that pytest-qfield and pytest-qfield-app share:
|
|
74
|
+
|
|
75
|
+
| Option | Env | Ini |
|
|
76
|
+
| --- | --- | --- |
|
|
77
|
+
| `--qfield-version` | `QFIELD_VERSION` | `qfield_version` |
|
|
78
|
+
| | `QFIELD_FETCH_CACHE_DIR` | `qfield_fetch_cache_dir`, relative to the rootdir |
|
|
79
|
+
|
|
80
|
+
The option wins over the env, and the env over the ini. The `qfield_fetch_cache_dir` fixture
|
|
81
|
+
returns the cache in use.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# qfield-fetch
|
|
2
|
+
|
|
3
|
+
Downloads QField release AppImages, and QField and QFieldCloud sources, into one cache.
|
|
4
|
+
[pytest-qfield](https://github.com/Joonalai/qfield-dev-tools/tree/main/components/pytest-qfield) and [pytest-qfield-app](https://github.com/Joonalai/qfield-dev-tools/tree/main/components/pytest-qfield-app)
|
|
5
|
+
fetch through it, and the command line manages the same cache.
|
|
6
|
+
|
|
7
|
+
Each entry is fetched once, even by parallel processes such as pytest-xdist workers.
|
|
8
|
+
Sources are shallow clones of the one ref asked for (`git clone --depth=1 --branch=<ref>`).
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install qfield-fetch
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Fetching AppImages needs Linux. Cloning needs `git`.
|
|
17
|
+
|
|
18
|
+
## Command line
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
qfield-fetch appimage 4.2.9 # prints .../appimage/4.2.9/AppRun
|
|
22
|
+
qfield-fetch source 4.2.9 # tag v4.2.9, prints the checkout
|
|
23
|
+
qfield-fetch source master --update # a branch, cloned again after it moved
|
|
24
|
+
qfield-fetch qfieldcloud latest # newest QFieldCloud release
|
|
25
|
+
qfield-fetch list
|
|
26
|
+
qfield-fetch remove source v4.2.9
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Versions take an optional `v`, and `latest` is the newest release. `qff` is a short
|
|
30
|
+
alias of `qfield-fetch`.
|
|
31
|
+
|
|
32
|
+
## Cache
|
|
33
|
+
|
|
34
|
+
`~/.cache/qfield-fetch` (or `$XDG_CACHE_HOME/qfield-fetch`) by default. Set `QFIELD_FETCH_CACHE_DIR`,
|
|
35
|
+
or pass `--cache-dir`, to use another one.
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
appimage/4.2.9/AppRun
|
|
39
|
+
source/v4.2.9/
|
|
40
|
+
qfieldcloud/v26.30/
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Python
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from qfield_fetch import appimage, qfield_source, qfieldcloud_source
|
|
47
|
+
|
|
48
|
+
app_run = appimage("4.2.9")
|
|
49
|
+
checkout = qfield_source("release-4_3", update=True)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Pytest options
|
|
53
|
+
|
|
54
|
+
The package registers options that pytest-qfield and pytest-qfield-app share:
|
|
55
|
+
|
|
56
|
+
| Option | Env | Ini |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| `--qfield-version` | `QFIELD_VERSION` | `qfield_version` |
|
|
59
|
+
| | `QFIELD_FETCH_CACHE_DIR` | `qfield_fetch_cache_dir`, relative to the rootdir |
|
|
60
|
+
|
|
61
|
+
The option wins over the env, and the env over the ini. The `qfield_fetch_cache_dir` fixture
|
|
62
|
+
returns the cache in use.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "qfield-fetch"
|
|
3
|
+
description = "Download QField AppImages and QField and QFieldCloud sources into one cache"
|
|
4
|
+
readme = "README.md"
|
|
5
|
+
version = "0.1.0"
|
|
6
|
+
keywords = [
|
|
7
|
+
"QField",
|
|
8
|
+
"QFieldCloud",
|
|
9
|
+
"GIS",
|
|
10
|
+
"AppImage",
|
|
11
|
+
]
|
|
12
|
+
license = "GPL-2.0-or-later"
|
|
13
|
+
license-files = ["LICENSE"]
|
|
14
|
+
requires-python = ">=3.12"
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Framework :: Pytest",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Topic :: Software Development :: Testing",
|
|
19
|
+
"Programming Language :: Python",
|
|
20
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
21
|
+
"Operating System :: POSIX",
|
|
22
|
+
]
|
|
23
|
+
dependencies = ["typer>=0.16"]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
homepage = "https://github.com/Joonalai/qfield-dev-tools"
|
|
27
|
+
repository = "https://github.com/Joonalai/qfield-dev-tools"
|
|
28
|
+
|
|
29
|
+
[project.scripts]
|
|
30
|
+
qfield-fetch = "qfield_fetch.cli:app"
|
|
31
|
+
qff = "qfield_fetch.cli:app"
|
|
32
|
+
|
|
33
|
+
[project.entry-points.pytest11]
|
|
34
|
+
qfield-fetch = "qfield_fetch.pytest_plugin"
|
|
35
|
+
|
|
36
|
+
[build-system]
|
|
37
|
+
requires = ["uv_build>=0.10.9,<0.14.0"]
|
|
38
|
+
build-backend = "uv_build"
|
|
39
|
+
|
|
40
|
+
[tool.uv.build-backend]
|
|
41
|
+
module-name = "qfield_fetch"
|
|
42
|
+
|
|
43
|
+
[tool.pytest.ini_options]
|
|
44
|
+
addopts = "-p no:pytest-qfield -p no:pytest_qgis -p no:pytest-qt"
|
|
45
|
+
testpaths = ["test"]
|
|
46
|
+
|
|
47
|
+
[tool.semantic_release]
|
|
48
|
+
commit_parser = "conventional-monorepo"
|
|
49
|
+
major_on_zero = false
|
|
50
|
+
allow_zero_version = true
|
|
51
|
+
version_toml = ["pyproject.toml:project.version"]
|
|
52
|
+
tag_format = "qfield-fetch-v{version}"
|
|
53
|
+
commit_message = """
|
|
54
|
+
chore(release): qfield-fetch {version}
|
|
55
|
+
|
|
56
|
+
Automatically generated by python-semantic-release
|
|
57
|
+
"""
|
|
58
|
+
build_command = """
|
|
59
|
+
set -euo pipefail
|
|
60
|
+
python -m pip install uv
|
|
61
|
+
rm -rf dist
|
|
62
|
+
uv lock --upgrade-package "$PACKAGE_NAME"
|
|
63
|
+
git add ../../uv.lock
|
|
64
|
+
uv build --out-dir dist
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
[tool.semantic_release.commit_parser_options]
|
|
68
|
+
path_filters = ["."]
|
|
69
|
+
scope_prefix = "fetch"
|
|
70
|
+
minor_tags = ["feat"]
|
|
71
|
+
patch_tags = [
|
|
72
|
+
"fix",
|
|
73
|
+
"build",
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
[tool.semantic_release.changelog]
|
|
77
|
+
mode = "update"
|
|
78
|
+
exclude_commit_patterns = ['(?!(?:feat|fix)(?:\([^)]*?\))?!?: ).*']
|
|
79
|
+
|
|
80
|
+
[tool.semantic_release.branches.main]
|
|
81
|
+
match = "(main)"
|
|
82
|
+
prerelease_token = "dev"
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "qfield-fetch"
|
|
3
|
+
description = "Download QField AppImages and QField and QFieldCloud sources into one cache"
|
|
4
|
+
readme = "README.md"
|
|
5
|
+
version = "0.1.0"
|
|
6
|
+
keywords = ["QField", "QFieldCloud", "GIS", "AppImage"]
|
|
7
|
+
license = "GPL-2.0-or-later"
|
|
8
|
+
license-files = ["LICENSE"]
|
|
9
|
+
requires-python = ">=3.12"
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Framework :: Pytest",
|
|
12
|
+
"Intended Audience :: Developers",
|
|
13
|
+
"Topic :: Software Development :: Testing",
|
|
14
|
+
"Programming Language :: Python",
|
|
15
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
16
|
+
"Operating System :: POSIX",
|
|
17
|
+
]
|
|
18
|
+
dependencies = [
|
|
19
|
+
"typer>=0.16",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
homepage = "https://github.com/Joonalai/qfield-dev-tools"
|
|
24
|
+
repository = "https://github.com/Joonalai/qfield-dev-tools"
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
qfield-fetch = "qfield_fetch.cli:app"
|
|
28
|
+
qff = "qfield_fetch.cli:app"
|
|
29
|
+
|
|
30
|
+
[project.entry-points.pytest11]
|
|
31
|
+
qfield-fetch = "qfield_fetch.pytest_plugin"
|
|
32
|
+
|
|
33
|
+
[build-system]
|
|
34
|
+
requires = ["uv_build>=0.10.9,<0.14.0"]
|
|
35
|
+
build-backend = "uv_build"
|
|
36
|
+
|
|
37
|
+
[tool.uv.build-backend]
|
|
38
|
+
module-name = "qfield_fetch"
|
|
39
|
+
|
|
40
|
+
[tool.pytest.ini_options]
|
|
41
|
+
# The QGIS based plugins import Qt on load, these tests need none of it.
|
|
42
|
+
addopts = "-p no:pytest-qfield -p no:pytest_qgis -p no:pytest-qt"
|
|
43
|
+
testpaths = ["test"]
|
|
44
|
+
|
|
45
|
+
[tool.semantic_release]
|
|
46
|
+
commit_parser = "conventional-monorepo"
|
|
47
|
+
major_on_zero = false
|
|
48
|
+
allow_zero_version = true
|
|
49
|
+
version_toml = ["pyproject.toml:project.version"]
|
|
50
|
+
tag_format = "qfield-fetch-v{version}"
|
|
51
|
+
commit_message = """\
|
|
52
|
+
chore(release): qfield-fetch {version}
|
|
53
|
+
|
|
54
|
+
Automatically generated by python-semantic-release
|
|
55
|
+
"""
|
|
56
|
+
build_command = """
|
|
57
|
+
set -euo pipefail
|
|
58
|
+
python -m pip install uv
|
|
59
|
+
rm -rf dist
|
|
60
|
+
uv lock --upgrade-package "$PACKAGE_NAME"
|
|
61
|
+
git add ../../uv.lock
|
|
62
|
+
uv build --out-dir dist
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
[tool.semantic_release.commit_parser_options]
|
|
66
|
+
path_filters = ["."]
|
|
67
|
+
scope_prefix = "fetch"
|
|
68
|
+
# Only feat, fix and build (dependency bumps) commits are releasable
|
|
69
|
+
minor_tags = ["feat"]
|
|
70
|
+
patch_tags = ["fix", "build"]
|
|
71
|
+
|
|
72
|
+
[tool.semantic_release.changelog]
|
|
73
|
+
mode = "update"
|
|
74
|
+
# Keep only feat and fix commits in the changelog
|
|
75
|
+
exclude_commit_patterns = [
|
|
76
|
+
'''(?!(?:feat|fix)(?:\([^)]*?\))?!?: ).*''',
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
[tool.semantic_release.branches.main]
|
|
80
|
+
match = "(main)"
|
|
81
|
+
prerelease_token = "dev"
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Copyright (C) 2026 qfield-dev-tools Contributors.
|
|
2
|
+
#
|
|
3
|
+
#
|
|
4
|
+
# This file is part of qfield-dev-tools.
|
|
5
|
+
#
|
|
6
|
+
# qfield-dev-tools is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# qfield-dev-tools is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with qfield-dev-tools. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
"""QField AppImages and QField and QFieldCloud sources, kept in one cache."""
|
|
20
|
+
|
|
21
|
+
from qfield_fetch.cache import (
|
|
22
|
+
CACHE_ENV,
|
|
23
|
+
LATEST,
|
|
24
|
+
QFIELD,
|
|
25
|
+
QFIELDCLOUD,
|
|
26
|
+
Entry,
|
|
27
|
+
FetchError,
|
|
28
|
+
Kind,
|
|
29
|
+
appimage,
|
|
30
|
+
default_cache_dir,
|
|
31
|
+
entries,
|
|
32
|
+
entry_path,
|
|
33
|
+
latest_release,
|
|
34
|
+
qfield_source,
|
|
35
|
+
qfieldcloud_source,
|
|
36
|
+
release_version,
|
|
37
|
+
remove,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
__all__ = [
|
|
41
|
+
"CACHE_ENV",
|
|
42
|
+
"LATEST",
|
|
43
|
+
"QFIELD",
|
|
44
|
+
"QFIELDCLOUD",
|
|
45
|
+
"Entry",
|
|
46
|
+
"FetchError",
|
|
47
|
+
"Kind",
|
|
48
|
+
"appimage",
|
|
49
|
+
"default_cache_dir",
|
|
50
|
+
"entries",
|
|
51
|
+
"entry_path",
|
|
52
|
+
"latest_release",
|
|
53
|
+
"qfield_source",
|
|
54
|
+
"qfieldcloud_source",
|
|
55
|
+
"release_version",
|
|
56
|
+
"remove",
|
|
57
|
+
]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Copyright (C) 2026 qfield-dev-tools Contributors.
|
|
2
|
+
#
|
|
3
|
+
#
|
|
4
|
+
# This file is part of qfield-dev-tools.
|
|
5
|
+
#
|
|
6
|
+
# qfield-dev-tools is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# qfield-dev-tools is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with qfield-dev-tools. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
from qfield_fetch.cli import app
|
|
20
|
+
|
|
21
|
+
app(prog_name="qfield-fetch")
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
# Copyright (C) 2026 qfield-dev-tools Contributors.
|
|
2
|
+
#
|
|
3
|
+
#
|
|
4
|
+
# This file is part of qfield-dev-tools.
|
|
5
|
+
#
|
|
6
|
+
# qfield-dev-tools is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# qfield-dev-tools is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with qfield-dev-tools. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
"""Downloads kept in one cache, each fetched once even by parallel processes.
|
|
20
|
+
|
|
21
|
+
An entry is complete once its directory exists. It is built in a temporary
|
|
22
|
+
directory next to it and renamed into place while holding a file lock.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
|
|
27
|
+
import fcntl
|
|
28
|
+
import hashlib
|
|
29
|
+
import json
|
|
30
|
+
import logging
|
|
31
|
+
import os
|
|
32
|
+
import re
|
|
33
|
+
import shutil
|
|
34
|
+
import subprocess
|
|
35
|
+
import tempfile
|
|
36
|
+
from contextlib import contextmanager
|
|
37
|
+
from dataclasses import dataclass
|
|
38
|
+
from enum import StrEnum
|
|
39
|
+
from functools import partial
|
|
40
|
+
from pathlib import Path
|
|
41
|
+
from typing import TYPE_CHECKING, Any
|
|
42
|
+
from urllib.request import Request, urlopen
|
|
43
|
+
|
|
44
|
+
if TYPE_CHECKING:
|
|
45
|
+
from collections.abc import Callable, Iterator
|
|
46
|
+
|
|
47
|
+
LOGGER = logging.getLogger(__name__)
|
|
48
|
+
|
|
49
|
+
CACHE_ENV = "QFIELD_FETCH_CACHE_DIR"
|
|
50
|
+
GITHUB = "https://github.com"
|
|
51
|
+
GITHUB_API = "https://api.github.com"
|
|
52
|
+
QFIELD = "opengisch/QField"
|
|
53
|
+
QFIELDCLOUD = "opengisch/QFieldCloud"
|
|
54
|
+
LATEST = "latest"
|
|
55
|
+
DOWNLOAD_CHUNK = 1 << 20
|
|
56
|
+
VERSION_PATTERN = re.compile(r"v?(\d+\.\d+\.\d+[A-Za-z0-9.-]*)")
|
|
57
|
+
# Refs name cache directories, so nothing that could leave the cache.
|
|
58
|
+
REF_PATTERN = re.compile(r"[A-Za-z0-9][A-Za-z0-9._/-]*")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class FetchError(RuntimeError):
|
|
62
|
+
"""A download or clone failed."""
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class Kind(StrEnum):
|
|
66
|
+
APPIMAGE = "appimage"
|
|
67
|
+
SOURCE = "source"
|
|
68
|
+
QFIELDCLOUD = "qfieldcloud"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@dataclass(frozen=True)
|
|
72
|
+
class Entry:
|
|
73
|
+
kind: Kind
|
|
74
|
+
name: str
|
|
75
|
+
path: Path
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def default_cache_dir() -> Path:
|
|
79
|
+
"""Return `$QFIELD_FETCH_CACHE_DIR`, or `qfield-fetch` in the user cache."""
|
|
80
|
+
configured = os.environ.get(CACHE_ENV)
|
|
81
|
+
if configured:
|
|
82
|
+
return Path(configured).expanduser().resolve()
|
|
83
|
+
base = os.environ.get("XDG_CACHE_HOME") or Path.home() / ".cache"
|
|
84
|
+
return Path(base) / "qfield-fetch"
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _github_api(path: str) -> dict[str, Any]:
|
|
88
|
+
headers = {"Accept": "application/vnd.github+json"}
|
|
89
|
+
# Anonymous calls are limited to 60 an hour, CI runners share that.
|
|
90
|
+
if token := os.environ.get("GITHUB_TOKEN"):
|
|
91
|
+
headers["Authorization"] = f"Bearer {token}"
|
|
92
|
+
request = Request(f"{GITHUB_API}{path}", headers=headers) # noqa: S310 GitHub API URL
|
|
93
|
+
with urlopen(request, timeout=30) as response: # noqa: S310 GitHub API URL
|
|
94
|
+
return json.load(response)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def latest_release(repository: str) -> str:
|
|
98
|
+
"""Return the tag of the newest release, `v4.2.9` for example."""
|
|
99
|
+
return str(_github_api(f"/repos/{repository}/releases/latest")["tag_name"])
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _asset_digest(version: str, name: str) -> str | None:
|
|
103
|
+
"""Return the SHA-256 GitHub lists for a release asset, if it lists one."""
|
|
104
|
+
try:
|
|
105
|
+
release = _github_api(f"/repos/{QFIELD}/releases/tags/v{version}")
|
|
106
|
+
except OSError as error:
|
|
107
|
+
LOGGER.warning("Not verifying %s, its release is unavailable: %s", name, error)
|
|
108
|
+
return None
|
|
109
|
+
for asset in release.get("assets", []):
|
|
110
|
+
digest = str(asset.get("digest") or "")
|
|
111
|
+
if asset.get("name") == name and digest.startswith("sha256:"):
|
|
112
|
+
return digest.removeprefix("sha256:")
|
|
113
|
+
LOGGER.warning("Not verifying %s, its release lists no digest", name)
|
|
114
|
+
return None
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def release_version(version: str) -> str:
|
|
118
|
+
"""Return the QField release `4.2.9` for `4.2.9`, `v4.2.9` or `latest`."""
|
|
119
|
+
if version == LATEST:
|
|
120
|
+
version = latest_release(QFIELD)
|
|
121
|
+
match = VERSION_PATTERN.fullmatch(version)
|
|
122
|
+
if not match:
|
|
123
|
+
msg = f"Not a QField release version: {version!r}"
|
|
124
|
+
raise ValueError(msg)
|
|
125
|
+
return match[1]
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def appimage(version: str, cache_dir: Path | None = None) -> Path:
|
|
129
|
+
"""Download and extract a QField release AppImage once, and return its `AppRun`.
|
|
130
|
+
|
|
131
|
+
:param version: A release such as `4.2.9`, or `latest`
|
|
132
|
+
"""
|
|
133
|
+
version = release_version(version)
|
|
134
|
+
target = _entry_path(Kind.APPIMAGE, version, cache_dir)
|
|
135
|
+
_ensure(target, partial(_install_appimage, version), update=False)
|
|
136
|
+
return target / "AppRun"
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def qfield_source(
|
|
140
|
+
ref: str, cache_dir: Path | None = None, *, update: bool = False
|
|
141
|
+
) -> Path:
|
|
142
|
+
"""Clone QField at one ref only, and return the checkout.
|
|
143
|
+
|
|
144
|
+
:param ref: A release such as `4.2.9`, `latest`, a tag or a branch
|
|
145
|
+
:param update: Clone again, for a branch that moved
|
|
146
|
+
"""
|
|
147
|
+
ref = _git_ref(ref, QFIELD)
|
|
148
|
+
if match := VERSION_PATTERN.fullmatch(ref):
|
|
149
|
+
ref = f"v{match[1]}"
|
|
150
|
+
target = _entry_path(Kind.SOURCE, ref, cache_dir)
|
|
151
|
+
return _ensure(target, partial(_clone, QFIELD, ref), update=update)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def qfieldcloud_source(
|
|
155
|
+
ref: str, cache_dir: Path | None = None, *, update: bool = False
|
|
156
|
+
) -> Path:
|
|
157
|
+
"""Clone QFieldCloud at one ref only, and return the checkout.
|
|
158
|
+
|
|
159
|
+
:param ref: A tag such as `v26.30`, `latest` or a branch
|
|
160
|
+
:param update: Clone again, for a branch that moved
|
|
161
|
+
"""
|
|
162
|
+
ref = _git_ref(ref, QFIELDCLOUD)
|
|
163
|
+
target = _entry_path(Kind.QFIELDCLOUD, ref, cache_dir)
|
|
164
|
+
return _ensure(target, partial(_clone, QFIELDCLOUD, ref), update=update)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def entries(cache_dir: Path | None = None) -> list[Entry]:
|
|
168
|
+
root = cache_dir or default_cache_dir()
|
|
169
|
+
return [
|
|
170
|
+
Entry(kind, path.name, path)
|
|
171
|
+
for kind in Kind
|
|
172
|
+
for path in sorted((root / kind).glob("[!.]*"))
|
|
173
|
+
if path.is_dir()
|
|
174
|
+
]
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def entry_path(kind: Kind, name: str, cache_dir: Path | None = None) -> Path:
|
|
178
|
+
"""Return where an entry is kept, fetched or not.
|
|
179
|
+
|
|
180
|
+
:param name: A release version or resolved ref, as `entries` names them
|
|
181
|
+
"""
|
|
182
|
+
return _entry_path(Kind(kind), _checked_ref(name), cache_dir)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def remove(kind: Kind, name: str, cache_dir: Path | None = None) -> bool:
|
|
186
|
+
"""Remove one entry, and return whether it existed."""
|
|
187
|
+
target = entry_path(kind, name, cache_dir)
|
|
188
|
+
if not target.exists():
|
|
189
|
+
return False
|
|
190
|
+
with _locked(target):
|
|
191
|
+
shutil.rmtree(target)
|
|
192
|
+
return True
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def _git_ref(ref: str, repository: str) -> str:
|
|
196
|
+
if ref == LATEST:
|
|
197
|
+
return latest_release(repository)
|
|
198
|
+
return _checked_ref(ref)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def _checked_ref(ref: str) -> str:
|
|
202
|
+
if not REF_PATTERN.fullmatch(ref) or ".." in ref:
|
|
203
|
+
msg = f"Not a release or git ref: {ref!r}"
|
|
204
|
+
raise ValueError(msg)
|
|
205
|
+
return ref
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def _entry_path(kind: Kind, name: str, cache_dir: Path | None) -> Path:
|
|
209
|
+
return (cache_dir or default_cache_dir()) / kind / name.replace("/", "_")
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
@contextmanager
|
|
213
|
+
def _locked(target: Path) -> Iterator[None]:
|
|
214
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
215
|
+
with target.with_name(f".{target.name}.lock").open("w") as lock:
|
|
216
|
+
fcntl.flock(lock, fcntl.LOCK_EX)
|
|
217
|
+
yield
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def _ensure(target: Path, install: Callable[[Path], None], *, update: bool) -> Path:
|
|
221
|
+
"""Build the entry with `install` unless it exists, and return it."""
|
|
222
|
+
if target.exists() and not update:
|
|
223
|
+
return target
|
|
224
|
+
with _locked(target):
|
|
225
|
+
if target.exists() and not update:
|
|
226
|
+
return target
|
|
227
|
+
# Holding the lock, so these are left by killed processes.
|
|
228
|
+
for leftover in target.parent.glob(f".{target.name}-*"):
|
|
229
|
+
shutil.rmtree(leftover, ignore_errors=True)
|
|
230
|
+
with tempfile.TemporaryDirectory(
|
|
231
|
+
prefix=f".{target.name}-", dir=target.parent
|
|
232
|
+
) as work_dir:
|
|
233
|
+
work = Path(work_dir)
|
|
234
|
+
install(work / "new")
|
|
235
|
+
if target.exists():
|
|
236
|
+
target.rename(work / "old")
|
|
237
|
+
(work / "new").rename(target)
|
|
238
|
+
return target
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def _run(*args: str, cwd: Path | None = None) -> None:
|
|
242
|
+
completed = subprocess.run( # noqa: S603 fixed commands, refs are checked
|
|
243
|
+
args, cwd=cwd, check=False, capture_output=True, text=True
|
|
244
|
+
)
|
|
245
|
+
if completed.returncode:
|
|
246
|
+
msg = f"{' '.join(args)} failed:\n{completed.stderr[-3000:]}"
|
|
247
|
+
raise FetchError(msg)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def _install_appimage(version: str, target: Path) -> None:
|
|
251
|
+
name = f"qfield-v{version}-linux-x64.AppImage"
|
|
252
|
+
image = target.parent / name
|
|
253
|
+
LOGGER.info("Downloading %s", name)
|
|
254
|
+
url = f"{GITHUB}/{QFIELD}/releases/download/v{version}/{name}"
|
|
255
|
+
sha256 = hashlib.sha256()
|
|
256
|
+
try:
|
|
257
|
+
with (
|
|
258
|
+
urlopen(url, timeout=60) as response, # noqa: S310 GitHub release URL
|
|
259
|
+
image.open("wb") as out,
|
|
260
|
+
):
|
|
261
|
+
while chunk := response.read(DOWNLOAD_CHUNK):
|
|
262
|
+
sha256.update(chunk)
|
|
263
|
+
out.write(chunk)
|
|
264
|
+
except OSError as error:
|
|
265
|
+
msg = f"Downloading {url} failed: {error}"
|
|
266
|
+
raise FetchError(msg) from error
|
|
267
|
+
expected = _asset_digest(version, name)
|
|
268
|
+
if expected and sha256.hexdigest() != expected:
|
|
269
|
+
msg = f"{name} does not match the SHA-256 of its release"
|
|
270
|
+
raise FetchError(msg)
|
|
271
|
+
image.chmod(0o755)
|
|
272
|
+
# Extracting avoids FUSE, which containers and CI runners often lack.
|
|
273
|
+
_run(str(image), "--appimage-extract", cwd=target.parent)
|
|
274
|
+
(target.parent / "squashfs-root").rename(target)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def _clone(repository: str, ref: str, target: Path) -> None:
|
|
278
|
+
LOGGER.info("Cloning %s at %s", repository, ref)
|
|
279
|
+
_run(
|
|
280
|
+
*("git", "-c", "advice.detachedHead=false", "clone", "--quiet"),
|
|
281
|
+
*("--depth=1", f"--branch={ref}"),
|
|
282
|
+
f"{GITHUB}/{repository}.git",
|
|
283
|
+
str(target),
|
|
284
|
+
)
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Copyright (C) 2026 qfield-dev-tools Contributors.
|
|
2
|
+
#
|
|
3
|
+
#
|
|
4
|
+
# This file is part of qfield-dev-tools.
|
|
5
|
+
#
|
|
6
|
+
# qfield-dev-tools is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# qfield-dev-tools is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with qfield-dev-tools. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
"""The `qfield-fetch` command."""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
from typing import TYPE_CHECKING, Annotated
|
|
25
|
+
|
|
26
|
+
import typer
|
|
27
|
+
|
|
28
|
+
from qfield_fetch import cache
|
|
29
|
+
|
|
30
|
+
if TYPE_CHECKING:
|
|
31
|
+
from collections.abc import Callable
|
|
32
|
+
|
|
33
|
+
app = typer.Typer(
|
|
34
|
+
help="Download QField AppImages and QField and QFieldCloud sources into one cache.",
|
|
35
|
+
no_args_is_help=True,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
CacheDir = Annotated[
|
|
39
|
+
Path | None,
|
|
40
|
+
typer.Option(
|
|
41
|
+
envvar=cache.CACHE_ENV,
|
|
42
|
+
help="Cache directory, ~/.cache/qfield-fetch by default.",
|
|
43
|
+
show_default=False,
|
|
44
|
+
),
|
|
45
|
+
]
|
|
46
|
+
Update = Annotated[bool, typer.Option(help="Clone again, for a branch that moved.")]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _echo_result(fetch: Callable[[], object]) -> None:
|
|
50
|
+
try:
|
|
51
|
+
typer.echo(fetch())
|
|
52
|
+
except (ValueError, cache.FetchError) as error:
|
|
53
|
+
typer.echo(error, err=True)
|
|
54
|
+
raise typer.Exit(1) from error
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _resolved(cache_dir: Path | None) -> Path | None:
|
|
58
|
+
return cache_dir.expanduser().resolve() if cache_dir else None
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@app.command()
|
|
62
|
+
def appimage(
|
|
63
|
+
version: Annotated[str, typer.Argument(help="A release such as 4.2.9, or latest.")],
|
|
64
|
+
cache_dir: CacheDir = None,
|
|
65
|
+
) -> None:
|
|
66
|
+
"""Download and extract a QField AppImage, and print its AppRun."""
|
|
67
|
+
_echo_result(lambda: cache.appimage(version, _resolved(cache_dir)))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@app.command()
|
|
71
|
+
def source(
|
|
72
|
+
ref: Annotated[
|
|
73
|
+
str, typer.Argument(help="A release such as 4.2.9, latest, a tag or a branch.")
|
|
74
|
+
],
|
|
75
|
+
*,
|
|
76
|
+
update: Update = False,
|
|
77
|
+
cache_dir: CacheDir = None,
|
|
78
|
+
) -> None:
|
|
79
|
+
"""Clone QField at one ref only, and print the checkout."""
|
|
80
|
+
_echo_result(lambda: cache.qfield_source(ref, _resolved(cache_dir), update=update))
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@app.command()
|
|
84
|
+
def qfieldcloud(
|
|
85
|
+
ref: Annotated[
|
|
86
|
+
str, typer.Argument(help="A tag such as v26.30, latest or a branch.")
|
|
87
|
+
],
|
|
88
|
+
*,
|
|
89
|
+
update: Update = False,
|
|
90
|
+
cache_dir: CacheDir = None,
|
|
91
|
+
) -> None:
|
|
92
|
+
"""Clone QFieldCloud at one ref only, and print the checkout."""
|
|
93
|
+
_echo_result(
|
|
94
|
+
lambda: cache.qfieldcloud_source(ref, _resolved(cache_dir), update=update)
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
@app.command("list")
|
|
99
|
+
def list_entries(cache_dir: CacheDir = None) -> None:
|
|
100
|
+
"""List what the cache holds."""
|
|
101
|
+
for entry in cache.entries(_resolved(cache_dir)):
|
|
102
|
+
typer.echo(f"{entry.kind}\t{entry.name}\t{entry.path}")
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@app.command()
|
|
106
|
+
def remove(
|
|
107
|
+
kind: Annotated[cache.Kind, typer.Argument(help="What to remove.")],
|
|
108
|
+
name: Annotated[str, typer.Argument(help="Name as `list` shows it.")],
|
|
109
|
+
cache_dir: CacheDir = None,
|
|
110
|
+
) -> None:
|
|
111
|
+
"""Remove one entry from the cache."""
|
|
112
|
+
try:
|
|
113
|
+
removed = cache.remove(kind, name, _resolved(cache_dir))
|
|
114
|
+
except ValueError as error:
|
|
115
|
+
typer.echo(error, err=True)
|
|
116
|
+
raise typer.Exit(1) from error
|
|
117
|
+
if not removed:
|
|
118
|
+
typer.echo(f"No {kind} {name}", err=True)
|
|
119
|
+
raise typer.Exit(1)
|
|
File without changes
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Copyright (C) 2026 qfield-dev-tools Contributors.
|
|
2
|
+
#
|
|
3
|
+
#
|
|
4
|
+
# This file is part of qfield-dev-tools.
|
|
5
|
+
#
|
|
6
|
+
# qfield-dev-tools is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# qfield-dev-tools is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with qfield-dev-tools. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
"""Pytest options that pytest-qfield and pytest-qfield-app share."""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import os
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
|
|
26
|
+
import pytest
|
|
27
|
+
|
|
28
|
+
from qfield_fetch.cache import CACHE_ENV, default_cache_dir
|
|
29
|
+
|
|
30
|
+
VERSION_ENV = "QFIELD_VERSION"
|
|
31
|
+
VERSION_KEY = "qfield_version"
|
|
32
|
+
CACHE_KEY = "qfield_fetch_cache_dir"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def pytest_addoption(parser: pytest.Parser) -> None:
|
|
36
|
+
group = parser.getgroup("qfield-fetch")
|
|
37
|
+
group.addoption(
|
|
38
|
+
"--qfield-version",
|
|
39
|
+
help=f"QField release or git ref to test against. Env {VERSION_ENV}.",
|
|
40
|
+
)
|
|
41
|
+
parser.addini(VERSION_KEY, "QField release or git ref to test against.")
|
|
42
|
+
parser.addini(
|
|
43
|
+
CACHE_KEY,
|
|
44
|
+
f"qfield-fetch cache, relative to the rootdir. Env {CACHE_ENV}.",
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def configured_version(config: pytest.Config) -> str | None:
|
|
49
|
+
"""Return the QField version from the option, the env or the ini, in that order."""
|
|
50
|
+
return (
|
|
51
|
+
config.getoption(VERSION_KEY)
|
|
52
|
+
or os.environ.get(VERSION_ENV)
|
|
53
|
+
or config.getini(VERSION_KEY)
|
|
54
|
+
or None
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def configured_cache_dir(config: pytest.Config) -> Path:
|
|
59
|
+
"""Return the cache from the env or the ini, or the user cache."""
|
|
60
|
+
configured = config.getini(CACHE_KEY)
|
|
61
|
+
if configured and not os.environ.get(CACHE_ENV):
|
|
62
|
+
return config.rootpath / Path(configured).expanduser()
|
|
63
|
+
return default_cache_dir()
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@pytest.fixture(scope="session")
|
|
67
|
+
def qfield_fetch_cache_dir(pytestconfig: pytest.Config) -> Path:
|
|
68
|
+
"""Where qfield-fetch keeps AppImages and sources."""
|
|
69
|
+
return configured_cache_dir(pytestconfig)
|