• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python xmltramp.parse函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中xmltramp.parse函数的典型用法代码示例。如果您正苦于以下问题:Python parse函数的具体用法?Python parse怎么用?Python parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了parse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setUp

    def setUp(cls):
        # Create two unique labs
        lab1 = data_setup.create_labcontroller(fqdn=u'lab_%d' %
                                               int(time.time() * 1000))
        lab2 = data_setup.create_labcontroller(fqdn=u'lab_%d' %
                                               int(time.time() * 1000))

        # Create two distros and only put one in each lab.
        cls.distro_tree1 = data_setup.create_distro_tree()
        cls.distro_tree2 = data_setup.create_distro_tree()
        session.flush()
        cls.distro_tree1.lab_controller_assocs = [LabControllerDistroTree(
                lab_controller=lab2, url=u'http://notimportant')]
        cls.distro_tree2.lab_controller_assocs = [LabControllerDistroTree(
                lab_controller=lab1, url=u'http://notimportant')]

        # Create a user
        user = data_setup.create_user()

        # Create two systems but only put them in lab1.
        system1 = data_setup.create_system(owner=user)
        system2 = data_setup.create_system(owner=user)
        system1.lab_controller = lab1
        system2.lab_controller = lab1

        session.flush()

        # Create two jobs, one requiring distro_tree1 and one requiring distro_tree2
        job = '''
            <job>
                <whiteboard>%s</whiteboard>
                <recipeSet>
                    <recipe>
                        <distroRequires>
                            <distro_name op="=" value="%s" />
                        </distroRequires>
                        <hostRequires/>
                        <task name="/distribution/install" role="STANDALONE">
                            <params/>
                        </task>
                    </recipe>
                </recipeSet>
            </job>
                 ''' 
        xmljob1 = XmlJob(xmltramp.parse(job % (cls.distro_tree1.distro.name,
                cls.distro_tree1.distro.name)))
        xmljob2 = XmlJob(xmltramp.parse(job % (cls.distro_tree2.distro.name,
                cls.distro_tree2.distro.name)))

        cls.job1 = Jobs().process_xmljob(xmljob1, user)
        cls.job2 = Jobs().process_xmljob(xmljob2, user)
开发者ID:sujithshankar,项目名称:beaker,代码行数:51,代码来源:test_deadrecipes.py


示例2: test_namespaces_repr

    def test_namespaces_repr(self):
        doc = Namespace("http://example.org/bar")
        bbc = Namespace("http://example.org/bbc")
        dc = Namespace("http://purl.org/dc/elements/1.1/")
        d = parse("""<doc version="2.7182818284590451"
        xmlns="http://example.org/bar"
        xmlns:dc="http://purl.org/dc/elements/1.1/"
        xmlns:bbc="http://example.org/bbc">
            <author>John Polk and John Palfrey</author>
            <dc:creator>John Polk</dc:creator>
            <dc:creator>John Palfrey</dc:creator>
            <bbc:show bbc:station="4">Buffy</bbc:show>
        </doc>""")
        assert repr(d) == '<doc version="2.7182818284590451">...</doc>'
        # I supect py3 does not see equality in type below.
        #assert d.__repr__(1) == '<doc xmlns:bbc="http://example.org/bbc" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://example.org/bar" version="2.7182818284590451"><author>John Polk and John Palfrey</author><dc:creator>John Polk</dc:creator><dc:creator>John Palfrey</dc:creator><bbc:show bbc:station="4">Buffy</bbc:show></doc>'
        #assert d.__repr__(1, 1) == '<doc xmlns:bbc="http://example.org/bbc" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://example.org/bar" version="2.7182818284590451">\n\t<author>John Polk and John Palfrey</author>\n\t<dc:creator>John Polk</dc:creator>\n\t<dc:creator>John Palfrey</dc:creator>\n\t<bbc:show bbc:station="4">Buffy</bbc:show>\n</doc>'
        assert repr(parse("<doc xml:lang='en' />")) == '<doc xml:lang="en"></doc>'
        self.assertEqual(d.author, d['author'])
        assert d.author == "John Polk and John Palfrey"
        assert d.author._name == doc.author
        assert str(d[dc.creator]) == "John Polk"
        assert d[dc.creator]._name == dc.creator
        assert str(d[dc.creator:][1]) == "John Palfrey"
        d[dc.creator] = "Me!!!"
        assert str(d[dc.creator]) == "Me!!!"
        assert len(d[dc.creator:]) == 1
        d[dc.creator:] = "You!!!"
        assert len(d[dc.creator:]) == 2
        assert d[bbc.show](bbc.station) == "4"
        d[bbc.show](bbc.station, "5")
        assert d[bbc.show](bbc.station) == "5"

        e = Element('e')
        e.c = '<img src="foo">'
        assert e.__repr__(1) == '<e><c>&lt;img src="foo"></c></e>'
        e.c = '2 > 4'
        assert e.__repr__(1) == '<e><c>2 > 4</c></e>'
        e.c = 'CDATA sections are <em>closed</em> with ]]>.'
        assert e.__repr__(1) == '<e><c>CDATA sections are &lt;em>closed&lt;/em> with ]]&gt;.</c></e>'
        e.c = parse('<div xmlns="http://www.w3.org/1999/xhtml">i<br /><span></span>love<br />you</div>')
        assert e.__repr__(1) == '<e><c><div xmlns="http://www.w3.org/1999/xhtml">i<br /><span></span>love<br />you</div></c></e>'

        e = Element('e')
        e('c', 'that "sucks"')
        assert e.__repr__(1) == '<e c="that &quot;sucks&quot;"></e>'
        assert quote("]]>") == "]]&gt;"
        assert quote('< dkdkdsd dkd sksdksdfsd fsdfdsf]]> kfdfkg >') == '&lt; dkdkdsd dkd sksdksdfsd fsdfdsf]]&gt; kfdfkg >'
        assert parse('<x a="&lt;"></x>').__repr__(1) == '<x a="&lt;"></x>'
        assert parse('<a xmlns="http://a"><b xmlns="http://b"/></a>').__repr__(1) == '<a xmlns="http://a"><b xmlns="http://b"></b></a>'
开发者ID:tBaxter,项目名称:xmltramp2,代码行数:50,代码来源:tests.py


示例3: get_youtube_data

def get_youtube_data(video):
    """
    Helper to extract video and thumbnail from youtube
    """
    video.source = 'youtube'
    if 'youtube.com/watch' in video.url:
        parsed = urlparse.urlsplit(video.url)
        query  = urlparse.parse_qs(parsed.query)
        try:
            video.key  = query.get('v')[0]
        except IndexError:
            video.key = None
    else:
        video.key = video.url.rsplit('/', 1)[1]
    video.embed_src = 'http://www.youtube.com/embed/'
    #http://gdata.youtube.com/feeds/api/videos/Agdvt9M3NJA
    api_url = 'http://gdata.youtube.com/feeds/api/videos/%s' % video.key
    video_data = urllib.urlopen(api_url).read()
    xml = xmltramp.parse(video_data)

    video.title = unicode(xml.title)
    video.slug = slugify(video.title)
    video.summary = unicode(xml.content)
    video.thumb_url = xml[xml_media.group][xml_media.thumbnail:][1]('url')
    return video
开发者ID:kennethlove,项目名称:Tango,代码行数:25,代码来源:helpers.py


示例4: getPhotoListingFromPhotoSet

 def getPhotoListingFromPhotoSet( self, photoSetId, page=1):
     #print "Getting photo listing for photoset", photoSetId, "for page", page, "...",
     d = {
         api.method   : "flickr.photosets.getPhotos",
         api.token    : str(self.token),
         api.perms    : str(self.perms),
         "photoset_id": str( photoSetId ),
         "per_page"   : str( 500 ),
         "page"       : str( page )
     }
     sig = self.signCall( d )
     d[ api.sig ] = sig
     d[ api.key ] = FLICKR[ api.key ]
     url = self.build_request(api.rest, d, ())
     xml = urllib2.urlopen( url ).read()
     res = xmltramp.parse(xml)
     if ( self.isGood( res ) ):
         #print "successful."
         photos = []
         for photo in res.photoset:
             photos.append(photo('title').encode('ascii', 'ignore'))
         if photoSetId in self.listings :
             self.listings[photoSetId].extend(photos)
         else :
             self.listings[photoSetId] = photos
         if int(res.photoset('page')) < int(res.photoset('pages')) :
             self.getPhotoListingFromPhotoSet(photoSetId, page+1)
     else :
         print "Problem while getting photo listing for photoset",photoSetId
         self.reportError( res )
     sys.stdout.flush()
开发者ID:mwerlen,项目名称:flickr_uploadr,代码行数:31,代码来源:uploadr.py


示例5: createPhotoSet

 def createPhotoSet( self, photoSetIdFile, directoryName, photoId):
     print "Creating photoSet for folder", directoryName , "...",
     d = {
         api.method   : "flickr.photosets.create",
         api.token    : str(self.token),
         api.perms    : str(self.perms),
         "title"      : str(directoryName),
         "description": str(directoryName),
         "primary_photo_id"   : str(photoId)
     }
     sig = self.signCall( d )
     d[ api.sig ] = sig
     d[ api.key ] = FLICKR[ api.key ]        
     url = self.build_request(api.rest, d, ())    
     xml = urllib2.urlopen( url ).read()
     res = xmltramp.parse(xml)
     if ( self.isGood( res ) ):
         print "successful."
         photoSetId  = res.photoset('id')
         self.listings[photoSetId] = [];
         self.setCachedPhotoSetId(photoSetIdFile, photoSetId)
     else :
         print "problem.."
         self.reportError( res )
     sys.stdout.flush()
开发者ID:mwerlen,项目名称:flickr_uploadr,代码行数:25,代码来源:uploadr.py


示例6: uploadImage

 def uploadImage( self, image ):
     if ( not self.isAlreadyUploaded(image) ):
         print "Uploading ", image , "...",
         try:
             photo = ('photo', image, open(image,'rb').read())
             filename = self.getImageTitle(image)
             d = {
                 api.token   : str(self.token),
                 api.perms   : str(self.perms),
                 "tags"      : str( FLICKR["tags"] ),
                 "is_public" : str( FLICKR["is_public"] ),
                 "is_friend" : str( FLICKR["is_friend"] ),
                 "is_family" : str( FLICKR["is_family"] ),
                 "title"     : str( filename )
             }
             sig = self.signCall( d )
             d[ api.sig ] = sig
             d[ api.key ] = FLICKR[ api.key ]        
             url = self.build_request(api.upload, d, (photo,))    
             xml = urllib2.urlopen( url ).read()
             res = xmltramp.parse(xml)
             if ( self.isGood( res ) ):
                 print "successful."
                 self.addImageToFlickrSet( res.photoid, image )
             else :
                 print "problem.."
                 self.reportError( res )
             sys.stdout.flush()
         except:
             print str(sys.exc_info())
     else:
         #print "Already uploaded image", image
         pass
开发者ID:mwerlen,项目名称:flickr_uploadr,代码行数:33,代码来源:uploadr.py


示例7: getResponse

    def getResponse( self, url ):
        """
        Send the url and get a response.  Let errors float up
        """

        xml = urllib2.urlopen( url ).read()
        return xmltramp.parse( xml )
开发者ID:dinResita,项目名称:uploadr.py,代码行数:7,代码来源:uploadr.py


示例8: uploadImage

 def uploadImage( self, image ):
     if ( not self.uploaded.has_key( image ) ):
         print "Uploading ", image , "...",
         try:
             photo = ('photo', image, open(image,'rb').read())
             d = {
                 api.token   : str(self.token),
                 api.perms   : str(self.perms),
                 "tags"      : str( FLICKR["tags"] ),
                 "is_public" : str( FLICKR["is_public"] ),
                 "is_friend" : str( FLICKR["is_friend"] ),
                 "is_family" : str( FLICKR["is_family"] )
             }
             sig = self.signCall( d )
             d[ api.sig ] = sig
             d[ api.key ] = FLICKR[ api.key ]        
             url = self.build_request(api.upload, d, (photo,))    
             xml = urllib2.urlopen( url ).read()
             res = xmltramp.parse(xml)
             if ( self.isGood( res ) ):
                 print "successful."
                 self.logUpload( res.photoid, image )
                 message = "Uploaded photo " + image
                 #self.growlNotify( "Photo uploaded", message)
                 return True
             else :
                 print "problem.."
                 self.reportError( res )
                 return False
         except:
             print str(sys.exc_info())
开发者ID:carylee,项目名称:uploadr.py,代码行数:31,代码来源:uploadr.py


示例9: uploadImage

    def uploadImage( self, image ):
        """ uploadImage
        """
	if self.history.uploaded(image):
	  print "Already uploaded ", image, ", skipping."
	else:
	    success = False

	    while not success:
	      print "Uploading ", image , "..."
	      try:
		  photo = ('photo', image, open(image,'rb').read())
		  d = {
		      api.token   : str(self.token),
		      api.perms   : str(self.perms),
		      "tags"      : str( FLICKR["tags"] ),
		      "is_public" : str( FLICKR["is_public"] ),
		      "is_friend" : str( FLICKR["is_friend"] ),
		      "is_family" : str( FLICKR["is_family"] )
		  }
		  sig = self.signCall( d )
		  d[ api.sig ] = sig
		  d[ api.key ] = FLICKR[ api.key ]
		  url = self.build_request(api.upload, d, (photo,))
		  xml = urllib2.urlopen( url ).read()
		  res = xmltramp.parse(xml)
		  if self.isGood(res):
		      print "successful."
		      self.logUpload(res.photoid, image)
		      success = True
		  else:
		      print "problem."
		      self.reportError( res )
	      except:
		  logging.exception('Failed upload')
开发者ID:brett-w-thompson,项目名称:uploadr-stdin,代码行数:35,代码来源:uploadr-stdin.py


示例10: uploadImage

    def uploadImage(self, image):
        """ uploadImage
        """

        if not self.uploaded.has_key(image):
            print("Uploading ", image, "...")
            try:
                photo = ("photo", image, open(image, "rb").read())
                d = {
                    api.token: str(self.token),
                    api.perms: str(self.perms),
                    "title": str(FLICKR["title"]),
                    "description": str(FLICKR["description"]),
                    "tags": str(FLICKR["tags"]),
                    "is_public": str(FLICKR["is_public"]),
                    "is_friend": str(FLICKR["is_friend"]),
                    "is_family": str(FLICKR["is_family"]),
                }
                sig = self.signCall(d)
                d[api.sig] = sig
                d[api.key] = FLICKR[api.key]
                url = self.build_request(api.upload, d, (photo,))
                xml = urllib2.urlopen(url).read()
                res = xmltramp.parse(xml)
                if self.isGood(res):
                    print("successful.")
                    self.logUpload(res.photoid, image)
                else:
                    print("problem..")
                    self.reportError(res)
            except:
                print(str(sys.exc_info()))
开发者ID:priestd09,项目名称:flickrUploadr,代码行数:32,代码来源:uploadr.py


示例11: uploadImage

    def uploadImage( self, image ):
        if ( not (LOG_UPLOADED and self.uploaded.has_key( image ) ) ):
            print "Uploading ", image , "...",
            try:
                photo = ('photo', image, open(image,'rb').read())
                d = {
                    api.token   : str(self.token),
                    api.perms   : str(self.perms),
                    "tags"      : str( FLICKR["tags"] ),
                    "is_public" : str( FLICKR["is_public"] ),
                    "is_friend" : str( FLICKR["is_friend"] ),
                    "is_family" : str( FLICKR["is_family"] )
                }
                sig = self.signCall( d )
                d[ api.sig ] = sig
                d[ api.key ] = FLICKR[ api.key ]        
                url = self.build_request(api.upload, d, (photo,))    
                xml = urllib2.urlopen( url ).read()
                res = xmltramp.parse(xml)
                if ( self.isGood( res ) ):
                    print "successful."
                    if ( LOG_UPLOADED ):
                        self.logUpload( res.photoid, image )
                    return res.photoid
                else :
                    print "problem.."
                    self.reportError( res )
	    except KeyboardInterrupt:
		print "stopping:";
		if (LOG_UPLOADED): self.uploaded.close();
		sys.exit(-1);		    
            except:
        	print "ERROR"
                print str(sys.exc_info())
开发者ID:elek,项目名称:uploadr.py,代码行数:34,代码来源:uploadr.py


示例12: post

	def post(self, conn=None, alwaysReturnList=False):
		headers = { "User-Agent": "BeatBox/" + __version__,
					"SOAPAction": "\"\"",
					"Content-Type": "text/xml; charset=utf-8" }
		if gzipResponse:
			headers['accept-encoding'] = 'gzip'
		if gzipRequest:
			headers['content-encoding'] = 'gzip'					
		close = False
		(scheme, host, path, params, query, frag) = urlparse(self.serverUrl)
		if conn == None:
			conn = makeConnection(scheme, host)
			close = True
		conn.request("POST", path, self.makeEnvelope(), headers)
		response = conn.getresponse()
		rawResponse = response.read()
		if response.getheader('content-encoding','') == 'gzip':
			rawResponse = gzip.GzipFile(fileobj=StringIO(rawResponse)).read()
		if close:
			conn.close()
		tramp = xmltramp.parse(rawResponse)
		try:
			faultString = str(tramp[_tSoapNS.Body][_tSoapNS.Fault].faultstring)
			faultCode   = str(tramp[_tSoapNS.Body][_tSoapNS.Fault].faultcode).split(':')[-1]
			raise SoapFaultError(faultCode, faultString)
		except KeyError:
			pass
		# first child of body is XXXXResponse
		result = tramp[_tSoapNS.Body][0]
		# it contains either a single child, or for a batch call multiple children
		if alwaysReturnList or len(result) > 1:
			return result[:]
		else:
			return result[0]
开发者ID:3dfxmadscientist,项目名称:odoo-extra-1,代码行数:34,代码来源:beatbox.py


示例13: test_uploading_job_with_invalid_hostRequires_raises_exception

 def test_uploading_job_with_invalid_hostRequires_raises_exception(self):
     session.begin()
     try:
         xmljob = XmlJob(xmltramp.parse('''
             <job>
                 <whiteboard>job with invalid hostRequires</whiteboard>
                 <recipeSet>
                     <recipe>
                         <distroRequires>
                             <distro_name op="=" value="BlueShoeLinux5-5" />
                         </distroRequires>
                         <hostRequires>
                             <memory op=">=" value="500MB" />
                         </hostRequires>
                         <task name="/distribution/install" role="STANDALONE">
                             <params/>
                         </task>
                     </recipe>
                 </recipeSet>
             </job>
             '''))
         self.assertRaises(BX, lambda: self.controller.process_xmljob(xmljob, self.user))
     finally:
         session.rollback()
         session.close()
开发者ID:ustbgaofan,项目名称:beaker,代码行数:25,代码来源:test_jobs.py


示例14: main

def main():
    """
    Search for wishlists using command line arguments.
    """
    # Leaving out the program name, grab all space-separated arguments.
    name   = " ".join(sys.argv[1:])
    
    # Construct the list of arguments for the AWS query
    args = {
        'Service'        : 'AWSECommerceService',
        'Operation'      : 'ListSearch',
        'ListType'       : 'WishList',
        'SubscriptionId' : AWS_ID,
        'Name'           : name
    }
    
    # Build the URL for the API call using the base URL and params.
    url = "%s?%s" % (AWS_URL, urllib.urlencode(args))
    
    # Perform the query, fetch and parse the results.
    data  = HTTPCache(url).content()
    doc   = xmltramp.parse(data)
    
    # Print out the list IDs found.
    lists = [ x for x in doc.Lists if 'List' in x._name ]
    for list in lists:
        print '%15s: %s' % ( list.ListId, list.CustomerName )
开发者ID:lmorchard,项目名称:hacking_rss_and_atom,代码行数:27,代码来源:ch13_amazon_find_wishlist.py


示例15: uploadImage

 def uploadImage( self, image ):
     print "Uploading ", image , "..."
     try:
         photo = ('photo', image, open(image,'rb').read())
         d = {
             api.token   : str(self.token),
             api.perms   : str(self.perms),
             "tags"      : str( FLICKR["tags"] ),
             "is_public" : str( FLICKR["is_public"] ),
             "is_friend" : str( FLICKR["is_friend"] ),
             "is_family" : str( FLICKR["is_family"] )
         }
         sig = self.signCall( d )
         d[ api.sig ] = sig
         d[ api.key ] = FLICKR[ api.key ]        
         url = self.build_request(api.upload, d, (photo,))    
         xml = urllib2.urlopen( url ).read()
         res = xmltramp.parse(xml)
         if ( self.isGood( res ) ):
             print "successful."
             self.logUpload( image )
             self.addPhotoToSet(image, res.photoid)
         else :
             print "problem.."
             self.reportError( res )
     except:
         print str(sys.exc_info())
开发者ID:ElJeffe,项目名称:dotfiles,代码行数:27,代码来源:flickrUploadr.py


示例16: test_abort_recipe_bubbles_status_to_job

    def test_abort_recipe_bubbles_status_to_job(self):
        xmljob = XmlJob(xmltramp.parse('''
            <job>
                <whiteboard>job </whiteboard>
                <recipeSet>
                    <recipe>
                        <distroRequires>
                            <distro_name op="=" value="BlueShoeLinux5-5" />
                        </distroRequires>
                        <hostRequires/>
                        <task name="/distribution/install" role="STANDALONE">
                            <params/>
                        </task>
                    </recipe>
                </recipeSet>
                <recipeSet>
                    <recipe>
                        <distroRequires>
                            <distro_name op="=" value="BlueShoeLinux5-5" />
                        </distroRequires>
                        <hostRequires/>
                        <task name="/distribution/install" role="STANDALONE">
                            <params/>
                        </task>
                    </recipe>
                </recipeSet>
            </job>
            '''))
        job = self.controller.process_xmljob(xmljob, self.user)
        session.flush()
        for recipeset in job.recipesets:
            for recipe in recipeset.recipes:
                recipe.process()
                recipe.queue()
                recipe.schedule()
                recipe.waiting()

        # Abort the first recipe.
        job.recipesets[0].recipes[0].abort()
        job.update_status()

        # Verify that it and its children are aborted.
        self.assertEquals(job.recipesets[0].recipes[0].status, TaskStatus.aborted)
        for task in job.recipesets[0].recipes[0].tasks:
            self.assertEquals(task.status, TaskStatus.aborted)

        # Verify that the second recipe and its children are still waiting.
        self.assertEquals(job.recipesets[1].recipes[0].status, TaskStatus.waiting)
        for task in job.recipesets[1].recipes[0].tasks:
            self.assertEquals(task.status, TaskStatus.waiting)

        # Verify that the job still shows waiting.
        self.assertEquals(job.status, TaskStatus.waiting)

        # Abort the second recipe now.
        job.recipesets[1].recipes[0].abort()
        job.update_status()

        # Verify that the whole job shows aborted now.
        self.assertEquals(job.status, TaskStatus.aborted)
开发者ID:ShaolongHu,项目名称:beaker,代码行数:60,代码来源:test_update_status.py


示例17: fetch_items

 def fetch_items(self):
     """
     Grab search result items for given index and keywords.
     """
     # Construct the list of arguments for the AWS query
     args = {
         'Service'        : 'AWSECommerceService',
         'Operation'      : 'ListLookup',
         'ResponseGroup'  : 'Medium,ListFull,ItemAttributes',
         'Sort'           : 'LastUpdated',
         'ListType'       : 'WishList',
         'ListId'         : self.wishlist_id,
         'SubscriptionId' : self.aws_id,
     }
     
     # Build the URL for the API call using the base URL and params.
     url = "%s?%s" % (self.AWS_URL, urllib.urlencode(args))
     
     # Perform the query, fetch and parse the results.
     data  = HTTPCache(url).content()
     doc   = xmltramp.parse(data)
     
     # Update the feed link and title from search result metadata
     self.FEED_META['feed.link']  = doc.Lists.List.ListURL
     self.FEED_META['feed.title'] = \
         'Amazon.com wishlist items for "%s"' % \
         doc.Lists.List.CustomerName
     
     # Fetch first page of items.
     return [ x.Item for x in doc.Lists.List if 'ListItem' in x._name ]
开发者ID:lmorchard,项目名称:hacking_rss_and_atom,代码行数:30,代码来源:ch13_amazon_wishlist_scraper.py


示例18: character

def character( guild, character, force = False ):
    if not guild and not character.guild:
        # erase characters without a guild
        logging.info("deleting guildless character %s"%character.name)
        character.delete()
        return

    try:
        raw_xml = fetch_raw( character.armory_url() )
    except FetchError:
        logging.info("fetcherror")
        return # normally this is an armory failure. I'm not going to put clever handling in here.
    
    char_xml = xmltramp.parse( raw_xml )
    try:
        char = char_xml['characterInfo']['character']
    except KeyError:
        logging.info("keyerror")
        return # normally armoury error

    character.achPoints = long(char('points'))
    
    added_count = add_achievements( character, raw_xml )
    if added_count >= 5:
        logging.info("Seen at least 5 new achievements - running backfill")
        added_count = backfill( character, char_xml )
    
    logging.info("added %d achievements"%added_count)

    # otherwise we're done.
    character.last_fetch = datetime.utcnow()
    character.put()

    guild.update_achievements_cache_for( character )
    guild.put()
开发者ID:tominsam,项目名称:GaeAchievements,代码行数:35,代码来源:fetcher.py


示例19: addSetToCollection

 def addSetToCollection( self, set_id , collection_id ):
     success = False
     print("Adding set with id " + str(set_id) + " to collection with id " + str(collection_id) + "...")
     try:
         d = {
             api.token       : str(self.token),
             api.perms       : str(self.perms),
             "method"        : "flickr.collections.addSet",
             "collection_id" : str(collection_id),
             "photoset_id"   : str(set_id)
         }
         sig = self.signCall( d )
         d[ api.sig ] = sig
         d[ api.key ] = FLICKR[ api.key ]
         url = self.build_request(api.rest, d, ())
         xml = urllib2.urlopen( url ).read()
         res = xmltramp.parse(xml)
         if ( self.isGood( res ) ):
             print("    Success.")
             success = True
         else :
             print("    Problem:")
             self.reportError( res )
     except KeyboardInterrupt:
         flick.printStats()
         print "\nUploading session interrupted by user..."
         sys.exit()
     except:
         print(str(sys.exc_info()))
     return success
开发者ID:pawcik,项目名称:uploadr.py,代码行数:30,代码来源:uploadr.py


示例20: serviceGetParameters

def serviceGetParameters():
    printDebugMessage('serviceGetParameters', 'Begin', 1)
    requestUrl = baseUrl + '/parameters'
    printDebugMessage('serviceGetParameters', 'requestUrl: ' + requestUrl, 2)
    xmlDoc = restRequest(requestUrl)
    doc = xmltramp.parse(xmlDoc)
    printDebugMessage('serviceGetParameters', 'End', 1)
    return doc['id':]
开发者ID:jasmendes,项目名称:leish-domains,代码行数:8,代码来源:iprscan_urllib2.py



注:本文中的xmltramp.parse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python xmlunittest.XmlTestCase类代码示例发布时间:2022-05-26
下一篇:
Python xmltramp.islst函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap