Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F56514294
deactivate_repo.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, Mar 28, 19:16
Size
1 KB
Mime Type
text/x-python
Expires
Sat, Mar 30, 19:16 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
16727092
Attached To
rPHINFRA c4science
deactivate_repo.py
View Options
#!/usr/bin/env python3
from
phabricator
import
Phabricator
import
time
phab
=
Phabricator
(
host
=
'https://c4science.ch/api/'
)
phab
.
update_interfaces
()
#phab.diffusion.repository.edit(
# objectIdentifier = phid,
# transactions = [
# {'type': 'status', 'value': 'inactive'},
# ],
#)
repos
=
open
(
'/tmp/repo-id'
,
'r'
)
.
read
()
.
split
(
'
\n
'
)
ids
=
[]
callsigns
=
[]
# Parse file for IDs
for
r
in
repos
:
if
len
(
r
)
==
0
:
continue
if
r
[
0
]
==
'R'
:
ids
.
append
(
int
(
r
[
1
:]))
else
:
callsigns
.
append
(
r
[
1
:])
# Deactivate repo
def
deactivate
(
phid
):
phab
.
diffusion
.
repository
.
edit
(
objectIdentifier
=
phid
,
transactions
=
[
{
'type'
:
'status'
,
'value'
:
'inactive'
},
],
)
def
activate
(
phid
):
phab
.
diffusion
.
repository
.
edit
(
objectIdentifier
=
phid
,
transactions
=
[
{
'type'
:
'status'
,
'value'
:
'active'
},
],
)
# Search repo
def
search
(
constraints
):
after
=
0
while
after
!=
None
:
search
=
phab
.
diffusion
.
repository
.
search
(
after
=
after
,
constraints
=
constraints
)
after
=
search
[
'cursor'
][
'after'
]
for
s
in
search
[
'data'
]:
state
=
s
[
'fields'
][
'status'
]
print
(
s
[
'id'
],
state
)
#deactivate(s['phid'])
activate
(
s
[
'phid'
])
for
i
in
ids
:
# for some reasons it doesn't work in batch for ids but for callsigns....
time
.
sleep
(
0.5
)
search
({
'ids'
:
[
i
]})
if
len
(
callsigns
)
>
0
:
search
({
'callsigns'
:
callsigns
})
Event Timeline
Log In to Comment