示例#1
0
def system_info():
    systime = xbmc.getInfoLabel('System.Time ')
    dns1 = xbmc.getInfoLabel('Network.DNS1Address')
    gateway = xbmc.getInfoLabel('Network.GatewayAddress')
    ipaddy = xbmc.getInfoLabel('Network.IPAddress')
    linkstate = xbmc.getInfoLabel('Network.LinkState').replace("Link:", "")
    freespace = xbmc.getInfoLabel('System.FreeSpace')
    screenres = xbmc.getInfoLabel('system.screenresolution')
    totalspace = xbmc.getInfoLabel('System.TotalSpace')
    freemem = xbmc.getInfoLabel('System.FreeMemory')
    #######################################################################
    #           FIND WHAT VERSION OF KODI IS RUNNING
    #######################################################################

    xbmc_version = xbmc.getInfoLabel("System.BuildVersion")
    versioni = xbmc_version[:4]

    # if version >= 11.0 and version <= 11.9:
    #   codename = 'Eden'
    # if version >= 12.0 and version <= 12.9:
    #   codename = 'Frodo'
    # if version >= 13.0 and version <= 13.9:
    #   codename = 'Gotham'
    # if version >= 14.0 and version <= 14.9:
    #   codename = 'Helix'
    # if version >= 15.0 and version <= 15.9:
    #   codename = 'Isengard'
    # if version >= 16.0 and version <= 16.9:
    #   codename = 'Jarvis'
    # if version >= 17.0 and version <= 17.9:
    #   codename = 'Krypton'

    VERSIONS = {
        10: 'Dharma',
        11: 'Eden',
        12: 'Frodo',
        13: 'Gotham',
        14: 'Helix',
        15: 'Isengard',
        16: 'Jarvis',
        17: 'Krypton'
    }
    v_str = versioni
    version = int(float(v_str.strip()))
    unknown = chr(version + 58) + '**'
    codename = VERSIONS.get(version, unknown)

    f = urllib.urlopen("http://www.canyouseeme.org/")
    html_doc = f.read()
    f.close()
    m = re.search(
        '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)',
        html_doc)

    check_folders = plugintools.get_setting("maint_check_folders")

    HOME = xbmc.translatePath('special://home/')
    PACKAGES = xbmc.translatePath(
        os.path.join('special://home/addons', 'packages'))
    THUMBS = xbmc.translatePath(
        os.path.join('special://home/userdata', 'Thumbnails'))
    CACHE_FOLDER = xbmc.translatePath(os.path.join('special://home', 'cache'))
    TEMP_FOLDER = xbmc.translatePath(os.path.join('special://', 'temp'))
    CACHE = "NULL"

    if check_folders == "true":
        if os.path.exists(CACHE_FOLDER):
            CACHE = CACHE_FOLDER

        if os.path.exists(TEMP_FOLDER):
            CACHE = TEMP_FOLDER

        if not os.path.exists(PACKAGES):
            os.makedirs(PACKAGES)

        if CACHE == "NULL":
            try:
                PACKAGES_SIZE_BYTE = maintool.get_size(PACKAGES)
                THUMB_SIZE_BYTE = maintool.get_size(THUMBS)
            except:
                pass
        else:
            try:
                CACHE_SIZE_BYTE = maintool.get_size(CACHE)
                PACKAGES_SIZE_BYTE = maintool.get_size(PACKAGES)
                THUMB_SIZE_BYTE = maintool.get_size(THUMBS)
            except:
                pass

        if CACHE == "NULL":
            try:
                PACKAGES_SIZE = maintool.convertSize(PACKAGES_SIZE_BYTE)
                THUMB_SIZE = maintool.convertSize(THUMB_SIZE_BYTE)
            except:
                pass
        else:
            try:
                CACHE_SIZE = maintool.convertSize(CACHE_SIZE_BYTE)
                PACKAGES_SIZE = maintool.convertSize(PACKAGES_SIZE_BYTE)
                THUMB_SIZE = maintool.convertSize(THUMB_SIZE_BYTE)
            except:
                pass

        if CACHE == "NULL":
            CACHE_SIZE = "Error reading cache"

    PV = sys.version_info

    kodi.addItem(
        '[COLOR ghostwhite]Version: [/COLOR][COLOR lime]%s' % codename + " " +
        str(versioni) + "[/COLOR]",
        '',
        100,
        artwork + 'icon.png',
        "",
        description=" ")
    kodi.addItem('[COLOR ghostwhite]System Time: [/COLOR][COLOR lime]' +
                 systime + '[/COLOR]',
                 '',
                 100,
                 artwork + 'icon.png',
                 "",
                 description=" ")
    kodi.addItem('[COLOR ghostwhite]Gateway: [/COLOR][COLOR blue]' + gateway +
                 '[/COLOR]',
                 '',
                 100,
                 artwork + 'icon.png',
                 "",
                 description=" ")
    kodi.addItem('[COLOR ghostwhite]Local IP: [/COLOR][COLOR blue]' + ipaddy +
                 '[/COLOR]',
                 '',
                 100,
                 artwork + 'icon.png',
                 "",
                 description=" ")
    kodi.addItem('[COLOR ghostwhite]External IP: [/COLOR][COLOR blue]' +
                 m.group(0) + '[/COLOR]',
                 '',
                 100,
                 artwork + 'icon.png',
                 "",
                 description=" ")
    kodi.addItem('[COLOR ghostwhite]DNS 1: [/COLOR][COLOR blue]' + dns1 +
                 '[/COLOR]',
                 '',
                 100,
                 artwork + 'icon.png',
                 "",
                 description=" ")
    kodi.addItem('[COLOR ghostwhite]Network: [/COLOR][COLOR gold]' +
                 linkstate + '[/COLOR]',
                 '',
                 100,
                 artwork + 'icon.png',
                 "",
                 description=" ")
    kodi.addItem('[COLOR ghostwhite]Disc Space: [/COLOR][COLOR gold]' +
                 str(totalspace) + '[/COLOR]',
                 '',
                 100,
                 artwork + 'icon.png',
                 "",
                 description=" ")
    kodi.addItem('[COLOR ghostwhite]Disc Space: [/COLOR][COLOR gold]' +
                 str(freespace) + '[/COLOR]',
                 '',
                 100,
                 artwork + 'icon.png',
                 "",
                 description=" ")
    kodi.addItem('[COLOR ghostwhite]Free Memory: [/COLOR][COLOR gold]' +
                 str(freemem) + '[/COLOR]',
                 '',
                 100,
                 artwork + 'icon.png',
                 "",
                 description=" ")
    kodi.addItem('[COLOR ghostwhite]Resolution: [/COLOR][COLOR gold]' +
                 str(screenres) + '[/COLOR]',
                 '',
                 100,
                 artwork + 'icon.png',
                 "",
                 description=" ")
    kodi.addItem(
        '[COLOR ghostwhite]Python Version: [/COLOR][COLOR lime]%d.%d.%d' %
        (PV[0], PV[1], PV[2]) + '[/COLOR]',
        '',
        100,
        artwork + 'icon.png',
        "",
        description=" ")
    if check_folders == "true":
        try:
            kodi.addItem("Cache Size: [COLOR blue]" + str(CACHE_SIZE) +
                         '[/COLOR]',
                         '',
                         'null',
                         artwork + 'currentcache.png',
                         description="Clear your device cache!")
            kodi.addItem("Packages Size: [COLOR blue]" + str(PACKAGES_SIZE) +
                         '[/COLOR]',
                         'null',
                         '',
                         artwork + 'currentpackages.png',
                         description="Clear your device cache!")
            kodi.addItem("Thumbnail Size: [COLOR blue]" + str(THUMB_SIZE) +
                         '[/COLOR]',
                         'null',
                         '',
                         artwork + 'currentthumbs.png',
                         description="Clear your device cache!")
        except:
            pass

    viewsetter.set_view("files")
示例#2
0
if not os.path.exists(CACHE):
    CACHE     =  xbmc.translatePath(os.path.join('special://home/temp',''))
if not os.path.exists(PACKAGES):
    os.makedirs(PACKAGES)
    
if not CLEAR_CACHE_SIZE == "0":
    if CLEAR_CACHE_SIZE == "1":
        CACHE_TO_CLEAR = 25000000
    if CLEAR_CACHE_SIZE == "2":
        CACHE_TO_CLEAR = 50000000
    if CLEAR_CACHE_SIZE == "3":
        CACHE_TO_CLEAR = 75000000
    if CLEAR_CACHE_SIZE == "4":
        CACHE_TO_CLEAR = 100000000

    CACHE_SIZE_BYTE    = maintool.get_size(CACHE)
    
    if  CACHE_SIZE_BYTE > CACHE_TO_CLEAR:
        maintool.AUTO_CLEAR_CACHE_MB()

if not CLEAR_PACKAGES_SIZE == "0":
    if CLEAR_PACKAGES_SIZE == "1":
        PACKAGES_TO_CLEAR = 25000000
    if CLEAR_PACKAGES_SIZE == "2":
        PACKAGES_TO_CLEAR = 50000000
    if CLEAR_PACKAGES_SIZE == "3":
        PACKAGES_TO_CLEAR = 75000000
    if CLEAR_PACKAGES_SIZE == "4":
        PACKAGES_TO_CLEAR = 100000000

    PACKAGES_SIZE_BYTE    = maintool.get_size(PACKAGES)