Guest User

Untitled

a guest
Sep 24th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. def book_post_save(sender, instance=False, **kwargs):
  2.  
  3. pdf = Post.objects.get(pk=instance.pk)
  4. command = "convert -quality 95 -thumbnail 100 %s%s[0] %s%s" % (settings.MEDIA_ROOT, pdf.file, settings.MEDIA_ROOT, pdf.file)
  5. proc = subprocess.Popen(command,
  6. shell=True,
  7. stdin=subprocess.PIPE,
  8. stdout=subprocess.PIPE,
  9. stderr=subprocess.PIPE,
  10. )
  11. stdout_value = proc.communicate()[0]
  12. post_save.connect(book_post_save, sender=Post)
Add Comment
Please, Sign In to add comment