Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61057171
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 4, 06:32
Size
1 KB
Mime Type
text/x-python
Expires
Mon, May 6, 06:32 (2 d)
Engine
blob
Format
Raw Data
Handle
17459037
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
)
phab
=
Phabricator
(
host
=
'https://scitassrv18.epfl.ch/api/'
)
user
=
phab
.
user
.
whoami
()
logging
.
debug
(
'user=
%s
'
%
user
)
# Get random project
project
=
None
while
project
==
None
or
len
(
project
[
'data'
])
==
0
:
proj_id
=
random
.
randint
(
1
,
1500
)
logging
.
debug
(
'proj_id=
%i
'
%
proj_id
)
project
=
phab
.
project
.
search
(
constraints
=
{
'ids'
:
[
proj_id
]},
)
project
=
project
[
'data'
][
0
]
logging
.
debug
(
'project=
%s
'
%
project
)
# 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'
:
[
project
[
'phid'
]]},
],
)
logging
.
debug
(
'task=
%s
'
%
task
)
Event Timeline
Log In to Comment