本文整理匯總了Python中Windows.delete_updates方法的典型用法代碼示例。如果您正苦於以下問題:Python Windows.delete_updates方法的具體用法?Python Windows.delete_updates怎麽用?Python Windows.delete_updates使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Windows
的用法示例。
在下文中一共展示了Windows.delete_updates方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_commands
# 需要導入模塊: import Windows [as 別名]
# 或者: from Windows import delete_updates [as 別名]
#.........這裏部分代碼省略.........
is_open = FileUtilities.openfiles.is_open(path)
ok = not is_open and os.path.isfile(path) and \
not os.path.islink(path) and \
FileUtilities.ego_owner(path) and \
not self.whitelisted(path)
if ok:
yield Command.Delete(path)
# temporary files
if 'nt' == os.name and 'tmp' == option_id:
dirname = os.path.expandvars(
"$USERPROFILE\\Local Settings\\Temp\\")
for filename in children_in_directory(dirname, True):
yield Command.Delete(filename)
dirname = os.path.expandvars("$windir\\temp\\")
for filename in children_in_directory(dirname, True):
yield Command.Delete(filename)
# trash
if 'posix' == os.name and 'trash' == option_id:
dirname = os.path.expanduser("~/.Trash")
for filename in children_in_directory(dirname, False):
yield Command.Delete(filename)
# fixme http://www.ramendik.ru/docs/trashspec.html
# http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
# ~/.local/share/Trash
# * GNOME 2.22, Fedora 9
# * KDE 4.1.3, Ubuntu 8.10
dirname = os.path.expanduser("~/.local/share/Trash/files")
for filename in children_in_directory(dirname, True):
yield Command.Delete(filename)
dirname = os.path.expanduser("~/.local/share/Trash/info")
for filename in children_in_directory(dirname, True):
yield Command.Delete(filename)
dirname = os.path.expanduser("~/.local/share/Trash/expunged")
# [email protected] tells me that the trash
# backend puts files in here temporary, but in some situations
# the files are stuck.
for filename in children_in_directory(dirname, True):
yield Command.Delete(filename)
# clipboard
if HAVE_GTK and 'clipboard' == option_id:
def clear_clipboard():
gtk.gdk.threads_enter()
clipboard = gtk.clipboard_get()
clipboard.set_text("")
gtk.gdk.threads_leave()
return 0
yield Command.Function(None, clear_clipboard, _('Clipboard'))
# overwrite free space
shred_drives = options.get_list('shred_drives')
if 'free_disk_space' == option_id and shred_drives:
for pathname in shred_drives:
# TRANSLATORS: 'Free' means 'unallocated.'
# %s expands to a path such as C:\ or /tmp/
display = _("Overwrite free disk space %s") % pathname
def wipe_path_func():
for ret in FileUtilities.wipe_path(pathname, idle=True):
# Yield control to GTK idle because this process
# is very slow. Also display progress.
yield ret
yield 0
yield Command.Function(None, wipe_path_func, display)
# MUICache
if 'nt' == os.name and 'muicache' == option_id:
keys = (
'HKCU\\Software\\Microsoft\\Windows\\ShellNoRoam\\MUICache',
'HKCU\\Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\Shell\\MuiCache')
for key in keys:
yield Command.Winreg(key, None)
# prefetch
if 'nt' == os.name and 'prefetch' == option_id:
for path in glob.iglob(os.path.expandvars('$windir\\Prefetch\\*.pf')):
yield Command.Delete(path)
# recycle bin
if 'nt' == os.name and 'recycle_bin' == option_id:
for drive in Windows.get_fixed_drives():
# TRANSLATORS: %s expands to a drive letter such as C:\ or D:\
label = _("Recycle bin %s") % drive
def emptyrecyclebin():
return Windows.empty_recycle_bin(drive, True)
# fixme: enable size preview
yield Command.Function(None, emptyrecyclebin, label)
# Windows Updates
if 'nt' == os.name and 'updates' == option_id:
for wu in Windows.delete_updates():
yield wu
# return queued files
for filename in files:
if os.path.lexists(filename):
yield Command.Delete(filename)
示例2: get_commands
# 需要導入模塊: import Windows [as 別名]
# 或者: from Windows import delete_updates [as 別名]
#.........這裏部分代碼省略.........
# trash
if "posix" == os.name and "trash" == option_id:
dirname = os.path.expanduser("~/.Trash")
for filename in children_in_directory(dirname, False):
yield Command.Delete(filename)
# fixme http://www.ramendik.ru/docs/trashspec.html
# http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
# ~/.local/share/Trash
# * GNOME 2.22, Fedora 9
# * KDE 4.1.3, Ubuntu 8.10
dirname = os.path.expanduser("~/.local/share/Trash/files")
for filename in children_in_directory(dirname, True):
yield Command.Delete(filename)
dirname = os.path.expanduser("~/.local/share/Trash/info")
for filename in children_in_directory(dirname, True):
yield Command.Delete(filename)
dirname = os.path.expanduser("~/.local/share/Trash/expunged")
# [email protected] tells me that the trash
# backend puts files in here temporary, but in some situations
# the files are stuck.
for filename in children_in_directory(dirname, True):
yield Command.Delete(filename)
# clipboard
if HAVE_GTK and "clipboard" == option_id:
def clear_clipboard():
gtk.gdk.threads_enter()
clipboard = gtk.clipboard_get()
clipboard.set_text("")
gtk.gdk.threads_leave()
return 0
yield Command.Function(None, clear_clipboard, _("Clipboard"))
# overwrite free space
shred_drives = options.get_list("shred_drives")
if "free_disk_space" == option_id and shred_drives:
for pathname in shred_drives:
# TRANSLATORS: 'Free' means 'unallocated.'
# %s expands to a path such as C:\ or /tmp/
display = _("Overwrite free disk space %s") % pathname
def wipe_path_func():
for ret in FileUtilities.wipe_path(pathname, idle=True):
# Yield control to GTK idle because this process
# is very slow. Also display progress.
yield ret
yield 0
yield Command.Function(None, wipe_path_func, display)
# MUICache
if "nt" == os.name and "muicache" == option_id:
keys = (
"HKCU\\Software\\Microsoft\\Windows\\ShellNoRoam\\MUICache",
"HKCU\\Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\Shell\\MuiCache",
)
for key in keys:
yield Command.Winreg(key, None)
# prefetch
if "nt" == os.name and "prefetch" == option_id:
for path in glob.iglob(os.path.expandvars("$windir\\Prefetch\\*.pf")):
yield Command.Delete(path)
# recycle bin
if "nt" == os.name and "recycle_bin" == option_id:
# This method allows shredding
for path in Windows.get_recycle_bin():
yield Command.Delete(path)
# If there were any files deleted, Windows XP will show the
# wrong icon for the recycle bin indicating it is not empty.
# The icon will be incorrect until logging in to Windows again
# or until it is emptied using the Windows API call for emptying
# the recycle bin.
# Windows 10 refreshes the recycle bin icon when the user
# opens the recycle bin folder.
# This is a hack to refresh the icon.
import tempfile
tmpdir = tempfile.mkdtemp()
Windows.move_to_recycle_bin(tmpdir)
try:
Windows.empty_recycle_bin(None, True)
except:
logger = logging.getLogger(__name__)
logger.info("error in empty_recycle_bin()", exc_info=True)
# Windows Updates
if "nt" == os.name and "updates" == option_id:
for wu in Windows.delete_updates():
yield wu
# return queued files
for filename in files:
if os.path.lexists(filename):
yield Command.Delete(filename)