~ubuntu-branches/ubuntu/vivid/gpodder/vivid

« back to all changes in this revision

Viewing changes to src/gpodder/my.py

  • Committer: Package Import Robot
  • Author(s): tony mancill
  • Date: 2013-04-12 22:07:02 UTC
  • mfrom: (5.2.27 sid)
  • Revision ID: package-import@ubuntu.com-20130412220702-mux8v9r8zt2jin0x
Tags: 3.5.1-1
* New upstream release.
* d/control: declare versioned dependency on python-gtk2 (>= 2.16)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
# -*- coding: utf-8 -*-
3
3
#
4
4
# gPodder - A media aggregator and podcast client
5
 
# Copyright (c) 2005-2012 Thomas Perl and the gPodder Team
 
5
# Copyright (c) 2005-2013 Thomas Perl and the gPodder Team
6
6
#
7
7
# gPodder is free software; you can redistribute it and/or modify
8
8
# it under the terms of the GNU General Public License as published by
44
44
import mygpoclient
45
45
mygpoclient.user_agent += ' ' + gpodder.user_agent
46
46
 
 
47
# 2013-02-08: We should update this to 1.7 once we use the new features
47
48
MYGPOCLIENT_REQUIRED = '1.4'
48
49
 
49
50
if not hasattr(mygpoclient, 'require_version') or \
73
74
 
74
75
EXAMPLES_OPML = 'http://gpodder.org/directory.opml'
75
76
TOPLIST_OPML = 'http://gpodder.org/toplist.opml'
 
77
EPISODE_ACTIONS_BATCH_SIZE=100
76
78
 
77
79
# Database model classes
78
80
class SinceValue(object):
508
510
 
509
511
            # Step 2: Upload Episode actions
510
512
 
511
 
            # Convert actions to the mygpoclient format for uploading
512
 
            episode_actions = [convert_to_api(a) for a in actions]
513
 
 
514
 
            # Upload the episode actions
515
 
            self._client.upload_episode_actions(episode_actions)
516
 
 
517
 
            # Actions have been uploaded to the server - remove them
518
 
            self._store.remove(actions)
 
513
            # Uploads are done in batches; uploading can resume if only parts
 
514
            # be uploaded; avoids empty uploads as well
 
515
            for lower in range(0, len(actions), EPISODE_ACTIONS_BATCH_SIZE):
 
516
                batch = actions[lower:lower+EPISODE_ACTIONS_BATCH_SIZE]
 
517
 
 
518
                # Convert actions to the mygpoclient format for uploading
 
519
                episode_actions = [convert_to_api(a) for a in batch]
 
520
 
 
521
                # Upload the episode actions
 
522
                self._client.upload_episode_actions(episode_actions)
 
523
 
 
524
                # Actions have been uploaded to the server - remove them
 
525
                self._store.remove(batch)
 
526
 
519
527
            logger.debug('Episode actions have been uploaded to the server.')
520
528
            return True
521
529