вывод df -h в pdf


#!/usr/bin/python
import subprocess
import datetime
 
from reportlab.pdfgen import canvas
from reportlab.lib.units import inch
 
def disk_report():
   p=subprocess.Popen("df -h", shell=True,stdout=subprocess.PIPE)
   #записываем вывод df -h
   return p.stdout.readlines()

def create_pdf(input,output="disk_rep.pdf"):
   #создаем pdf, записываем дату
   now=datetime.datetime.today()
   date=now.strftime("%h %d %Y %H:%M:%S")
   c=canvas.Canvas(output)
   textobj=c.beginText()
   textobj.setTextOrigin(inch,11*inch)
   textobj.textLines('''
   Disk Capacity Report: %s ''' % date)
   for line in input:
     textobj.textLine(line.strip())
   c.drawText(textobj)
   c.showPage()
   c.save()
report=disk_report() #записываем вывод в переменную
create_pdf(report)

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

Time limit is exhausted. Please reload the CAPTCHA.

Этот сайт использует Akismet для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.