service.preclass.processors.pdf2png module

class service.preclass.processors.pdf2png.SERVICE[source]

Bases: object

Service class for handling PDF to PNG conversion jobs using RabbitMQ and MongoDB.

_collection

MongoDB collection for storing job information (internal use)

_queue_name

Name of the RabbitMQ queue for this service (internal use)

Type:

str

_logger

Logger instance for the service (internal use)

static callback(ch, method, properties, body)[source]

Callback function for processing PDF to PNG conversion jobs from RabbitMQ.

Parameters:
  • ch – RabbitMQ channel

  • method – RabbitMQ method frame

  • properties – RabbitMQ properties

  • body – Message body containing the job ID

Returns:

None

static launch_worker()[source]

Launch the worker to consume PDF to PNG conversion jobs from RabbitMQ queue. The worker runs indefinitely until interrupted with CTRL+C.

Returns:

None

static trigger(parent_service, lecture_id, parent_job_id)[source]

Trigger a new PDF to PNG conversion job.

Parameters:
  • parent_service (str) – Name of the parent service that triggered this job

  • lecture_id (ObjectId) – MongoDB ObjectId of the lecture

  • parent_job_id (ObjectId) – MongoDB ObjectId of the parent job

Returns:

The job ID of the created conversion job

Return type:

str

service.preclass.processors.pdf2png.convert_pdf_to_png(input_file, output_dir)[source]

Convert a PDF file to a series of PNG images, one for each page.

Parameters:
  • input_file (str) – Path to the input PDF file

  • output_dir (str) – Directory where the PNG images will be saved

Returns:

None

service.preclass.processors.pdf2png.now(tz=None)

Returns new datetime object representing current time local to tz.

tz

Timezone object.

If no tz is specified, uses local timezone.