def save(self): self.description_html = markdown(self.description) super(Event, self).save() try: ping_google() except Exception: pass
def save(self, *args, **kwargs): self.slug = slugify(self.title) try: ping_google() except Exception: pass return super(Post, self).save(*args, **kwargs)
def task_submit_sitemap(domain): """ Submits yesterday's sitemap to google for the given domain Input: :domain: sitemap domain """ ping_google('http://{d}/sitemap.xml'.format(d=domain))
def save(self, *args, **kwargs): super(Post, self).save(*args, **kwargs) if getattr(settings, 'PING_GOOGLE', False): try: ping_google() except: pass
def save(self, *args, **kwargs): created = False if self.pk is None: created = True if self.slug == '': self.slug = slugify(unidecode(self.title[:255])) super(Post, self).save(*args, **kwargs) if not settings.DEBUG: try: ping_google(sitemap_url='/sitemap.xml') except Exception(): pass if created: context = { "title": self.title, "url": "http://fun.mitaka-g.net/post/" + str(self.pk) + "/" + self.slug + "/", "content": self.content, "author": self.author } for author in Author.objects.filter(~Q(pk=self.author.pk) & Q(is_active=True)): if author.receive_update == 1: logger.info("Sending notification via email to %s", author.email) template = read_template('/home/django/projects/fun/core/templates/core/post_email.txt') send_gearman_mail('New post on fun.mitaka-g.net', template.render(Context(context)), '*****@*****.**', [author.email], fail_silently=False, auth_user=settings.MANDRILL_USER, auth_password=settings.MANDRILL_API_KEY, host=settings.MANDRILL_HOST) elif author.receive_update == 3: logger.info("Sending notification via jabber to %s", author.jabber_contact) template = read_template('/home/django/projects/fun/core/templates/core/post_jabber.txt', replace_newlines=False) send_gearman_jabber(template.render(Context(context)), author.jabber_contact)
def save(self, *args, **kwargs): ''' On save, update timestamps ''' if not self.id: self.created = datetime.datetime.today() self.modified = datetime.datetime.today() if not self.slug: self.slug = slugify( self.title ) # Where self.title is the field used for 'pre-populate from' while True: try: super(Offer, self).save() # Assuming the IntegrityError is due to a slug fight except IntegrityError: match_obj = re.match(r'^(.*)-(\d+)$', self.slug) if match_obj: next_int = int(match_obj.group(2)) + 1 self.slug = match_obj.group(1) + '-' + str(next_int) else: self.slug += '-2' else: break # ping google to update sitemap.xml try: ping_google() except Exception: pass return super(Offer, self).save(*args, **kwargs)
def send_pings(article, site_url=None, sitemap_url=None, article_url=None, feed_url=None): # TODO: Implement more robust logging and exception handling. if getattr(settings, 'PING', False): site = Site.objects.get_current() if site_url is None: site_url = u'http://%s' % site.domain if sitemap_url is None: sitemap_url = u'%s/%s' % (site_url, reverse('sitemap')) if article_url is None: article_url = u'%s/%s' % (site_url, article.get_absolute_url()) if feed_url is None: feed_url = u'%s/%s' % (site_url, reverse('feed', kwargs={'url':'articles'})) for url in PING_SERVICES: try: s = xmlrpclib.Server(url) try: reply = s.weblogUpdates.extendedPing( site.name, site_url, article_url, feed_url) except Exception, e: reply = s.weblogUpdates.ping(site.name, site_url) except: pass urllib2.urlopen(YAHOO % site_url) urllib2.urlopen(YAHOO % sitemap_url) urllib2.urlopen(YAHOO % feed_url) ping_google(sitemap_url)
def ping_google(self): from django.contrib.sitemaps import ping_google try: ping_google() except: pass
def save(self, *args, **kwargs): self.slug = slugify(self.company_name) try: ping_google() except Exception: pass return super(Experience, self).save(*args, **kwargs)
def send_pings(article, site_url=None, sitemap_url=None, article_url=None, feed_url=None): # TODO: Implement more robust logging and exception handling. if getattr(settings, 'PING', False): site = Site.objects.get_current() if site_url is None: site_url = u'http://%s' % site.domain if sitemap_url is None: sitemap_url = u'%s/%s' % (site_url, reverse('sitemap')) if article_url is None: article_url = u'%s/%s' % (site_url, article.get_absolute_url()) if feed_url is None: feed_url = u'%s/%s' % (site_url, reverse('feed', kwargs={'url': 'articles'})) for url in PING_SERVICES: try: s = xmlrpclib.Server(url) try: reply = s.weblogUpdates.extendedPing( site.name, site_url, article_url, feed_url) except Exception, e: reply = s.weblogUpdates.ping(site.name, site_url) except: pass urllib2.urlopen(YAHOO % site_url) urllib2.urlopen(YAHOO % sitemap_url) urllib2.urlopen(YAHOO % feed_url) ping_google(sitemap_url)
def put(self): result = super(Post, self).put() try: ping_google() except Exception: pass return result
def notify_google(sender, **kwargs): instance = kwargs.pop('instance', None) if instance.status in ('ACC', 'PUB'): try: ping_google() except Exception: pass
def save(self): super(Entry, self).save() try: ping_google() except Exception: # Bare 'except' because we could get a variety of HTTP-related exceptions pass
def save(self, force_insert=False, force_update=False): super(Collection, self).save(force_insert, force_update) if (settings.SITE_ID == 1): try: ping_google('/sitemap.xml') except Exception: pass
def save(self, **kwargs): super(Place, self).save(**kwargs) try: ping_google(sitemap_url='http://koworking.info/sitemap.xml') except Exception as err: print str(err)
def ping(request): try: if request.user.is_admin: ping_google() except: pass return redirect('/')
def post_save(self, created, **kwargs): """Docstring.""" # --------------------------------------------------------------------- # --- Ping Google try: ping_google() except Exception as e: print colored("###" * 27, "white", "on_red") print colored( "### EXCEPTION @ `{module}`: {msg}".format( module=inspect.stack()[0][3], msg=str(e), ), "white", "on_red") # --------------------------------------------------------------------- # --- Update/insert SEO Model Instance Metadata update_seo_model_instance_metadata( title=self.title, description=self.description, keywords=self.forum.title, heading=self.title, path=self.get_absolute_url(), object_id=self.id, content_type_id=ContentType.objects.get_for_model(self).id, )
def save(self, *args, **kwargs): self.slug = slugify(self.title) try: ping_google() except Exception: pass super(ProjectCategory, self).save(*args, **kwargs)
def save(self, force_insert=False, force_update=False): super(Article, self).save(force_insert, force_update) try: if getattr(settings, 'DEBUG', False) is False: ping_google() except Exception: pass
def save(self, force_insert=False, force_update=False, using=None): super(Post, self).save(force_insert, force_update, using=using) if self.yayinlandi: try: ping_google("/sitemap.xml") except: pass
def save(self, force_insert=False, force_update=False, using=None, update_fields=None): super(Post, self).save(force_insert, force_update, using, update_fields) try: ping_google() except Exception: pass
def save(self): self.summary_html = markdown(self.summary) super(PressRelease, self).save() try: ping_google() except Exception: pass
def save(self, *args, **kwargs): ''' On save, update timestamps ''' if not self.id: self.created = datetime.datetime.today() self.modified = datetime.datetime.today() if not self.slug: self.slug = slugify(self.title) # Where self.title is the field used for 'pre-populate from' while True: try: super(Offer, self).save() # Assuming the IntegrityError is due to a slug fight except IntegrityError: match_obj = re.match(r'^(.*)-(\d+)$', self.slug) if match_obj: next_int = int(match_obj.group(2)) + 1 self.slug = match_obj.group(1) + '-' + str(next_int) else: self.slug += '-2' else: break # ping google to update sitemap.xml try: ping_google() except Exception: pass return super(Offer, self).save(*args, **kwargs)
def save(self): """ override save method. to add tag automatically. Arguments: - `self`: """ """ if current_posted_date != prev_posted_date if self.id == None or self.edit_posted == True: site_id = settings.SITE_ID site = Site.objects.select_related().get(pk=site_id) blog = site.blog_set.all()[0] tz = timezone(blog.timezone) #replace the timezone first, then convert to utc #self.posted = self.posted.replace(tzinfo=tz).astimezone(pytz.utc) """ super(Entry,self).save() self.tags = self.tag_list try: ping_google() except Exception: # Bare 'except' because we could get a variety # of HTTP-related exceptions. pass
def save(self, force_insert=False, force_update=False): self.body_html = markup(self.body) super(Story, self).save(force_insert, force_update) try: ping_google() except Exception: pass
def handle(self, *args, **options): self.stdout.write('ping google') try: ping_google() except Exception, e: CommandError('error: %s' % e) raise e
def update_google(): # Let google's search panel know that I've updated something on the site. try: ping_google() except: # bare except because so much can go wrong. It's not worth retrying. pass
def parse_and_save_post(post, author=None, **kwargs): """generic method to use with posts to be used prior to saving post edit or addition """ assert (author is not None) last_revision = post.html data = post.parse() post.html = data['html'] newly_mentioned_users = set(data['newly_mentioned_users']) - set([author]) removed_mentions = data['removed_mentions'] #a hack allowing to save denormalized .summary field for questions if hasattr(post, 'summary'): post.summary = strip_tags(post.html)[:120] #delete removed mentions for rm in removed_mentions: rm.delete() created = post.pk is None #this save must precede saving the mention activity #because generic relation needs primary key of the related object super(post.__class__, post).save(**kwargs) if last_revision: diff = htmldiff(last_revision, post.html) else: diff = post.get_snippet() timestamp = post.get_time_of_last_edit() #create new mentions for u in newly_mentioned_users: from askbot.models.user import Activity Activity.objects.create_new_mention(mentioned_whom=u, mentioned_in=post, mentioned_by=author, mentioned_at=timestamp) #todo: this is handled in signal because models for posts #are too spread out from askbot.models import signals signals.post_updated.send(post=post, updated_by=author, newly_mentioned_users=newly_mentioned_users, timestamp=timestamp, created=created, diff=diff, sender=post.__class__) try: from askbot.conf import settings as askbot_settings if askbot_settings.GOOGLE_SITEMAP_CODE != '': ping_google() except Exception: logging.debug('cannot ping google - did you register with them?')
def save(self): super(Event, self).save() if not settings.DEBUG: try: ping_google() except Exception: import logging logging.warn('Google ping on save did not work.')
def save(self, **kwargs): dir = self.navigation.slug+'/'+self.slug+'/' #self.content=migrate(dir, self.content) super(SubNavigation, self).save(**kwargs) try: ping_google() except Exception: pass
def save(self): self.summary_html = markdown(self.summary) self.body_html = markdown(self.body) super(Entry, self).save() try: ping_google() except Exception: pass
def ping_search_engines(sender, instance, **kwargs): article = instance if not settings.DEBUG and article.status == 2: try: ping_google() except: pass
def save(self): super(Aktualnosci, self).save() try: ping_google() except Exception: # Bare 'except' because we could get a variety # of HTTP-related exceptions. pass
def save(self, *args, **kwargs): self.meta_desc = unidecode(self.description) super(Posts, self).save(*args, **kwargs) try: ping_google() except Exception: pass
def ping_google(): try: sitemaps.ping_google('/sitemap.xml') except Exception as exc: # Bare 'except' because we could get a variety # of HTTP-related exceptions. logger.error(exc) pass
def save(self, *args, **kwargs): if not self.published_at and self.is_public: self.published_at = timezone.now() super().save(*args, **kwargs) try: ping_google() except Exception: pass
def save(self, **kwargs): super(Answer, self).save(**kwargs) try: ping_google() except Exception: logging.debug( 'problem pinging google did you register you sitemap with google?' )
def delete(self): super(Question, self).delete() try: ping_google() except Exception: logging.debug( 'problem pinging google did you register you sitemap with google?' )
def reject(self, request, queryset): queryset.update(approved=False) first_tip = [tip for zhishi in queryset][0] try: self._notificate_user_about_rejection_for(first_tip) ping_google() except Exception: pass
def save(self, force_insert=False, force_update=False): super(ProjectSitemap, self).save(force_insert, force_update) try: ping_google() except Exception: # Bare 'except' because we could get a variety # of HTTP-related exceptions. pass
def reject(self, request, queryset): queryset.update(approved=False) first_tip = [ tip for tip in queryset ][0] try: self._notificate_user_about_rejection_for(first_tip) ping_google() except Exception: pass
def save(self, *args, **kwargs): super(Punch, self).save(*args, **kwargs) # Call the "real" save() method. try: ping_google() except Exception as ex: # Bare 'except' because we could get a variety # of HTTP-related exceptions. send_mail('ping google failed', ex.message, settings.DEFAULT_FROM_EMAIL, [settings.DEFAULT_FROM_EMAIL])
def delete(self): super(Question, self).delete() try: from askbot.conf import settings as askbot_settings if askbot_settings.GOOGLE_SITEMAP_CODE != '': ping_google() except Exception: logging.debug('problem pinging google did you register you sitemap with google?')
def test_something(self, urlopen): ping_google() params = urlencode({ 'sitemap': 'http://example.com/sitemap-without-entries/sitemap.xml' }) full_url = 'https://www.google.com/webmasters/tools/ping?%s' % params urlopen.assert_called_with(full_url)
def save(self, force_insert=False, force_update=False): super(Post, self).save(force_insert, force_update) try: ping_google() except Exception: # Bare 'except' because we could get a variety # of HTTP-related exceptions. pass
def save(self, *args, **kwargs): super(ExpPost, self).save(*args, **kwargs) try: ping_google() except Exception: # Bare 'except' because we could get a variety # of HTTP-related exceptions. pass
def on_post_live(sender, instance, **kwargs): tasks.publish_on_twitter(instance) tasks.publish_on_facebook(instance) try: from django.conf import settings if not settings.DEBUG: ping_google() except Exception as e: pass
def put(self): result = super(SitemapModel, self).put() try: ping_google() except Exception: # Bare 'except' because we could get a variety # of HTTP-related exceptions. pass return result
def ping(request): """Googleへpingを送信する.""" try: url = reverse_lazy('blog:sitemap') ping_google(sitemap_url=url) except Exception: raise else: return redirect('blog:index', permanent=True)
def create_resource_handler(sender, instance, created, **kwargs): """Cuando un recurso es creado, menda un ping a google. Solo lo manda si DEBUG es False. """ if created and settings.DEBUG is False: try: ping_google() except Exception: pass
def publish(self): self.published_date = timezone.now() self.save() try: ping_google('/sitemap.xml') except Exception: # Bare 'except' because we could get a variety # of HTTP-related exceptions. pass
def ping_google_sitemap(sender, **kwargs): try: ping_google(sitemap_url="/sitemap.xml", ping_url=settings.PING_GOOGLE_URL, sitemap_uses_https=True) except Exception as error: with open("logs/ceo_log.txt", 'a') as f: text = str(error) + "\n" f.write(text)