upsies.jobs.imagehost

Upload images to image hosting services

Classes

class upsies.jobs.imagehost.ImagehostJob(*, home_directory=None, cache_directory=None, cache_id='', ignore_cache=False, no_output_is_ok=False, hidden=False, autostart=True, guaranteed=False, precondition=None, prejobs=(), callbacks={}, **kwargs)[source]

Bases: JobBase

Upload images to an image hosting service

cache_id = None
initialize(*, imagehosts, image_paths=(), thumb_width=None, output_format=None)[source]

Validate arguments and set internal state

Parameters:
  • imagehosts – Sequence of ImagehostBase subclass instances (see imagehosts.imagehost())

  • image_paths – Sequence of image paths to upload

  • thumb_width (int) – Width in pixels for thumbnails

  • output_format (str) – Format string for each image URL Uses {url} and {thumbnail} as replacement tokens.

First, image_paths are uploaded. If a Job named “screenshots” exists in siblings, screenshots from that job are uploaded as well.

async run()[source]

Do the work

This method is called by start(). Its coroutine is passed to add_task().

Any keyword arguments passed to initialize() are available via kwargs.

The job is_finished when all added tasks are done or cancelled. (See also finalize() and finalization().)

This method may call add_task() if more tasks are required.

property exit_code

0 if all images were uploaded, 1 otherwise, None if unfinished

property uploaded_images

Sequence of UploadedImage objects

Use this property to get additional information like thumbnail URLs that are not part of this job’s output.

property urls_by_file

Map of image file paths to UploadedImage instances

property images_uploaded

Number of uploaded images

property images_total

Expected number of images to upload

set_images_total(value)[source]

images_total setter as a method