Read platform numbers from $PPP_CONFIG_DIR/platforms.txt if available.
506554
def read_platform_numbers(in_upper=False, num_as_int=False):
    """"""
    out_dict = {}
    os.getenv('PPP_CONFIG_DIR', PKG_CONFIG_DIR)
    platform_file = None
    if 'PPP_CONFIG_DIR' in os.environ:
        platform_file = os.path.join(os.environ['PPP_CONFIG_DIR'], 'platforms.txt')
    if not platform_file or not os.path.isfile(platform_file):
        platform_file = os.path.join(PKG_CONFIG_DIR, 'platforms.txt')

    try:
        fid = open(platform_file, 'r')
    except IOError:
        LOGGER.error("Platform file %s not found.", platform_file)
        return out_dict
    for row in fid:
        # skip comment lines
        if not row.startswith('#'):
            parts = row.split()
            if len(parts) < 2:
                continue
            if in_upper:
                parts[0] = parts[0].upper()
            if num_as_int:
                parts[1] = int(parts[1])
            out_dict[parts[0]] = parts[1]
    fid.close()

    return out_dict
1026932
def get_platform_info():
        

        try:
            system_name = platform.system()
            release_name = platform.release()
        except:
            system_name = "Unknown"
            release_name = "Unknown"

        return {
            'system': system_name,
            'release': release_name,
        }
280762
def try_read(self, config_dir=None, **kwargs):
        
        if isinstance(config_dir, basestring):
            config_dir = (config_dir,)

        for cdir in config_dir:
            try:
                self.read(cdir, **kwargs)
                return cdir

            except IOError as e:
                pass
860762
def detect_platform(self):
        """"""
        platform = Scraper.detect_platform(self)

        # On OS X we have to special case the platform detection code and
        # fallback to 64 bit builds for the en-US locale
        if mozinfo.os == 'mac' and self.locale == 'en-US' and \
                mozinfo.bits == 64:
            platform = "%s%d" % (mozinfo.os, mozinfo.bits)

        return platform
737288
function PlatformInfo(PlatformCtor, platformId) {

    this._Ctor = PlatformCtor;
    this._platformId = platformId;

    // Prefix all platform-specific args with the platform name
    var argSpec = PlatformCtor.getArgs ? PlatformCtor.getArgs() : {};
    this._argSpec = {};
    for (var cmd in argSpec) {
        var cmdArgSpec = argSpec[cmd];
        var platformCmdArgSpec = {};
        for (var key in cmdArgSpec) {
            platformCmdArgSpec["--" + platformId + "-" + key] = cmdArgSpec[key];
        }
        this._argSpec[cmd] = platformCmdArgSpec;
    }

    // Look for platforms env vars
    this._envSpec = PlatformCtor.getEnv ? PlatformCtor.getEnv() : {};
}
794422
def ppp_read(self, ppp_fd):
        ''''''
        buf = os.read(ppp_fd, 100)
        if len(buf) == 0:
            # EOF on the child fd
            self.stop_ppp_link()
            return
        print("ppp packet len=%u" % len(buf))
        master = self.master
        master.mav.ppp_send(len(buf), buf)
1124370
def _read_modeling_results(self, directory, silent=False):
        

        voltage_file = directory + os.sep + 'volt.dat'
        if os.path.isfile(voltage_file):
            if not silent:
                print('reading voltages')
            self.read_voltages(voltage_file)

        sens_files = sorted(glob(
            directory + os.sep + 'sens' + os.sep + 'sens*.dat')
        )
        # check if there are sensitivity files, and that the nr corresponds to
        # the nr of configs
        if(len(sens_files) > 0 and
           len(sens_files) == self.configs.nr_of_configs):
            print('reading sensitivities')
            self._read_sensitivities(directory + os.sep + 'sens')

        # same for potentials
        pot_files = sorted(glob(
            directory + os.sep + 'pot' + os.sep + 'pot*.dat')
        )
        # check if there are sensitivity files, and that the nr corresponds to
        # the nr of configs
        if(len(pot_files) > 0 and
           len(pot_files) == self.configs.nr_of_configs):
            print('reading potentials')
            self._read_potentials(directory + os.sep + 'pot')
1043358
def _read(self):
        
        if self._dask:
            d = da.from_delayed(
                delayed(read_from_bpch, )(
                    self.filename, self.file_position, self.shape,
                    self.dtype, self.endian, use_mmap=self._mmap
                ),
                self.shape, self.dtype
            )
        else:
            d = read_from_bpch(
                    self.filename, self.file_position, self.shape,
                    self.dtype, self.endian, use_mmap=self._mmap
            )

        return d
371267
def _parse_ethtool_pppoe_opts(opts, iface):
    '''
    
    '''
    config = {}

    for opt in _DEB_CONFIG_PPPOE_OPTS:
        if opt in opts:
            config[opt] = opts[opt]

    if 'provider' in opts and not opts['provider']:
        _raise_error_iface(iface, 'provider', _CONFIG_TRUE + _CONFIG_FALSE)

    valid = _CONFIG_TRUE + _CONFIG_FALSE
    for option in ('noipdefault', 'usepeerdns', 'defaultroute', 'hide-password', 'noauth', 'persist', 'noaccomp'):
        if option in opts:
            if opts[option] in _CONFIG_TRUE:
                config.update({option: 'True'})
            elif opts[option] in _CONFIG_FALSE:
                config.update({option: 'False'})
            else:
                _raise_error_iface(iface, option, valid)

    return config
559215
def read_postmaster_opts(self):
        """"""
        result = {}
        try:
            with open(os.path.join(self._data_dir, 'postmaster.opts')) as f:
                data = f.read()
                for opt in data.split('" "'):
                    if '=' in opt and opt.startswith('--'):
                        name, val = opt.split('=', 1)
                        result[name.strip('-')] = val.rstrip('"\n')
        except IOError:
            logger.exception('Error when reading postmaster.opts')
        return result
889061
def render_check_and_set_platforms(self):
        
        phase = 'prebuild_plugins'
        plugin = 'check_and_set_platforms'
        if not self.pt.has_plugin_conf(phase, plugin):
            return

        if self.user_params.koji_target.value:
            self.pt.set_plugin_arg(phase, plugin, "koji_target",
                                   self.user_params.koji_target.value)
1344350
def get_platform():
        """"""
        _sys_map = {'linux2': 'linux', 'linux': 'linux',
                    'darwin': 'osx', 'win32': 'win', 'openbsd5': 'openbsd'}

        non_x86_linux_machines = {'armv6l', 'armv7l', 'ppc64le'}
        sys_platform = _sys_map.get(sys.platform, 'unknown')
        bits = 8 * tuple.__itemsize__

        if (sys_platform == 'linux' and
                platform.machine() in non_x86_linux_machines):
            arch_name = platform.machine()
            subdir = 'linux-{0}'.format(arch_name)
        else:
            arch_name = {64: 'x86_64', 32: 'x86'}[bits]
            subdir = '{0}-{1}'.format(sys_platform, bits)

        return subdir
994415
def getPID(self):
        
        if self._pid is not None:
            if not PlatformManager.isPIDValid(self._pid):
                self._pid = -1
            return self._pid
        return -1
1255301
def list_platform_sets(server_url):
    '''
    
    '''
    config = _get_asam_configuration(server_url)
    if not config:
        return False

    url = config['platformset_config_url']

    data = {
        'manual': 'false',
    }

    auth = (
        config['username'],
        config['password']
    )

    try:
        html_content = _make_post_request(url, data, auth, verify=False)
    except Exception as exc:
        err_msg = "Failed to look up existing platform sets"
        log.error('%s:\n%s', err_msg, exc)
        return {server_url: err_msg}

    parser = _parse_html_content(html_content)
    platform_set_list = _get_platform_sets(parser.data)

    if platform_set_list:
        return {server_url: platform_set_list}
    else:
        return {server_url: "No existing platform sets found"}
434268
def read_ppdesc(self, filename):
        
        if filename.endswith(".xml"):
            raise self.Error("XML pseudo not supported yet")

        else:
            # Assume file with the abinit header.
            lines = _read_nlines(filename, 80)

            for lineno, line in enumerate(lines):

                if lineno == 2:
                    try:
                        tokens = line.split()
                        pspcod, pspxc = map(int, tokens[:2])
                    except:
                        msg = "%s: Cannot parse pspcod, pspxc in line\n %s" % (filename, line)
                        logger.critical(msg)
                        return None

                    #if tokens[-1].strip().replace(" ","") not in ["pspcod,pspxc,lmax,lloc,mmax,r2well",
                    #                              "pspcod,pspxc,lmax,llocal,mmax,r2well"]:
                    #    raise self.Error("%s: Invalid line\n %s"  % (filename, line))
                    #    return None

                    if pspcod not in self._PSPCODES:
                        raise self.Error("%s: Don't know how to handle pspcod %s\n" % (filename, pspcod))

                    ppdesc = self._PSPCODES[pspcod]

                    if pspcod == 7:
                        # PAW -> need to know the format pspfmt
                        tokens = lines[lineno+1].split()
                        pspfmt, creatorID = tokens[:2]
                        #if tokens[-1].strip() != "pspfmt,creatorID":
                        #    raise self.Error("%s: Invalid line\n %s" % (filename, line))
                        #    return None

                        ppdesc = ppdesc._replace(format = pspfmt)

                    return ppdesc

            return None
1156960
def findRequirements(platform):
  
  includePycapnp = platform not in WINDOWS_PLATFORMS
  requirementsPath = fixPath(os.path.join(PY_BINDINGS, "requirements.txt"))
  return [
    line.strip()
    for line in open(requirementsPath).readlines()
    if not line.startswith("#") and (not line.startswith("pycapnp") or includePycapnp)
  ]
381073
function findProvidesModule(directories, opts = {}) {
  const options = Object.assign({}, defaultOpts, opts);

  const modulesMap = {};

  const walk = dir => {
    const stat = fs.lstatSync(dir);

    if (stat.isDirectory()) {
      fs.readdirSync(dir).forEach(file => {
        if (options.blacklist.indexOf(file) >= 0) {
          return;
        }
        walk(path.join(dir, file));
      });
      return;
    }

    if (stat.isFile()) {
      const jsFileName = getJSFileName(dir);
      if (!jsFileName) {
        return;
      }

      const fileName = getPlatformFileName(jsFileName, options.platforms);

      const moduleName = getProvidedModuleName(dir);
      if (!moduleName) {
        return;
      }

      // Throw when duplicated modules are provided from a different
      // fileName
      if (modulesMap[moduleName] && modulesMap[moduleName] !== fileName) {
        throw new Error('Duplicate haste module found');
      }
      modulesMap[moduleName] = fileName;
    }
  };

  directories.forEach(walk);

  return modulesMap;
}