def processing(pdfName): # socket.setdefaulttimeout(10.0) environment = os.getenv('SERVER_TYPE') #, 'development') #TEST logger.info('') logger.info('') logger.info('START PROCESSING {}'.format(pdfName)) logger.info('─' * (len(pdfName) + 17)) logger.info('SERVER_TYPE={}'.format(environment)) #TEST pdf = PDF(pdfName) # Переименовываем - из названия PDF удаляется имя выводильщика remove_ctpbureau_from_pdfname(pdf) # Crop via PyPDF2 library crop(pdf) # Compress via Ghostscript compress(pdf) # Make JPEG preview for Grid (only first page) generating_jpeg(pdf) # Сalculating ink coverage pdf.inks = analyze_inkcoverage(pdf.cropped_file) # Custom operation depends on outputter custom_operations(pdf) # Send Preview PDF to press FTP pdf.upload_to_press_status, pdf.upload_to_press_error = upload_to_press(pdf) # Send Original PDF to Outputter pdf.upload_to_ctpbureau_status, pdf.upload_to_ctpbureau_error = upload_to_ctpbureau(pdf) # Send SMS via http://smsc.ua/ send_sms(pdf) send_telegram(pdf) # Запись в БД save_bd_record(pdf) # Удаление временных файлов cleaning_temps(pdf)
class TestSlate(unittest.TestCase): def setUp(self): with open('example.pdf', 'rb') as f: self.doc = PDF(f) with open('protected.pdf', 'rb') as f: self.passwd = PDF(f, 'a') def test_basic(self): assert self.doc[0] == 'This is a test.\n\n\x0c' def test_no_text_carry_over(self): assert self.doc[1] == '\x0c' def test_metadata_extraction(self): assert self.doc.metadata def test_text_method(self): assert "This is a test" in self.doc.text() def test_text_method_unclean(self): assert '\x0c' in self.doc.text(clean=0) def test_password(self): assert self.passwd[0] == "Chamber of secrets.\n\n\x0c"
def pytest_funcarg__passwd(request): with open(get_pdf_path('protected.pdf'), 'rb') as f: return PDF(f, 'a')
def pytest_funcarg__doc(request): with open(get_pdf_path('example.pdf'), 'rb') as f: return PDF(f)
def setUp(self): with open('example.pdf', 'rb') as f: self.doc = PDF(f) with open('protected.pdf', 'rb') as f: self.passwd = PDF(f, 'a')
from classes import PDF from xlwt import * # logging.propagate = False # logging.getLogger().setLevel(logging.ERROR) # def pytest_funcarg__doc(): # with open('1.pdf', 'rb') as f: # return PDF(f) # def pytest_funcarg__doc(): input_pdf = input("Insert PDF File name with '.pdf' : ") with open(input_pdf, 'rb') as f: doc = PDF(f) action_no_list = [] response_list = [] line_list = [] pdf_txt = '1.txt' text_file = open("1.txt", "w") for i, page in enumerate(doc): # print('*****************') # print(i, page) text_file.write(page) text_file.close()
def pytest_funcarg__doc(request): with open('example.pdf', 'rb') as f: return PDF(f)