To get the data from different scenarios in the filename, scene value see `remote_download` in 1, 2, 3, 4
760525
def __getFilename(self, data, scene=1):
        """"""
        try:
            filename = None
            if scene == 1:
                plugin_filename = [i for i in parse_qs(urlsplit(data).query).get("plugin_filename") or [] if i]
                if plugin_filename and len(plugin_filename) == 1:
                    filename = plugin_filename[0]
            elif scene == 2:
                filename = basename(urlsplit(data).path)
            elif scene == 3:
                if PY2:
                    cd = data.headers.getheader("Content-Disposition", "")
                else:
                    cd = data.getheader("Content-Disposition", "")
                filename = parse_header(cd)[-1].get("filename")
            elif scene == 4:
                if PY2:
                    cd = data.info().subtype
                else:
                    cd = data.info().get_content_subtype()
                mt = {'zip': 'zip', 'x-compressed-tar': 'tar.gz', 'x-gzip': 'tar.gz'}
                subtype = mt.get(cd)
                if subtype:
                    filename = "." + subtype
        except Exception as e:
            self.logger.warning(e)
        else:
            if self.__isValidFilename(filename):
                return filename
957625
def _parse_downloaded_items(self, result, camera, path):
        """"""
        for item in result:
            try:
                created_at = item['created_at']
                camera_name = item['camera_name']
                is_deleted = item['deleted']
                address = item['address']
            except KeyError:
                _LOGGER.info("Missing clip information, skipping...")
                continue

            if camera_name not in camera and 'all' not in camera:
                _LOGGER.debug("Skipping videos for %s.", camera_name)
                continue

            if is_deleted:
                _LOGGER.debug("%s: %s is marked as deleted.",
                              camera_name,
                              address)
                continue

            clip_address = "{}{}".format(self.urls.base_url, address)
            filename = "{}_{}.mp4".format(camera_name, created_at)
            filename = os.path.join(path, filename)

            if os.path.isfile(filename):
                _LOGGER.info("%s already exists, skipping...", filename)
                continue

            response = api.http_get(self, url=clip_address,
                                    stream=True, json=False)
            with open(filename, 'wb') as vidfile:
                copyfileobj(response.raw, vidfile)

            _LOGGER.info("Downloaded video to %s", filename)
441013
def _filename(self, name=None, suffix=None, prefix=None):
        

        filename = ''

        if prefix:
            filename += str(prefix) + '_'

        if name:
            filename += str(name)
        else:
            filename += str(self.scene)

        if suffix:
            filename += '_' + str(suffix)

        if self.clipped:
            bounds = [tuple(self.bounds[0:2]), tuple(self.bounds[2:4])]
            polyline = PolylineCodec().encode(bounds)
            filename += '_clipped_' + polyline

        filename += '.TIF'

        return filename
25216
def _winpath2bytes_py3(text, codec):
    """"""

    # merge surrogate codepoints
    if _normalize_codec(codec).startswith("utf-16"):
        # fast path, utf-16 merges anyway
        return text.encode(codec, _surrogatepass)
    return _decode_surrogatepass(
        text.encode("utf-16-le", _surrogatepass),
        "utf-16-le").encode(codec, _surrogatepass)
1116184
def curl_remote_name(cls, file_url):
        
        tar_gz_file_name = file_url.split('/')[-1]

        if sys.version_info >= (3, 2):
            from urllib.request import urlopen
            from urllib.error import HTTPError
        else:
            from urllib2 import urlopen
            from urllib2 import HTTPError

        response = None
        try:
            response = urlopen(file_url)
        except HTTPError as e:
            message = 'Download failed: URL: {0}, reason: {1}'.format(
                      file_url, e)
            if 'HTTP Error 404' in str(e):
                raise RemoteFileNotFoundError(message)
            else:
                raise InstallError(message)

        tar_gz_file_obj = io.BytesIO(response.read())
        with open(tar_gz_file_name, 'wb') as f_out:
            f_out.write(tar_gz_file_obj.read())
        return tar_gz_file_name
233559
function processFiles(bucket, key, transform, cb, currentFileNum=0, lastFileNum=0, arn=null, retries=0) {
  const maxRetries = 5

  var nextFileNum = (currentFileNum < lastFileNum) ? currentFileNum + 1 : null
  //invokeLambda(bucket, key, currentFileNum, lastFileNum, arn)

  processFile(
    bucket, `${key}${currentFileNum}.csv`, transform
  ).then((n_scenes) => {
    invokeLambda(bucket, key, nextFileNum, lastFileNum, arn, 0)
    cb()
  }).catch((e) => {
    // if CSV failed, try it again
    if (retries < maxRetries) {
      invokeLambda(bucket, key, currentFileNum, lastFileNum, arn, retries + 1)
    } else {
      // log and move onto the next one
      console.log(`error: maxRetries hit in file ${currentFileNum}`)
      invokeLambda(bucket, key, nextFileNum, lastFileNum, arn, 0)
    }
    cb()
  })
}
920871
def get_dataset(self, key, info):
        """"""
        logger.debug("Reading %s.", key)
        return self.file_content[key.name]
1306360
def get(self, filename):
        
        params = {
            "v": 'dreambox',
            "kolejka": "false",

            "nick": "",
            "pass": "",

            "napios": sys.platform,
            "l": self.language.upper(),

            "f": self.prepareHash(filename),
        }
        params['t'] = self.discombobulate(params['f'])

        url = self.url_base + urllib.urlencode(params)

        subs = urllib.urlopen(url).read()

        if subs.startswith('brak pliku tymczasowego'):
            raise NapiprojektException('napiprojekt.pl API error')

        if subs[0:4] != 'NPc0':
            # napiprojekt keeps subtitles in cp1250
            # ... but, sometimes they are in utf8
            for cdc in ['cp1250', 'utf8']:
                try:
                    return codecs.decode(subs, cdc)
                except:
                    pass
842030
def get(name, defval=None):
    '''
    
    '''
    with s_datfile.openDatFile('synapse.data/%s.mpk' % name) as fd:
        return s_msgpack.un(fd.read())
1031730
def gettextfile(remotefile, localfile = File.basename(remotefile)) # :yield: line
      result = nil
      if localfile
        f = open(localfile, "w")
      elsif !block_given?
        result = ""
      end
      begin
	retrlines("RETR " + remotefile) do |line|
	  f.puts(line) if localfile
	  yield(line) if block_given?
          result.concat(line + "\n") if result
	end
        return result
      ensure
	f.close if localfile
      end
    end
904183
def scene_name(sequence_number, scene_id, name):
        """"""
        return MessageWriter().string("scene.name").uint64(sequence_number).uint32(scene_id).string(name).get()
238572
def get(remotefile, localfile = File.basename(remotefile),
	    blocksize = DEFAULT_BLOCKSIZE, &block) # :yield: data
      unless @binary
	gettextfile(remotefile, localfile, &block)
      else
	getbinaryfile(remotefile, localfile, blocksize, &block)
      end
    end
1135832
def get_remote_file(url):
    
    try:
        return requests.get(url)
    except requests.exceptions.ConnectionError as e:
        print("Connection error!")
        print(e.message.reason)
        exit(1)
724150
def _get_cifar(directory, url):
  """"""
  filename = os.path.basename(url)
  path = generator_utils.maybe_download(directory, filename, url)
  tarfile.open(path, "r:gz").extractall(directory)
64493
def _get_remote_video_url(self, remote_node, session_id):
        
        url = '{}/video'.format(self._get_remote_node_url(remote_node))
        timeout = time.time() + 5  # 5 seconds from now

        # Requests videos list until timeout or the video url is found
        video_url = None
        while time.time() < timeout:
            response = requests.get(url).json()
            try:
                video_url = response['available_videos'][session_id]['download_url']
                break
            except KeyError:
                time.sleep(1)
        return video_url
837970
def get_file_client(opts, pillar=False):
    '''
    
    '''
    client = opts.get('file_client', 'remote')
    if pillar and client == 'local':
        client = 'pillar'
    return {
        'remote': RemoteClient,
        'local': FSClient,
        'pillar': PillarClient,
    }.get(client, RemoteClient)(opts)
526422
def loadnetcdf(filename, copy=True):
    
    filename = str(Path(filename).expanduser())

    if copy:
        dataarray = xr.open_dataarray(filename).copy()
    else:
        dataarray = xr.open_dataarray(filename, chunks={})

    if dataarray.name is None:
        dataarray.name = filename.rstrip('.nc')

    for key, val in dataarray.coords.items():
        if val.dtype.kind == 'S':
            dataarray[key] = val.astype('U')
        elif val.dtype == np.int32:
            dataarray[key] = val.astype('i8')

    return dataarray