Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F63240608
create-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
Sat, May 18, 17:58
Size
1 KB
Mime Type
text/x-python
Expires
Mon, May 20, 17:58 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17716089
Attached To
rPHINFRA c4science
create-repo.py
View Options
#!/usr/bin/env python3
from
phabricator
import
Phabricator
import
logging
,
random
,
namesgenerator
logging
.
basicConfig
(
level
=
logging
.
DEBUG
,
format
=
'
%(asctime)s
%(message)s
'
)
phab
=
Phabricator
(
host
=
'https://scitassrv18.epfl.ch/api/'
)
user
=
phab
.
user
.
whoami
()
logging
.
debug
(
'user=
%s
'
%
user
)
# Get random project
projects
=
None
while
projects
==
None
or
len
(
projects
[
'data'
])
==
0
:
ids
=
[]
for
i
in
range
(
10
):
ids
.
append
(
random
.
randint
(
1
,
1500
))
logging
.
debug
(
'ids=
%s
'
%
ids
)
projects
=
phab
.
project
.
search
(
constraints
=
{
'ids'
:
ids
})
projects
=
projects
[
'data'
]
logging
.
debug
(
'projects=
%s
'
%
[
p
[
'fields'
][
'name'
]
for
p
in
projects
])
# Create the repository
task
=
phab
.
diffusion
.
repository
.
edit
(
transactions
=
[
{
'type'
:
'name'
,
'value'
:
namesgenerator
.
get_random_name
()},
{
'type'
:
'vcs'
,
'value'
:
'git'
},
{
'type'
:
'status'
,
'value'
:
'active'
},
{
'type'
:
'view'
,
'value'
:
'users'
},
{
'type'
:
'edit'
,
'value'
:
'obj.repository.author'
},
{
'type'
:
'policy.push'
,
'value'
:
'obj.repository.author'
},
{
'type'
:
'projects.add'
,
'value'
:
[
p
[
'phid'
]
for
p
in
projects
]},
],
)
logging
.
debug
(
'task=
%s
'
%
task
)
Event Timeline
Log In to Comment