HXN1

Clean your pc.py

May 6th, 2022
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.33 KB | None | 0 0
  1. import os
  2. try:
  3.     import requests
  4.     import socket as s
  5.     import webbrowser
  6.     from sys import platform
  7.     import colorama
  8.  
  9. except ModuleNotFoundError:
  10.     os.system("pip install requests")
  11.     os.system("pip install socket")
  12.     os.system("pip install webbrowser")
  13.     os.system("pip install sys")
  14.     os.system("pip install platform")
  15.     os.system("pip install colorama")
  16.     os.system("pip install Today")
  17.     os.system("pip install Date")
  18.     os.system("pip install os")
  19. import webbrowser
  20. url = "https://t.me/HEXiN1K"
  21. webbrowser.open(url)
  22. from sys import platform
  23. from colorama import *
  24. import socket
  25. import requests
  26. from datetime import datetime
  27.  
  28. now = datetime.now()
  29.  
  30. current_time = now.strftime
  31.  
  32. name = socket.gethostname()
  33.  
  34. myHostName = socket.gethostname()
  35.  
  36. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  37.  
  38. print("\n===========================================================")
  39. name = ("""\n                    Hello sir """ +name+Style.RESET_ALL)
  40. print(name)
  41.  
  42. import datetime
  43. e = datetime.datetime.now()
  44. print (Fore.CYAN+"""\n                   Your Day is """+"%s/%s/%s" % (e.day, e.month, e.year))
  45. print ("""\n                   The time is """+ "%s:%s:%s" % (e.hour, e.minute, e.second))
  46.  
  47. host = (Fore.WHITE+"""\n                  Your platform is """+ platform+Style.RESET_ALL)
  48. print(host)
  49.  
  50. api = "https://api.ipify.org/?format=json"
  51. req = requests.get(api)
  52. response = req.json()
  53. a = response["ip"]
  54.  
  55. IP = ("""\n                Your Local iP is """+Fore.RED+a+Style.RESET_ALL)
  56. print(IP)
  57.  
  58. v = (Fore.RED+"""\n                    Your iNFO PROXY is\n"""+Style.RESET_ALL)
  59.  
  60. print(v)
  61. print(s)
  62.  
  63. print("\n===========================================================")
  64.  
  65.  
  66. import webbrowser
  67. import tkinter
  68. import tkinter.messagebox
  69. import os
  70. import os.path
  71. import threading
  72. url = "https://instagram.com/hxn.py/"
  73. webbrowser.open(url)
  74.  
  75. rubbishExt = ['.tmp', '.bak', '.old', '.wbk', '.xlk', '_mp', '.gid',
  76.               '.chk', '.syd', '.$$$', '.@@@', ".~*"]
  77.  
  78.  
  79. def GetDrives():
  80.     drives = []
  81.     for i in range(65, 91):
  82.         vol = chr(i) + ":/"
  83.         if os.path.isdir(vol):
  84.             drives.append(vol)
  85.     return tuple(drives)
  86.  
  87.  
  88. class Window:
  89.     def __init__(self):
  90.         self.root = tkinter.Tk()
  91.  
  92.         menu = tkinter.Menu(self.root)
  93.  
  94.         submenu = tkinter.Menu(menu, tearoff=0)
  95.         submenu.add_command(label="About...", command=self.MenuAbout)
  96.         submenu.add_separator()
  97.         submenu.add_command(label="Quit", command=self.MenuExit)
  98.         menu.add_cascade(label="System", menu=submenu)
  99.  
  100.         submenu = tkinter.Menu(menu, tearoff=0)
  101.         submenu.add_command(label="Scan", command=self.MenuScanRubbish)
  102.         submenu.add_command(label="Delete", command=self.MenuDelRubbish)
  103.         menu.add_cascade(label="Clean", menu=submenu)
  104.  
  105.         submenu = tkinter.Menu(menu, tearoff=0)
  106.         submenu.add_command(label="Search Big Files",
  107.                             command=self.MenuScanBigFile)
  108.         submenu.add_separator()
  109.         submenu.add_command(label="Search Big Files By Name",
  110.                             command=self.MenuSearchFile)
  111.         menu.add_cascade(label="Search", menu=submenu)
  112.  
  113.         self.root.config(menu=menu)
  114.  
  115.         self.progress = tkinter.Label(self.root, anchor=tkinter.W,
  116.                                       text='Status', bitmap='hourglass',
  117.                                       compound='left')
  118.         self.progress.place(x=10, y=370, width=480, height=15)
  119.  
  120.         self.flist = tkinter.Text(self.root)
  121.         self.flist.place(x=10, y=10, width=480, height=350)
  122.  
  123.         self.vscroll = tkinter.Scrollbar(self.flist)
  124.         self.vscroll.pack(side='right', fill='y')
  125.         self.flist['yscrollcommand'] = self.vscroll.set
  126.         self.vscroll['command'] = self.flist.yview
  127.  
  128.     def MainLoop(self):
  129.         self.root.title("Clean Your PC ~ insta @hxn.py")
  130.         self.root.minsize(500, 400)
  131.         self.root.maxsize(500, 400)
  132.         self.root.mainloop()
  133.  
  134.     def MenuAbout(self):
  135.         tkinter.messagebox.showinfo("Clean Your PC ~ insta @hxn.py",
  136.                                     "Hello sir, this program is special for you to clean your disk of suspicious and large files :)")
  137.  
  138.     def MenuExit(self):
  139.         self.root.quit()
  140.  
  141.     def MenuScanRubbish(self):
  142.         result = tkinter.messagebox.askquestion("Clean Your PC ~ insta @hxn.py", "Scaning" +
  143.                                                 " junk files may cost much time. Continue?")
  144.         if result == 'no':
  145.             return
  146.         tkinter.messagebox.showinfo("Clean Your PC ~ insta @hxn.py", "Scaning in no time!")
  147.  
  148.         self.drives = GetDrives()
  149.         t = threading.Thread(target=self.ScanRubbish, args=(self.drives,))
  150.         t.start()
  151.  
  152.     def MenuDelRubbish(self):
  153.         result = tkinter.messagebox.askquestion("Clean Your PC ~ insta @hxn.py",
  154.                                                 "Deleting junk files may cost much time. Continue?")
  155.         if result == 'no':
  156.             return
  157.         tkinter.messagebox.showinfo("Clean Your PC ~ insta @hxn.py", "Deleting in no time!")
  158.         self.drives = GetDrives()
  159.         t = threading.Thread(target=self.DeleteRubbish, args=(self.drives,))
  160.         t.start()
  161.  
  162.     def MenuScanBigFile(self):
  163.         result = tkinter.messagebox.askquestion("Clean Your PC ~ insta @hxn.py",
  164.                                                 "Scaning big files may cost much time. Continue?")
  165.         if result == 'no':
  166.             return
  167.         tkinter.messagebox.showinfo("Clean Your PC ~ insta @hxn.py", "Scaning in no time!")
  168.  
  169.     def MenuSearchFile(self):
  170.         result = tkinter.messagebox.askquestion("Clean Your PC ~ insta @hxn.py,"
  171.                                                 "Searching big files by name may cost much time. Continue?")
  172.         if result == 'no':
  173.             return
  174.         tkinter.messagebox.showinfo("Clean Your PC ~ insta @hxn.py", "Searching in no time!")
  175.  
  176.     def ScanRubbish(self, scanpath):
  177.         global rubbishExt
  178.         total = 0
  179.         filesize = 0
  180.         for drive in scanpath:
  181.             for root, dirs, files in os.walk(drive):
  182.                 try:
  183.                     for fil in files:
  184.                         filesplit = os.path.splitext(fil)
  185.                         if filesplit[1] == '':
  186.                             continue
  187.                         try:
  188.                             if rubbishExt.index(filesplit[1]) >= 0:
  189.                                 fname = os.path.join(
  190.                                     os.path.abspath(root), fil)
  191.                                 filesize += os.path.getsize(fname)
  192.                                 if total % 20 == 0:
  193.                                     self.flist.delete(0.0, tkinter.END)
  194.                                 self.flist.insert(tkinter.END, fname + '\n')
  195.                                 l = len(fname)
  196.                                 if l > 60:
  197.                                     self.progress['text'] = fname[:30] + '...' + \
  198.                                                             fname[l - 30:l]
  199.                                 else:
  200.                                     self.progress['text'] = fname
  201.                                 total += 1
  202.                         except ValueError:
  203.                             pass
  204.                 except Exception as e:
  205.                     print(e)
  206.                     pass
  207.         self.progress['text'] = "Find %s junk files, occupy %.2f M disk space" \
  208.                                 % (total, filesize / 1024 / 1024)
  209.  
  210.     def DeleteRubbish(self, scanpath):
  211.         global rubbishExt
  212.         total = 0
  213.         filesize = 0
  214.         for drive in scanpath:
  215.             for root, dirs, files in os.walk(drive):
  216.                 try:
  217.                     for fil in files:
  218.                         filesplit = os.path.splitext(fil)
  219.                         if filesplit[1] == '':
  220.                             continue
  221.                         try:
  222.                             if rubbishExt.index(filesplit[1]) >= 0:
  223.                                 fname = os.path.join(
  224.                                     os.path.abspath(root), fil)
  225.                                 filesize += os.path.getsize(fname)
  226.                                 try:
  227.                                     os.remove(fname)
  228.                                     l = len(fname)
  229.                                     if l > 50:
  230.                                         fname = fname[:25] + "..." + \
  231.                                                 fname[l - 25:l]
  232.                                     if total % 15 == 0:
  233.                                         self.flist.delete(0.0, tkinter.END)
  234.                                     self.flist.insert(tkinter.END, 'Deleted '
  235.                                                       + fname + '\n')
  236.                                     self.progress['text'] = fname
  237.                                     total += 1
  238.                                 except:
  239.                                     pass
  240.                         except ValueError:
  241.                             pass
  242.                 except Exception as e:
  243.                     print(e)
  244.                     pass
  245.         self.progress['text'] = f"Deleted {total} junk files, recover {filesize / 1024 / 1024} M disk space"
  246.  
  247.  
  248. if __name__ == "__main__":
  249.     window = Window()
  250.     window.MainLoop()
  251.  
Advertisement
Add Comment
Please, Sign In to add comment