Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
8299481e
提交
8299481e
authored
3月 09, 2020
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
object detection: revise
上级
5de56735
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
145 行增加
和
0 行删除
+145
-0
database.py
opencv-motion-detect/dingbot/database.py
+18
-0
models.py
opencv-motion-detect/dingbot/models.py
+16
-0
notify.py
opencv-motion-detect/dingbot/notify.py
+69
-0
object-detect.service
opencv-yolo/deployment/object-detect.service
+20
-0
start-local.sh
opencv-yolo/deployment/start-local.sh
+22
-0
没有找到文件。
opencv-motion-detect/dingbot/database.py
0 → 100644
浏览文件 @
8299481e
from
sqlalchemy
import
create_engine
from
sqlalchemy.orm
import
scoped_session
,
sessionmaker
from
sqlalchemy.ext.declarative
import
declarative_base
engine
=
create_engine
(
'sqlite:///dingbot.db'
,
convert_unicode
=
True
)
db_session
=
scoped_session
(
sessionmaker
(
autocommit
=
False
,
autoflush
=
False
,
bind
=
engine
))
Base
=
declarative_base
()
Base
.
query
=
db_session
.
query_property
()
def
init_db
():
# import all modules here that might define models so that
# they will be registered properly on the metadata. Otherwise
# you will have to import them first before calling init_db()
import
models
Base
.
metadata
.
create_all
(
bind
=
engine
)
\ No newline at end of file
opencv-motion-detect/dingbot/models.py
0 → 100644
浏览文件 @
8299481e
from
sqlalchemy
import
Column
,
Integer
,
String
,
Boolean
,
DateTime
from
database
import
Base
import
datetime
class
Terminal
(
Base
):
__tablename__
=
'terminals'
sn
=
Column
(
String
(
20
),
primary_key
=
True
,
unique
=
True
)
active
=
Column
(
Boolean
,
default
=
True
)
time
=
Column
(
DateTime
,
default
=
datetime
.
datetime
.
utcnow
)
def
__init__
(
self
,
sn
):
self
.
sn
=
sn
def
__repr__
(
self
):
return
'<terminal
%
r>'
%
(
self
.
sn
)
\ No newline at end of file
opencv-motion-detect/dingbot/notify.py
0 → 100644
浏览文件 @
8299481e
from
flask
import
Flask
,
escape
,
request
,
jsonify
,
g
,
url_for
,
current_app
import
time
import
hmac
import
hashlib
import
base64
import
urllib.parse
import
requests
import
os
,
json
from
database
import
db_session
from
models
import
Terminal
SECRET
=
os
.
getenv
(
'SECRET'
,
'SEC3219d0b06510f560349170c4d571b8fd10a5dfa616d4f9ef5494f63add766d65'
)
# SECf8938911f24df40a0b86b711179fa7fc8ba88eb5d82e4e9f07bc03b5f29e8f6a
TOKEN
=
os
.
getenv
(
"TOKEN"
,
'3bb560ac5a3ee5943aeeb21c452162a3f23c44d675b42935c56f6685aceb4153'
)
#'3d72d0b376f8061b9cae44c1d1048221bc19e245a631ef31fa195f89fca9215d')
API_ADDR
=
os
.
getenv
(
'API'
,
'https://oapi.dingtalk.com/robot/send'
)
API_TPL
=
API_ADDR
+
"?access_token={}×tamp={}&sign={}"
app
=
Flask
(
__name__
,
static_url_path
=
''
,
static_folder
=
None
)
class
DingBot
:
secret
=
None
token
=
None
def
__init__
(
self
,
token
,
secret
):
self
.
secret
=
secret
self
.
token
=
token
def
sign
(
self
):
timestamp
=
round
(
time
.
time
()
*
1000
)
secret_enc
=
bytes
(
self
.
secret
,
encoding
=
'utf-8'
)
string_to_sign
=
'{}
\n
{}'
.
format
(
timestamp
,
self
.
secret
)
string_to_sign_enc
=
bytes
(
string_to_sign
,
encoding
=
'utf-8'
)
hmac_code
=
hmac
.
new
(
secret_enc
,
string_to_sign_enc
,
digestmod
=
hashlib
.
sha256
)
.
digest
()
return
timestamp
,
urllib
.
parse
.
quote_plus
(
base64
.
b64encode
(
hmac_code
))
def
send_msg
(
self
,
title
,
text
):
ts
,
sign
=
self
.
sign
()
url
=
API_TPL
.
format
(
self
.
token
,
ts
,
sign
)
body
=
{
'msgtype'
:
'markdown'
,
'markdown'
:{
'title'
:
title
,
'text'
:
text
}}
r
=
requests
.
post
(
url
,
json
=
body
)
print
(
r
.
status_code
,
r
.
text
)
def
destroy
(
self
):
pass
@app.teardown_appcontext
def
shutdown_session
(
exception
=
None
):
db_session
.
remove
()
DINGBOT
=
DingBot
(
TOKEN
,
SECRET
)
@app.route
(
'/'
)
def
index
():
name
=
request
.
args
.
get
(
"name"
,
"World"
)
# DINGBOT.send_msg('test', 'this is a test')
term
=
Terminal
.
query
.
filter
(
Terminal
.
sn
==
'SNaaaaaa'
)
.
first
()
ret
=
'ok'
if
term
:
ret
=
term
.
sn
print
(
term
)
return
ret
@app.route
(
'/addterminal'
,
methods
=
[
'POST'
])
def
add_terminal
():
pass
if
__name__
==
'__main__'
:
app
.
run
(
host
=
'0.0.0.0'
,
port
=
'5000'
)
opencv-yolo/deployment/object-detect.service
0 → 100644
浏览文件 @
8299481e
[Unit]
Description=object detection program
After=network.target network-online.target
[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/opt/data/repos/evsuits/opencv-yolo/web
ExecStart=/bin/bash start-local.sh start
ExecStopPost=/bin/bash start-local.sh stop
RestartSec=3
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=od
[Install]
WantedBy=multi-user.target
\ No newline at end of file
opencv-yolo/deployment/start-local.sh
0 → 100755
浏览文件 @
8299481e
#!/bin/bash
export
API_HOST
=
http://40.73.45.56:9009
export
RABBITMQ_URI
=
amqp://ilabservice:iLabServiceOps123456@40.73.43.214:5672
export
MQTT_HOST
=
evcloudsvc.ilabservice.cloud
export
MQTT_PORT
=
11883
export
MQTT_USER
=
admin
export
MQTT_PASSWORD
=
vJ3zHqWrHbrqxVMT
export
CFG_DIR
=
edet_model.pth
export
BIN_PRE
=
/opt/apps/anaconda3/bin/python
export
BIN_DIR
=
/opt/data/repos/evsuits/opencv-yolo/web
export
BIN_NAME
=
detect_video.py
if
[
"
$1
"
==
"start"
]
then
cd
/opt/data/repos/evsuits/opencv-yolo/web
;
/opt/apps/anaconda3/bin/celery multi start 4
-E
-A
web.worker
-l
info
-n
%n.%h
--autoscale
=
4,1
--pidfile
=
%n.pid
/opt/apps/anaconda3/bin/flower
-A
web.worker
--loglevel
=
info &disown
/opt/apps/anaconda3/bin/python web.py
else
/opt/apps/anaconda3/bin/celery multi stop 4
pkill
-9
flower
fi
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论