Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm-play-gui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roman Alifanov
eepm-play-gui
Commits
f33549cd
You need to sign in or sign up before continuing.
Commit
f33549cd
authored
Nov 14, 2024
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
applicationrow: download list of available files first, rather than trying to download each one
parent
6969d3de
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
2 deletions
+28
-2
applicationrow.py
src/widgets/applicationrow.py
+28
-2
No files found.
src/widgets/applicationrow.py
View file @
f33549cd
...
...
@@ -2,11 +2,13 @@ import os
import
urllib.request
import
threading
from
gi.repository
import
Adw
,
Gtk
,
GdkPixbuf
,
Gio
,
GLib
,
Gdk
from
bs4
import
BeautifulSoup
# Не забудьте установить BeautifulSoup4
class
IconLoader
:
BASE_URL
=
"https://download.etersoft.ru/pub/Etersoft/XimperLinux/eepm_play_gui/icons/"
SUPPORTED_EXTENSIONS
=
[
'png'
,
'jpg'
,
'svg'
]
CACHE_DIR
=
os
.
path
.
join
(
os
.
path
.
expanduser
(
"~"
),
".cache"
,
"ru.eepm.PlayGUI"
,
"apps_icons"
)
available_files
=
set
()
@classmethod
def
ensure_cache_dir
(
cls
):
...
...
@@ -30,7 +32,11 @@ class IconLoader:
def
load_icon
():
for
ext
in
cls
.
SUPPORTED_EXTENSIONS
:
icon_url
=
f
"{cls.BASE_URL}{icon_name}.{ext}"
icon_filename
=
f
"{icon_name}.{ext}"
if
icon_filename
not
in
cls
.
available_files
:
continue
# Пропустить загрузку, если файл отсутствует
icon_url
=
f
"{cls.BASE_URL}{icon_filename}"
try
:
with
urllib
.
request
.
urlopen
(
icon_url
)
as
response
:
input_stream
=
Gio
.
MemoryInputStream
.
new_from_data
(
response
.
read
(),
None
)
...
...
@@ -43,10 +49,27 @@ class IconLoader:
return
except
Exception
as
e
:
print
(
f
"
Icon for {icon_name} not found in
{ext}: {e}"
)
print
(
f
"
Failed to load {icon_name}.
{ext}: {e}"
)
threading
.
Thread
(
target
=
load_icon
,
daemon
=
True
)
.
start
()
@classmethod
def
fetch_file_list
(
cls
):
print
(
"fetch file list..."
)
try
:
with
urllib
.
request
.
urlopen
(
cls
.
BASE_URL
)
as
response
:
html
=
response
.
read
()
soup
=
BeautifulSoup
(
html
,
'html.parser'
)
# Ищем ссылки на файлы
for
link
in
soup
.
find_all
(
'a'
):
href
=
link
.
get
(
'href'
)
if
any
(
href
.
endswith
(
ext
)
for
ext
in
cls
.
SUPPORTED_EXTENSIONS
):
cls
.
available_files
.
add
(
href
)
except
Exception
as
e
:
print
(
f
"Failed to fetch file list: {e}"
)
class
ApplicationRow
(
Adw
.
ActionRow
):
__gtype_name__
=
'ApplicationRow'
...
...
@@ -103,3 +126,6 @@ class ApplicationRow(Adw.ActionRow):
else
:
# self.add_css_class("unchanged")
print
(
"marked-unchanged"
)
# Загрузить список доступных файлов при запуске
IconLoader
.
fetch_file_list
()
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