Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F60715426
create-task.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, May 2, 03:53
Size
2 KB
Mime Type
text/x-python
Expires
Sat, May 4, 03:53 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17401191
Attached To
rPHINFRA c4science
create-task.py
View Options
#!/usr/bin/env python
from
phabricator
import
Phabricator
import
logging
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
phab
=
Phabricator
()
user
=
phab
.
user
.
whoami
()
logging
.
debug
(
'user=
%s
'
%
user
)
group_c4s_admin
=
'PHID-PROJ-3bgiie5tgoy7syk7ulhy'
group_c4s
=
'PHID-PROJ-itwdg3fgxutsrdnqjklb'
with
open
(
'/tmp/size.csv'
,
'r'
)
as
f
:
for
l
in
f
.
readlines
():
repo_info
=
l
.
replace
(
'
\n
'
,
''
)
.
split
(
','
)
logging
.
debug
(
'repo_info=
%s
'
%
repo_info
)
if
len
(
repo_info
)
<
4
:
logging
.
error
(
'CSV error=
%s
'
%
l
)
break
repo_user
=
phab
.
user
.
query
(
usernames
=
[
repo_info
[
3
]])
logging
.
debug
(
'repo_user=
%s
'
%
repo_user
)
policy_view
=
phab
.
policy
.
create
(
objectType
=
'TASK'
,
default
=
'deny'
,
policy
=
[
{
'action'
:
'allow'
,
'rule'
:
'PhabricatorUsersPolicyRule'
,
'value'
:
[
repo_user
[
0
][
'phid'
]]
},
{
'action'
:
'allow'
,
'rule'
:
'PhabricatorProjectsPolicyRule'
,
'value'
:
[
group_c4s_admin
]
}
])
policy_edit
=
phab
.
policy
.
create
(
objectType
=
'TASK'
,
default
=
'deny'
,
policy
=
[
{
'action'
:
'allow'
,
'rule'
:
'PhabricatorProjectsPolicyRule'
,
'value'
:
[
group_c4s_admin
]
}
])
logging
.
debug
(
'policy_view=
%s
'
%
policy_view
)
logging
.
debug
(
'policy_edit=
%s
'
%
policy_edit
)
repo_email_txt
=
open
(
'./create-task-email.txt'
,
'r'
)
.
read
()
repo_email
=
repo_email_txt
.
format
(
name
=
repo_user
[
0
][
'realName'
],
repo_id
=
repo_info
[
1
],
repo_name
=
repo_info
[
2
],
repo_size
=
repo_info
[
0
])
logging
.
debug
(
'repo_email=
%s
'
%
repo_email
)
task
=
phab
.
maniphest
.
createtask
(
title
=
'C4science: One of your repository is too big'
,
description
=
repo_email
,
viewPolicy
=
policy_view
[
'phid'
],
editPolicy
=
policy_edit
[
'phid'
],
projectPHIDs
=
[
group_c4s
],
priority
=
100
,
ccPHIDs
=
[
repo_user
[
0
][
'phid'
]],
)
logging
.
debug
(
'task=
%s
'
%
task
)
Event Timeline
Log In to Comment