Esempio n. 1
0
    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
        ])
Esempio n. 2
0
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
Esempio n. 3
0
 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)
Esempio n. 4
0
    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])
Esempio n. 5
0
    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])
Esempio n. 6
0
    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])
Esempio n. 7
0
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
Esempio n. 8
0
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)
Esempio n. 9
0
def get_all_cards():
    get_cards_url = url_builder(GET_CARDS_URL)

    response = requests.request("GET", get_cards_url)

    return json.loads(response.text)
Esempio n. 10
0
def test(ip_url):
    return url_builder(ip_url, def_path='/path', def_port=90)