Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/apport/crashdb_impl/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyc


5Oc@sdZddlZddlZddlZddlZddlZddlZddlZyddl	m
Z
Wn!ek
rddlm
Z
nXddl
mZddlmZddlZddlZejjdZdZdZd	ejjfd
YZddlZddlZddlZddlZeadej fdYZ!d
ej"fdYZ#eddZ$e%dkrddl&Z&ddlZddl'Z'ddl(Z(ddl)Z)eaea*ea+de&j,fdYZ-e&j.ndS(s,Crash database implementation for Launchpad.iN(tStringIO(t	HTTPError(t	Launchpads%~/.cache/apport/launchpad.credentialsccs{xt|D]l}y|jj}Wn!tk
rCtjdqnX|j}|jdsk|jdr|VqqWdS(Ns"Broken attachment on bug, ignorings.txts.gz(tdatatopenRtapportterrortfilenametendswith(tattachmentst
attachmenttftname((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pytfilter_filenames


	cCstd|DS(Ncss-|]#}t|jjdjVqdS(t/N(tintt	self_linktsplittpop(t.0ti((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pys	<genexpr>)s(tset(ttasks((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pytid_set'st
CrashDatabasecBs(eZdZdZedZdZedZddZ	dZ
dZdZd	Z
eddd
ZddZd
ZdZdZdZdZdZdZdZdZdZdZdZdZddZdZdZ dZ!RS(s5Launchpad implementation of crash database interface.cCs<tjdr%tjd|d<n|sj|jd}|ratd|jddd}qjt}ntjjj||||jd|_	|j	rd|kst
d	nd|kst
d
dtjj|_
||_||_|jst
d|_d|_tjd|jd
|_dS(sFInitialize Launchpad crash database.

        You need to specify a launchpadlib-style credentials file to
        access launchpad. If you supply None, it will use
        default_credentials_path (~/.cache/apport/launchpad.credentials).

        Recognized options are:
        - distro: Name of the distribution in Launchpad
        - project: Name of the project in Launchpad
        (Note that exactly one of "distro" or "project" must be given.)
        - launchpad_instance: If set, this uses the given launchpad instance
          instead of production (optional). This can be overriden or set by
          $APPORT_LAUNCHPAD_INSTANCE environment.
        - cache_dir: Path to a permanent cache directory; by default it uses a
          temporary one. (optional). This can be overridden or set by
          $APPORT_LAUNCHPAD_CACHE environment.
        - escalation_subscription: This subscribes the given person or team to
          a bug once it gets the 10th duplicate.
        - escalation_tag: This adds the given tag to a bug once it gets more
          than 10 duplicates.
        tAPPORT_LAUNCHPAD_INSTANCEtlaunchpad_instancet.s://iitdistrotprojects/Must not set both "project" and "distro" options0Need to have either "project" or "distro" optionsneed-%s-retracetAPPORT_LAUNCHPAD_CACHEt	cache_dirN(tostgetenvtgettdefault_credentials_pathRRtcrashdbRt__init__RtAssertionErrort	packagingtget_system_architecturetarch_tagtoptionstauthtNonet_CrashDatabase__launchpadt_CrashDatabase__lp_distrot_CrashDatabase__lpcache(tselfR+R*tlp_instance((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyR%/s(!						cCs|jr|jS|jjdr7|jjd}nd}tjj|j}|r{tjj|r{tj|ny:t	j
d|d|jddgd|jdd	|_Wn]tk
r}t
|d
r|j}nt|}tjd||jtjdnX|jS(
sReturn Launchpad instance.Rt
productionsapport-collecttlaunchpadlib_dirtallow_access_levelst
WRITE_PRIVATEtcredentials_filetversions1.0tcontentsZconnecting to Launchpad failed: %s
You can reset the credentials by removing the file "%s"ic(R-R*R"R tpathtdirnameR+tisdirtmakedirsRt
login_withR/t	ExceptionthasattrR8tstrRRtsystexit(R0Rtauth_dirtetmsg((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyt	launchpad_s*				ccsi|jstnxP|D]H}|jj|jksYtjd|j|jjr|VqqWdS(Ns^.+\(%s.*\)$(Rt
StopIterationtbug_target_nametlowertretmatch(R0Rtt((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyt_get_distro_taskss		
"cCs<|js
dS|jdkr5|jj|j|_n|jS(N(RR,R.RFt
distributions(R0((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyt	lp_distros
	c
Cs|j|sti}d|dj|d<|jd}|sU|dkrg|jd}n|r|dcd|7<nd|kr|dcd|dj7<nd|kr<|rd	|ksd
|krd|d<d
|d<|dcd|7<q<d|kr<d|d<d
|d<|dcd7<q<nd|krkd|dkrk|dcd7<nd|kr|d|d<ndddddddddg	}tj}|j|d|ddgd||j|jd t	||d!|j
}|st|S("sUpload given problem report return a handle for it.

        This should happen noninteractively.

        If the implementation supports it, and a function progress_callback is
        passed, that is called repeatedly with two arguments: the number of
        bytes already sent, and the total number of bytes to send. This can be
        used to provide a proper upload progress indication on frontends.
        s	apport-%stProblemTypetTagstPackageArchitecturetalltArchitecturet t
DistroReleasetVmCoretCoreDumptyestPrivateRtSubscriberss need-%s-retracet	Tracebacks need-duplicate-checktDuplicateSignaturesneed-duplicate-checktCheckboxSubmissionsHWDB-SubmissiontPackaget
RegressiontReproducibletTestedUpstreamtProcVersionSignaturetUnametNonfreeKernelModulest
extra_headerst	skip_keystpriority_fieldsithostname(tacceptsR&RIR"ttempfilet
TemporaryFilet
write_mimetflushtseektupload_blobtget_hostname(R0treporttprogress_callbackthdrtatordertmimetticket((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pytuploadsB
!



"

cCs@|jjd}|r6|dkr-d}q<d}nd}|S(s/Return the hostname for the Launchpad instance.Rtstagingsstaging.launchpad.nets
launchpad.devs
launchpad.net(R*R"(R0RRi((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyRqs		cCsi}|jd|j}|r[t|tdkrN|jd}n||d<n|j}|jjd}|sd|krd||j|d|tj|fSd||j|tj|fSnd|||tj|fSd	S(
s/Return an URL that should be opened after report has been uploaded
        and upload() returned handle.

        Should return None if no URL should be opened (anonymous filing without
        user comments); in that case this function should do whichever
        interactive steps it wants to perform.tTitletsUTF-8sfield.titleRt
SourcePackages,https://bugs.%s/%s/+source/%s/+filebug/%s?%ss!https://bugs.%s/%s/+filebug/%s?%sN(	R"tstandard_titlettypetencodeRqR*Rturllibt	urlencode(R0RrthandletargsttitleRiR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pytget_comment_urls 
$ cCsdt|S(sReturn URL for a given report ID.

        The report is passed in case building the URL needs additional
        information from it, such as the SourcePackage name.

        Return None if URL is not available or cannot be determined.
        s https://bugs.launchpad.net/bugs/(R@(R0Rrtid((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyt
get_id_urlscCsLtj}|jj|}tjd|jtj}|sbtjd|jtjtjB}n|stt	d|j
djdjddjdd	}d
|krd|kr|j
dd\}}|jd
d	d|j
d
dd}q|j
d
dd}n|jt|d
|krty|jj|d
<Wqttk
rp|j|d
<qtXnd|krd|jkrd|d<qd|jkrd|d<qd|jkrd|d<qd|jkrd|d<qtdt|jndj|j|d<d|kr?|d|d<n|j|d<xt|jD]}tjj|j\}	}
yd||	<Wn
q\nX|
dkr|j||	<q\|
dkr1y tj d|j||	<WqDt!k
r-}dt|kr
n|j"d|j||	<qDXq\t#d |jq\W|S(!s>Download the problem report from given ID and return a Report.s(ProblemType:.*)$s^--- \r?$[\r\n]*(.*)s8bug description must contain standard apport format dataisUTF-8s RUs
s
s

sUname:itDateRPs
apport-bugtBugsapport-crashtCrashsapport-kernelcrashtKernelCrashsapport-packageR_s(cannot determine ProblemType from tags: RQR{t
OriginalTitleR|s.txts.gztfileobjs
Not a gzipsUnknown attachment type: ($RtReportRFtbugsRJtsearchtdescriptiontStMR&tgroupRtreplaceRtloadRtdate_createdtctimetAttributeErrorttagst
ValueErrorR@tjoinRR
R	R R9tsplitextRtreadtgziptGzipFiletIOErrorRoR>(R0RRrtbtmRtpart1tpart2R
tkeytextRD((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pytdownloadsd%0-





 
cCs|jj|}|r5t|jt|}nd}tj}	|j|	d||	j|	j	dt
j|	}
|
j}|j
}|jst|j
}|jst|jdkst|sM|j}
|
jdd|kr'|
|djj7}
n|
|_|j|jj|}n|r|jd|jdtjdd	|_|jn"|jd
|jdtd|xZ|D]R}|jd|pd
d|jddd|jdtd|jdtqWdS(shUpdate the given report ID with all data from report.

        This creates a text comment with the "short" data (see
        ProblemReport.write_mime()), and creates attachments for all the
        bulk/binary data.

        If change_description is True, and the crash db implementation supports
        it, the short data will be put into the description instead (like in a
        new bug).

        comment will be added to the "short" data. If attachment_comment is
        given, it will be added to the attachment uploads.

        If key_filter is a list or set, then only those keys will be added.
        Rgis
text/plainsapport-collectedRQs
--- 
tdecodesUTF-8RR8tsubjecttcommentR|Rtcontent_typeRRtis_patchN(RFRRtkeysR,RkRlRmRnRotemailtmessage_from_filetwalktnexttis_multipartR&tget_content_typeRtappendRIRtlp_saveRtget_payloadtTrueRt
newMessaget
addAttachmenttget_filenametFalse(R0RRrRtchange_descriptiontattachment_commentt
key_filtertbugRgRwREtmsg_itertparttx((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pytupdateQsD



	
,

R|c	Cstjjj|||||jj|}d|krxc|jD]U}|jjj	drB|j
jd|d|_|j|jj|}PqBqBWn|j
rxE|jD]:}|jdkry|jWqtk
rqXqqWyA|j|jj}|jdkr2d|_|jnWntk
rFnX|j}|rtjd|j}|r|jd|kr|jd	||jd
|_y|jWntk
rnX|jj|}qqn|j||dS(sUpdate the given report ID for retracing results.

        This updates Stacktrace, ThreadStacktrace, StacktraceTop,
        and StacktraceSource. You can also supply an additional comment.
        R}s
#distributionRsCoreDump.gzt	UndecidedtMediums,^(.*crashed with SIG.* in )([^( ]+)(\(\).*$)iiiN(RR$Rt
update_tracesRFRt	bug_tasksttargettresource_type_linkRROtgetSourcePackageRthas_useful_stacktraceR	Rt
removeFromBugRRMRt
importanceRGtstacktrace_top_functionRJRKRt_subscribe_triaging_team(	R0RRrRRttaskRutfnR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyRsD

	
#
cCsH|jj|}tjd|j}|r8|jdStddS(sNGet 'DistroRelease: <release>' from the given report ID and return
        it.s"DistroRelease: ([-a-zA-Z0-9.+/ ]+)is)URL does not contain DistroRelease: fieldN(RFRRJRRRR(R0RRR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pytget_distro_releases

cCstjd|j}|jj|}g}x]|jD]R}|j|jj}|s]q6n|j	dkrrq6n|j
|jdq6W|S(s5Return list of affected source packages for given ID.s5/%s/(?:(?P<suite>[^/]+)/)?\+source/(?P<source>[^/]+)$tInvalids	Won't FixsFix Releasedtsource(Rs	Won't FixsFix Released(RJtcompileRRFRRRRRtstatusRR(R0Rt
bug_target_reRtresultRRK((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pytget_affected_packagess
cCs)|jj|}|jj|jjjkS(s3Check whether the user is the reporter of given ID.(RFRtownerRtme(R0RR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pytis_reporterscCsz|jj|}|jrtS|jj|jjjkr<tS|jjj}x(|j	j
D]}|d|krXtSqXWtS(sBCheck whether the user is eligible to update a report.

        A user should add additional information to an existing ID if (s)he is
        the reporter or subscribed, the bug is open, not a duplicate, etc. The
        exact policy and checks should be done according to  the particular
        implementation.
        tperson_link(RFRtduplicate_ofRRRRRRt
subscriptionstentries(R0RRRtsub((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyt
can_updates	cCsiy,|jjd|jdd}t|SWn6tk
rd}tjdt|tj	dnXdS(s}Return an ID set of all crashes which have not been retraced yet and
        which happened on the current host architecture.Rt
created_sinces
2011-08-01s"connecting to Launchpad failed: %sicN(
ROtsearchTasksR)RR>RRR@RARB(R0RRD((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pytget_unretracedscCsfy)|jjdddd}t|SWn6tk
ra}tjdt|tjdnXdS(s#Return an ID set of all crashes which have not been checked for
        being a duplicate.

        This is mainly useful for crashes of scripting languages such as
        Python, since they do not need to be retraced. It should not return
        bugs that are covered by get_unretraced().Rsneed-duplicate-checkRs
2011-08-01s"connecting to Launchpad failed: %sicN(	RORRR>RRR@RARB(R0RRD((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pytget_dup_unchecked
scCs|jjdd}t|S(sOReturn an ID set of all crashes which are not yet fixed.

        The list must not contain bugs which were rejected or duplicate.

        This function should make sure that the returned list is correct. If
        there are any errors with connecting to the crash database, it should
        raise an exception (preferably IOError).Rsapport-crash(RORR(R0R((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pytget_unfixeds	cCs5|jjjdtd|d|jj}|djS(sReturn the version of given source package in the latest release of
        given distribution.

        If 'distro' is None, we will look for a launchpad project .
        texact_matchtsource_namet
distro_seriesi(ROtmain_archivetgetPublishedSourcesRtcurrent_seriestsource_package_version(R0tpackagetsources((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyt_get_source_version(s
c	syjj|}Wntk
r(dSX|jr6dSt|j}jr^djjtfd|}|stfd|}|rdSnt	|dkrt
jdj|dS|r|j}yj
|jjdSWq[tk
rdSXqtfd	|}|rtfd
|}|s[dSqn2td|}|rzdStd|rdSd
S(sReturn the package version that fixes a given crash.

        Return None if the crash is not yet fixed, or an empty string if the
        crash is fixed, but it cannot be determined by which version. Return
        'invalid' if the crash report got invalidated, such as closed a
        duplicate or rejected.

        This function should make sure that the returned result is correct. If
        there are any errors with connecting to the crash database, it should
        raise an exception (preferably IOError).
        tinvalids(%s)cs"|jdko!|jjkS(NsFix Released(Rtbug_target_display_nameRI(R(tdistro_identifier(sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyt<lambda>Rscs+|jdko*|jjjjkS(NsFix Released(RRHRIR(R(R0(sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyRVsR|isVThere is more than one task fixed in %s %s, using first one to determine fixed versionics"|jdko!|jjkS(NRs	Won't FixtExpired(sInvalids	Won't FixR(RRRI(R(R(sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyRiscs"|jdko!|jjkS(NRs	Won't FixR(sInvalids	Won't FixsExpired(RRRI(R(R(sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyRlscSs
|jdkS(NsFix Released(R(R((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyRqscSs
|jdkS(NR(R(R((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyRwsN(RFRtKeyErrorRtlistRRRItfiltertlenRtwarningRRRRt
IndexErrorR,(	R0RRRtfixed_taskstfixed_distroRt
invalid_taskstnon_invalid_tasks((R0RsA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pytget_fixed_version6sN
				
		
		cCs(|jj|j}|r |jSdSdS(scReturn master ID for a duplicate bug.

        If the bug is not a duplicate, return None.
        N(RFRRRR,(R0RR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyR|sc	Cs.|jj|}|r||ks8tdt||jj|}|jr|j}|j}|j|krtjd||dSnxE|jD]:}|j	dkry|j
Wqtk
rqXqqW|jj|}|jdd|d
d|jj|}|j
r#t|_
n|js8||_nt|jdkrd|jkr|jd|jkr|jjdd|jkr|j|jdg|_|jnd|jkr|jjdd|jkr|jj|jd}|jd|qn|jrd|jks;d|jkr|j||d|dddddddg|jj|}|j}y|jdWntk
rnXy|jdWntk
rnX||_y|jWqtk
rqXqn|jrd|_n|jr*|jndS( slMark a crash id as duplicate of given master ID.

        If master is None, id gets un-duplicated.
        s+cannot mark bug %s as a duplicate of itselfsNBug %i was manually marked as a dupe of newer bug %i, not closing as duplicateNsCoreDump.gzsStacktrace.txtsThreadStacktrace.txtsProcMaps.txtsProcStatus.txts
Registers.txtsDisassembly.txtR8sThank you for taking the time to report this crash and helping to make this software better.  This particular crash has already been reported and is a duplicate of bug #%i, so is being marked as such.  Please look at the other bug report to see if there is any missing information that you can provide, or to see if there is a workaround for the bug.  Additionally, any further discussion regarding the bug should occur in the other report.  Please continue to report any other bugs you may find.RsThis bug is a duplicatei
tescalation_tagt
escalated_tags	 invalid tescalation_subscriptiontpersonsapport-request-retracesapport-failed-retraces)Updated stack trace from duplicate bug %iRt
StacktracetThreadStacktraceR_tDependenciestProcMapstProcCmdline(sCoreDump.gzsStacktrace.txtsThreadStacktrace.txtsProcMaps.txtsProcStatus.txts
Registers.txtsDisassembly.txt(RFRR&R@RRRRR	RRRRtprivateRRt
duplicatesR*RR"Rtpeoplet	subscribeRRtremoveRR,t_dirty_attributes(	R0RrRt	master_idRtmasterRutpR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pytclose_duplicates|"				
	
	
		



	

		cCs[|jj|}|jdd|dd|jj|}|jdg|_|jdS(spMark a crash id as reintroducing an earlier crash which is
        already marked as fixed (having ID 'master').R8sThis crash has the same stack trace characteristics as bug #%i. However, the latter was already fixed in an earlier package version than the one in this report. This might be a regression or because the problem is in a dependent package.RsPossible regression detectedsregression-retracerN(RFRRRR(R0RRR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pytmark_regressions	
cCsn|jj|}|j|jkrj|j}|j|j||_y|jWqjtk
rfqjXndS(sMark crash id as retraced.N(RFRR)RRRR(R0RRR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyt
mark_retraceds
	
cCs|jj|}|ry|j|jj}Wntk
rR|jd}nXd|_|j|jd|ddxw|j	D]:}|j
dkry|jWqtk
rqXqqWn/d|j
kr|j
dg|_
|jndS(	s%Mark crash id as 'failed to retrace'.iRR8Rs Crash report cannot be processedsCoreDump.gzsapport-failed-retraceN(RFRRMRRRGRRRR	RRRR(R0Rtinvalid_msgRRRu((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pytmark_retrace_faileds&
	

cCs|jj|}d|krxc|jD]U}|jjjdr&|jjd|d|_|j|jj|}Pq&q&Wnd|j	kr|j	}|j
d||_	|jn|j||dS(s/Mark crash id as checked for being a duplicate.R}s
#distributionRsneed-duplicate-checkN(RFRRRRRRORRRRR(R0RRrRRR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyt_mark_dup_checkeds


	
cCstjjj||}|s"|S||d<ytj|d}Wntk
rW|SX|j}|jdswt	SxM|D]E}|jdrd|ksd|krdSPn|js~Pq~q~W|S(sCheck if the crash db already knows about the crash signature.

        Check if the report has a DuplicateSignature, crash_signature(), or
        StacktraceAddressSignature, and ask the database whether the problem is
        already known. If so, return an URL where the user can check the status
        or subscribe (if available), or just return True if the report is known
        but there is no public URL. In that case the report will not be
        uploaded (i. e. upload() will not be called).

        Return None if the report does not have any signature or the crash
        database does not support checking for duplicates on the client side.

        The default implementation uses a text file format generated by
        duplicate_db_publish() at an URL specified by the "dupdb_url" option.
        Subclasses are free to override this with a custom implementation, such
        as a real database lookup.
        tDuplicateOfs/+textsbug:stags:sapport-failed-retracesapport-request-retraceN(RR$RtknownRturlopenRtreadlinet
startswithRR,tstrip(R0RrturlRtline((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyR,s&


cCsNd|kr*|djddkr*dSd|jj}|jd|dS(s-Subscribe the right triaging team to the bug.RVitUbuntuNs%s~ubuntu-crashes-universeR(RRFt	_root_uriR(R0RRrR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyRcs&N("t__name__t
__module__t__doc__R%tpropertyRFRMROR,RyRqRRRRRRRRRRRRRRRRRRRRRRR(((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyR,s<	0 		9	
	 	
	QH0						
				F		Z		
		7tHTTPSProgressConnectioncBseZdZdZRS(sWImplement a HTTPSConnection with an optional callback function for
    upload progress.cCststjj||dSd}t|}d}x||krt||tj}tjj|||||!||7}tj}||dkr|d9}q8||dkr8|d:}q8q8WdS(Niig?i(t_https_upload_callbackthttplibtHTTPSConnectiontsendRttime(R0Rtsentttotalt	chunksizett1tt2((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyR.s 


(R&R'R(R.(((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyR*|stHTTPSProgressHandlercBseZdZRS(cCs|jt|S(N(tdo_openR*(R0treq((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyt
https_opens(R&R'R8(((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyR5ss
launchpad.netcCsdd}|atjttj}d|}|j|idd6|d6}|jj	d}|S(s
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.
    shttps://%s/+storeblobt1tFORM_SUBMITs
field.blobsX-Launchpad-Blob-TokenN(
R,R+turllib2tbuild_openerR5tmultipartpost_handlertMultipartPostHandlerRtinfoR"(tblobRsRiRxtopenerR"R((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyRps
	t__main__t_TcBspeZdZdZdZdZdZedZdZ	dZ
dZdZd	Z
d
ZdZdZd
ZdZdZdZdZdZdZdZdZdZedZdZdZd&dZ dZ!dZ"dZ#dZ$dZ%d Z&d!Z'd"Z(d#Z)ed$d%Z*RS('t	coreutilscCsts|jant|_tj|_|jj|jjd|jd<|j|_|j	d|jj
|_|jj
|_dS(NRDR}slangpack-o-matic(
R$t
_get_instanceRRt
ref_reporttadd_os_infot
add_user_infot_file_uncommon_description_bugtuncommon_description_bugt_create_projectRt
known_test_idtknown_test_id2(R0((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pytsetUps	



cCs]|jjj|}|sY|jjjjd|dd|d|d|dd|dndS(s8Create a project using launchpadlib to be used by tests.Rtdisplay_nameRtsummaryRN(R$RFtprojectstnew_project(R0RR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyRKs

cCs7d}|jjjjddjd|d|jjS(sFile a bug report with an uncommon description.

            Example taken from real LP bug 269539. It contains only
            ProblemType/Architecture/DistroRelease in the description, and has
            free-form description text after the Apport data.
            sbproblem

ProblemType: Package
Architecture: amd64
DistroRelease: Ubuntu 8.10

more text

and more
Rsmixed description bugRR(R$RFRt	createBugRRO(R0tdesc((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyRIs
cCs
|jjS(s1Get the Launchpad hostname for the given crashdb.(R$Rq(R0((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyRiscCs|j}|j|j|j|j|j|j|jdd|d<d|d<|jj	|}|j
||j|j|}|j
||j|||}|j
|dk||fS(sNFile a SEGV crash report.

            Return (crash ID, report).
            s!crash crashed with SIGSEGV in f()s "]"
tShortGibberishsa
b
c
d
e

t
LongGibberishi(
t_generate_sigsegv_reporttadd_package_infottest_packageRGtadd_gdb_infoRHtassertEqualR~R$Ryt
assertTruet_get_bug_targett	_file_bug(R0trRt
bug_targetR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyt_file_segv_reports






cCsb|j\}}|a|jj||}tjjd|j|ftjjd|dS(s{upload() and get_comment_url() for SEGV crash

            This needs to run first, since it sets segv_report.
            s(https://%s/bugs/%i) s[%s] N(Ratsegv_reportR$RRAtstderrtwriteRi(R0RRrR"((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_1_report_segv$s
cCstjd}d|d<d|d<d|d<|j|j|j|j|j|jd|jj	|}|j
||j|j|}|j
||j|||}|j
|d	k|a
tjjd
|j|fdS(supload() and get_comment_url() for Python crash

            This needs to run early, since it sets python_report.
            Rs/bin/footExecutablePathsTraceback (most recent call last):
  File "/bin/foo", line 67, in fuzz
    print(weird)
NameError: global name 'weird' is not definedR\sboogus pybogusRQsHfoo crashed with NameError in fuzz(): global name 'weird' is not definedis(https://%s/bugs/%i) N(RRRXRYRGRHR[R~R$RyR\R]R^t
python_reportRARcRdRi(R0R_RR`R((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_1_report_python3s"






cCst|jjt}|j|dd|j|dd|j|d|jd|j|d|jd|j|d|jd|j|jd|jjd|j|jd	|jjd	t|d
j}|j|t|jjdt	j
jg|j|dd
|j|dj
d|j|d|j|j|dj|jd|jd|dk|jd|dk|jd|dk|jt|ddk|jd|k|jd|k|jd|k|jjt}t|d
j}|j|tddddt	j
jgdS( s
download()RPRR{s!crash crashed with SIGSEGV in f()RVRTRdRet
UserGroupsRQsapport-crashtSignalt11Rfs/crashR}R_RUsf (x=42)Rt
StacktraceTopR	RXiR
tDisassemblyt	Registerstboogustpybogussneed-duplicate-checkN(R$RRbR[RFR"RRR)RR'R(R\Rttest_srcpackageR RYRRg(R0R_R((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_2_downloadPs6%!cCs|jjt}|jd|k|jd|k|jd|k|jd|k|jd|k|jd|k|j|ddd	|d
<d|d<d|d<d
|d<|jjt|d|jjt}|jd|k|jd|k|jd|k|jd|k|jd|k|jd|k|jd|k|j|dd|jjjtj	}|jd|k|jd|kd|d
<d|d<d|d<|jjt|d|jjt}|jd|k|jd|k|jd|k|jd|k|jd|k|jd|k|jd|k|j|dd|jjjt}d|_
y|jWntk
rnXd|d
<|jjt|d|jjt}|j|dd|jjjt}d|_
y|jWntk
r]nXd|d
<|jjt|d|jjt}|j|ddd|d<d|d<d|d<|jjt|ddS( supdate_traces()RXR
RmRnRR	R{s!crash crashed with SIGSEGV in f()s?? ()Rls
long
tracesthread
even longer
tracetbogustFooBarsI can has a better retrace?sapport-crashsapport-collecteds=read () from /lib/libc.6.so
foo (i=1) from /usr/lib/libfoo.sos
good retrace!s$crash crashed with SIGSEGV in read()s)crash crashed with SIGSEGV in f() on exits!good retrace with title amendments,crash crashed with SIGSEGV in read() on exitscrash is crashysgood retrace with custom titleR|s"]"
sa
b
c
d
e

tStacktraceSourcettestsN(
R$RRbR\R[RtassertFalseRFRRRRR(R0R_RR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_3_update_tracesrs|






	

	




cCsd}tjd}||d<|jj|d}|j|jd|jd|d<|jj|d}|j|jdd|d<|jj|d}|j|jd	d
S(s&get_comment_url() for non-ASCII titless1ä♥2RR{i*s1/ubuntu/+filebug/42?field.title=1%C3%A4%E2%99%A52sUTF-8RDR}sC/ubuntu/+source/coreutils/+filebug/42?field.title=1%C3%A4%E2%99%A52N(RRR$RR\RR(R0RR_R"((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_get_comment_urls

cCsf|jjjdd}|jjjjddd|dd}|j}|j|dktj	j
d	|j|ftj
d
}d|d<d
|d<d|d<d|d<dd|d<|jj||ddt|jj|}|j|dd|j|dd|j|dd|j|ddd|j|jjj|jdgdS(s"update() with changing descriptionRtbashRstest description for test bug.RRttestbugis(https://%s/bugs/%i) Rsbogus→tOneLinersf()
g()
h(1)Rlslineone
linetwotShortGoosone
two
three
four
five
sixtDpkgTerminalLogsitVarLogDistupgradeBinGootNotMeRsapport-collectedN(R$RORRFRRSRR\RARcRdRiRRRRRR[R(R0R`RRR_((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_update_descriptions,		



cCsx|jjjdd}|jjjjddd|dd}|j}|j|dktj	j
d	|j|ftj
d
}d|d<d
|d<d|d<d|d<dd|d<|jj||ddt|jj|}|jd|k|jd|k|j|dd
|j|dd|j|ddd|j|jjj|jdgdS(supdate() with appending commentRRzRsPr0blem

--- 
ProblemType: BugRRR{is(https://%s/bugs/%i) Rsbogus→R|sf()
g()
h(1)Rlslineone
linetwoR}sone
two
three
four
five
sixR~siRtmeowRRPsapport-collectedN(R$RORRFRRSRR\RARcRdRiRRRRRRwR[R(R0R`RRR_((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_update_comments.		



c
Cs|jjjdd}|jjjjddd|dd}|j}|j|dktj	j
d	|j|ftj
d
}d|d<d
|d<d|d<d|d<dd|d<|jj||ddtddddg|jj|}|jd|k|j|dd|j|dd
|j|dd|jd|k|j|jjj|jgdS(supdate() with a key filterRRzRstest description for test bugRRR{is(https://%s/bugs/%i) Rsbogus→R|sf()
g()
h(1)Rlslineone
linetwoR}sone
two
three
four
five
sixR~siRRRRRPN(R$RORRFRRSRR\RARcRdRiRRRRRRwR[R(R0R`RRR_((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_update_filters.		



cCs'|j|jjt|jddS(sget_distro_release()RVN(R[R$RRbRF(R0((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_get_distro_release=scCs*|j|jjt|jdgdS(sget_affected_packages()R}N(R[R$RRbRF(R0((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_get_affected_packagesCscCs6|j|jjt|j|jjddS(s
is_reporter()iN(R\R$RRbRw(R0((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_is_reporterIscCs6|j|jjt|j|jjddS(scan_update()iN(R\R$RRbRw(R0((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_can_updateOscCs|j|jjtd	|j|jjtd	|jjt}|jj|t|j|j|jjt|j|jj|t|j|j|jjt|j|j|jjtd|jj|td	|j|jjtd	|j|jjtd	|jjt}|j	d|k|j	d|k|j	d|k|j	d|k|j	d|k|j	d|k|j	d|k|jjt
j|j|j|jj|t|j|j|jjt|j|jjt
j|jd	|jjt
j|jd	|jj|td	|jjt
j|jd	|j|jj|jd	|jj
t|j|jtd	S(
sduplicate handlingRRXRmRt
ProcStatusRnRR	N(R[R$RRbR,RRRRLRwRRRMRt_verify_marked_regression(R0R_((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_duplicatesUs>

cCs|jj}|jt|k|jt|k|jjt|jj}|jt|k|j||jt	tg|j|jj
td|jt|jjt|jj
t|jj}|jt|k|j||jt	tg|j|jj
td|jt|jjt|jj
td|jj}|jt|k|j||jt	tg|j|jj
tddS(s-processing status markings for signal crashessI don't like youRN(R$RR\RbRwRgRR[tunionRRR,t_mark_needs_retraceR(R0tunretraced_beforetunretraced_after((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_marking_segvs4	
	
	cCs|jj}|jt|k|jt|k|jjt|j|jj}|jt|k|j||j	t
tg|j|jjtddS(s2processing status markings for interpreter crashesN(
R$RR\RgRwRbRRFR[RRRR,(R0tunchecked_beforetunchecked_after((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_marking_pythons	cCs|jd}tjjd|j|f|jj|}|jj||td|d<d|d<d|d<|jj	||d	|jj|}|j
d
|kdS(supdating an invalid crash

            This simulates a race condition where a crash being processed gets
            invalidated by marking it as a duplicate.
            is(https://%s/bugs/%i) s=read () from /lib/libc.6.so
foo (i=1) from /usr/lib/libfoo.soRls
long
traceRsthread
even longer
traceR	s
good retrace!RXN(RaRARcRdRiR$RRRbRRw(R0RR_((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_update_traces_invalids


cCss|jt|jjt}|j|d|j|dj|jt|j	|jjtddS(sget_fixed_version() for fixed bugs

            Other cases are already checked in test_marking_segv() (invalid
            bugs) and test_duplicates (duplicate bugs) for efficiency.
            iN(
t_mark_report_fixedRbR$RtassertNotEqualR,R\tisdigitt_mark_report_newR[(R0t	fixed_ver((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_get_fixed_versions

cCs?tjjdpd}ttjjdidd6|d6S(sCreate a CrashDB instanceRRztLP_CREDENTIALStubuntuRR(R tenvironR"R(tklassR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyREs
cCsT|jjd}d|kr5|jjd|dS|rI|jj|S|jSdS(s&Return the bug_target for this report.RR}RN(R*R"RORRFRQ(R0tdbRrR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyR]scCs'|jj}d|krdSdSdS(s@Return the librarian hostname according to the LP hostname used.Rzsstaging.launchpadlibrarian.netslaunchpad.dev:58080N(R$Rq(R0Ri((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyt_get_librarian_hostnamescCs|jd|j}|jjjjd|}|jjj|d}x|jsktj	dqOW|j
}|jjjjd|dd|dd|d	d
|d|}	x"|dD]}|	j
d
|qWd|j}
xu|dD]i}|d}}
tjtj|
t|dd|j}|	jd|d|d|d|
qWx>|dD]2}|jjj|}|ro|	jd|qoqoWxJ|dD]>}|jjjd|jj|f}|	jd|qWt|	jS(sFile a bug report.R{ttokenRiRtextra_descriptionR
Rtinitial_tagsRRtcommentsR8s	http://%sR	t
file_alias_idRRRRtsubscribersRthwdb_submission_keyss(https://api.%s/beta/+hwdb/+submission/%st
submission(R"R~R$RFttemporary_blobstfetchRthasBeenProcessedR/tsleeptgetProcessedDataRRSRRRRtbasejoinR@RRRRRqtlinkHWSubmissionRR(R0R`RrRRt	bug_titlet	blob_infoR@tprocessed_blobRt
librarian_urlR
RRRt
subscriberRtsubmission_keyR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyR^sF	


	
$	cCsR|jjj|}|jj|jkrN|j|jjg|_|jndS(s$Mark a report ID as needing retrace.N(R$RFRR)RR(R0RR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyRAscCsF|jjj|}d|jkrB|jdg|_|jndS(s,Mark a report ID as needing duplicate check.sneed-duplicate-checkN(R$RFRRR(R0RR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyt_mark_needs_dupcheckIscCs[|jjj|}t|j}t|dks:t|d}d|_|jdS(sClose a report ID as "fixed".iisFix ReleasedN(	R$RFRRRRR&RR(R0RRRRL((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyRQs
	cCs[|jjj|}t|j}t|dks:t|d}d|_|jdS(sReopen a report ID as "new".iitNewN(	R$RFRRRRR&RR(R0RRRRL((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyR[s
	cCs-|jjj|}|jd|jkdS(s.Verify that report ID is marked as regression.sregression-retracerN(R$RFRR\R(R0RR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyRescCs#tjjdpd}ttjjdidd6|d6}|j|jdtjd}d|d	<d
|d<|j	|j
|j|jd|j|}|j
||j||}|j|jd|j|||}|j
|d
ktjjd|j|f|j|}d|d<d|d<d|d<|j||d|j|}|j|j|d|j|||j|j|j||j|j|j|d|j||d|j|j|d|j|j|ddS(s7reporting crashes against a project instead of a distroRRzRslangpack-o-maticRRRs/bin/fooRfsTraceback (most recent call last):
  File "/bin/foo", line 67, in fuzz
    print(weird)
NameError: global name 'weird' is not definedR\sHfoo crashed with NameError in fuzz(): global name 'weird' is not definedis(https://%s/bugs/%i) s=read () from /lib/libc.6.so
foo (i=1) from /usr/lib/libfoo.soRls
long
traceRsthread
even longer
traceR	s
good retrace!RN(R RR"RR[RR,RRRGRHR~RyR\R]RR^RARcRdRiRRRRRLR(R0RR$R_RR`R((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_projectks@









cCs^|jj|jj}|j|dd|j|dd|j|djddS(s*download() of uncommon description formatsRPR_RTtamd64RVsUbuntu N(R$RRJRR[R\R (R0R_((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_download_robustnesssc
	Cststdtjjdp'd}ttjjdidd6|d6dd	6d
d6}d}|jj|jdj	}d
}zxt
||dD]}|d7}tjj
d||jtj|t|jjt}|jd	|jk}tg|jD]}|j|k^q}	|dkrU|j||j|	q|j||j|	qWWdxHt
|||D]3}tjj
d||jtj|dqWXtjj
ddS(s,Escalating bugs with more than 10 duplicatess*you need to run test_1_report_segv() firstRRzRRRRt
omgkittensRsapport-hackersRii;i
is%i i
NsR%i s
(RbR&R RR"RRFRR*RtrangeRARcRdRRRRRtanyRRRwR\R,(
R0RRtcountRt	first_dupRthas_escalation_tagtsthas_escalation_subscription((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_escalations6


+

cCs|jt|jj}|jt|k|jjjt}|jrat|_|j	n|j
d}|jjjd|_|j	|j
d|jjjd|jjt|j|jj}|jt|k|j||jttg|jjjt}|j|j
djd|j|j
djd|j|j
djd|j|j
djd|j|jjtddS(	s9source package task fixup for marking interpreter crashesiRRRDRiscoreutils (Ubuntu)N(RRgR$RR\RFRR
RRRRNRtaddTaskRQRRFRwR[RRRHRRR,(R0RRRLR((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyttest_marking_python_task_mangles.
		


	Rkc	Csd}tj}tjj}zPtj}tj	t
j|tj|t
dd}|jdWdQXtjdddddgd	ksttjjdsttjd
ddd
dddgdtjtjjdsttjdddgdtjd	ks'ttjj|d|d<tjj|df|d<||d<|jWdtj|X|S(sCreate a test executable which will die with a SIGSEGV, generate a
            core dump for it, create a problem report with those two arguments
            (ExecutablePath and CoreDump) and call add_gdb_info().

            Return the apport.report.Report.
            scrash.ctwsS
int f(x) {
    int* p = 0; *p = x;
    return x+1;
}
int main() { return f(42); }
Ntgccs-gs-otcrashitgdbs--batchs--extrunsgenerate-core-file cores./crashtstdouttcoretreadelfs-nRfRXRj(R,R tgetcwdRRrRRktmkdtemptatexittregistertshutiltrmtreetchdirRRdt
subprocesstcallR&R9texiststPIPERRZ(Rtsignaltworkdirtorig_cwdtprtfd((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyRWs.

*
N(+R&R'RYRqRNRKRIR)RiRaReRhRrRxRyRRRRRRRRRRRRtclassmethodRER]RR,R^RRRRRRRRRRW(((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyRCsN							"	Q		 	#	!					3	#			
			C			
	
		2			#	'(/R(RRktos.pathR RJRRARt	cStringIORtImportErrortiotlaunchpadlib.errorsRtlaunchpadlib.launchpadRtapport.crashdbRR9t
expanduserR#R
RR$RR=R;R/R,R,R+R-R*tHTTPSHandlerR5RpR&tunittestRRRRbRgtTestCaseRCtmain(((sA/usr/lib/python2.7/dist-packages/apport/crashdb_impl/launchpad.pyt<module>s@H
		K0<\