Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
Nuovo sito
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
16
Issues
16
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gruppo Web
Nuovo sito
Commits
19be065b
Commit
19be065b
authored
Nov 02, 2023
by
shadMod
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added UbuntuRelease() to get list of all versions
replaced CompileVersion().get_list_version with self.list_version
parent
077430d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
31 deletions
+60
-31
uitwww/src/download/compile_download.py
uitwww/src/download/compile_download.py
+60
-31
No files found.
uitwww/src/download/compile_download.py
View file @
19be065b
...
...
@@ -13,16 +13,64 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
traceback
import
toml
import
json
import
requests
from
lxml
import
html
from
urllib.request
import
urlopen
from
urllib.error
import
HTTPError
class
UbuntuRelease
:
def
__init__
(
self
,
path_url
=
None
,
ignore_lts
=
None
,
ignore_interim
=
None
):
self
.
path_url
=
path_url
self
.
ignore_lts
=
ignore_lts
self
.
ignore_interim
=
ignore_interim
@
property
def
row_list
(
self
)
->
list
:
# get requests
res
=
requests
.
get
(
self
.
path_url
)
# check requests status code
status
=
res
.
status_code
if
status
!=
200
:
raise
Exception
(
f"Error requests - status:
{
status
}
"
)
# get all table rows
table_rows
=
html
.
fromstring
(
res
.
content
).
xpath
(
'//pre//text()'
)
# init clean row and row_list
row
=
[]
row_list
=
[]
# get table_rows without header
for
val
in
table_rows
[
8
:]:
val
=
val
.
strip
()
if
val
:
if
'Ubuntu '
not
in
val
:
row
.
append
(
val
.
replace
(
"/"
,
""
))
else
:
row
.
append
(
val
)
row_list
.
append
(
row
)
row
=
[]
return
row_list
@
property
def
get_list_version
(
self
)
->
dict
:
data
=
{
"latest"
:
[],
"lts"
:
[]}
for
row
in
self
.
row_list
:
if
not
row
[
0
].
split
(
"."
)[
0
].
isnumeric
():
continue
if
'LTS'
in
row
[
1
]:
name
=
row
[
1
].
split
(
"("
)[
1
].
replace
(
")"
,
""
)
short
=
name
.
split
()[
0
].
lower
()
data
[
'lts'
].
append
((
row
[
0
],
short
,
name
))
else
:
name
=
row
[
1
].
split
(
"("
)[
1
].
replace
(
")"
,
""
)
short
=
name
.
split
()[
0
].
lower
()
data
[
'latest'
].
append
((
row
[
0
],
short
,
name
))
return
data
class
CompileVersion
:
"""
:param ARM64: set distro with arm64 architecture
...
...
@@ -46,7 +94,7 @@ class CompileVersion:
def
__init__
(
self
,
path_url
:
str
=
"https://releases.ubuntu.com/
?C=M;O=A
"
,
path_url
:
str
=
"https://releases.ubuntu.com/"
,
path_out
:
str
=
"../../data/downloads.toml"
,
constants
:
str
=
"./assets/costants.json"
,
ignore_interim
:
list
=
None
,
...
...
@@ -58,6 +106,12 @@ class CompileVersion:
self
.
ignore_interim
=
ignore_interim
if
ignore_interim
else
[]
self
.
ignore_lts
=
ignore_lts
if
ignore_lts
else
[]
self
.
list_version
=
UbuntuRelease
(
path_url
=
self
.
path_url
,
ignore_lts
=
self
.
ignore_lts
,
ignore_interim
=
self
.
ignore_interim
,
).
get_list_version
@
property
def
data_sources
(
self
)
->
list
:
return
[
...
...
@@ -89,36 +143,11 @@ class CompileVersion:
@
property
def
ver_lts_list
(
self
)
->
list
:
return
self
.
get_
list_version
[
"lts"
]
return
self
.
list_version
[
"lts"
]
@
property
def
ver_interim_list
(
self
)
->
list
:
return
self
.
get_list_version
[
"latest"
]
@
property
def
get_list_version
(
self
)
->
dict
:
res
=
requests
.
get
(
self
.
path_url
)
status
=
res
.
status_code
if
status
!=
200
:
raise
Exception
(
f"Error requests - status:
{
status
}
"
)
ver_list
=
{
"latest"
:
[],
"lts"
:
[]}
table_rows
=
res
.
text
.
split
(
'<img src="/icons/folder.gif" alt="[DIR]"> '
)[
1
:]
for
val
in
table_rows
:
row
=
val
.
split
(
'/">'
)
version
=
row
[
0
].
replace
(
'<a href="'
,
""
)
if
"Ubuntu "
in
row
[
1
]
and
"."
in
version
:
_version
,
name
=
row
[
1
].
split
(
"Ubuntu "
)[
1
].
split
(
"("
)
name
=
name
.
replace
(
")
\
n
"
,
""
)
codename
=
name
.
split
(
" "
)[
0
].
lower
()
ver
,
release_type
=
_version
.
split
(
" "
)[
0
:
2
]
if
release_type
==
"LTS"
:
if
codename
not
in
self
.
ignore_lts
:
ver_list
[
"lts"
].
append
((
version
,
codename
,
name
))
else
:
if
codename
not
in
self
.
ignore_interim
:
ver_list
[
"latest"
].
append
((
version
,
codename
,
name
))
return
ver_list
return
self
.
list_version
[
"latest"
]
def
compile_download
(
self
)
->
None
:
# put constants in empty data
...
...
@@ -192,7 +221,7 @@ class CompileVersion:
def
populate_archs_releases
(
self
,
distro
:
str
,
arch
:
str
)
->
dict
:
rels
=
{}
for
key
,
data
in
self
.
get_
list_version
.
items
():
for
key
,
data
in
self
.
list_version
.
items
():
rels
[
key
]
=
self
.
get_releases
(
data
,
distro
,
arch
,
key
)
if
not
rels
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment