Changeset 628 for trunk/Update Podcasts


Ignore:
Timestamp:
08/19/10 00:19:30 (14 years ago)
Author:
Nicholas Riley
Message:

Wait for missing iPod; wait 0.5 seconds before checking "Sync" button.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Update Podcasts/update_podcasts.py

    r627 r628  
    1818        time.sleep(0.5)
    1919
    20 def wait_for_iPod_update(iTunes):
     20def sync_iPod(iTunes):
     21    try:
     22        iTunes.update()
     23    except CommandError:
     24        print >> sys.stderr, 'No iPod detected.  Waiting for iPod...'
     25        while True:
     26            time.sleep(0.5)
     27            try:
     28                iTunes.update()
     29            except CommandError:
     30                pass
     31
    2132    # show iPod
    2233    iTunes.sources[its.kind == AEEnum('kPod')].sources[1].library_playlists[1].reveal()
     34
     35    # wait for update to complete
    2336    sync_enabled = iTunes_main_pane().buttons[u'Sync'].enabled
    2437    while True:
     38        time.sleep(0.5)
    2539        try:
    2640            if sync_enabled.get() == True:
     
    2842        except CommandError:
    2943            pass
    30         time.sleep(0.5)
    3144
    3245if __name__ == '__main__':
     
    3548    iTunes.updateAllPodcasts()
    3649    print >> sys.stderr, 'Synchronizing iPod...'
    37     iTunes.update()
    38     wait_for_iPod_update(iTunes)
     50    sync_iPod(iTunes)
    3951    print >> sys.stderr, 'Updating podcasts...'
    4052    iTunes.updateAllPodcasts()
    4153    wait_for_podcast_update(iTunes)
    4254    print >> sys.stderr, 'Synchronizing iPod...'
    43     iTunes.update()
    44     wait_for_iPod_update(iTunes)
     55    sync_iPod(iTunes)
    4556    app(id='net.sabi.UpdatePodcasts').quit()
Note: See TracChangeset for help on using the changeset viewer.