Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
my_flask_web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 8bb1327b
authored
Feb 28, 2024
by
周杭
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加日志打印
1 parent
8f12c536
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
kafka_consumer/ocr_consumer.py
kafka_consumer/ocr_consumer.py
View file @
8bb1327
...
@@ -38,6 +38,9 @@ else:
...
@@ -38,6 +38,9 @@ else:
from
config_dev
import
Config
from
config_dev
import
Config
log
.
info
(
vars
(
Config
))
log
.
info
(
vars
(
Config
))
log
.
info
(
"启动1"
)
# 配置 Kafka 消费者
# 配置 Kafka 消费者
consumer
=
KafkaConsumer
(
consumer
=
KafkaConsumer
(
Config
.
kafka_consumer_topic
,
Config
.
kafka_consumer_topic
,
...
@@ -45,7 +48,7 @@ consumer = KafkaConsumer(
...
@@ -45,7 +48,7 @@ consumer = KafkaConsumer(
group_id
=
Config
.
kafka_consumer_group_id
,
# 消费者组 ID
group_id
=
Config
.
kafka_consumer_group_id
,
# 消费者组 ID
auto_offset_reset
=
Config
.
kafka_consumer_auto_offset_reset
# 从最早的消息开始消费
auto_offset_reset
=
Config
.
kafka_consumer_auto_offset_reset
# 从最早的消息开始消费
)
)
log
.
info
(
"启动2"
)
# 连接database
# 连接database
conn_dev
=
pymysql
.
connect
(
conn_dev
=
pymysql
.
connect
(
host
=
Config
.
host
,
host
=
Config
.
host
,
...
@@ -58,6 +61,7 @@ conn_dev = pymysql.connect(
...
@@ -58,6 +61,7 @@ conn_dev = pymysql.connect(
# 得到一个可以执行SQL语句的光标对象
# 得到一个可以执行SQL语句的光标对象
cursor_dev
=
conn_dev
.
cursor
()
cursor_dev
=
conn_dev
.
cursor
()
log
.
info
(
"启动3"
)
# load model
# load model
# Paddleocr目前支持中英文、英文、法语、德语、韩语、日语,可以通过修改 lang参数进行切换
# Paddleocr目前支持中英文、英文、法语、德语、韩语、日语,可以通过修改 lang参数进行切换
# lang参数依次为`ch`, `en`, `french`, `german`, `korean`, `japan`
# lang参数依次为`ch`, `en`, `french`, `german`, `korean`, `japan`
...
@@ -93,7 +97,7 @@ ocr = PaddleOCR(
...
@@ -93,7 +97,7 @@ ocr = PaddleOCR(
# # 获取查询结果
# # 获取查询结果
# result = cursor_dev.fetchall()
# result = cursor_dev.fetchall()
log
.
info
(
"启动4"
)
def
generate_random_filename
():
def
generate_random_filename
():
timestamp
=
int
(
time
.
time
())
# 获取当前时间戳
timestamp
=
int
(
time
.
time
())
# 获取当前时间戳
random_number
=
random
.
randint
(
1000
,
9999
)
# 生成一个随机数
random_number
=
random
.
randint
(
1000
,
9999
)
# 生成一个随机数
...
@@ -426,6 +430,7 @@ def handle_process(jsonData):
...
@@ -426,6 +430,7 @@ def handle_process(jsonData):
log
.
info
(
"权限不足,无法删除文件"
)
log
.
info
(
"权限不足,无法删除文件"
)
def
consume_kafka
():
def
consume_kafka
():
log
.
info
(
"启动consume_kafka"
)
# 消费消息并进行逻辑处理
# 消费消息并进行逻辑处理
try
:
try
:
for
msg
in
consumer
:
for
msg
in
consumer
:
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment