刷新文件目录，文档 http://developer.qiniu.com/article/fusion/api/refresh.html

        Args:
           urls: 待刷新的目录列表
           dirs: 待刷新的文件列表

        Returns:
           一个dict变量和一个ResponseInfo对象
           参考代码 examples/cdn_manager.py
16910
def refresh_urls_and_dirs(self, urls, dirs):
        
        req = {}
        if urls is not None and len(urls) > 0:
            req.update({"urls": urls})
        if dirs is not None and len(dirs) > 0:
            req.update({"dirs": dirs})

        body = json.dumps(req)
        url = '{0}/v2/tune/refresh'.format(self.server)
        return self.__post(url, body)
569856
def ProcessListDirectory(self, responses):
    
    if not responses.success:
      raise flow.FlowError("Unable to list directory.")

    with data_store.DB.GetMutationPool() as pool:
      for response in responses:
        stat_entry = rdf_client_fs.StatEntry(response)
        filesystem.CreateAFF4Object(
            stat_entry, self.client_urn, pool, token=self.token)
        self.SendReply(stat_entry)
901180
def update_metadata(self):
        
        if self._data_directory is None:
            raise Exception('Need to call `api.set_data_directory` first.')

        metadata_url = 'https://repo.continuum.io/pkgs/metadata.json'
        filepath = os.sep.join([self._data_directory, 'metadata.json'])
        worker = self.download_requests(metadata_url, filepath)
        return worker
844019
def _prepare_request_file_vs_dir(self, request: Request) -> bool:
        '''
        '''
        if self._item_session.url_record.link_type:
            is_file = self._item_session.url_record.link_type == LinkType.file
        elif request.url_info.path.endswith('/'):
            is_file = False
        else:
            is_file = 'unknown'

        if is_file == 'unknown':
            files = yield from self._fetch_parent_path(request)

            if not files:
                return True

            filename = posixpath.basename(request.file_path)

            for file_entry in files:
                if file_entry.name == filename:
                    _logger.debug('Found entry in parent. Type {}',
                                  file_entry.type)
                    is_file = file_entry.type != 'dir'
                    break
            else:
                _logger.debug('Did not find entry. Assume file.')
                return True

            if not is_file:
                request.url = append_slash_to_path_url(request.url_info)
                _logger.debug('Request URL changed to {}. Path={}.',
                              request.url, request.file_path)

        return is_file
9092
def refresh(self):
      '''
      '''
      response = requests.get('%s/categories/%s' % (API_BASE_URL, self.name))
      attributes = response.json()
      
      self.ancestors = [Category(name) for name in attributes['ancestors']]
      self.contents = WikiText(attributes['contents_raw'],
                               attributes['contents_rendered'])
      self.description = attributes['description']
      self.guides = []
      for guide in attributes['guides']:
         self.guides.append(Guide(guide['guideid']))
      # Unlike guides, categories return flags as a dict, keyed by flagid.
      # *Except* when it's empty, in which case we get an empty list due to
      # PHP's json_encode() not knowing the difference between an empty array
      # and an empty dict.
      flags = dict(attributes['flags']).values()
      self.flags = [Flag.from_id(flag['flagid']) for flag in flags]
      self.image = Image(attributes['image']['id']) if attributes['image'] else None
      self.locale = attributes['locale']
      #self.parts = attributes['parts']
      #self.solutions = attributes['solutions']
      self.title = attributes['display_title']
251573
def refresh(self):
        '''
        
        '''
        kwd = {
            'pager': '',
            'title': '最近文档',
        }
        self.render('wiki_page/wiki_list.html',
                    view=MWiki.query_dated(16),
                    format_date=tools.format_date,
                    kwd=kwd,
                    userinfo=self.userinfo)
791973
def update_batches() -> None:
    ""
    batches_data  = requests.get(BATCHES_API_URL).json()
    batches_url   = {i["name"]: i["download_url"] for i in batches_data
                     if i["type"] == "file"}
    order_batches = sorted(batches_url, key=int)

    try:
        existing = set(os.listdir(BATCHES_DIR))
    except FileNotFoundError:
        BATCHES_DIR.mkdir(parents=True)
        existing = set()

    def get_batch(name: str) -> None:
        if name in existing and name != order_batches[-1]:
            return

        answer = requests.get(batches_url[name])
        try:
            answer.raise_for_status()
        except requests.RequestException:
            return

        with AtomicFile(BATCHES_DIR / name, "w") as file:
            file.write(answer.text)

    ThreadPool(8).map(get_batch, order_batches)
928544
def update(self, url, data):
        
        url = self.get_full_url(url)
        self.log.debug("update url : " + url)
        # Building request
        post_data = json.dumps(data).encode("UTF-8")
        request = urllib2.Request(url, post_data)
        request.add_header('Content-Type', 'application/json; charset=UTF-8')
        request.add_header('Accept', 'application/json')
        request.get_method = lambda: 'PUT'
        # Do request
        ret = self.do_request(request)
        self.log.debug("""put url : %(url)s : request time : %(time)s""",
                       {"url": url,
                        "time": self.last_req_time})
        return ret
1089293
def do_update(config, config_dir):
    
    if not os.path.exists(config_dir):
        print "Configuration '{}' does not exist.".format(config)
        exit(1)

    config_file = os.path.join(config_dir, 'config')
    with open(config_file, 'r') as f:
        old_config_data = json.load(f)

    old_url = old_config_data['url']
    old_torrent_dir = old_config_data['torrent_dir']
    old_update_interval = old_config_data['update_interval']

    url = raw_input("RSS URL for processing [{}]: "\
        .format(old_url)) or old_url
    torrent_dir = raw_input("Output directory for found .torrent files [{}]: "\
        .format(old_torrent_dir)) or old_torrent_dir
    update_interval = raw_input("Update interval (mins) [{}]: "\
        .format(old_update_interval)) or old_update_interval

    editor = os.environ["EDITOR"]

    config_filter = os.path.join(config_dir, 'filter')
    if confirm("Do you want to edit filters list?", False):
        call([editor, config_filter])
        print "Filter configuration has been saved."

    config_blacklist = os.path.join(config_dir, 'blacklist')
    if confirm("Do you want to edit blacklist?", False):
        call([editor, config_filter])
        print "Blacklist configuration has been saved."

    config_data = json.dumps({
        "url": url,
        "torrent_dir": torrent_dir,
        "update_interval": update_interval
    }, sort_keys=True, indent=4, separators=(',', ': '))
    with open(config_file, 'w') as f:
        f.write(config_data)

    ct = CronTab(user=True)
    for job in ct:
        if re.match('.*ghetto.*\-e\s{}'.format(config), job.command):
            ct.remove(job)

    cmd = "{} {} -e {}".format(sys.executable,
                               os.path.abspath(__file__),
                               config)
    new_job = ct.new(command=cmd)
    new_job.minute.every(update_interval)
    new_job.enable()
    ct.write()
    print "Crontab updated."

    print "Configuration '{}' has been updated.".format(config)
695111
def put_directory(self, mdir):
        
        log.debug('PutDirectory %r', mdir)
        headers = {"Content-Type": "application/json; type=directory"}
        res, content = self._request(mdir, "PUT", headers=headers)
        if res["status"] != "204":
            raise errors.MantaAPIError(res, content)
1024607
def urlretrieve(url, dest, write_mode="w"):
    """"""
    response = urllib2.urlopen(url)
    mkdir_recursive(os.path.dirname(dest))
    with open(dest, write_mode) as f:
        f.write(response.read())
        f.close()
200143
function updateSite () {
    start('Adding new version of the docs site...');
    const options = { cwd: './code.material.angularjs.org' };
    writeDocsJson();

    // build files for bower
    exec([
        'rm -rf dist',
        'gulp docs'
    ]);
    replaceFilePaths();

    // copy files over to site repo
    exec([
        `cp -Rf ../dist/docs ${newVersion}`,
        'rm -rf latest && cp -Rf ../dist/docs latest',
        'git add -A',
        `git commit -m "release: version ${newVersion}"`,
        'rm -rf ../dist'
    ], options);
    replaceBaseHref(newVersion);
    replaceBaseHref('latest');

    // update firebase.json file
    updateFirebaseJson();
    exec(['git commit --amend --no-edit -a'], options);
    done();

    // add steps to push script
    pushCmds.push(
        comment('push the site'),
        'cd ' + options.cwd,
        'git pull --rebase --strategy=ours',
        'git push',
        'cd ..'
    );

    function updateFirebaseJson () {
      fs.writeFileSync(options.cwd + '/firebase.json', getFirebaseJson());
      function getFirebaseJson () {
        const json = require(options.cwd + '/firebase.json');
        json.hosting.rewrites = json.hosting.rewrites || [];
        const rewrites = json.hosting.rewrites;

        switch (rewrites.length) {
          case 0:
            rewrites.push(getRewrite('HEAD'));
          case 1:
            rewrites.push(getRewrite('latest'));
          default:
            rewrites.push(getRewrite(newVersion));
        }
        return JSON.stringify(json, null, 2);
        function getRewrite (str) {
          return {
            source:      '/' + str + '/**/!(*.@(js|html|css|json|svg|png|jpg|jpeg))',
            destination: '/' + str + '/index.html'
          };
        }
      }
    }

    function writeDocsJson () {
      const config = require(options.cwd + '/docs.json');
      config.versions.unshift(newVersion);

      // only set to default if not a release candidate
      config.latest = newVersion;
      fs.writeFileSync(options.cwd + '/docs.json', JSON.stringify(config, null, 2));
    }
  }
1195919
def refresh(self, groupId, groupName):
        

        desc = {
            "name": "CodeSuccessReslut",
            "desc": " http 成功返回结果",
            "fields": [{
                "name": "code",
                "type": "Integer",
                "desc": "返回码，200 为正常。"
            }, {
                "name": "errorMessage",
                "type": "String",
                "desc": "错误信息。"
            }]
        }
        r = self.call_api(
            method=('API', 'POST', 'application/x-www-form-urlencoded'),
            action='/group/refresh.json',
            params={"groupId": groupId,
                    "groupName": groupName})
        return Response(r, desc)
1197860
def get_dir_contents(self, path, ref=github.GithubObject.NotSet):
        
        assert isinstance(path, (str, unicode)), path
        assert ref is github.GithubObject.NotSet or isinstance(ref, (str, unicode)), ref
        url_parameters = dict()
        if ref is not github.GithubObject.NotSet:
            url_parameters["ref"] = ref
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            self.url + "/contents/" + urllib.quote(path),
            parameters=url_parameters
        )

        # Handle 302 redirect response
        if headers.get('status') == '302 Found' and headers.get('location'):
            headers, data = self._requester.requestJsonAndCheck(
                "GET",
                headers['location'],
                parameters=url_parameters
            )

        return [
            github.ContentFile.ContentFile(self._requester, headers, attributes, completed=(attributes["type"] != "file"))  # Lazy completion only makes sense for files. See discussion here: https://github.com/jacquev6/PyGithub/issues/140#issuecomment-13481130
            for attributes in data
        ]
1074084
def update_urls(response)
      mode = response[:mode].to_sym
      raise CommunicationModeSwitch, "RightNet communication mode switching from #{@mode.inspect} to #{mode.inspect}" if @mode && @mode != mode
      @mode = mode
      @shard_id = response[:shard_id].to_i
      if (new_url = response[:router_url]) != @router_url
        Log.info("Updating RightNet router URL to #{new_url.inspect}")
        @router_url = new_url
      end
      if (new_url = response[:api_url]) != @api_url
        Log.info("Updating RightApi URL to #{new_url.inspect}")
        @api_url = new_url
        create_http_client
      end
      true
    end
71869
private void refreshFileList()
      throws IOException {
    FileStatus[] files = fileSystem.globStatus(inputDirectoryAndPattern);
    for (FileStatus file : files) {
      String fileName = file.getPath().getName();
      if (!knownFileSet.contains(fileName)) {
        if (endFileNumber != -1) {
          // Sanity check against endFileNumber.
          int newFileIndex = parseFileIndex(fileName);
          Preconditions.checkState(newFileIndex < endFileNumber,
              "Found new file '%s' with index %s, which isn't less than endFileNumber %s!",
              fileName, newFileIndex, endFileNumber);
        }

        logger.atInfo().log(
            "Adding new file '%s' of size %s to knownFileSet.", fileName, file.getLen());
        knownFileSet.add(fileName);
        fileQueue.add(file);
      }
    }
  }
461571
function fetchCdnVersion(cdnUrl) {
        var fullUrl = cdnUrl + path.sep + SONAR_RUNNER_DIST;
        console.log('Fetching sonar-runner from CDN url [' + fullUrl + '].');
        try {
            var response = request('GET', fullUrl);
            if(response.statusCode === 200) {
                var destination = path.join('.tmp', SONAR_RUNNER_DIST);
                fs.mkdirsSync('.tmp', '0775');
                fs.writeFileSync(destination, response.getBody(), {replace: true});
                return destination;
            } else if(response.statusCode === 404) {
                console.error('Could not find '+ SONAR_RUNNER_DIST + ' on the specified CDN url[' + fullUrl +'].');
            } else {
                console.error('Something went wrong while fetching '+ SONAR_RUNNER_DIST + ' on the specified CDN url[' + fullUrl +'], statusCode [' + response.statusCode + '] was received.');
            }
        } catch (e) {
            console.error('Could not connect to CDN url[' + cdnUrl +'], received message [' + e + ']');
        }
    }