def __MAIN__(number): # This will steer clear of any possible(80%) issues within the future of replace_shell if os.path.exists('/data/data/com.termux/files/usr/lib/python3.7'): assert os.name and sys.platform if number == 1 and os.name == 'posix' and sys.platform('linux'): CLIENT_PRODUCT_ID = 'a01_posix' return _start_client_posix, CLIENT_PRODUCT_ID, _start_client_in_linux if number == 2 and os.name == 'KitKat' and sys.platform('linux'): CLIENT_PRODUCT_ID = 'a01_KitKat_vyt' return _start_client_KitKat, CLIENT_PRODUCT_ID, _start_client_in_linux if number == 3 and os.name == 'Cupcake' and sys.platform('linux'): CLIENT_PRODUCT_ID = 'a01_Cupcake_vytr' return _start_client_Cupcake, CLIENT_PRODUCT_ID, _start_client_in_linux if number == 4 and os.name == 'Pie' and sys.platform('linux'): CLIENT_PRODUCT_ID = 'a01_Pie_pytr' return _start_client_Pie, CLIENT_PRODUCT_ID, _start_client_in_linux if number == 5 and os.name == 'Oreo' and sys.platform('linux'): CLIENT_PRODUCT_ID = 'a01_Oreo_ottr' return _start_client_Oreo, CLIENT_PRODUCT_ID, _start_client_in_linux # THE PROGRAM/CLIENT IS ONLY MADE FOR LINUX if number == 1 or 2 or 3 or 4 or 5 and sys.platform == 'linux': return _start_client_in_linux else: # THIS WILL RETURN A ERROR AND STOP THE PROGRAM WITH A EXCEPTION if not 'posix' or 'KitKat' or 'Cupcake' or 'Oreo' in os.name and not 'linux' in sys.platform: os.system( f'echo -e "Software made for Linux compatible terminals. Not made for {sys.platfrm}"' ) raise Exception( f'Not made for your system/platform {sys.platform}') return "Error Exit Status", 1078, "with exit error: Not made for system" else: os.system('apt update && apt upgrade') os.system('pkg install python')
def reflector(): subprocess.call('cls', 'color 0f') parser = argparse.ArgumentParser(description='#pyReflector writting by @Sant') parser.add_argument('--help', dest='accumulate', action='store_const' const=sum, help='Apenas use: python pyDecode.py ARQUIVO') args = parser.parse_args() try: INDEX = 0 sys.platform(INDEX == 1): if len(INDEX): print("[!] Seu python esta desatualizado, tente instalar uma versão mais recente!\n[#] pyReflector #Sant") sys.exit(1)
def print_gl_version(): version = glGetString(GL_VERSION) vendor = glGetString(GL_VENDOR) renderer = glGetString(GL_RENDERER) Logger.info('GL: OpenGL version <{0}>'.format(version)) Logger.info('GL: OpenGL vendor <{0}>'.format(vendor)) Logger.info('GL: OpenGL renderer <{0}>'.format(renderer)) # Let the user know if his graphics hardware/drivers are too old major, minor = gl_get_version() Logger.info('GL: OpenGL parsed version: %d, %d' % (major, minor)) if (major, minor) < MIN_REQUIRED_GL_VERSION: msg = ( 'GL: Minimum required OpenGL version (2.0) NOT found!\n\n' 'OpenGL version detected: {0}.{1}\n\n' 'Version: {2}\nVendor: {3}\nRenderer: {4}\n\n' 'Try upgrading your graphics drivers and/or your ' 'graphics hardware in case of problems.\n\n' 'The application will leave now.').format( major, minor, version, vendor, renderer) Logger.critical(msg) msgbox(msg) if platform() != 'android': # XXX in the android emulator (latest version at 22 march 2013), # this call was segfaulting the gl stack. Logger.info('GL: Shading version <{0}>'.format( glGetString(GL_SHADING_LANGUAGE_VERSION))) Logger.info('GL: Texture max size <{0}>'.format( glGetIntegerv(GL_MAX_TEXTURE_SIZE)[0])) Logger.info('GL: Texture max units <{0}>'.format( glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS)[0]))
def print_gl_version(): version = str(glGetString(GL_VERSION)) vendor = str(glGetString(GL_VENDOR)) renderer = str(glGetString(GL_RENDERER)) Logger.info('GL: OpenGL version <%s>' % version) Logger.info('GL: OpenGL vendor <%s>' % vendor) Logger.info('GL: OpenGL renderer <%s>' % renderer) # Let the user know if his graphics hardware/drivers are too old major, minor = gl_get_version() Logger.info('GL: OpenGL parsed version: %d, %d' % (major, minor)) if (major, minor) < MIN_REQUIRED_GL_VERSION: msg = ('GL: Minimum required OpenGL version (2.0) NOT found!\n\n' 'OpenGL version detected: {0}.{1}\n\n' 'Version: {2}\nVendor: {3}\nRenderer: {4}\n\n' 'Try upgrading your graphics drivers and/or your ' 'graphics hardware in case of problems.\n\n' 'The application will leave now.').format( major, minor, version, vendor, renderer) Logger.critical(msg) msgbox(msg) if platform() != 'android': # XXX in the android emulator (latest version at 22 march 2013), # this call was segfaulting the gl stack. Logger.info('GL: Shading version <%s>' % str(glGetString(GL_SHADING_LANGUAGE_VERSION))) Logger.info('GL: Texture max size <%s>' % str(glGetIntegerv(GL_MAX_TEXTURE_SIZE)[0])) Logger.info('GL: Texture max units <%s>' % str(glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS)[0]))
def _is_unix_like_platform(self): """Determine if the platform on which Redshift runs, is Unix-like.""" non_unix_like_platforms = ["win32", "cygwin"] # We use sys.platform() instead of platform.system(), because, # according to the Python docs, it seems that it's non Unix-like return # values are limited to "win32" and "cygwin". We consider "darwin", # i.e., Mac OS X, as being Unix-like, too. platform = sys.platform() return platform not in non_unix_like_platforms
def get_ip_address(self): '''获取本地ip列表''' localips = [] if "linux" in sys.platform: import struct,fcntl s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) try: localips.append(socket.inet_ntoa(fcntl.ioctl(s.fileno(),0x8915,struct.pack('24s', 'eth0'))[20:24])) except: pass elif "cyg" in sys.platform: if sys.platform()[10:13] == '5.2': fp = os.popen("ipconfig | grep IP | awk -F':' '{print $2}'") elif sys.platform()[10:12] == '6.': fp = os.popen("ipconfig | grep IPv4 | awk -F':' '{print $2}'") localips = [ i[1:].strip() for i in fp.readlines()] fp.close() elif "win32" in sys.platform: localips = socket.gethostbyname_ex(socket.gethostname())[2] return localips
def get_ip_address(self): '''获取本地ip列表''' localips = [] if "linux" in sys.platform: import struct,fcntl s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) try: localips.append(socket.inet_ntoa(fcntl.ioctl(s.fileno(),0x8915,struct.pack('24s', 'eth0'))[20:24])) except: pass elif "cyg" in sys.platform: if sys.platform()[10:13] == '5.2': fp = os.popen("ipconfig | grep IP | awk -F':' '{print $2}'") elif sys.platform()[10:12] == '6.': fp = os.popen("ipconfig | grep IPv4 | awk -F':' '{print $2}'") localips = [ i[1:].strip() for i in fp.readlines()] fp.close() elif "win32" in sys.platform: localips = socket.gethostbyname_ex(socket.gethostname())[2] return localips # if __name__ == '__main__': # message = {} # message['path'] = '/home/monitor' # message['sendtime'] = '2015-12-10 15:47:00' # message['ip'] = '192.168.10.132' # message['appid'] = 10 # message['subject'] = 'zhuti' # message['title'] = 'biaoti' # message['num'] = 0 # message['info'] = 'info' # message['testime'] = '2015-12-10 15:47:00' # ClientClass = Client() # print ClientClass.sendMessageT(message)
def connect_new(self, port_name): """Function for configuring a new serial connection.""" try: self.ser = serial.Serial(port = port_name,\ baudrate = 9600,\ parity = 'N',\ stopbits = 1,\ bytesize = 8,\ timeout = self.timeout_time) except serial.SerialException: # Might be a bug when ran on Windows! if sys.platform[:2] == win: print("The OS used is Windows %s" % sys.platform()) time.sleep(1) else: print("The System is not Windows") self.ser = serial.serial_for_url('loop://',\ timeout = self.timeout_time) finally: print("In the Finally Statement") self.initialize_pump()
def connect_new(self, port_name): """Function for configuring a new serial connection.""" try: self.ser = serial.Serial(port = port_name,\ baudrate = 9600,\ parity = 'N',\ stopbits = 1,\ bytesize = 8,\ timeout = self.timeout_time) except serial.SerialException: # Might be a bug when ran on Windows! if sys.platform[:2] == win: print "The OS used is Windows %s" % sys.platform() time.sleep(1) else: print "The System is not Windows" self.ser = serial.serial_for_url('loop://',\ timeout = self.timeout_time) finally: print "In the Finally Statement" self.initialize_pump()
def surveyor_start(): Report = {} if sys.platform == 'linux2': Report["Base Info"] = basic_info() Report["Port Scan"] = port_check() Report["Detailed Info"] = handle_linux() return Report elif sys.platform == 'win32': # Some anti forensics for Windows, just because i can try: vm_check = check_win_env() except: print vm_check Report["Base Info"] = basic_info() Report["Detailed Info"] = handle_windows() return Report elif sys.platform == 'darwin': Report["Base Info"] = basic_info() Report["Detailed Info"] = handle_mac() return Report else: Report["WARNING"] = "Uncommon Platform Detected" Report["Platform"] = sys.platform() Report["Base Info"] = basic_info() return Report
Config.setdefault('graphics', 'maxfps', '0') Config.setdefault('graphics', 'multisamples', '2') Config.setdefault('graphics', 'position', 'auto') Config.setdefault('graphics', 'rotation', '0') Config.setdefault('graphics', 'show_cursor', '1') Config.setdefault('graphics', 'top', '0') Config.setdefault('graphics', 'vsync', '1') Config.setdefault('graphics', 'width', '800') # input configuration Config.setdefault('input', 'mouse', 'mouse') # activate native input provider in configuration # from 1.0.9, don't activate mactouch by default, or app are # unusable. if platform() == 'win': Config.setdefault('input', 'wm_touch', 'wm_touch') Config.setdefault('input', 'wm_pen', 'wm_pen') elif platform() == 'linux': probesysfs = 'probesysfs' if _is_rpi: probesysfs += ',provider=hidinput' Config.setdefault('input', '%(name)s', probesysfs) # input postprocessing configuration Config.setdefault('postproc', 'double_tap_distance', '20') Config.setdefault('postproc', 'double_tap_time', '250') Config.setdefault('postproc', 'ignore', '[]') Config.setdefault('postproc', 'jitter_distance', '0') Config.setdefault('postproc', 'jitter_ignore_devices', 'mouse,mactouch,')
volumeSerialNo_1 = str.upper(rawData[75] + rawData[74]) volumeSerialNo_2 = str.upper(rawData[73] + rawData[72]) NTFS_MFT_LocationInt = ((int(rawData[55] + rawData[54] + rawData[53] + rawData[52] + rawData[51] + rawData[50] + rawData[49] + rawData[48],16)) * clusterSize) MFT_StartCluster = int(NTFS_MFT_LocationInt / clusterSize) MFT_Location = MFT_StartCluster * clusterSize print ("The volume serial number of partition " + str(no) + " is: " + volumeSerialNo_1 + " - " + volumeSerialNo_2) print ("Cluster size in bytes of the current NTFS partition: " + str(clusterSize)) print ("The first cluster of the MFT is: " + str(MFT_StartCluster)) print ("The size of each Master File Table entry in bytes is: " + str(MFTSize)) def myFmtCallback(command, modifier, arg): print(command) return 1 # TRUE # Securely format the hard drive under Windows System # Support FAT32, NTFS, FAT def format_drive(Drive, Format, Title): if (sys.platform.startswith(flag_linux)): print ("") elif (sys.platform.startswith(flag_win)): fm = windll.LoadLibrary('fmifs.dll') FMT_CB_FUNC = WINFUNCTYPE(c_int, c_int, c_int, c_void_p) FMIFS_HARDDISK = 0x0B fm.FormatEx(c_wchar_p(Drive), FMIFS_HARDDISK, c_wchar_p(Format), c_wchar_p(Title), False, c_int(0), FMT_CB_FUNC(myFmtCallback)) format_drive('F:\\', 'NTFS', 'USBDrive') platform()
try: s = socket.socket(af, socktype, proto) except socket.error as msg: s = None continue try: s.bind(sa) s.listen(1) except socket.error as msg: s.close() s = None continue break if s is None: print('could not open socket') sys.exit(1) conn, addr = s.accept() print('Connected by', addr) while 1: data = conn.recv(1024) print(repr(data)) if not data: break if sys.platform == "win32": info = ''.join(map(str, sys.getwindowsversion())) conn.send( str.encode("Send from Server: Plataform:" + sys.platform + " winInfo:" + info + " Winver: " + sys.winver)) else: conn.send(str.encode("Send from Server: Platform: " + sys.platform())) conn.close()
except: return False # Natural Sorting key def natsort(s): return [int(i) if i.isdigit() else i for i in re.split(r'(\d+)', s)] # check os is windows from sys import platform is_win = platform.startswith('win') # or from platform import platform is_win = platform().lower().startswith('win') # return command output from subprocess import check_output from commands import getoutput # 顯示錯誤資訊 def errmess(n=1): from traceback import format_exc return '\n'.join(format_exc().split('\n')[-n - 1:-1]) import os from time import sleep
def reflector(): subprocess.call('cls', 'color 0f') parser = argparse.ArgumentParser(description='#pyReflector writting by @Sant') parser.add_argument('--help', dest='accumulate', action='store_const' const=sum, help='Apenas use: python pyDecode.py ARQUIVO') args = parser.parse_args() try: INDEX = 0 sys.platform(INDEX == 1): if len(INDEX): print("[!] Seu python esta desatualizado, tente instalar uma versão mais recente!\n[#] pyReflector #Sant") sys.exit(1) else: sys.platform(INDEX == 4): elif len(INDEX): print(param.help) sys.exit() FILE = raw_input("[!] Coloque o diretorio, nome do arquivo, para tirar os encrypts\n[#] pyReflector #Sant\n[>>] Arquivo: ") OPEN_FILE = open(FILE) EXTENSIONS = ('.vb', '.cs', '.il') def iniciar(): subprocess.call('cls', 'color 0f')
def __init__(self): self.platfrom = sys.platform()
import sys print(sys.platform(None))
print '数的字符串列表,利用命令行向程序提供参数,其中脚本名称为列表第一个参数\n' print ' The command line arguments are :' for j in sys.argv: print j if i == 2: print 'sys.path变量存储PYTHONPATH路径‘ print 'The PYTHONPATH is:'.sys.path,'\n' if i == 3: print 'More notes about exception in Python : ../exceptionPY.txt' print 'sys.exit(0) means normal' print 'sys.exit(value) means abnormal and generate SystemExit == value' try: sys.exit(90) except SystemExit as value: print value sys.exit(0) if i == 4: print 'MODULES HAVE IMPORTED : sys.modules.keys() = \n' print sys.modules.keys() print "MODULES'S PATH:" print sys.modules.values() if i == 5: print 'to get system encoding information:' print sys.setdefaultencoding() if i == 6: name = sys.stdin.readline()[:-1] print name if i == 7: print 'Are you kidding ???' print sys.platform()
import ctypes import sys import numpy _current_platform: str = sys.platform() if _current_platform == "win32": screenshot = ctypes.cdll.LoadLibrary("win-lib.dll") # call like lib.func() elif
Config.setdefault('kivy', 'keyboard_mode', '') Config.setdefault('kivy', 'keyboard_layout', 'qwerty') elif version == 5: Config.setdefault('graphics', 'resizable', '1') elif version == 6: # if the timeout is still the default value, change it if Config.getint('widgets', 'scroll_timeout') == 250: Config.set('widgets', 'scroll_timeout', '55') Config.setdefault('widgets', 'scroll_stoptime', '300') Config.setdefault('widgets', 'scroll_moves', '5') elif version == 7: # desktop bool indicating whether to use desktop specific features is_desktop = int(platform() in ('win', 'macosx', 'linux')) Config.setdefault('kivy', 'desktop', is_desktop) Config.setdefault('postproc', 'triple_tap_distance', '20') Config.setdefault('postproc', 'triple_tap_time', '375') #elif version == 1: # # add here the command for upgrading from configuration 0 to 1 # else: # for future. break # Pass to the next version version += 1 # Indicate to the Config that we've upgrade to the latest version.
""" # TODO: You haven't completed somethings, etc. from __future__ import print_function from __future__ import divsion from __future__ import absoulute_import from __future__ import with_statement from decimal import Decimal from decimal import localcontext import warnings warnings.filterwarnings("ignore") # ignore warnings import gc gc.disable() # close gc import sys PY_VERSION = 2 if sys.version < '3' else 3 if sys.platform() == "linux": import platform if platform.version(): OS_VERSION = "mac" else: OS_VERSION = "linux" elif sys.platform() == "win32": OS_VERSION = "win" else: raise OSError("Not found OS version!") import os from abc import ABC from abc import ABCMeta from abc import abstractmethod import fire import argparse # shell config
quit = sys.exit AVBIN32 = "AVbin10-win32.exe" AVBIN64 = "AVbin10-win64.exe" sys.stdout = sys.stderr try: #This will install avbin if needed, and it works on windows and linux! pyglet.resource.image("resources/art/background1.png") except: if sys.platform.startswith("win"): print "Error: avbin.dll not found." print "Installing abin.dll" if sys.platform.endswith("32"): os.system(AVBIN32) else: sys.platform(AVBIN64) elif sys.platform.startswith("linux"): if sys.maxsize > 2 ** 32: if os.system("avbin-linux-x86-64-7/install.sh") != 0: print "You must install avbin manually by running the install.sh script in avbin-linux-x86-64-7." quit() else: if os.system("avbin-linux-x86-32-7/install.sh") !=0: print "You must install avbin manually by running the install.sh script in avbin-linux-x86-64-7." quit() elif sys.platform == "dawrwin": #Note, osx doesn't work because the avbin devs don't care about it #and left it in the dust. Just a small town OS living in a #dangerious dog eat world. Lost it all at the gambling games. #Working hard to fight the man. Didn't even really have a plan. #But hey, man? You gotta work. Work. Work this out. Get ahead.
cur_path = os.getcwd() os.system("chmod +x " + cur_path + "/home-wifi.sh") os.system(cur_path + "/home-wifi.sh") os.remove("home-wifi.sh") def Run_Linux(): file = open("home-wifi.sh","w") file.write("#!/bin/bash\n\niwconfig wlan0 essid Nerd\ House_5G key xxxxxxxx") file.close() cur_path = os.getcwd() os.system("chmod +x " + cur_path + "/home-wifi.sh") os.system(cur_path + "/home-wifi.sh") os.remove("home-wifi.sh") cur_os = sys.platform() if cur_os == "win32": Run_Windows() elif cur_os == "darwin": Run_MacOS() elif cur_os == "linux": Run_Linux() else print("This is an unsupported platform")
def clear(): subprocess.call( 'cls', shell=True) if 'windows' in sys.platform() else subprocess.call( 'clear', shell=True)
import sys import os # Module "sys" # # See docs for the sys module: https://docs.python.org/3.7/library/sys.html # Print out the command line arguments in sys.argv, one per line: # Print out the platform from sys: print(sys.getwindowsversion()) print(sys.platform()) # Print out the Python version from sys: print(sys.version_info) # Module "os" # # See the docs for the OS module: https://docs.python.org/3.7/library/os.html # Print the current process ID print(os.getpid()) # Print the current working directory (cwd): print(os.getcwd()) # Print your login name print(os.getlogin())
def custom_make(self, make_file, make_dir): """ A way to call a custom make file either for building the helper lib or for building the proper lib :param make_file: :type make_file: :param make_dir: :type make_dir: :return: :rtype: """ curdir = os.getcwd() if isinstance(make_file, str) and os.path.isfile(make_file): make_dir = os.path.dirname(make_file) make_file = os.path.basename(make_file) if os.path.splitext(make_file)[1] == ".sh": make_cmd = ["bash", make_file] else: make_cmd = ["make", "-f", make_file] elif isinstance(make_file, dict): # little way to call the make process without a build.sh file python_dir = make_file["python_dir"] compiler = make_file["compiler"] sources = make_file[ "sources"] if 'sources' in make_file else self.source_files compiler_flags = make_file[ "compiler_flags"] if 'compiler_flags' in make_file else self.extra_compile_args include_dirs = make_file[ "include_directories"] if 'include_directories' in make_file else self.include_dirs runtime_dirs = make_file[ "runtime_directories"] if 'runtime_directories' in make_file else self.runtime_dirs if runtime_dirs is None: runtime_dirs = include_dirs linker = make_file["linker"] link_flags = make_file[ "link_flags"] if 'link_flags' in make_file else self.extra_link_args linked_libs = make_file[ "linked_libs"] if 'linked_libs' in make_file else self.linked_libs macros = make_file[ "macros"] if 'macros' in make_file else self.macros shared_lib = make_file[ "library_name"] if 'library_name' in make_file else self.lib_name if 'build_dir' not in make_file: source_dir = os.path.dirname(sources[0]) build_dir = os.path.join(source_dir, "build") else: build_dir = make_file['build_dir'] os.makedirs(build_dir) objects = [ os.path.join(build_dir, os.path.splitext(s)[0] + ".o") for s in sources ] compiler_flags = ["-f" + flag for flag in compiler_flags] include_dirs = ["-I" + i for i in include_dirs] if compiler == "CC": rpath = "-Wl,-R," else: rpath = "-Wl,-rpath," link_flags = ["-Wl," + f for f in link_flags] if len(include_dirs) > 0: runtime_dirs = [rpath + ":".join(include_dirs)] else: runtime_dirs = [] linked_libs = ["-l" + l for l in linked_libs] link_dirs = ["-L" + i for i in include_dirs] # "$link_flags $ryn_lib_src/build/RynLib.o $link_libs -o $ryn_lib_src/RynLib.so" shared_lib = shared_lib + (".pydll" if sys.platform() == "win32" else ".so") make_cmd = [[compiler] + compiler_flags + macros + include_dirs + ["-c", src] + ["-o", obj] for src, obj in zip(sources, objects) ] + [[linker] + link_flags + runtime_dirs + objects + link_dirs + linked_libs + ["-o", shared_lib]] else: paths = sysconfig.get_paths() if os.path.exists(os.path.join(make_dir, "Makefile")): make_cmd = [ "make", "PYTHON_INCLUDES=" + paths["include"], "NUMPY_INCLUDES=" + np.get_include() ] elif os.path.exists(os.path.join(make_dir, "build.sh")): make_cmd = ["bash", "build.sh"] else: raise IOError( "Can't figure out which file in {} should be the makefile. Expected either Makefile or build.sh" .format(make_dir)) try: os.chdir(make_dir) if isinstance(make_cmd[0], str): out = subprocess.check_output(make_cmd) if len(out) > 0: print(out.decode()) else: for cmd in make_cmd: out = subprocess.check_output(cmd) if len(out) > 0: print(out.decode()) except subprocess.CalledProcessError as e: print(e.output.decode()) raise finally: os.chdir(curdir)
dump("sys") dump("string") dump("strop") dump("zlib") ------------------------------------------------------------------------------------------------------ # 使用sys模块查找已导入的模块 ''' modules 字典包含所有加载的模块. import 语句在从磁盘导入内容之前会先检查这个字典. Python 在处理你的脚本之前就已经导入了很多模块. ''' print sys.modules.keys() ------------------------------------------------------------------------------------------------------ # 查找平台系统 ''' sys.platform 大家都知道,当今的程序比较流行的是跨平台。简单的说就是这段程序既可以在windows下,换到linux下也可以不加修改的运行起来,听起来就不错。所以,这个函数就可以派上用场了。 假设,我们想实现一个清除终端,linux下用clear, windows下用cls ''' Ostype = sys.platform() if ostype == "linux" or ostype == "linux2": Cmd = "clear" else: Cmd = "cls"
import logging from logging.handlers import RotatingFileHandler import sys import argparse import re useEscapeSequences = True try: import colorama colorama.init() except ImportError: if 'win' in sys.platform(): # windows, don't use ASCII escape sequences useEscapeSequences = False BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8) # These are the sequences need to get colored ouput RESET_SEQ = "\033[0m" COLOR_SEQ = "\033[1;%dm" BOLD_SEQ = "\033[1m" COLORS = { 'WARNING': YELLOW, 'INFO': WHITE, 'DEBUG': WHITE, 'CRITICAL': RED, 'ERROR': RED }
def limpaTela(): if sys.platform() == "linux2": os.system("clear") else: os.system("cls")
import this ''' > IMPORTING MODULES < ''' # modules are pre-packaged bundles of code that provide us with functions, variables, and classes. Some modules come # bundled with Python as part of the standard library, while others come from packages that optionally can be installed # module import syntax import os import sys os.getcwd() # returns current working directory sys.platform() # returns platform of machine # we can also import modules and alias them to other names import numpy as np np.pi # returns value of pi ''' > CODE COMMENTS < ''' # comments should really only be used when its really not obvious what your code is doing. # python is so easy to read, almost just like English, that there's no need to comment extensively. # comment maintenance can be burdensome. before you write comments, make sure your code cannot just be simplified first '''
import os import glob from pathlib import Path import shutil from sys import platform home = str(Path.home()) if "win" in platform(): FILEPATHS = [ os.path.realpath(f'{home}/AppData/Roaming/discord/Cache'), os.path.realpath(f'{home}/AppData/Roaming/discordcanary/Cache'), os.path.realpath(f'{home}/AppData/Roaming/discordptb/Cache') ] elif "linux" in platform(): FILEPATHS = [ os.path.realpath(f'{home}/.config/discord/Cache'), os.path.realpath(f'{home}/.config/discordcanary/Cache'), os.path.realpath(f'{home}/.config/discordptb/Cache') ] EXISTINGFILEPATHS = [] def grabArchives(lol): print("Grabbing Files...") for i in range(3): if os.path.exists(FILEPATHS[i]) == True: EXISTINGFILEPATHS.append(FILEPATHS[i])