本文整理汇总了Python中InternetArchiveCommon.make_docketxml_request方法的典型用法代码示例。如果您正苦于以下问题:Python InternetArchiveCommon.make_docketxml_request方法的具体用法?Python InternetArchiveCommon.make_docketxml_request怎么用?Python InternetArchiveCommon.make_docketxml_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InternetArchiveCommon
的用法示例。
在下文中一共展示了InternetArchiveCommon.make_docketxml_request方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_documents_from_docket
# 需要导入模块: import InternetArchiveCommon [as 别名]
# 或者: from InternetArchiveCommon import make_docketxml_request [as 别名]
def delete_documents_from_docket(court, casenum, documents):
# Step 1: Get docket and convert into DocketXML
docketstring, fetcherror = IADirect.get_docket_string(court, casenum)
if not docketstring:
print "Could not find docket on IA, exiting...."
exit()
ia_docket, message = DocketXML.parse_xml_string(docketstring)
if not ia_docket:
print "Docket parsing error: %s.%s, exiting...." % (court, casenum)
exit()
# Step 2: Remove documents from DocketXML object
for document in documents:
ia_docket.remove_document(document.docnum, document.subdocnum)
# Step 3: upload modified xml
docketbits = ia_docket.to_xml()
request = IACommon.make_docketxml_request(docketbits, court, casenum,
ia_docket.casemeta)
success_status = False
try:
response = urllib2.urlopen(request)
except urllib2.HTTPError, e:
if e.code == 201 or e.code == 200: # 201 Created: Success!
print "Updated %s %s docket.xml" % (court, casenum)
success_status = True
示例2: put_docket
# 需要导入模块: import InternetArchiveCommon [as 别名]
# 或者: from InternetArchiveCommon import make_docketxml_request [as 别名]
def put_docket(docket, court, casenum, casemeta_diff=1):
docketbits = docket.to_xml()
request = IACommon.make_docketxml_request(docketbits, court, casenum,
docket.casemeta)
put_result, put_msg = _dispatch_direct_put(request)
if put_result:
cleanup_docket_put(court, casenum, docket, metadiff=casemeta_diff)
return put_result, put_msg
示例3: upload_docket
# 需要导入模块: import InternetArchiveCommon [as 别名]
# 或者: from InternetArchiveCommon import make_docketxml_request [as 别名]
def upload_docket(docket, nonce):
"""Case should be locked prior to this method"""
ia_docket, message = _get_docket_from_IA(docket)
if ia_docket:
docket.merge_docket(ia_docket)
# Don't upload if nothing has changed
if docket == ia_docket:
return True, 'Unmodified'
docket.nonce = nonce
#TK: Check that it's okay to always request a new bucket made
request = IACommon.make_docketxml_request(docket.to_xml(),
docket.get_court(),
docket.get_casenum(),
docket.casemeta,
makenew=True)
success, msg = _post_request(request)
if not success:
logger.error('XML Docket upload for %s.%s failed: %s', docket.get_court(),
docket.get_casenum(),
msg)
return False, msg
logger.info('XML Docket upload for %s.%s succeeded', docket.get_court(),
docket.get_casenum())
# TK: Maybe handle this in a separate function that can deal with html?
# Assuming this is sucessful, also upload an update to the html page
request = IACommon.make_dockethtml_request(docket.to_html(),
docket.get_court(),
docket.get_casenum(),
docket.casemeta)
success, msg = _post_request(request)
if not success:
logger.error('HTML Docket upload for %s.%s failed: %s', docket.get_court(),
docket.get_casenum(),
msg)
return False, msg
logger.info('HTML Docket upload for %s.%s succeeded', docket.get_court(),
docket.get_casenum())
return success, msg
示例4: put_docket
# 需要导入模块: import InternetArchiveCommon [as 别名]
# 或者: from InternetArchiveCommon import make_docketxml_request [as 别名]
def put_docket(docket, court, casenum, ppentry, newbucket=0, casemeta_diff=1):
# Put the docket to IA
docketbits = docket.to_xml()
request = IACommon.make_docketxml_request(docketbits, court, casenum,
docket.casemeta, newbucket)
put_result, put_msg = _dispatch_put(request, ppentry)
if put_result:
html_put_msg = IADirect.cleanup_docket_put(court, casenum, docket,
metadiff=casemeta_diff)
print " gov.uscourts.%s.%s.docket.html upload: %s" % (court,
unicode(
casenum),
html_put_msg)
DocumentManager.update_local_db(docket)
return put_result, put_msg