What happens when you run the shell script manually?

R

On Sep 1, 5:42 am, vanderkerkoff <tonm...@gmail.com> wrote:
> I wonder if someone can help me here
>
> We've been using cron to run an update script that looks in our django
> commmunity pages(aggy), pulls out Feeds and creates feeditems.
>
> Here's what an example of the cron file looks like
>
> 17 13 * * * /var/www/django/django_projects/scripts/computing_feeds.sh
>
> Here's what that shell script looks like
>
> #!/bin/bash
> /usr/bin/python /var/www/django/django_projects/scripts/
> update_feeds.py --settings=fact.settings_computing
>
> I've got a fact.pth file in my site-packages folder for python(fact is
> the name of the django application, with multiple settings files),
> looks like this
>
> /var/www/django/django_projects
>
> The fact folder sits in that folder
>
> I've pasted in a copy of update_feeds.py that we've been using for
> over 5 years now.  At some point in the last 2 months it's stopped
> working.
>
> I can run the commands from the command line, which leads me to
> believe that DJANGO_SETTINGS_MODULE is not being passed to the
> update_feeds.py script.
>
> The problem I've got with this is that it has been working for a very
> long time.
>
> If anyone can shed any light on what is going on here, or have any
> ideas on how to solve it, I'd be more than grateful for any advice or
> tips.
>
> vi /var/www/django/django_projects/scripts/update_feeds.py
>
> !/usr/bin/python
> """
> Update feeds for Django community page.  Requires Mark Pilgrim's
> excellent
> Universal Feed Parser (http://feedparser.org)
> """
>
> import os
> import time
> import optparse
> import datetime
> import feedparser
>
> def update_feeds():
>     from fact.aggy.models import Feed, FeedItem
>     for feed in Feed.objects.filter(is_defunct=False):
>         parsed_feed = feedparser.parse(feed.feed_url)
>         for entry in parsed_feed.entries:
>             title = entry.title.encode(parsed_feed.encoding,
> "xmlcharrefreplace")
>             guid = entry.get("id",
> entry.link).encode(parsed_feed.encoding, "xmlcharrefreplace")
>             link = entry.link.encode(parsed_feed.encoding,
> "xmlcharrefreplace")
>
>             if hasattr(entry, "summary"):
>                 content = entry.summary
>             elif hasattr(entry, "content"):
>                 content = entry.content[0].value
>             elif hasattr(entry, "description"):
>                 content = entry.description
>             else:
>                 content = u""
>             content = content.encode(parsed_feed.encoding,
> "xmlcharrefreplace")
>
>             if entry.has_key('modified_parsed'):
>                 date_modified =
> datetime.datetime.fromtimestamp(time.mktime(entry.modified_parsed))
>             elif parsed_feed.feed.has_key('modified_parsed'):
>                 date_modified =
> datetime.datetime.fromtimestamp(time.mktime(parsed_feed.feed.modified_parsed))
>             elif parsed_feed.has_key('modified'):
>                 date_modified =
> datetime.datetime.fromtimestamp(time.mktime(parsed_feed.modified))
>             else:
>                 date_modified = datetime.datetime.now()
>
>             try:
>                 feed.feeditem_set.get(guid=guid)
>             except FeedItem.DoesNotExist:
>                 feed.feeditem_set.create(title=title, link=link,
> summary=content, guid=guid, date_modified=date_modified)
>
> if __name__ == '__main__':
>     parser = optparse.OptionParser()
>     parser.add_option('--settings')
>     options, args = parser.parse_args()
>     if options.settings:
>         os.environ["DJANGO_SETTINGS_MODULE"] = options.settings
>     update_feeds()

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to