Back to index

apport  2.4
Classes | Functions | Variables
apport.crashdb_impl.launchpad Namespace Reference

Classes

class  CrashDatabase
class  HTTPSProgressConnection
class  HTTPSProgressHandler
class  _T

Functions

def filter_filename
def id_set
def upload_blob

Variables

 Launchpad = None
tuple default_credentials_path = os.path.expanduser('~/.cache/apport/launchpad.credentials')
 _https_upload_callback = None
 crashdb = None
 _segv_report = None
 _python_report = None
 _uncommon_description_report = None

Function Documentation

Definition at line 41 of file launchpad.py.

00041 
00042 def filter_filename(attachments):
00043     for attachment in attachments:
00044         try:
00045             f = attachment.data.open()
00046         except HTTPError:
00047             apport.error('Broken attachment on bug, ignoring')
00048             continue
00049         name = f.filename
00050         if name.endswith('.txt') or name.endswith('.gz'):
00051             yield f
00052 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 53 of file launchpad.py.

00053 
00054 def id_set(tasks):
00055     # same as set(int(i.bug.id) for i in tasks) but faster
00056     return set(int(i.self_link.split('/').pop()) for i in tasks)
00057 

Here is the caller graph for this function:

def apport.crashdb_impl.launchpad.upload_blob (   blob,
  progress_callback = None,
  hostname = 'launchpad.net' 
)
Upload blob (file-like object) to Launchpad.

progress_callback can be set to a function(sent, total) which is regularly
called with the number of bytes already sent and total number of bytes to
send. It is called every 0.5 to 2 seconds (dynamically adapted to upload
bandwidth).

Return None on error, or the ticket number on success.

By default this uses the production Launchpad hostname. Set
hostname to 'launchpad.dev' or 'staging.launchpad.net' to use another
instance for testing.

Definition at line 993 of file launchpad.py.

00993 
00994 def upload_blob(blob, progress_callback=None, hostname='launchpad.net'):
00995     '''Upload blob (file-like object) to Launchpad.
00996 
00997     progress_callback can be set to a function(sent, total) which is regularly
00998     called with the number of bytes already sent and total number of bytes to
00999     send. It is called every 0.5 to 2 seconds (dynamically adapted to upload
01000     bandwidth).
01001 
01002     Return None on error, or the ticket number on success.
01003 
01004     By default this uses the production Launchpad hostname. Set
01005     hostname to 'launchpad.dev' or 'staging.launchpad.net' to use another
01006     instance for testing.
01007     '''
01008     ticket = None
01009     url = 'https://%s/+storeblob' % hostname
01010 
01011     global _https_upload_callback
01012     _https_upload_callback = progress_callback
01013 
01014     # build the form-data multipart/MIME request
01015     data = email.mime.multipart.MIMEMultipart()
01016 
01017     submit = email.mime.text.MIMEText('1')
01018     submit.add_header('Content-Disposition', 'form-data; name="FORM_SUBMIT"')
01019     data.attach(submit)
01020 
01021     form_blob = email.mime.base.MIMEBase('application', 'octet-stream')
01022     form_blob.add_header('Content-Disposition', 'form-data; name="field.blob"; filename="x"')
01023     form_blob.set_payload(blob.read().decode('ascii'))
01024     data.attach(form_blob)
01025 
01026     data_flat = BytesIO()
01027     if sys.version_info.major == 2:
01028         gen = email.generator.Generator(data_flat, mangle_from_=False)
01029     else:
01030         gen = email.generator.BytesGenerator(data_flat, mangle_from_=False)
01031     gen.flatten(data)
01032 
01033     # do the request; we need to explicitly set the content type here, as it
01034     # defaults to x-www-form-urlencoded
01035     req = Request(url, data_flat.getvalue())
01036     req.add_header('Content-Type', 'multipart/form-data; boundary=' + data.get_boundary())
01037     opener = build_opener(HTTPSProgressHandler)
01038     result = opener.open(req)
01039     ticket = result.info().get('X-Launchpad-Blob-Token')
01040 
01041     assert ticket
01042     return ticket
01043 
01044 #
01045 # Unit tests
01046 #

Here is the caller graph for this function:


Variable Documentation

Definition at line 949 of file launchpad.py.

Definition at line 1053 of file launchpad.py.

Definition at line 1052 of file launchpad.py.

Definition at line 1054 of file launchpad.py.

Definition at line 1051 of file launchpad.py.

tuple apport.crashdb_impl.launchpad.default_credentials_path = os.path.expanduser('~/.cache/apport/launchpad.credentials')

Definition at line 38 of file launchpad.py.

Definition at line 33 of file launchpad.py.