コード例 #1
0
ファイル: regioninfo.py プロジェクト: prufrax/boto
def load_endpoint_json(path):
    """
    Loads a given JSON file & returns it.

    :param path: The path to the JSON file
    :type path: string

    :returns: The loaded data
    """
    with open(path, 'r') as endpoints_file:
        return json.load(endpoints_file)
コード例 #2
0
ファイル: regioninfo.py プロジェクト: AlexanderNapierski/boto
def load_endpoint_json(path):
    """
    Loads a given JSON file & returns it.

    :param path: The path to the JSON file
    :type path: string

    :returns: The loaded data
    """
    with open(path, 'r') as endpoints_file:
        return json.load(endpoints_file)
コード例 #3
0
ファイル: layer1.py プロジェクト: FYJen/GoogleCloud
 def make_request(self, verb, resource, headers=None, data='',
                  expected_status=None, params=None):
     if headers is None:
         headers = {}
     response = AWSAuthConnection.make_request(
         self, verb, resource, headers=headers, data=data)
     body = json.load(response)
     if response.status == expected_status:
         return body
     else:
         error_type = response.getheader('x-amzn-ErrorType').split(':')[0]
         error_class = self._faults.get(error_type, self.ResponseError)
         raise error_class(response.status, response.reason, body)
コード例 #4
0
ファイル: layer1.py プロジェクト: antleocar/testing
 def make_request(self, verb, resource, headers=None, data='',
                  expected_status=None, params=None):
     if headers is None:
         headers = {}
     response = AWSAuthConnection.make_request(
         self, verb, resource, headers=headers, data=data)
     body = json.load(response)
     if response.status == expected_status:
         return body
     else:
         error_type = response.getheader('x-amzn-ErrorType').split(':')[0]
         error_class = self._faults.get(error_type, self.ResponseError)
         raise error_class(response.status, response.reason, body)
コード例 #5
0
def dynamodb_load(tables, in_dir, create_tables):
    conn = boto.connect_dynamodb()
    for t in tables:
        metadata_file = os.path.join(in_dir, "%s.metadata" % t)
        data_file = os.path.join(in_dir, "%s.data" % t)
        if create_tables:
            with open(metadata_file) as meta_fd:
                metadata = json.load(meta_fd)
            table = conn.create_table(
                name=t,
                schema=Schema(metadata["schema"]),
                read_units=metadata["read_units"],
                write_units=metadata["write_units"],
            )
            table.refresh(wait_for_active=True)
        else:
            table = conn.get_table(t)

        with open(data_file) as in_fd:
            load_table(table, in_fd)
コード例 #6
0
def dynamodb_load(tables, in_dir, create_tables):
    conn = boto.connect_dynamodb()
    for t in tables:
        metadata_file = os.path.join(in_dir, "%s.metadata" % t)
        data_file = os.path.join(in_dir, "%s.data" % t)
        if create_tables:
            with open(metadata_file) as meta_fd:
                metadata = json.load(meta_fd)
            table = conn.create_table(
                name=t,
                schema=Schema(metadata["schema"]),
                read_units=metadata["read_units"],
                write_units=metadata["write_units"],
            )
            table.refresh(wait_for_active=True)
        else:
            table = conn.get_table(t)

        with open(data_file) as in_fd:
            load_table(table, in_fd)
コード例 #7
0
def unjson(path):
    with open(path) as o:
        return json.load(o)
コード例 #8
0
def unjson(path):
    with open(path) as o:
        return json.load(o)