Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F391
script_to_test_fetching_attachments_from_bugzilla
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
chasemp
Oct 22 2014, 9:25 PM
2014-10-22 21:25:30 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
script_to_test_fetching_attachments_from_bugzilla
View Options
#!/usr/bin/env python
#####################################################
# This script for retrieving attachments from bugzilla
# try bug # 72256 for a sampling of attachment types
user
=
''
password
=
''
save_path
=
'./data'
######################################################
import
time
import
sys
import
xmlrpclib
import
os
import
re
import
os.path
as
p
def
save_file
(
path
,
data
):
with
open
(
path
,
'wb'
)
as
f
:
f
.
write
(
data
)
def
create
(
bugid
):
if
not
p
.
exists
(
save_path
):
os
.
makedirs
(
save_path
)
server
=
xmlrpclib
.
ServerProxy
(
'https://bugzilla.wikimedia.org/xmlrpc.cgi'
,
use_datetime
=
True
)
token_data
=
server
.
User
.
login
({
'login'
:
user
,
'password'
:
password
})
token
=
token_data
[
'token'
]
#http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html#attachments
kwargs
=
{
'ids'
:
[
bugid
],
'Bugzilla_token'
:
token
}
attached
=
server
.
Bug
.
attachments
(
kwargs
)[
'bugs'
][
str
(
bugid
)]
#print attached
for
a
in
attached
:
fqfp
=
p
.
join
(
save_path
,
a
[
'file_name'
])
print
"Saving:
%s
"
%
(
fqfp
,)
save_file
(
fqfp
,
a
[
'data'
]
.
data
)
create
(
sys
.
argv
[
1
])
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
385
Default Alt Text
script_to_test_fetching_attachments_from_bugzilla (1 KB)
Attached To
Mode
P36 script to test fetching attachments from bugzilla
Attached
Detach File
Event Timeline
Log In to Comment