Exemplo n.º 1
0
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
Exemplo n.º 2
0
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')
Exemplo n.º 3
0
 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")
Exemplo n.º 4
0
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
Exemplo n.º 5
0
def clean():
    # for windows
    if os_name() == 'Windows':
        _ = system('cls')
    # for mac and linux(here, os.name is 'posix')
    else:
        _ = system('clear')
Exemplo n.º 6
0
def trace(address):
    """tracerout"""
    print('\n')
    if os_name().lower() == 'windows':
        os.system('tracert ' + address)
    else:
        os.system('traceroute ' + address)
Exemplo n.º 7
0
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'))
Exemplo n.º 8
0
 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
Exemplo n.º 9
0
 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
Exemplo n.º 10
0
    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)
Exemplo n.º 11
0
 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
Exemplo n.º 12
0
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
Exemplo n.º 13
0
    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)
Exemplo n.º 14
0
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)
Exemplo n.º 15
0
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
Exemplo n.º 16
0
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
Exemplo n.º 17
0
 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('\\', '/')
Exemplo n.º 19
0
    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
Exemplo n.º 20
0
def loc(x):
    '''to fix dir problem'''
    if os_name().lower() == 'windows':
        return x.replace('/', '\\')
    else:
        return x.replace('\\', '/')
Exemplo n.º 21
0
""" 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():
Exemplo n.º 22
0
		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'
Exemplo n.º 23
0
def clear_console():
    if 'Windows' in os_name():
        system('cls')
    else:
        system('clear')
Exemplo n.º 24
0
def ping(address):
    """ping"""
    if os_name().lower() == 'windows':
        os.system('ping -n 2 ' + address)
    else:
        os.system('ping -c 2 ' + address)