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
1
Merge Requests
1
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
deeb156b
Commit
deeb156b
authored
Mar 29, 2025
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
very large speed up of getting a list of packages
parent
60cc02a0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
30 deletions
+50
-30
appsmanager.py
src/tools/appsmanager.py
+50
-30
No files found.
src/tools/appsmanager.py
View file @
deeb156b
...
@@ -10,7 +10,7 @@ class ApplicationManager:
...
@@ -10,7 +10,7 @@ class ApplicationManager:
@staticmethod
@staticmethod
def
_get_available_applications
(
callback
):
def
_get_available_applications
(
callback
):
process
=
subprocess
.
Popen
([
"epm"
,
"play"
,
"--list-all"
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
text
=
True
)
process
=
subprocess
.
Popen
([
"epm"
,
"play"
,
"--
full-
list-all"
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
text
=
True
)
def
read_output
():
def
read_output
():
stdout
,
stderr
=
process
.
communicate
()
stdout
,
stderr
=
process
.
communicate
()
...
@@ -23,6 +23,55 @@ class ApplicationManager:
...
@@ -23,6 +23,55 @@ class ApplicationManager:
threading
.
Thread
(
target
=
read_output
,
daemon
=
True
)
.
start
()
threading
.
Thread
(
target
=
read_output
,
daemon
=
True
)
.
start
()
@staticmethod
@staticmethod
def
parse_applications_output
(
output
):
apps_dict
=
{}
for
line
in
output
.
splitlines
()[
1
:]:
line
=
line
.
strip
()
if
not
line
:
continue
parts
=
line
.
split
(
' - '
,
1
)
if
len
(
parts
)
!=
2
:
continue
name_part
,
dscr
=
parts
name_part
=
name_part
.
strip
()
dscr
=
dscr
.
strip
()
if
'='
in
name_part
:
base
,
alternative
=
name_part
.
split
(
'='
,
1
)
else
:
base
=
name_part
alternative
=
None
if
base
not
in
apps_dict
:
apps_dict
[
base
]
=
{
'dscr'
:
dscr
if
alternative
is
None
else
''
,
'alt'
:
[]
}
if
alternative
is
not
None
:
apps_dict
[
base
][
'alt'
]
.
append
(
alternative
)
else
:
if
alternative
is
None
:
apps_dict
[
base
][
'dscr'
]
=
dscr
elif
alternative
not
in
apps_dict
[
base
][
'alt'
]:
apps_dict
[
base
][
'alt'
]
.
append
(
alternative
)
applications
=
[]
for
base
,
data
in
apps_dict
.
items
():
applications
.
append
({
'name'
:
base
.
replace
(
'&'
,
'&'
),
'dscr'
:
data
[
'dscr'
]
.
replace
(
'&'
,
'&'
),
'alt'
:
data
[
'alt'
]
})
return
applications
@staticmethod
def
get_installed_applications
(
callback
):
def
get_installed_applications
(
callback
):
threading
.
Thread
(
target
=
ApplicationManager
.
_get_installed_applications
,
daemon
=
True
,
args
=
(
callback
,))
.
start
()
threading
.
Thread
(
target
=
ApplicationManager
.
_get_installed_applications
,
daemon
=
True
,
args
=
(
callback
,))
.
start
()
...
@@ -41,36 +90,7 @@ class ApplicationManager:
...
@@ -41,36 +90,7 @@ class ApplicationManager:
threading
.
Thread
(
target
=
read_output
,
daemon
=
True
)
.
start
()
threading
.
Thread
(
target
=
read_output
,
daemon
=
True
)
.
start
()
@staticmethod
@staticmethod
def
parse_applications_output
(
output
):
applications
=
[]
for
line
in
output
.
splitlines
()[
1
:]:
# Пропустить заголовок
parts
=
line
.
split
(
' - '
,
1
)
# Ограничить сплит до 2 частей
if
len
(
parts
)
==
2
:
name
,
dscr
=
map
(
str
.
strip
,
parts
)
alternatives
=
ApplicationManager
.
get_alternatives
(
name
)
applications
.
append
({
'name'
:
name
.
replace
(
'&'
,
'&'
),
'dscr'
:
dscr
.
replace
(
'&'
,
'&'
),
"alt"
:
alternatives
.
split
()
})
else
:
# Логгирование некорректной строки для диагностики
print
(
f
"Неправильный формат строки: {line}"
)
return
applications
@staticmethod
def
get_alternatives
(
name
):
alternatives
,
stderr
=
subprocess
.
Popen
([
"epm"
,
"play"
,
"--product-alternatives"
,
name
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
DEVNULL
,
text
=
True
,
bufsize
=
1
)
.
communicate
()
return
alternatives
@staticmethod
def
parse_installed_applications_output
(
output
):
def
parse_installed_applications_output
(
output
):
lines
=
output
.
splitlines
()[
1
:]
lines
=
output
.
splitlines
()[
1
:]
return
[
line
.
split
(
' - '
)[
0
]
.
strip
()
.
split
()[
0
]
for
line
in
lines
]
return
[
line
.
split
(
' - '
)[
0
]
.
strip
()
.
split
()[
0
]
for
line
in
lines
]
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