예제 #1
0
class Command(BaseCommand):
    help = "Update social media feeds"

    def add_arguments(self, parser):
        parser.add_argument('--cached',
                            action='store_true',
                            dest='cached',
                            default=False,
                            help='Use local cache for HTTP requests')
        parser.add_argument('--type',
                            action='store',
                            dest='type',
                            help='Types of feed to update')
        parser.add_argument('--feed-id',
                            action='store',
                            dest='feed_id',
                            help='Update only single feed')

    def handle(self, *args, **options):
        self.logger = logging.getLogger(__name__)
        if options['cached']:
            import requests_cache
            requests_cache.install_cache("update-social")
        self.updater = FeedUpdater(self.logger)
        update_opts = {}
        if 'type' in options and options['type']:
            update_opts['type'] = options['type'].split(',')
        update_opts['feed_id'] = options.get('feed_id', None)
        self.updater.update_feeds(**update_opts)
예제 #2
0
class Command(BaseCommand):
    help = "Update social media feeds"

    def handle(self, *args, **options):
        import requests_cache
        requests_cache.configure("update-social")
        self.logger = logging.getLogger(__name__)
        self.updater = FeedUpdater(self.logger)
        self.updater.update_feeds()
예제 #3
0
class Command(BaseCommand):
    help = "Update social media feeds"

    def handle(self, *args, **options):
        import requests_cache
        requests_cache.configure("update-social")
        self.logger = logging.getLogger(__name__)
        self.updater = FeedUpdater(self.logger)
        self.updater.update_feeds()
예제 #4
0
 def handle(self, *args, **options):
     self.logger = logging.getLogger(__name__)
     if options['cached']:
         import requests_cache
         requests_cache.install_cache("update-social")
     self.updater = FeedUpdater(self.logger)
     update_opts = {}
     if 'type' in options and options['type']:
         update_opts['type'] = options['type'].split(',')
     update_opts['feed_id'] = options.get('feed_id', None)
     self.updater.update_feeds(**update_opts)
예제 #5
0
class Command(BaseCommand):
    help = "Update social media feeds"
    option_list = BaseCommand.option_list + (
        make_option('--cached', action='store_true', dest='cached', default=False,
            help='Use local cache for HTTP requests'),
    )

    def handle(self, *args, **options):
        self.logger = logging.getLogger(__name__)
        if options['cached']:
            import requests_cache
            requests_cache.install_cache("update-social")
        self.updater = FeedUpdater(self.logger)
        self.updater.update_feeds()
예제 #6
0
 def handle(self, *args, **options):
     self.logger = logging.getLogger(__name__)
     if options['cached']:
         import requests_cache
         requests_cache.install_cache("update-social")
     self.updater = FeedUpdater(self.logger)
     self.updater.update_feeds()
예제 #7
0
class Command(BaseCommand):
    help = "Update social media feeds"
    option_list = BaseCommand.option_list + (
        make_option('--cached', action='store_true', dest='cached', default=False,
            help='Use local cache for HTTP requests'),
        make_option('--type', action='store', dest='type', help='Types of feed to update'),
    )

    def handle(self, *args, **options):
        self.logger = logging.getLogger(__name__)
        if options['cached']:
            import requests_cache
            requests_cache.install_cache("update-social")
        self.updater = FeedUpdater(self.logger)
        update_opts = {}
        if 'type' in options and options['type']:
            update_opts['type'] = options['type'].split(',')
        self.updater.update_feeds(**update_opts)
예제 #8
0
 def handle(self, *args, **options):
     self.logger = logging.getLogger(__name__)
     if options['cached']:
         import requests_cache
         requests_cache.install_cache("update-social")
     self.updater = FeedUpdater(self.logger)
     update_opts = {}
     if 'type' in options and options['type']:
         update_opts['type'] = options['type'].split(',')
     self.updater.update_feeds(**update_opts)
예제 #9
0
파일: tasks.py 프로젝트: ilkkah/datavaalit
 def run(self, **kwargs):
     logger = self.get_logger()
     updater = FeedUpdater(logger)
     print "Updating feeds"
     updater.update_feeds()
     print "Feed update done"
예제 #10
0
            feeds = feed_cls.objects.filter(member=member, type='TW')
            if len(feeds):
                self.logger.warning(
                    "%s: TW feed already found (screen name '%s')" %
                    (person_name, mf.account_name))
                return
            mf = feed_cls(member=member, type='TW')
            self.logger.info("%s: adding TW feed %s" %
                             (person_name, origin_id))

        mf.origin_id = origin_id
        mf.account_name = res.get('screen_name', None)
        mf.save()


imp = FeedImporter()
imp.logger = logging.getLogger(__name__)
imp.feed_updater = FeedUpdater(imp.logger)
imp.replace = False

reader = csv.reader(open('some-feeds.csv', 'r'), delimiter=',')
for row in reader:
    mp_name = "%s %s" % (row[0].decode('utf8'), row[1].decode('utf8'))
    mp_name = fix_mp_name(mp_name)
    member = Member.objects.get(name=mp_name)
    print("%s: %s" % (mp_name, row[2]))
    if row[2] == 'TW':
        imp.validate_twitter_feed(MemberSocialFeed, member, row[3])
    else:
        imp.validate_fb_feed(MemberSocialFeed, member, row[3])
예제 #11
0
파일: tasks.py 프로젝트: kansanmuisti/kamu
 def run(self, **kwargs):
     logger = self.get_logger()
     updater = FeedUpdater(logger)
     print("Updating feeds")
     updater.update_feeds()
     print("Feed update done")
예제 #12
0
 def handle(self, *args, **options):
     import requests_cache
     requests_cache.configure("update-social")
     self.logger = logging.getLogger(__name__)
     self.updater = FeedUpdater(self.logger)
     self.updater.update_feeds()
예제 #13
0
 def handle(self, *args, **options):
     import requests_cache
     requests_cache.configure("update-social")
     self.logger = logging.getLogger(__name__)
     self.updater = FeedUpdater(self.logger)
     self.updater.update_feeds()