def main(url, username, password, target_filepath, imagery_dir): """Program to load targets and upload via interoperability. Args: url: The interoperability URL. username: The interoperability username. password: The interoperability password. target_filepath: Filepath to the tab-delimited target file. imagery_dir: Base to form paths to imagery files. """ # Load target details. targets = load_target_file(target_filepath) # Form full imagery filepaths. targets = [(t, os.path.join(imagery_dir, i)) for t, i in targets] # Validate filepath for each image. for _, image_filepath in targets: if not os.path.exists(image_filepath): raise ValueError('Could not find imagery file: %s' % image_filepath) # Validate type of each image. for _, image_filepath in targets: image_type = imghdr.what(image_filepath) if image_type not in ['jpeg', 'png']: raise ValueError('Invalid imagery type: %s' % image_type) # Create client and upload targets. client = Client(url, username, password) for target, image_filepath in targets: image_data = None with open(image_filepath, 'rb') as f: image_data = f.read() target = client.post_target(target) client.put_target_image(target.id, image_data)
def main(url, username, password, target_filepath, imagery_dir): """Program to load targets and upload via interoperability. Args: url: The interoperability URL. username: The interoperability username. password: The interoperability password. target_filepath: Filepath to the tab-delimited target file. imagery_dir: Base to form paths to imagery files. """ # Load target details. targets = load_target_file(target_filepath) # Form full imagery filepaths. targets = [(t, os.path.join(imagery_dir, i)) for t, i in targets] # Validate filepath for each image. for _, image_filepath in targets: if not os.path.exists(image_filepath): raise ValueError('Could not find imagery file: %s' % image_filepath) # Validate type of each image. for _, image_filepath in targets: image_type = imghdr.what(image_filepath) if image_type not in ['jpeg', 'png']: raise ValueError('Invalid imagery type: %s' % image_type) # Create client and upload targets. client = Client(url, username, password) for target, image_filepath in targets: image_data = None with open(image_filepath, 'rb') as f: image_data = f.read() target = client.post_target(target) client.put_target_image(target.id, image_data)
from interop import Client c = Client('htts://10.10.130.10:80', 'losangeles', '9886843481') f = open('test.png', 'rb') c.put_target_image(1, f)