def amazon_s3_url(self, sat, band): """ Return an amazon s3 url the contains the scene and band provided. :param sat: Expects an object created by scene_interpreter method :type sat: dict :param filename: The filename that has to be downloaded from Amazon :type filename: String :returns: (String) The URL to a S3 file """ if band != 'MTL': filename = '%s_B%s.TIF' % (sat['scene'], band) else: filename = '%s_%s.txt' % (sat['scene'], band) return url_builder([ self.s3, sat['sat'], sat['path'], sat['row'], sat['scene'], filename ])
def fetch(symbol, config): '''fetches stock data from api, return as a pandas dataframe''' print('***fetching stock data for ' + symbol + '***') # fetch stock data for a symbol param_list = [ 'function=' + config['function'], 'symbol=' + symbol, 'outputsize=' + config['output_size'], 'datatype=' + config['data_type'], 'apikey=' + config['api_key'] ] url = utils.url_builder(constants.BASEURL, param_list) json_data = utils.get_json_from_url(url) dataframe = {} try: dataframe = pd.DataFrame(list(json_data.values())[1]).transpose() except IndexError: print(json_data) dataframe = pd.DataFrame() pattern = re.compile('[a-zA-Z]+') dataframe.columns = dataframe.columns.map( lambda a: pattern.search(a).group()) # print(dataframe) return dataframe
def _make_url(self, target: str) -> str: if target == 'api': target_path = 'api/method/{}.{}'.format(self._cfg['object_name'], self._cfg['object_method']) elif target == 'cmd': target_path = 'command.php' else: return '' return '{}/{}'.format(url_builder(self._cfg['ip']), target_path)
def google_storage_url(self, sat): """ Returns a google storage url the contains the scene provided. :param sat: Expects an object created by scene_interpreter method :type sat: dict :returns: (String) The URL to a google storage file """ filename = sat['scene'] + '.tar.bz' return url_builder([self.google, sat['sat'], sat['path'], sat['row'], filename])
def google_storage_url(self, sat): """ Returns a google storage url the contains the scene provided. :param sat: Expects an object created by scene_interpreter method :type sat: dict :returns: (String) The URL to a google storage file """ filename = sat['scene'] + '.tar.bz' return url_builder( [self.google, sat['sat'], sat['path'], sat['row'], filename])
def amazon_s3_url(self, sat, filename): """ Return an amazon s3 url the contains the scene and band provided. :param sat: Expects an object created by scene_interpreter method :type sat: dict :param filename: The filename that has to be downloaded from Amazon :type filename: String :returns: (String) The URL to a S3 file """ return url_builder([self.s3, sat['sat'], sat['path'], sat['row'], sat['scene'], filename])
def fetch(indicator, symbol, config): '''fetches stock data from api, then outputs as a pandas dataframe''' print("fetching indicator " + indicator + " for " + symbol) # fetch stock data for each symbol dataframe = pd.DataFrame([]) params = [ 'function=' + indicator, 'symbol=' + symbol, 'interval=' + config['interval'], 'time_period=' + config['time_period'], 'series_type=' + config['series_type'], 'apikey=' + config['api_key'] ] url = utils.url_builder(constants.BASEURL, params) json_data = utils.get_json_from_url(url) dataframe = {} try: dataframe = pd.DataFrame(list(json_data.values())[1]).transpose() except IndexError: dataframe = pd.DataFrame() return dataframe
def post_new_cards(new_cards): post_cards_url = url_builder(POST_CARDS_URL) for new_card in new_cards: requests.post(post_cards_url, params=new_card)
def get_all_cards(): get_cards_url = url_builder(GET_CARDS_URL) response = requests.request("GET", get_cards_url) return json.loads(response.text)
def test(ip_url): return url_builder(ip_url, def_path='/path', def_port=90)