def main(url): if is_dir(join_path(self.path, url)): index_path = join_path(self.path, url, 'index') if file_exists(index_path + '.html', file_exists_param): print(join_path(self.path, url, 'index.html')) return self.fastread( join_path(self.path, url, 'index.html')) elif file_exists(index_path + '.htm', file_exists_param): return self.fastread( join_path(self.path, url, 'index.htm')) else: return self.error404() elif url[-5:] == '.html' or url[-4:] == '.htm': joined = join_path(self.path, url) if file_exists(joined, file_exists_param): return self.fastread(joined) else: return self.error404() else: joined = join_path(self.path, url) print(joined) if file_exists(joined, file_exists_param): return self.app.send_static_file(url) else: return self.error404()
def main_index(): index_path = join_path(self.path, 'index') if file_exists(index_path + '.html', file_exists_param): return self.fastread(join_path(self.path, 'index.html')) elif file_exists(index_path + '.htm', file_exists_param): return self.fastread(join_path(self.path, 'index.htm')) else: return self.error404()
def error404(self): error_404_path = join_path(self.path, '404') if file_exists(error_404_path + '.html', file_exists_param): return self.fastread(join_path(self.path, '404.html')), 404 elif file_exists(error_404_path + '.htm', file_exists_param): return self.fastread(join_path(self.path, '404.htm')), 404 else: return 'Error404', 404
def check_player(self): if not file_exists(play_sound_path + 'play_sound.exe', file_exists_param): try: download( 'https://github.com/Pixelsuft/wav_win_sound/raw/main/wav_win_sound/play_sound.exe', play_sound_path + 'play_sound.exe') return True except: return False else: return True
def menu(): music_menu = False if file_exists('music\\menu.wav', file_exists_param): music_menu = True snd_main_class.load('music\\menu.wav') snd_main_class.async_play() global menu_running menu_running = True txx_m = ('00000 0 0 00000 0 0 00000', '0 00 0 0 0 0 0 0 ', '00000 0 0 0 00000 000 00000', ' 0 0 00 0 0 0 0 0 ', '00000 0 0 0 0 0 0 00000') tmp_r = {'0': str(a.back.GREEN + ' ' + a.style.RESET_ALL)} for i in range(len(txx_m)): a.text(txx_m[i], (int(a.width / 2 - 29 / 2), i), replacer=tmp_r) backward_m = False count = 0 a.text('Press Space To Start...', (int(a.width / 2 - 23 / 2), int(a.height / 2) + 4), start=a.fore.GREEN, end=a.style.RESET_ALL) to_sleep = int(fps / 10) thread(target=waitkey_space).start() while menu_running: if backward_m: if count > to_sleep: count = 0 backward_m = False else: a.text('Press Space To Start...', (int(a.width / 2 - 23 / 2), int(a.height / 2) + 4), start=a.back.GREEN + a.fore.BLACK, end=a.style.RESET_ALL) count += 1 else: if count > to_sleep: count = 0 backward_m = True else: a.text('Press Space To Start...', (int(a.width / 2 - 23 / 2), int(a.height / 2) + 4), start=a.fore.GREEN, end=a.style.RESET_ALL) count += 1 a.convert() a.up_screen() a.display() a.tick(fps) if music_menu: snd_main_class.stop() game_loop()
def __init__(self, **kwargs): super(SnakeWidget, self).__init__(**kwargs) txt_cfg = 'self.set_speed(2)\nself.set_max_speed(18)\nself.set_grid(15)' if file_exists('config.txt', file_exists_param): temp_f = open('config.txt', 'r') txt_cfg = temp_f.read() temp_f.close() else: temp_f = open('config.txt', 'w') temp_f.write(txt_cfg) temp_f.close() self.load_config(txt_cfg) self.menu_sound.play() Clock.schedule_interval(self.main_loop, 1 / self.fps)
def run_app_def(): prog = txt.get() prog = prog.replace('"', '') prog = prog.replace("'", "") if prog == '': messagebox.showerror('Error!', 'Launchstring is empty!') else: if file_exists(prog, mode=check_param) == False: messagebox.showerror('Error!', 'File is not exists!') else: if is_builded == True: cmd_run('start ' + argv[0] + ' -win7style -prog ' + prog) else: cmd_run('start python ' + argv[0] + ' -win7style -prog ' + prog)
def game_over(): global fps global game_running game_running = False t_f_p_s = fps fps = default_fps snd_main_class.stop() a.clear() n = int(a.width / 2 - 13 / 2) a.text('Game Over :(', (n, 0), start=a.fore.GREEN, end=a.style.RESET_ALL) a.text(f'Score : {score}', (n, 1), start=a.fore.GREEN, end=a.style.RESET_ALL) a.text(f'Speed : {t_f_p_s}', (n, 2), start=a.fore.GREEN, end=a.style.RESET_ALL) a.text('Escape - Exit', (n, 3), start=a.fore.GREEN, end=a.style.RESET_ALL) a.text('R - Restart', (n, 4), start=a.fore.GREEN, end=a.style.RESET_ALL) a.text('M - Menu', (n, 5), start=a.fore.GREEN, end=a.style.RESET_ALL) a.convert() a.up_screen() a.display() to = 'exit' if file_exists('music\\fail1.wav', file_exists_param): snd_main_class.load('music\\fail' + str(rand(1, 3)) + '.wav') snd_main_class.async_play() while True: key_r = a.wait_for_key() if key_r == b'\x1b': to = 'exit' break elif key_r == b'r': to = 'restart' break elif key_r == b'm': to = 'menu' break a.clear() if to == 'exit': exit() elif to == 'menu': menu() elif to == 'restart': game_loop()
def is_opensuse_host(self): return os.file_exists('/etc/SuSE-release')
from random import randint as rand if not __name__ == '__main__': exit() a.title('Pixelsuft Console Snake') cmd_run('color 0a') default_fps = 60 default_speed = 2 max_speed = 40 fps = default_fps vector = 'right' temp_vector = 'right' score = 0 play_eat_sound = file_exists('music\\eat.wav', file_exists_param) at = input('Enter default speed (2): ') if at: try: default_speed = int(at) except ValueError: pass at = input('Enter max speed (40): ') if at: try: max_speed = int(at) except ValueError: pass at = input('Enter default fps (60): ') if at: try:
def generate_def(x_downgrade, y_downgrade, chroma_type, chroma_key, x_size, y_size): log('Generate Function Called') image_file_name = file_open_input.get() log(f'Picture file is "{image_file_name}"') data_file_name = file_save_input.get() log(f'Data file is "{data_file_name}"') try: if data_file_name[::-1][0] == 't' and data_file_name[::-1][ 1] == 'x' and data_file_name[::-1][ 2] == 't' and data_file_name[::-1][3] == '.': log(f'File "{data_file_name}" Is Already Text File!') else: log(f'File "{data_file_name}" Is Not Text File!') data_file_name += '.txt' log(f'File "{data_file_name}" Is Already Text File!') except: log(f'File "{data_file_name}" Is Not Text File!') log('Index Is Out Of Range, Adding .txt On The End') data_file_name += '.txt' log(f'File "{data_file_name}" Is Already Text File!') log('Opening Image...') if file_exists(image_file_name, mode=exists_param) == True: try: #if True: imag = PIL_Image.open(f'{image_file_name}') width, height = imag.size level_data = '<levelXML><info v="1.87" x="121.35" y="67.7" c="11" f="t" h="f" bg="1" bgc="16777215" e="1"/><groups><g x="150" y="50" r="0" ox="-150" oy="-50" s="f" f="t" o="100" im="f" fr="f">' alphable = False log('Checking For Alpha...') try: a, b, c, d = imag.getpixel((1, 1)) alphable = True log('Alpha Detected!') except: alphable = False log('No Alpha Detected!') log('Generating Data...') skip_x = 0 skip_y = 0 rgb_a = [] if chroma_type == 1 or chroma_type == 2 or chroma_type == 3: log(chroma_key) rgb_a = chroma_key.split(' ') log(rgb_a) otvet_a = '' if alphable == True: otvet_a = messagebox.askquestion( 'Question!', f'File {image_file_name} has alpha. It\'s BETA!\nContinue?' ) if alphable == False or otvet_a == 'yes': for for_x in range(width): if skip_x == for_x: skip_y = 0 for for_y in range(height): if skip_y == for_y: if alphable == False: r, g, b = imag.getpixel((for_x, for_y)) rgb10 = (r * 65536) + (g * 256) + (b) cancont = False if chroma_type == -1: cancont = True elif chroma_type == 0: fr, fg, fb = ImageColor.getcolor( str(f'#{chroma_key}'), "RGB") if fr == int( rgb_a[0]) and fg == int( rgb_a[1] ) and fb == int(rgb_a[2]): cancont = False else: cancont = True elif chroma_type == 1 or chroma_type == 2: if r == int(rgb_a[0]) and g == int( rgb_a[1]) and b == int( rgb_a[2]): cancont = False else: cancont = True elif chroma_type == 3: if rgb10 == int(rgb_a[0]): cancont = False else: cancont = True if cancont == True: level_data += f'<sh t="0" i="f" p0="{for_x+3}" p1="{for_y+3}" p2="{x_size}" p3="{y_size}" p4="0" p5="t" p6="f" p7="1" p8="{rgb10}" p9="-1" p10="100" p11="1"/>' else: r, g, b, a = imag.getpixel( (for_x, for_y)) rgb10 = (r * 65536) + (g * 256) + (b) cancont = False if chroma_type == -1: cancont = True elif chroma_type == 0: fr, fg, fb = ImageColor.getcolor( str(f'#{chroma_key}'), "RGB") if fr == int( rgb_a[0]) and fg == int( rgb_a[1] ) and fb == int(rgb_a[2]): cancont = False else: cancont = True elif chroma_type == 1: if r == int(rgb_a[0]) and g == int( rgb_a[1]) and b == int( rgb_a[2]): cancont = False else: cancont = True elif chroma_type == 2: if r == int(rgb_a[0]) and g == int( rgb_a[1]) and b == int( rgb_a[2]) and a == int( rgb_a[3]): cancont = False else: cancont = True elif chroma_type == 3: if rgb10 == int(rgb_a[0]): cancont = False else: cancont = True if cancont == True: level_data += f'<sh t="0" i="f" p0="{for_x+3}" p1="{for_y+3}" p2="9" p3="7" p4="0" p5="t" p6="f" p7="1" p8="{rgb10}" p9="-1" p10="100" p11="1"/>' skip_y += y_downgrade skip_x += x_downgrade level_data += '</g></groups></levelXML>' log('Data Generated!') can = True log('Checking Exists...') if file_exists(data_file_name, mode=exists_param) == True: log(f'File {data_file_name} is already exists.') otvet = messagebox.askquestion( 'Question!', f'File {data_file_name} is already exists. Replace it?' ) if otvet == 'yes': can = True log(True) else: can = False log(False) if can == True: log('Opening File...') file = open(data_file_name, 'w') log('Writing Lines...') file.write(level_data) log('Closing File...') file.close() else: log('Operation Canceled!') except: log('Error With File!') messagebox.showerror('Error!', f'Error with file!!') else: if str(image_file_name) == '': log('Empty Image Path') messagebox.showerror('Error!', f'Image path is empty!') else: log(f'Image "{image_file_name}" Is Not Exists!') messagebox.showerror( 'Error!', f'Image "{image_file_name}" is not exists!')
def read_config(self): if file_exists('androidwebserver.txt', file_exists_param): config = self.fastread('androidwebserver.txt').split('\n') self.port = int(config[0]) self.host = str(config[1]) self.path = str(config[2])
global max_speed max_speed = vared def set_grid(vared): global grid grid = vared def load_config(cfg): for i in cfg.split('\n'): if not i == '': eval(str(i)) if file_exists('config.txt', file_exists_param): temp_f = open('config.txt', 'r') txt_cfg = temp_f.read() temp_f.close() load_config(txt_cfg) grid_width = int(width / grid) grid_height = int(height / grid) pygame.init() pygame.mixer.init() menu_color_back = False menu_color_count = 50 screen = pygame.display.set_mode((width, height)) pygame.display.set_caption('Pixelsuft Snake') pygame.display.set_icon(pygame.image.load('favicon.ico').convert()) if music == True:
from requests import get as req_get from requests import post as req_post from requests.exceptions import ConnectionError as ConnectException from os import access as file_exists from os import F_OK as file_exists_param from bs4 import BeautifulSoup as NewBS from colorama import init as colorama_init from colorama import Back as back from colorama import Fore as fore from colorama import Style as style from sys import exit as exit_ from time import sleep as time_sleep colorama_init(autoreset=True) is_installed = file_exists('config.txt', file_exists_param) url = 'https://steamunlocked.net/among-us-free-download/' headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' 'Chrome/88.0.4324.190 Safari/537.36', 'Upgrade-Insecure-Requests': '1', 'accept': '*/*' } print(''' 0000000 00 00 0000000 00 0 0000000 0 0 0000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0000000 0 0 0 0 0 0 0 0 0 000 0 0 0000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0
i += 1 video_path = args[i] elif args[i] == '-o' or args[i] == '--out': i += 1 out_path = args[i] elif args[i] == '-fps' or args[i] == '--framerate': i += 1 fps = int(args[i]) i += 1 if not video_path: out_path = str(input('Enter video path: ')) if not video_path: out_path = str(input('Enter new out video path: ')) if not file_exists(str(video_path), file_exists_param): return_exit(-1) cap = cv2.VideoCapture(video_path) codec = cv2.VideoWriter_fourcc(*"XVID") out = cv2.VideoWriter(out_path, codec, fps, (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)), int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)))) last_frame = [] last_frame = cap.read()[1] print('\033[2J', Pointer.UP() * 20, end='') started_at = get_ticks() while True: