def Fetch(self, url): """Fetches a file synchronously. """ if self._base_path is not None: return urlfetch.fetch(self._base_path + "/" + url, headers={"Cache-Control": "max-age=0"}) else: return urlfetch.fetch(url, headers={"Cache-Control": "max-age=0"})
def Fetch(self, url, username=None, password=None): """Fetches a file synchronously. """ headers = _MakeHeaders(username, password) if self._base_path is not None: return urlfetch.fetch('%s/%s' % (self._base_path, url), headers=headers) else: return urlfetch.fetch(url, headers={ 'Cache-Control': 'max-age=0' })
def Fetch(self, url): """Fetches a file synchronously. """ if self._base_path is not None: return urlfetch.fetch(self._base_path + '/' + url, headers={'Cache-Control': 'max-age=0'}) else: return urlfetch.fetch(url, headers={'Cache-Control': 'max-age=0'})
def Fetch(self, url, username=None, password=None): """Fetches a file synchronously. """ headers = _MakeHeaders(username, password) if self._base_path is not None: return urlfetch.fetch('%s/%s' % (self._base_path, url), headers=headers) else: return urlfetch.fetch(url, headers={'Cache-Control': 'max-age=0'})
def Fetch(self, url, username=None, password=None): """Fetches a file synchronously. """ headers = _MakeHeaders(username, password) import logging if self._base_path is not None: logging.info('%s/%s' % (self._base_path, url)) return urlfetch.fetch('%s/%s' % (self._base_path, url), headers=headers, deadline=20) else: logging.info(url) return urlfetch.fetch(url, headers={ 'Cache-Control': 'max-age=0' }, deadline=20)
def Fetch(self, url, username=None, password=None): """Fetches a file synchronously. """ headers = _MakeHeaders(username, password) import logging if self._base_path is not None: logging.info('%s/%s' % (self._base_path, url)) return urlfetch.fetch('%s/%s' % (self._base_path, url), headers=headers, deadline=20) else: logging.info(url) return urlfetch.fetch(url, headers={'Cache-Control': 'max-age=0'}, deadline=20)
def Fetch(self, url, username=None, password=None, access_token=None): """Fetches a file synchronously. """ return urlfetch.fetch(self._FromBasePath(url), deadline=20, headers=_MakeHeaders(username, password, access_token))
def run_cron_for_dir(d, path_prefix=''): success = True start_time = time.time() files = [f for f in server_instance.content_cache.GetFromFileListing(d) if not f.endswith('/')] for f in files: error = None path = '%s%s' % (path_prefix, f) try: response = MockResponse() server_instance.Get(path, MockRequest(path), response) if response.status != 200: error = 'Got %s response' % response.status #try: # urlfetch.fetch(url_constants.CRXDOCZH_MASTER_UPDATE_URL, # payload = json.dumps([f]), # method = 'POST', # deadline = 6) #except Exception as e: # pass try: urlfetch.fetch(url_constants.CRXDOCZH_MASTER_MIRROR_UPDATE_URL, payload = json.dumps([f]), method = 'POST', deadline = 6) except Exception as e: pass except error: pass if error: logging.error('cron/%s: error rendering %s: %s' % ( channel, path, error)) success = False logging.info('cron/%s: rendering %s files took %s seconds' % ( channel, len(files), time.time() - start_time)) return success
def Fetch(self, url, username=None, password=None, access_token=None): """Fetches a file synchronously. """ return urlfetch.fetch( self._FromBasePath(url), deadline=20, headers=_MakeHeaders(username, password, access_token) )
def Fetch(self, url, username=None, password=None): """Fetches a file synchronously. """ return urlfetch.fetch(self._FromBasePath(url), headers=_MakeHeaders(username, password))
def Fetch(self, url, username=None, password=None): """Fetches a file synchronously. """ if self._base_path is not None: url = '%s/%s' % (self._base_path, url) return urlfetch.fetch(url, headers=_MakeHeaders(username, password))