Esempio n. 1
0
 def empty(confirm=True, show_progress=True, sound=True):
     flags = 0
     if not confirm:
         flags |= shellcon.SHERB_NOCONFIRMATION
     if not show_progress:
         flags |= shellcon.SHERB_NOPROGRESSUI
     if not sound:
         flags |= shellcon.SHERB_NOSOUND
     shell.SHEmptyRecycleBin(None, None, flags)
Esempio n. 2
0
def empty_recycle_bin(drive, really_delete):
    """Empty the recycle bin or preview its size"""
    bytes_used = shell.SHQueryRecycleBin(drive)[0]
    if really_delete and bytes_used > 0:
        # Trying to delete an empty Recycle Bin on Vista/7 causes a
        # 'catastrophic failure'
        flags = shellcon.SHERB_NOSOUND | shellcon.SHERB_NOCONFIRMATION | shellcon.SHERB_NOPROGRESSUI
        shell.SHEmptyRecycleBin(None, drive, flags)
    return bytes_used
Esempio n. 3
0
def cmd_recycle_bin(ensoapi, operation="show"):
    """ Recycle bin {operation} """
    if operation.startswith("show"):
        #drive = operation.split(" ")[1]
        ensoapi.display_message("Opening Recycle Bin")
        """
        win32api.ShellExecute(
            0,
            "open",
            "explorer.exe " ,
            "/root,::{645FF040-5081-101B-9F08-00AA002F954E} ",
            None,
            1)
        """
        try:
            os.startfile(os.path.normpath(RECYCLE_BIN_LINK))
        except:
            pass
    elif operation.startswith("delete "):
        drive = operation.split(" ")[1]
        # SHERB_NOCONFIRMATION
        #    No dialog box confirming the deletion of the objects will be displayed.
        # SHERB_NOPROGRESSUI
        #    No dialog box indicating the progress will be displayed.
        # SHERB_NOSOUND
        #    No sound will be played when the operation is complete.
        print drive
        res = shell.SHEmptyRecycleBin(0, drive, 0)
    elif operation == "info":
        bins_info = _get_recycle_bins()
        if len(bins_info) > 0:
            infos = []
            for drive, size, files in bins_info:
                if files == 0 and size == 0:
                    infos.append(u"<command>%s</command> empty" % drive)
                else:
                    if size < 1024:
                        size_hr = "%.2f B" % size
                    elif size < 1024 * 1024:
                        size_hr = "%.2f kB" % (size / 1024)
                    elif size < 1024 * 1024 * 1024:
                        size_hr = "%.2f MB" % (size / 1024 / 1024)
                    elif size < 1024 * 1024 * 1024 * 1024:
                        size_hr = "%.2f GB" % (size / 1024 / 1024 / 1024)
                    elif size < 1024 * 1024 * 1024 * 1024 * 1024:
                        size_hr = "%.2f TB" % (size / 1024 / 1024 / 1024 /
                                               1024)
                    infos.append(u"<command>%s</command> %s in %d files" %
                                 (drive, size_hr, files))
                msg = u"<p>%s</p><caption>Recycle bin(s) information</caption>" % u"</p><p>".join(
                    infos)
            displayMessage(msg)
        else:
            ensoapi.display_message(
                u"There appears to be no recycle bins on this system")
Esempio n. 4
0
def empty_recycle_bin(path, really_delete):
    """Empty the recycle bin or preview its size.

    If the recycle bin is empty, it is not emptied again to avoid an error.

    Keyword arguments:
    path          -- A drive, folder or None.  None refers to all recycle bins.
    really_delete -- If True, then delete.  If False, then just preview.
    """
    (bytes_used, num_files) = shell.SHQueryRecycleBin(path)
    if really_delete and num_files > 0:
        # Trying to delete an empty Recycle Bin on Vista/7 causes a
        # 'catastrophic failure'
        flags = shellcon.SHERB_NOSOUND | shellcon.SHERB_NOCONFIRMATION | shellcon.SHERB_NOPROGRESSUI
        shell.SHEmptyRecycleBin(None, path, flags)
    return bytes_used
Esempio n. 5
0
	def cleanRecyclerBin(self, tipo=0, unidad='C:'):	# int Tipo, str Unidad.
		""" Tipos:
		 -------------------------------------------------------------
		| 0 = NORMAL			  | 4 = SIN_SONIDO					  |
		| 1 = SIN_CONFIRMACION	  | 5 = 4 + 1						  |
		| 2 = SIN_BARRA_PROGRESO  | 6 = 4 + 2						  |
		| 3 = 2 + 1				  | 7 = 4 + 2 + 1 = TOTAL_INADVERTIDO |
		 -------------------------------------------------------------
		"""
		unidad = unidad.upper()
		if re.search('^[A-Z]{1}:$', str(unidad)) == None:
			return False
		if tipo >= 0 and tipo <= 7:
			try:
				shell.SHEmptyRecycleBin(None, unidad, tipo)
			except pywintypes.com_error:
				raise self.ErrorVaciarPapelera('La papelera ya esta vacia.')
Esempio n. 6
0
 def empty(confirm=False, show_progress=False, sound=False):
     """
     清空回收站
     :param confirm: 是否弹出确认对话框
     :param show_progress: 是否展示处理进度条
     :param sound: 完成时是否声音提示
     :return:
     """
     if not RecycleBin.is_empty(None):
         flags = 0
         if not confirm:
             flags |= shellcon.SHERB_NOCONFIRMATION
         if not show_progress:
             flags |= shellcon.SHERB_NOPROGRESSUI
         if not sound:
             flags |= shellcon.SHERB_NOSOUND
         shell.SHEmptyRecycleBin(None, None, flags)
Esempio n. 7
0
    smtp = smtplib.SMTP("direcciondelsmtp", 587)
    # smtp = SMTP()
    smtp.ehlo()
    smtp.starttls()
    #    smtp.ehlo()
    smtp.login(from_address, "passworddelcorreo")
    smtp.sendmail(from_address, to_address, mime_message.as_string())
    smtp.quit()


if __name__ == "__main__":
    main()

#vaciamos la papeleria
shell.SHEmptyRecycleBin(
    None, None, shellcon.SHERB_NOCONFIRMATION
    | shellcon.SHERB_NOPROGRESSUI
    | shellcon.SHERB_NOSOUND)
#borrado de arcivos para 64 bits
print "Borrando Backup en c:\windows"
os.remove("C:\\Windows\\SysWOW64\\" + archivo1)
print "Se ha eliminado arcivo: " + archivo1
os.remove("C:\\Windows\\SysWOW64\\" + archivo2)
print "Se ha eliminado arcivo: " + archivo2
os.remove("C:\\Windows\\SysWOW64\\" + archivo3)
print "Se ha eliminado arcivo: " + archivo3
os.remove("C:\\Windows\\SysWOW64\\" + archivo4)
print "Se ha eliminado arcivo: " + archivo4
os.remove("C:\\Windows\\SysWOW64\\" + archivo5)
print "Se ha eliminado arcivo: " + archivo5
os.remove("C:\\Windows\\SysWOW64\\" + archivo6)
print "Se ha eliminado arcivo: " + archivo6
Esempio n. 8
0
def empty_recycle_bin():
    print('Emptying Recycle bin')
    shell.SHEmptyRecycleBin(0, None, 1)
    print('Recycle bin emptied')
    time.sleep(1)