Skip to content

Commit

Permalink
#2: Added connection to AMQP.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bystroushaak committed Nov 4, 2014
1 parent 13daa7f commit cfe6b75
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/edeposit/amqp/ltp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
# Interpreter version: python 2.7
#
# Imports =====================================================================
import settings
import structures
import shutil
import os.path

import ltp
import settings
import structures


# Functions & objects =========================================================
Expand Down Expand Up @@ -36,4 +38,21 @@ def reactToAMQPMessage(message, UUID):
Raises:
ValueError: if bad type of `message` structure is given.
"""
pass
if _instanceof(message, structures.ExportRequest):
tmp_folder = ltp.create_ltp_package(
aleph_record=message.aleph_record,
book_id=message.book_uuid,
ebook_fn=message.filename,
b64_data=message.b64_data
)

out_dir = os.path.join(settings.EXPORT_DIR, tmp_folder)
if os.path.exists(out_dir):
shutil.rmtree(out_dir)

shutil.move(tmp_folder, settings.EXPORT_DIR)
# return structures.ScanResult(message.filename, result)

raise ValueError(
"Unknown type of request: '" + str(type(message)) + "'!"
)

0 comments on commit cfe6b75

Please sign in to comment.