Ensures that the currently running platform is Windows,
exiting the process if it is not
172992
function ensureWindows () {
  if (process.platform !== 'win32') {
    log('This tool requires Windows 10.\n')
    log('You can run a virtual machine using the free VirtualBox and')
    log('the free Windows Virtual Machines found at http://modern.ie.\n')
    log('For more information, please see the readme.')
    process.exit(1)
  }

  let release = require('os').release()
  let major = parseInt(release.slice(0, 2), 10)
  let minor = parseInt(release.slice(3, 4), 10)
  let build = parseInt(release.slice(5), 10)

  if (major < 10 || (minor === 0 && build < 14316)) {
    log(`You are running Windows ${release}. You need at least Windows 10.0.14316.`)
    log('We can\'t confirm that you\'re running the right version, but we won\'t stop')
    log('this process - should things fail though, you might have to update your')
    log('Windows.')
  }
}
899012
def stop(self):
        
        if self._process is None:
            return
        if self._shared:
            BackendManager.SHARE_COUNT -= 1
            if BackendManager.SHARE_COUNT:
                return
        comm('stopping backend process')
        # close all sockets
        for s in self._sockets:
            s._callback = None
            s.close()

        self._sockets[:] = []
        # prevent crash logs from being written if we are busy killing
        # the process
        self._process._prevent_logs = True
        while self._process.state() != self._process.NotRunning:
            self._process.waitForFinished(1)
            if sys.platform == 'win32':
                # Console applications on Windows that do not run an event
                # loop, or whose event loop does not handle the WM_CLOSE
                # message, can only be terminated by calling kill().
                self._process.kill()
            else:
                self._process.terminate()
        self._process._prevent_logs = False
        self._heartbeat_timer.stop()
        comm('backend process terminated')
1307238
def _fallback_cleanups(self):
        '''
        
        '''
        # Add an extra fallback in case a forked process leaks through
        multiprocessing.active_children()

        # Cleanup Windows threads
        if not salt.utils.platform.is_windows():
            return
        for thread in self.win_proc:
            if not thread.is_alive():
                thread.join()
                try:
                    self.win_proc.remove(thread)
                    del thread
                except (ValueError, NameError):
                    pass
751771
def get_platform():
	""""""
	# Detect
	platform_str = platform.system()
	print 'Platform detected: {}'.format(platform_str)
	# Instantiate
	if platform_str == 'Windows':
		return WindowsPlatform()
	elif platform_str == 'Linux':
		return LinuxPlatform()
	else:
		raise NotImplementedError('This platform is not yet supported')
97476
function platformPostfix() {
    if (/^win/.test(process.platform)) {
        return process.arch == 'x64' ? 'win64' : 'win32';
    } else if (/^darwin/.test(process.platform)) {
        return 'osx64';
    }
    // This might not be ideal, but we don't have anything else and there is always a chance that it will work
    return process.arch == 'x64' ? 'linux64' : 'linux32';
}
1062276
def InternalPlatformSwitch(funcname, *args, **kwargs):
  """"""
  # pylint: disable=g-import-not-at-top
  clz = None
  if sys.platform.startswith('linux'):
    from pyu2f.hid import linux
    clz = linux.LinuxHidDevice
  elif sys.platform.startswith('win32'):
    from pyu2f.hid import windows
    clz = windows.WindowsHidDevice
  elif sys.platform.startswith('darwin'):
    from pyu2f.hid import macos
    clz = macos.MacOsHidDevice

  if not clz:
    raise Exception('Unsupported platform: ' + sys.platform)

  if funcname == '__init__':
    return clz(*args, **kwargs)
  return getattr(clz, funcname)(*args, **kwargs)
267010
def run(entry_point, drivers, loop = None):
    ''' 
    '''
    program = setup(entry_point, drivers)
    dispose = program.run()
    if loop == None:
        loop = asyncio.get_event_loop()

    loop.run_forever()
    dispose()
384585
def _using_stdout(self):
        
        if WINDOWS and colorama:
            # Then self.stream is an AnsiToWin32 object.
            return self.stream.wrapped is sys.stdout

        return self.stream is sys.stdout
1330749
def check_running(self):
        '''
        
        '''

        if self.check_pidfile():
            pid = self.get_pidfile()
            if not salt.utils.platform.is_windows():
                if self.check_pidfile() and self.is_daemonized(pid) and os.getppid() != pid:
                    return True
            else:
                # We have no os.getppid() on Windows. Use salt.utils.win_functions.get_parent_pid
                if self.check_pidfile() and self.is_daemonized(pid) and salt.utils.win_functions.get_parent_pid() != pid:
                    return True
        return False
1330808
def cli(ctx, lsftdi, lsusb, lsserial, info):
    """"""

    exit_code = 0

    if lsftdi:
        exit_code = System().lsftdi()
    elif lsusb:
        exit_code = System().lsusb()
    elif lsserial:
        exit_code = System().lsserial()
    elif info:
        click.secho('Platform: ', nl=False)
        click.secho(get_systype(), fg='yellow')
    else:
        click.secho(ctx.get_help())

    ctx.exit(exit_code)
859665
def main():
    

    if not sys.platform.startswith("win"):
        if "--daemon" in sys.argv:
            daemonize()
    from gns3server.run import run
    run()
494131
def check_tool_aux(command):
    
    assert isinstance(command, basestring)
    dirname = os.path.dirname(command)
    if dirname:
        if os.path.exists(command):
            return command
        # Both NT and Cygwin will run .exe files by their unqualified names.
        elif on_windows() and os.path.exists(command + '.exe'):
            return command
        # Only NT will run .bat files by their unqualified names.
        elif os_name() == 'NT' and os.path.exists(command + '.bat'):
            return command
    else:
        paths = path.programs_path()
        if path.glob(paths, [command]):
            return command
1121429
def multi_platform_open(cmd):
    
    if platform == "linux" or platform == "linux2":
        cmd = ['xdg-open', cmd]
    elif platform == "darwin":
        cmd = ['open', cmd]
    elif platform == "win32":
        cmd = ['start', cmd]
    subprocess.check_call(cmd)
1076276
public T execute() {
        if (isWindows()) {
            return onWindows();
        } else if (isMac()) {
            return onMac();
        } else if (isUnix()) {
            return onUnix();
        } else if (isSolaris()) {
            return onSolaris();
        } else {
            throw new IllegalStateException("Invalid operating system " + os);
        }
    }
393117
def safe_start(self):
        """"""
        try:
            self.start()
        except (KeyboardInterrupt, IOError):
            # The time.sleep call might raise
            # "IOError: [Errno 4] Interrupted function call" on KBInt.
            self.error_log('Keyboard Interrupt: shutting down')
            self.stop()
            raise
        except SystemExit:
            self.error_log('SystemExit raised: shutting down')
            self.stop()
            raise
329909
def _is_pid_running_on_windows(pid):
    
    import ctypes.wintypes

    kernel32 = ctypes.windll.kernel32
    handle = kernel32.OpenProcess(1, 0, pid)
    if handle == 0:
        return False
    exit_code = ctypes.wintypes.DWORD()
    ret = kernel32.GetExitCodeProcess(handle, ctypes.byref(exit_code))
    is_alive = (ret == 0 or exit_code.value == _STILL_ALIVE)  # pylint: disable=undefined-variable
    kernel32.CloseHandle(handle)
    return is_alive
946296
def default_subprocess_runner(cmd, cwd=None, extra_environ=None):
    """"""
    env = os.environ.copy()
    if extra_environ:
        env.update(extra_environ)

    check_call(cmd, cwd=cwd, env=env)