Ejemplo n.º 1
0
def play_with_links_old():
    for current in models.Movie.objects.all():
        local_path = utility.object_path_local(current)
        file_exists = os.path.exists(local_path)
        #print('path %s exists: %s ' % (local_path, file_exists))

        if file_exists and os.path.islink(local_path):
            print('LINK %s' % local_path)
Ejemplo n.º 2
0
def annotate(picture,me):
    """ decorate a picture with its friendly_name """
    filename = picture.fileName
    me_local, me_web, _ = my_private_directory(me)
    tmp_file = os.path.join(me_local,filename)
    web_file = os.path.join(me_web,filename)
    pic_path = utils.object_path_local(picture)
    #print('source %s destination %s' % (pic_path,tmp_file))
    #shutil.copyfile(pic_path,tmp_file)
    
    ccmd = '/usr/bin/convert '
    opts0 = ' -scale 1280x1080 '
    opts = ' -pointsize 30 -fill black -undercolor white -annotate +0+22 '
    acmd = ccmd + pic_path + opts0 + opts + picture.friendly_name() + ' ' + tmp_file
    # print('acmd %s' % acmd)    
    os.system(acmd)
    return web_file, tmp_file
Ejemplo n.º 3
0
def transfer_to_my_directory(me, songs):
    cleanup_my_private_directory(me, u'favourites')
    my_path, _ = my_private_directory(me, u'favourites')

    for song in songs:
        src_path = utils.object_path_local(song)
        song_path = os.path.basename(song.friendly_name())
        dest_path = os.path.join(my_path, song_path)

        # print('source %s destination %s' % (src_path,dest_path))
        try:
            cmd = 'cp ' + '"' + src_path + '" "' + dest_path + '"'
            print(cmd)
            os.system(cmd)
            #copy(src_path,dest_path)
        except Exception as ex:
            # would eventually like to catch the correct message
            message = str('Error during file copy %s' % (type(ex).__name__))
            print(message)
            raise MyException(message)

    return my_path
Ejemplo n.º 4
0
def send_to_kodi(ob, ip, local=False):
    """ send an object (song, movie) to kodi for playback
        where ob is the object, ip is the ip address
        of kodi where playback is requested
    """
    host = ip + settings.KODI_PORT
    if local:
        # use files from the local symbols links, no longer required
        # only need when running from 127.0.0.1
        thefile = utils.object_path_local(ob)
    else:
        thefile = utils.object_path_samba(ob)
    try:
        utils.log("Host %s" % host)
        utils.log("ip %s" % ip)
        xbmc_i = init_xbmc(host)
        to_kodi(thefile, host, xbmc_i)
    except Exception as ex:
        # in this case I want to see what the exception is
        # but there's no way to handle it, just pass it back for display
        message = str('Cannot init_xbmc host %s exception %s' %
                      (host, type(ex).__name__))
        utils.log(message)
        raise rutils.MyException(message)
Ejemplo n.º 5
0
def verify_list(alist):
    blist = []
    utility.log('--- Starting Diagnostics ---')
    for current in alist:
        if current.collection is None:
            msg = (u'DELETING no collection %s' % current.title)
            utility.log(msg)
            blist.append(msg)
            #current.delete()
        elif os.path.exists(settings.DRIVES[0]):
            lpath = utility.object_path_local(current)
            file_exists = os.path.exists(lpath)
            if not file_exists:
                msg = (u'DELETING file does not exist %s %s' %
                       (current.collection.filePath, current.title))
                utility.log(msg)
                blist.append(msg)
                #current.delete()
        else:
            msg = (u'ERROR diagnostic abandonded missing path %s' %
                   settings.DRIVES[0])
            blist.append(msg)
            utility.log(msg)
    return blist