python Mysql

import time
import pymysql
import json

base_dir="/home/wwwroot/test.acfun.org.cn/public/upload/"
with open('config.json') as f:
    info=json.loads(f.read())


db = pymysql.connect(host="localhost",user=info['dbUser'],password=info['dbPassword'],database=info['dbName'],port=3306 )
cursor = db.cursor()
cursor.execute("SELECT tid,or_file FROM cmf_pdf WHERE done='0' AND del='0' ")
data = cursor.fetchone()

ESP32P4 circuitpython

circuitpython 9.2.0 CPU 360MHZ RAM 33038080

圆周率计算如下图,对比rp2350(使用Micropython 1.24固件)在300MHZ下的计算圆周率速度相仿,但是未使用Micropython下比较。

处理器CPURAM版本10050010002000500010000
RP23501504868481.2411822791071878242860
RP23502504868481.24749167643527025717
RP23503004868481.24541139536439121430
RP2350(不稳定)3204868481.24538131503411620091
ESP32P4360330380809.2.04.3945341.9922163.086532.2273068.8511600.1

pi_circuitpython.py · micropython中文社区/PiCalcTest – Gitee.com

整合到一起

代码整合

from PIL import Image
import os

class do_it(object):
    def __init__(self):
        self.download="./pdf/"
        # 保存目录
    def create_img_pdf(self,file_name,ouput_pdf):
        page = Image.new('RGB', (2480, 3508), 'white')
        image=Image.open(file_name)
        i_w,i_h=image.size
        if i_w>i_h:
            i_n_w=2000
            i_n_h=int(i_h*2000/i_w)
        else:
            i_n_h=3000
            i_n_w=int(i_w*3000/i_h)
        n_img=image.resize((i_n_w,i_n_h))
        page.paste(n_img,(100,100))
        page.save(ouput_pdf,"PDF", resolution=100.0)
    def topdf(self,nfile):
        #保存在当前的pdf文件夹
        # nfile必须独一无二
        com="libreoffice --convert-to pdf:writer_pdf_Export "+nfile+" --outdir "+self.download
        os.system(com)
        name=nfile[nfile.rfind('/')+1:nfile.rfind('.')]+".pdf"
        newa=self.download+name
        return newa
    def combine(self,file_list,out_file):
        file_info=""
        for i in file_list:
            file_info=file_info+" "+i
        com="pdftk "+file_info+" cat output "+out_file
        os.system(com)

合并PDF

def combine(file_list,out_file):
    file_info=""
    for i in file_list:
        file_info=file_info+" "+i
    com="pdftk "+file_info+" cat output "+out_file
    os.system(com)