Beispiel #1
0
def installSkin(skin, version):
    if HELIX:
        sourceSkin = skin + '-Helix'
    elif JARVIS:
        sourceSkin = skin + '-Jarvis'
    else:
        return

    src = os.path.join(HOME, 'resources', sourceSkin)
    dst = os.path.join('special://home', 'addons', skin)

    if validateSkin(skin, version):
        return True

    busy = showBusy()

    sfile.copytree(src, dst)

    count = 15 * 10 #15 seconds
    xbmc.executebuiltin('UpdateLocalAddons')

    xbmc.sleep(1000)
    installed = xbmc.getCondVisibility('System.HasAddon(%s)' % skin) == 1 and compareVersions(xbmcaddon.Addon(skin).getAddonInfo('version'), version) >= 0

    while not installed and count > 0:
        count -= 1
        xbmc.sleep(100)
        installed = xbmc.getCondVisibility('System.HasAddon(%s)' % skin) == 1 and compareVersions(xbmcaddon.Addon(skin).getAddonInfo('version'), version) >= 0

    busy.close()

    return installed
Beispiel #2
0
def MigrateChannels(dst):
    dst = os.path.join(dst, 'channels')
    src = os.path.join(datapath, 'channels')

    if not sfile.exists(dst):
        try:    sfile.copytree(src, dst)
        except: pass
def MigrateChannels(dst):
    dst = os.path.join(dst, 'channels')
    src = os.path.join(datapath, 'channels')

    if not sfile.exists(dst):
        try:
            sfile.copytree(src, dst)
        except:
            pass
Beispiel #4
0
def BackupChannels():
    datapath = GetChannelFolder()
    
    src = os.path.join(datapath, 'channels')
    dst = os.path.join(datapath, 'channels-backup')

    try:    sfile.rmtree(dst)
    except: pass

    try:    sfile.copytree(src, dst)
    except: pass
Beispiel #5
0
def doZipfile(outputFile, includeSettings=True):
    zip = None

    source  = os.path.join(HOME, 'SF_Temp')

    if sfile.exists(source):
        sfile.rmtree(source)

    sfile.copytree(ROOT, source)

    relroot = os.path.abspath(os.path.join(source, os.pardir))

    ignore = ['c', 'downloads']

    for root, dirs, files in os.walk(source):

        if zip == None:
            zip = zipfile.ZipFile(outputFile, 'w', zipfile.ZIP_DEFLATED)

        local = os.path.relpath(root, relroot).split(os.sep, 1)
        if len(local) < 2:
            continue
        local = local[-1]

        # add directory (this is needed for empty dirs)
        if local.lower() in ignore:
            continue
        zip.write(root, local)

        for file in files:    
            if file == 'settings.xml':
                continue

            #ignore python obj
            if len(file.split('.py')[-1]) == 1:
                continue

            arcname  = os.path.join(local, file)
            filename = os.path.join(root, file)           
            zip.write(filename, arcname)

    if includeSettings:
        if zip == None:
            zip = zipfile.ZipFile(output_filename, 'w', zipfile.ZIP_DEFLATED)

        arcname  = 'settings.xml'
        filename = os.path.join(ADDON.getAddonInfo('profile'), arcname)
        filename = xbmc.translatePath(filename) #has to be a real path

        zip.write(filename, arcname)

    sfile.rmtree(source)
def BackupChannels():
    datapath = GetChannelFolder()

    src = os.path.join(datapath, 'channels')
    dst = os.path.join(datapath, 'channels-backup')

    try:
        sfile.rmtree(dst)
    except:
        pass

    try:
        sfile.copytree(src, dst)
    except:
        pass
Beispiel #7
0
def pasteFolderCopy(src, _dst, folderName):
    import sfile

    dst = os.path.join(_dst, folderName)

    index = 0
    while sfile.exists(dst):
        index += 1
        dst    = os.path.join(_dst, GETTEXT(30192) % (folderName, index))

    try:
        sfile.copytree(src, dst)
    except Exception, e: 
        utils.log('Error in pasteFolderCopy: %s' % str(e))
        return False
Beispiel #8
0
def extract(src, dp):
    success = False
    try:
        src = xbmc.translatePath(src)
        import zipfile

        update = os.path.join(PROFILE, 'update')
        update = xbmc.translatePath(update)
        sfile.makedirs(update)

        zin   = zipfile.ZipFile(src, 'r')
        nItem = float(len(zin.infolist()))

        index = 0
        for item in zin.infolist():
            index += 1

            percent  = int(index / nItem *100)
            #filename = item.filename

            zin.extract(item, update)
  
            if dp:
                dp.update(percent, utils.GETTEXT(30118), utils.GETTEXT(30080))

        addons = os.path.join('special://home', 'addons')
        current, folders, files = sfile.walk(update)

        for folder in folders:
            ori = os.path.join(addons, folder)
            src = os.path.join(current, folder)
            dst = os.path.join(addons, folder + '.temp')
            sfile.copytree(src, dst)
            sfile.rmtree(ori)
            while not sfile.exists(dst):
                xbmc.sleep(100)
            while sfile.exists(ori):
                xbmc.sleep(100)
            sfile.rename(dst, ori)   

        success = True
    except:
        success = False

    sfile.delete(update)
    return success
def doZipfile(outputFile, includeSettings=True):
    zip = None

    source = os.path.join(HOME, 'Temp')
    if sfile.exists(source):
        sfile.rmtree(source)
    sfile.copytree(ROOT, source)

    relroot = os.path.abspath(os.path.join(source, os.pardir))

    for root, dirs, files in os.walk(source):

        if zip == None:
            zip = zipfile.ZipFile(outputFile, 'w', zipfile.ZIP_DEFLATED)

        local = os.path.relpath(root, relroot).split(os.sep, 1)
        if len(local) < 2:
            continue
        local = local[-1]

        # add directory (this is needed for empty dirs)
        if local.lower() == 'c':
            continue
        zip.write(root, local)

        for file in files:
            if file == 'settings.xml':
                continue

            arcname = os.path.join(local, file)
            filename = os.path.join(root, file)
            zip.write(filename, arcname)

    if includeSettings:
        if zip == None:
            zip = zipfile.ZipFile(output_filename, 'w', zipfile.ZIP_DEFLATED)

        arcname = 'settings.xml'
        filename = os.path.join(HOME, arcname)

        zip.write(filename, arcname)

    sfile.rmtree(source)
def doZipfile(outputFile, includeSettings=True):
    zip = None

    source  = os.path.join(HOME, 'Temp')
    if sfile.exists(source):
        sfile.rmtree(source)
    sfile.copytree(ROOT, source)

    relroot = os.path.abspath(os.path.join(source, os.pardir))

    for root, dirs, files in os.walk(source):

        if zip == None:
            zip = zipfile.ZipFile(outputFile, 'w', zipfile.ZIP_DEFLATED)

        local = os.path.relpath(root, relroot).split(os.sep, 1)
        if len(local) < 2:
            continue
        local = local[-1]

        # add directory (this is needed for empty dirs)
        if local.lower() == 'c':
            continue
        zip.write(root, local)

        for file in files:    
            if file == 'settings.xml':
                continue

            arcname  = os.path.join(local, file)
            filename = os.path.join(root, file)           
            zip.write(filename, arcname)

    if includeSettings:
        if zip == None:
            zip = zipfile.ZipFile(output_filename, 'w', zipfile.ZIP_DEFLATED)

        arcname  = 'settings.xml'
        filename = os.path.join(HOME, arcname)

        zip.write(filename, arcname)

    sfile.rmtree(source)
Beispiel #11
0
                zin.extract(item, root)
            elif filename.lower().startswith('s'):
                zin.extract(item, root)
            elif filename.lower().startswith('h'):
                zin.extract(item, root)
            elif filename.lower().startswith('pl'):
                zin.extract(item, root)
            else:
                zin.extract(item, profile)

    except Exception, e:
        utils.log('Error whilst unzipping %s' % location)
        utils.log(e)        
        return False

    sfile.copytree(root, ROOT)
    sfile.rmtree(root)
    return True


def getFile(title, ext):
    filename = xbmcgui.Dialog().browse(1, title, 'files', '.'+ext, False, False, '')

    if filename == 'NO FILE':
        return None

    return filename



def getFolder(title):
Beispiel #12
0
def extractAll(filename, dp, location):
    global CHANGELOG
    CHANGELOG = None

    zin = zipfile.ZipFile(filename, 'r')

    relroot = os.path.abspath(os.path.join(ROOT, os.pardir))

    root = os.path.join(HOME, 'SF_Temp')
    profile = os.path.join(root, 'Super Favourites')

    #copy existing settings to root
    dst = os.path.join(root, 'settings.xml')
    src = os.path.join(ROOT, 'settings.xml')
    sfile.copy(src, dst)

    if IMPORT_RESET:
        try:
            sfile.rmtree(os.path.join(ROOT, 'Super Favourites'))
        except:
            pass

    try:
        nItem = float(len(zin.infolist()))
        index = 0
        for item in zin.infolist():
            index += 1

            percent = int(index / nItem * 100)
            filename = item.filename

            if dp:
                dp.update(percent,
                          GETTEXT(30140) % filename, location, GETTEXT(30141))

            if filename == 'settings.xml':
                if utils.DialogYesNo(GETTEXT(30135),
                                     line2='',
                                     line3=GETTEXT(30136),
                                     noLabel=None,
                                     yesLabel=None):
                    zin.extract(item, root)
            elif filename == 'changelog.txt':
                try:
                    zin.extract(item, root)
                    filename = os.path.join(root, filename)
                    CHANGELOG = sfile.read(filename)
                    utils.DeleteFile(filename)
                except Exception as e:
                    utils.log('Changelog error in extractAll')
                    utils.log(e)
            elif filename.lower().startswith('super favourites'):
                zin.extract(item, root)
            elif filename.lower().startswith('s'):
                zin.extract(item, root)
            elif filename.lower().startswith('h'):
                zin.extract(item, root)
            elif filename.lower().startswith('pl'):
                zin.extract(item, root)
            else:
                zin.extract(item, profile)

    except Exception as e:
        utils.log('Error whilst unzipping %s' % location)
        utils.log(e)
        return False

    sfile.copytree(root, ROOT)
    sfile.rmtree(root)
    return True