~ubuntu-branches/ubuntu/precise/bughelper/precise

« back to all changes in this revision

Viewing changes to launchpadBugs/storeblob.py

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-04-10 11:54:41 UTC
  • Revision ID: james.westby@ubuntu.com-20070410115441-7hix742g1qi8ztp7
Tags: 0.2~169
* Fixed numerous bugs. (LP: #93658, #89728, #95223, #81434, #99586, #102355,
  #99642, #103318, #102480, #107554 ,#107735, #107959, #99726, #79136,
  #79136, #79136, #79140, #109533, #79140, #109533).
* debian/control:
  - updated XS-Vcs-Bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
'''Temporarily store a blob in Launchpad and get a ticket for it.
2
 
 
3
 
Copyright (C) 2007 Canonical Ltd.
4
 
Author: Martin Pitt <martin.pitt@ubuntu.com>
5
 
 
6
 
This program is free software; you can redistribute it and/or modify it
7
 
under the terms of the GNU General Public License as published by the
8
 
Free Software Foundation; either version 2 of the License, or (at your
9
 
option) any later version.  See http://www.gnu.org/copyleft/gpl.html for
10
 
the full text of the license.
11
 
'''
12
 
 
13
 
import MultipartPostHandler, urllib2
14
 
 
15
 
def upload(blob):
16
 
    '''Upload given blob (file-like object) to Malone and return the ticket for
17
 
    it.
18
 
 
19
 
    Return None on error.'''
20
 
 
21
 
    ticket = None
22
 
 
23
 
    opener = urllib2.build_opener(MultipartPostHandler.MultipartPostHandler)
24
 
    result = opener.open('https://launchpad.net/+storeblob', 
25
 
        { 'FORM_SUBMIT': '1', 'field.blob': blob })
26
 
    ticket = result.info().get('X-Launchpad-Blob-Token')
27
 
 
28
 
    return ticket