def ins_n_imp_voice(): global voice_up voice_up=0 try: if os_name() == 'Windows': try: import pypiwin32 except: install(pypiwin32) delthisline() ins_n_imp("pyttsx3") # One time initialization elif os_name()=='Darwin': install('nsss') ins_n_imp('pyttsx3') elif os_name()=='Linux': install('espeak') ins_n_imp('pyttsx') global engine engine = pyttsx3.init() # Set properties _before_ you add things to say engine.setProperty('rate', 150) # Speed percent (can go over 100) engine.setProperty('volume', 0.9) # Volume 0-1 except: global n ins_frm_imp('gtts','gTTS') ins_frm_imp('playsound','playsound') language = 'en' n='0' voice_up=1
def clear_screen(): """ It just clears screen, u know... :return: void function """ if os_name() == 'Windows': system('cls') elif os_name() == 'Linux': system('clear') elif os_name() == 'Darwin': system('clear')
def _on_mousewheel(self, event): if self.vsb.get() != (0.0, 1.0): if os_name() == 'Windows': self.canvas.yview_scroll(int(-1 * (event.delta / 120)), "units") else: self.canvas.yview_scroll(-event.delta, "units")
def ins_n_imp_voice(): global not_installed, vmodule, importbit NoVoiceError = "\n \n\033[1;31;40mWarning! Voice won't work\n\033[1;37;40m" if os_name() == 'Windows': try: ins_n_imp('pyttsx3') vmodule = 'pyttsx3' global engine if importbit != 2: engine = pyttsx3.init() # Set properties _before_ you add things to say engine.setProperty('rate', 190) # Speed percent (can go over 100) engine.setProperty('volume', 1) # Volume 0-1 en_voice_id = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_ZIRA_11.0" # Use female English voice engine.setProperty('voice', en_voice_id) else: raise ValueError except ValueError: ins_frm_imp('gtts', 'gTTS') if check_installed('gtts') == True: vmodule = 'gtts' else: print(NoVoiceError) vmodule = 'unav' else: vmodule = 'unav' return vmodule
def clean(): # for windows if os_name() == 'Windows': _ = system('cls') # for mac and linux(here, os.name is 'posix') else: _ = system('clear')
def trace(address): """tracerout""" print('\n') if os_name().lower() == 'windows': os.system('tracert ' + address) else: os.system('traceroute ' + address)
def get_url(ports: list, service_url: str, service: str): """Build URL to be displayed""" # If not linux, I can't use IPs so display only exposed ports if ports and os_name() in ['Windows', 'Darwin']: main_port = ports[0] ports.remove(main_port) return 'http://localhost:{}'.format(main_port) + ' or '.join(ports) return service_url.format(docker_actions.get_ct_item(service, 'ip'))
def _edit_project_row(self, idx): curr_row = idx proj_settings = self.proj_settings[curr_row] # TODO: figure out why there is this weird asymmetry... if os_name() == 'Windows': ProjectSettingsWindow(self.master, proj_settings) else: ProjectSettingsWindow(self, proj_settings) self.projects_table.set_row(curr_row, self.settings_view(proj_settings)) self.proj_settings[curr_row] = proj_settings
def _add_project_row(self): proj_settings = dict() if os_name() == 'Windows': ProjectSettingsWindow(self.master, proj_settings) else: ProjectSettingsWindow(self, proj_settings) if proj_settings != dict(): if (proj_settings.get('ProjectID', '') not in [d.get('ProjectID', '') for d in self.proj_settings]): self.proj_settings.append(proj_settings) return self.settings_view(proj_settings) else: raise ValueError
def get_url(self, service_url: str, service: str): """Build URL to be displayed.""" proxy_conf = self.config['proxy'] # By default our URL is the IP url = docker.get_ct_item(service, 'ip') # If proxy enabled, display nice urls if bool(proxy_conf['enabled']): http_port = int(proxy_conf['http_port']) url = docker.get_ct_item(service, 'traefik_host').lower() url += '' if http_port == 80 else ':{}'.format(http_port) elif os_name() in ['Windows', 'Darwin']: puts(colored.yellow('[WARNING]') + ' Under Win and Mac, you need the proxy enabled') return service_url.format(url)
def clear(self, lines=100): """Clears the screen. Lines if used if system is not available. lines: The amound of lines to clear by. - Defaults to 100 Needs to be rewriten to work on school computers. """ try: if self.config["settings"]["cmd-limited"]: raise elif os_name() == "Windows": system("cls") elif os_name() == "Linux": system("clear") else: raise except: # Don't know what error it throughs as I have not been able to test. print("\n" * lines) for line in self.config["menus"]["false-clear"]: print(line) return None
def ins_n_imp_voice(): global voice_up voice_up = 0 print(os_name()) if os_name() == 'Windows': install('pypiwin32') delprevline() delprevline() delprevline() ins_n_imp("pyttsx3") # One time initialization elif os_name() == 'Darwin': install('nsss') delthisline() ins_n_imp('pyttsx3') elif os_name() == 'Linux': install('espeak') delthisline() ins_n_imp('pyttsx3') global engine engine = pyttsx3.init() # Set properties _before_ you add things to say engine.setProperty('rate', 150) # Speed percent (can go over 100) engine.setProperty('volume', 0.9) # Volume 0-1
def get_url(self, service_url: str, service: str): """Build URL to be displayed.""" proxy_conf = self.config['proxy'] # By default our URL is the IP url = docker.get_ct_item(service, 'ip') # If proxy enabled, display nice urls if bool(proxy_conf['enabled']): http_port = int(proxy_conf['http_port']) url = docker.get_ct_item(service, 'traefik_host').lower() url += '' if http_port == 80 else ':{}'.format(http_port) elif os_name() in ['Windows', 'Darwin']: puts( colored.yellow('[WARNING]') + ' Under Win and Mac, you need the proxy enabled') return service_url.format(url)
def run_elevated(python_path, update_args): if os_name() == 'Windows': # code c/o Martin De la Fuente from Stackoverflow: # https://stackoverflow.com/a/41930586 # we want to elevate the privileges: def is_admin(): return ctypes.windll.shell32.IsUserAnAdmin() if is_admin(): subprocess.run([python_path] + update_args) else: ctypes.windll.shell32.ShellExecuteW(None, 'runas', python_path, ' '.join(update_args), None, 1) else: # TODO: figure out for linux and mac? subprocess.run([python_path] + update_args)
def clear(lines=100): """Clears the screen. Lines is used if system is not available. lines: The amound of lines to clear by. - Defaults to 100 """ global _errors os = os_name() if not _errors["os-module"]: print("\n" * lines) print("Could not import os module - Using fall-back method") elif os == "Windows": system("cls") elif os == "Linux": system("clear") return None
def ins_n_imp_voice(): global not_installed NoVoiceError = "\n \n|*Warning! Voice won't work\n\033*|" if os_name() == 'Windows': try: if not check_installed('pywin32'): install('pywin32') ins_n_imp('pyttsx3') vmodule = 'pyttsx3' global engine if check_installed('pyttsx3') == True: engine = pyttsx3.init() # Set properties _before_ you add things to say engine.setProperty('rate', 190) # Speed percent (can go over 100) engine.setProperty('volume', 0.1) # Volume 0-1 en_voice_id = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_ZIRA_11.0" # Use female English voice engine.setProperty('voice', en_voice_id) else: raise ValueError except ValueError: ins_frm_imp('gtts', 'gTTS') if check_installed('gtts') == True: vmodule = 'gtts' else: print(NoVoiceError) vmodule = 'unav' elif os_name == 'linux': try: import androidhelper global droid droid = androidhelper.Android() vmodule = 'androidhelper' except: vmodule = 'unav' else: vmodule = 'unav' droid = None return vmodule
def __init__(self): self.os = OSNAMEMAP.get(os_name(), 'MAC')
def loc(x): if os_name().lower() == 'windows': return x.replace('/', '\\') else: return x.replace('\\', '/')
logging.error( "Greynir did not start due to a configuration error:\n{0}".format(e)) sys.exit(1) if Settings.DEBUG: print("\nStarting Greynir web app at {0} with debug={1}, " "host={2}:{3}, db_host={4}:{5}\n" "Python {6} on {7}\n{8}".format( datetime.utcnow(), Settings.DEBUG, Settings.HOST, Settings.PORT, Settings.DB_HOSTNAME, Settings.DB_PORT, sys.version, os_name(), "GreynirPackage {0} - Tokenizer {1}".format( greynir_version, tokenizer_version), )) # Clobber Settings.DEBUG in GreynirPackage and GreynirCorrect reynir.Settings.DEBUG = True reynir_correct.Settings.DEBUG = True if not RUNNING_AS_SERVER: if os.environ.get("GREYNIR_ATTACH_PTVSD"): # Attach to the VSCode PTVSD debugger, enabling remote debugging via SSH # import ptvsd # ptvsd.enable_attach() # ptvsd.wait_for_attach() # Blocks execution until debugger is attached
def loc(x): '''to fix dir problem''' if os_name().lower() == 'windows': return x.replace('/', '\\') else: return x.replace('\\', '/')
""" Module to handle loading and writing the default NMSDK settings file. """ # stdlib imports import json import os.path as op import os from platform import system as os_name # local imports from .io import get_MBINCompiler_path # noqa _os_name = os_name() if _os_name == 'Windows': SETTINGS_DIR = op.join(os.getenv('APPDATA'), 'NMSDK') elif _os_name == 'Linux': SETTINGS_DIR = op.expanduser('~/NMSDK') elif _os_name == 'Darwin': # UNTESTED! SETTINGS_DIR = op.join(op.expanduser('~'), 'Library', 'NMSDK') else: raise ValueError('Current operating system is not supported sorry!') SETTINGS_FNAME = 'settings.json' DEFAULT_SETTINGS = { 'export_directory': 'CUSTOMMODELS', 'group_name': '', 'MBINCompiler_path': get_MBINCompiler_path() } def read_settings():
if permit in cond: if permit in yes: install(pack) else: print("\033[1;31;40m*Some error will occur & the program will break!*\033[0;37;40m") importbit=1 if pack=='pyttsx3': importbit=2 elif pack=='gtts': importbit=3 finally: if importbit==0: globals()[aas] = importlib.import_module(pack) print(os_name()) import datetime x = datetime.datetime.now() print(x.year) print(x.strftime("its %A:%B %p")) def ins_n_imp_voice(): global not_installed, vmodule,importbit NoVoiceError="\n \n\033[1;31;40mWarning! Voice won't work\n\033[1;37;40m" if os_name()=='Windows': try: ins_n_imp('pyttsx3') vmodule='pyttsx3'
def clear_console(): if 'Windows' in os_name(): system('cls') else: system('clear')
def ping(address): """ping""" if os_name().lower() == 'windows': os.system('ping -n 2 ' + address) else: os.system('ping -c 2 ' + address)