How to use get_favicon method in AutoItDriverServer

Best Python code snippet using AutoItDriverServer_python

models.py

Source:models.py Github

copy

Full Screen

...27 def get_favicons(self):28 favicons = []29 for rel in config:30 for size in config[rel]:31 favicons.append(self.get_favicon(size, rel))32 return favicons33 def __str__(self):34 return self.faviconImage.name35 def get_absolute_url(self):36 return "%s" % self.faviconImage.name37 def del_image(self):38 self.faviconImage.delete()39 def get_favicon(self, size, rel, update=False):40 """41 get or create a favicon for size, rel(attr) and uploaded favicon42 optional:43 update=True44 """45 fav, _ = FaviconImg.objects.get_or_create(46 faviconFK=self, size=size, rel=rel)47 if update and fav.faviconImage:48 fav.del_image()49 if self.faviconImage and not fav.faviconImage:50 tmp = Image.open(storage.open(self.faviconImage.name))51 tmp.thumbnail((size, size), Image.ANTIALIAS)52 tmpIO = BytesIO()53 tmp.save(tmpIO, format='PNG')54 tmpFile = InMemoryUploadedFile(55 tmpIO, None, 'fav-%s.png' %56 (size,), 'image/png', sys.getsizeof(tmpIO), None)57 fav.faviconImage = tmpFile58 fav.save()59 return fav60 def save(self, *args, **kwargs):61 update = False62 if self.isFavicon:63 for n in Favicon.objects.exclude(pk=self.pk):64 n.isFavicon = False65 n.save()66 super(Favicon, self).save(*args, **kwargs)67 if self.faviconImage:68 for rel in config:69 for size in config[rel]:70 self.get_favicon(size=size,rel=rel, update=update)71 #make sure default favicon is set72 self.get_favicon(size=32, rel='shortcut icon')73class FaviconImg(models.Model):74 faviconFK = models.ForeignKey(Favicon, on_delete=models.CASCADE)75 size = models.IntegerField()76 rel = models.CharField(max_length=250, null=True)77 faviconImage = models.ImageField(upload_to='favicon')78 def del_image(self):79 self.faviconImage.delete()80from django.db.models import signals81from django.db.models.signals import pre_delete82from django.dispatch.dispatcher import receiver83signals.pre_delete.connect(pre_delete_image, sender=Favicon)...

Full Screen

Full Screen

database.py

Source:database.py Github

copy

Full Screen

...13 # No matter what, we will need to check for existing favicon14 favicon = Favicon.query.filter_by(url=rurl).first()15 if get_fresh:16 # If get_fresh is true we will not even check the database17 f = get_favicon(rurl)18 if f:19 if favicon:20 favicon.favicon = f21 else:22 favicon = Favicon(url=rurl, favicon=f)23 db.session.add(favicon)24 db.session.commit()25 else:26 # Return None if couldn't get favicon27 # We do not want to return existing from database28 return None29 else:30 if not favicon:31 f = get_favicon(rurl)32 if f:33 favicon = Favicon(url=rurl, favicon=f)34 db.session.add(favicon)35 db.session.commit()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run AutoItDriverServer automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful