Esempio n. 1
0
def copy_to_ipod():
    ###
    # Copy files from Listening folder to iPod
    u.printStep('Begin copy')
    
    # reserve some space
    desiredFiles = os.listdir(cfg.listeningFolder)
    u.printStatus( 'Making buffer space' )
    try:
        copyFile(path.join(cfg.listeningFolder, desiredFiles[0]), cfg.freeSpaceMagic)
    except IOError, ex:
        u.printWarning("No space on device. Cannot copy any files (%s)" % ex)
        raise ex
Esempio n. 2
0
def main():
    u.ensure_folders()
    select_and_move()
    p = dl.download_trim_clean()
    try:
        copy_to_ipod()
    except IOError:
        # When we get an io error, it's probably already been reported. We just
        # need to skip everything else except waiting for our external process
        pass
    try:
        rebuild_ipod()
    except IOError:
        u.printWarning("Failed to rebuild ipod database!")

    dl.wait_for_download(p)
Esempio n. 3
0
def _internal_download_trim_clean(silence=True):
    p = ''

    if silence:
        # We don't want to see output from our subprocess
        output = DevNullWrapper()
    else:
        output = StdOutWrapper()

    try:
        p = 'podget'
        subprocess.check_call([p], stderr=output.obj(), stdout=output.obj())

        p = path.join(os.getcwd(), 'trim.py')
        p = path.normpath(p)
        subprocess.check_call([p], stdout=output.obj())

    except subprocess.CalledProcessError, ex:
        u.printWarning('Failed to run %s (%s)' % (p, ex))
Esempio n. 4
0
def copy_to_ipod():
    ###
    # Copy files from Listening folder to iPod
    u.printStep('Begin copy')
    
    # reserve some space
    desiredFiles = os.listdir(cfg.listeningFolder)
    u.printStatus( 'Making buffer space' )
    try:
        copyFile(path.join(cfg.listeningFolder, desiredFiles[0]), cfg.freeSpaceMagic)
    except IOError, ex:
        u.printWarning("No space on device. Cannot copy any files (%s)" % ex)
        raise ex
    except KeyboardInterrupt, ex:
        u.printWarning('Interrupt caught, skipping copying step')
        return      ####### Early Return
    
    for f in desiredFiles:
        u.printStatus( 'Copying: %s' % f )
        src = path.join(cfg.listeningFolder, f)
        dst = path.join(cfg.iPodCastFolder, f)
        try:
            # move out of listening folder to ipod
            # hopefully, the move will only occur if there's space
            moveFile(src, dst)
        except IOError, ex:
            u.printWarning( "Warning: Out of space on device (%s)" % ex )
            # failure means it will stay in listening folder for the next iPod sync
        except KeyboardInterrupt, ex:
            u.printWarning('Interrupt caught, not copying any more files')
Esempio n. 5
0
        output = DevNullWrapper()
    else:
        output = StdOutWrapper()

    try:
        p = 'podget'
        subprocess.check_call([p], stderr=output.obj(), stdout=output.obj())

        p = path.join(os.getcwd(), 'trim.py')
        p = path.normpath(p)
        subprocess.check_call([p], stdout=output.obj())

    except subprocess.CalledProcessError, ex:
        u.printWarning('Failed to run %s (%s)' % (p, ex))
    except OSError, ex:
        u.printWarning('Cannot find application %s (%s)' % (p, ex))

    output.close()

def download_trim_clean():
    ###
    #u.printStep('Start download, trim, and cleanup in new thread')

    p = Process(target=_internal_download_trim_clean, args=())
    p.start()
    return p



def wait_for_download(p):
    # TODO: consider turning output back on (how?)