Kodi Community Forum
Packages zip remove script - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Program Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=151)
+---- Thread: Packages zip remove script (/showthread.php?tid=314931)



Packages zip remove script - myfototv - 2017-05-24

Hi there Im trying to make a script that will count and remove the old zip files from the packages folder.
Currently Im just trying to get the yesno dialog window up with the file count, but having no joy, could anyone help as to where its going wrong.
Possibly a module I havnt imported?

Code:
import os
import xbmc
import xbmcgui
import zipfile
import shutil
import time
import datetime
import sys

dir_to_count = xbmc.translatePath('special://home/addons/packages')

def count_files(dir_to_count):
    x = 0
    for root, dirs, files in os.walk(dir_to_count):
        for f in files:
            x = x+1
    YESNOWINDOW = xbmcgui.Dialog().yesno(
        "Your package folder has been Checked",
        "You have", x, "zip files in that directory",
        "Would you like to free up some space",
        "and remove these files?",
        "No Thanks",
        "Yes Please")
    if YESNOWINDOW:
        '''run the remove_zip script'''
        xbmcgui.Dialog().ok(
            "Running the removal script",
            "Thats it. All done",
            "Click OK to exit",
            "")
        
    else:
        xbmcgui.Dialog().ok(
            "Not running the removal script"            "
            "Nothing on your system has changed",
            "If you are low on space, you can",
            "run this program again at any time")