Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
altlinux-packages-bot
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
Kirill Unitsaev
altlinux-packages-bot
Commits
58a423d8
Verified
Commit
58a423d8
authored
Nov 03, 2025
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tasks: add tasks command
parent
4d998a9a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
155 additions
and
0 deletions
+155
-0
methods.py
src/altrepo/api/methods.py
+34
-0
models.py
src/altrepo/api/models.py
+50
-0
config.py
src/config.py
+1
-0
tasks.py
src/handlers/tasks.py
+61
-0
utils.py
src/services/utils.py
+9
-0
No files found.
src/altrepo/api/methods.py
View file @
58a423d8
...
...
@@ -58,6 +58,39 @@ class APIInfo:
return
models
.
APIVersion
(
**
data
)
class
TaskProcessInfo
:
def
__init__
(
self
,
client
:
BaseAPI
):
self
.
client
=
client
async
def
find_tasks
(
self
,
input
:
list
[
str
],
owner
:
str
|
None
=
None
,
branch
:
str
|
None
=
None
,
state
:
list
[
str
]
|
None
=
None
,
tasks_limit
:
int
=
100
,
by_package
:
bool
=
False
,
)
->
models
.
TasksListModel
:
params
=
{
k
:
v
for
k
,
v
in
{
"input"
:
input
,
"owner"
:
owner
,
"branch"
:
branch
,
"state"
:
state
,
"tasks_limit"
:
tasks_limit
,
"by_package"
:
by_package
}
.
items
()
if
v
is
not
None
}
data
=
await
self
.
client
.
get
(
"/task/progress/find_tasks"
,
params
)
return
models
.
TasksListModel
(
**
data
)
class
TaskInfo
:
def
__init__
(
self
,
client
:
BaseAPI
):
self
.
client
=
client
self
.
progress
=
TaskProcessInfo
(
self
.
client
)
class
PackageInfo
:
def
__init__
(
self
,
client
:
BaseAPI
):
self
.
client
=
client
...
...
@@ -247,6 +280,7 @@ class ALTRepoAPI:
self
.
BASE_API_VERSION
=
"1.19.34"
self
.
_client
=
BaseAPI
(
session
)
self
.
api
=
APIInfo
(
self
.
_client
)
self
.
task
=
TaskInfo
(
self
.
_client
)
self
.
package
=
PackageInfo
(
self
.
_client
)
self
.
packageset
=
PackagesetInfo
(
self
.
_client
)
self
.
acl
=
AclInfo
(
self
.
_client
)
...
...
src/altrepo/api/models.py
View file @
58a423d8
...
...
@@ -8,6 +8,56 @@ class APIVersion(BaseModel):
description
:
str
class
SubTaskArchitectureModel
(
BaseModel
):
stage_status
:
str
arch
:
str
class
SubTasksElementModel
(
BaseModel
):
subtask_id
:
int
subtask_type
:
str
subtask_srpm
:
str
subtask_srpm_name
:
str
subtask_srpm_evr
:
str
subtask_dir
:
str
subtask_tag_id
:
str
subtask_tag_name
:
str
subtask_tag_author
:
str
subtask_package
:
str
subtask_pkg_from
:
str
subtask_changed
:
str
type
:
str
archs
:
List
[
SubTaskArchitectureModel
]
class
TaskApprovalElementModel
(
BaseModel
):
type
:
str
nickname
:
str
message
:
str
class
TasksListElementModel
(
BaseModel
):
task_id
:
int
task_repo
:
str
task_state
:
str
task_owner
:
str
task_try
:
int
task_iter
:
int
task_testonly
:
int
task_changed
:
str
task_message
:
str
task_stage
:
str
dependencies
:
List
[
int
]
subtasks
:
List
[
SubTasksElementModel
]
approval
:
list
[
TaskApprovalElementModel
]
class
TasksListModel
(
BaseModel
):
request_args
:
Dict
[
str
,
Any
]
length
:
int
tasks
:
list
[
TasksListElementModel
]
class
PackageSetActivePackageSetsModel
(
BaseModel
):
length
:
int
packagesets
:
List
[
str
]
...
...
src/config.py
View file @
58a423d8
...
...
@@ -34,6 +34,7 @@ APPSTREAM_SKIP_LIST = [
"rpm-macros-"
]
TASK_URL
=
"https://packages.altlinux.org/ru/tasks/"
BUGS_URL
=
"https://bugzilla.altlinux.org/"
PACKAGES_URL
=
"https://packages.altlinux.org/ru/{repo}/"
CYBERTALK_URL
=
"https://lists.altlinux.org/pipermail/sisyphus-cybertalk/{}/"
...
...
src/handlers/tasks.py
0 → 100644
View file @
58a423d8
from
telegrinder
import
Dispatch
,
Message
from
telegrinder.rules
import
Command
,
Argument
from
telegrinder.tools.formatting
import
HTMLFormatter
,
link
from
datetime
import
datetime
from
altrepo
import
altrepo
from
altrepo.api.errors
import
DataNotFoundError
,
RequestValidationError
from
data.keyboards
import
package_keyboards
from
database.models
import
User
from
database.func
import
DB
from
services.utils
import
_bold
,
date_format
from
config
import
TASK_URL
dp
=
Dispatch
()
@dp.message
(
Command
(
"tasks"
,
Argument
(
"maintainer"
,
optional
=
True
),
Argument
(
"branch"
,
optional
=
True
)))
async
def
tasks_handler
(
m
:
Message
,
user
:
User
|
None
,
maintainer
:
str
|
None
=
None
,
branch
:
str
|
None
=
None
)
->
None
:
if
not
branch
:
if
user
:
branch
=
user
.
default_branch
else
:
branch
=
"sisyphus"
if
maintainer
:
_maintainer
=
maintainer
.
lower
()
maintainer
=
DB
.
maintainer
.
get
(
_maintainer
)
if
not
maintainer
:
await
m
.
answer
(
"Сопровождающий не найден."
)
return
else
:
if
user
:
maintainer
=
user
.
maintainer
else
:
return
print
(
f
"@{maintainer.nickname}"
f
"({branch})"
)
tasks_data
=
await
altrepo
.
api
.
task
.
progress
.
find_tasks
(
input
=
[
f
"@{maintainer.nickname}"
],
branch
=
branch
)
if
not
tasks_data
.
tasks
:
await
m
.
answer
(
"Нет тасков."
)
return
tasks
=
[
task
for
task
in
tasks_data
.
tasks
if
task
.
task_state
not
in
[
"DONE"
]]
tasks_message
=
_bold
(
"Таски:
\n\n
"
)
for
i
,
task
in
enumerate
(
tasks
):
if
i
==
100
:
break
build_time
=
await
date_format
(
task
.
task_changed
)
subtasks
=
len
(
task
.
subtasks
)
tasks_message
+=
HTMLFormatter
(
f
"<a href='{TASK_URL}{task.task_id}'>{task.task_id}</a>"
)
+
\
f
" | {task.task_state} | {build_time} | {subtasks} | {task.task_message}
\n
"
await
m
.
answer
(
tasks_message
)
src/services/utils.py
View file @
58a423d8
...
...
@@ -3,6 +3,7 @@ import asyncio
from
database.func
import
DB
import
re
from
datetime
import
datetime
async
def
_translate
(
text
):
...
...
@@ -58,3 +59,10 @@ def _bold(text: str):
def
is_valid_str
(
name
:
str
)
->
bool
:
pattern
=
r"^[A-Za-z0-9@]+$"
return
re
.
fullmatch
(
pattern
,
name
)
is
not
None
async
def
date_format
(
time
)
->
str
:
if
isinstance
(
time
,
(
int
,
float
)):
dt
=
datetime
.
fromtimestamp
(
time
)
elif
isinstance
(
time
,
str
):
dt
=
datetime
.
fromisoformat
(
time
)
return
dt
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
\ No newline at end of file
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