Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
physical
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
physical
Commits
8a12c69a
Commit
8a12c69a
authored
Sep 11, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
c12aab8c
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
287 additions
and
101 deletions
+287
-101
trans2es_mapping2es.py
trans2es/management/commands/trans2es_mapping2es.py
+27
-13
answer_reply1.py
vest/reply_answer/answer_reply1.py
+54
-39
answer_reply2.py
vest/reply_answer/answer_reply2.py
+10
-23
answer_reply3.py
vest/reply_answer/answer_reply3.py
+14
-26
answer_reply5.py
vest/reply_answer/answer_reply5.py
+58
-0
answer_reply7.py
vest/reply_answer/answer_reply7.py
+58
-0
reply_comment1.py
vest/reply_answer/reply_comment1.py
+22
-0
reply_comment5.py
vest/reply_answer/reply_comment5.py
+22
-0
reply_comment7.py
vest/reply_answer/reply_comment7.py
+22
-0
No files found.
trans2es/management/commands/trans2es_mapping2es.py
View file @
8a12c69a
...
@@ -13,7 +13,9 @@ from vest.click import true_click_five, true_click_two, true_click_four, true_cl
...
@@ -13,7 +13,9 @@ from vest.click import true_click_five, true_click_two, true_click_four, true_cl
from
vest.follow
import
auto_follow
,
auto_follow_new
from
vest.follow
import
auto_follow
,
auto_follow_new
from
vest.urge
import
auto_star_urge
,
auto_lunch_app
,
auto_lunch_app2
,
auto_urge1
,
auto_urge2
from
vest.urge
import
auto_star_urge
,
auto_lunch_app
,
auto_lunch_app2
,
auto_urge1
,
auto_urge2
from
vest.fix
import
fix_no_comment_click
from
vest.fix
import
fix_no_comment_click
from
vest.reply_answer
import
reply_comment2
,
reply_comment3
,
answer_reply2
,
answer_reply3
,
answer_reply1
from
vest.reply_answer
import
reply_comment2
,
reply_comment3
,
answer_reply2
,
answer_reply3
,
answer_reply1
,
\
answer_reply5
,
answer_reply7
from
vest.request
import
get_session
,
auto_user_id
from
vest.request
import
get_session
,
auto_user_id
from
vest.vest_majiauser
import
vest_click_reply
from
vest.vest_majiauser
import
vest_click_reply
from
vest.pictorial
import
principal_offline_comment1
,
principal_online_comment1
,
no_reply_principal
from
vest.pictorial
import
principal_offline_comment1
,
principal_online_comment1
,
no_reply_principal
...
@@ -117,18 +119,6 @@ class Command(BaseCommand):
...
@@ -117,18 +119,6 @@ class Command(BaseCommand):
if
options
[
"mvest"
]
==
"fix_no_comment_click"
:
if
options
[
"mvest"
]
==
"fix_no_comment_click"
:
fix_no_comment_click
.
fix_no_comment_click
()
fix_no_comment_click
.
fix_no_comment_click
()
# 二级评论
if
options
[
"mvest"
]
==
"answer_reply1"
:
answer_reply1
.
answer_reply1
()
if
options
[
"mvest"
]
==
"answer_reply2"
:
answer_reply2
.
answer_reply2
()
if
options
[
"mvest"
]
==
"answer_reply3"
:
answer_reply3
.
answer_reply3
()
if
options
[
"mvest"
]
==
"reply_comment2"
:
reply_comment2
.
reply_comment2
()
if
options
[
"mvest"
]
==
"reply_comment3"
:
reply_comment3
.
reply_comment3
()
# 获得session和use_id
# 获得session和use_id
if
options
[
"mvest"
]
==
"get_login_session"
:
if
options
[
"mvest"
]
==
"get_login_session"
:
get_session
.
get_session
()
get_session
.
get_session
()
...
@@ -164,6 +154,30 @@ class Command(BaseCommand):
...
@@ -164,6 +154,30 @@ class Command(BaseCommand):
if
options
[
"mvest"
]
==
"seven_days_ago_reply"
:
if
options
[
"mvest"
]
==
"seven_days_ago_reply"
:
seven_days_ago_reply
.
serven_days_ago_comment_one
()
seven_days_ago_reply
.
serven_days_ago_comment_one
()
# 修改的二级评论
# 二级评论
if
options
[
"mvest"
]
==
"answer_reply1"
:
answer_reply1
.
answer_reply1
()
if
options
[
"mvest"
]
==
"answer_reply2"
:
answer_reply2
.
answer_reply2
()
if
options
[
"mvest"
]
==
"answer_reply3"
:
answer_reply3
.
answer_reply3
()
if
options
[
"mvest"
]
==
"answer_reply5"
:
answer_reply5
.
answer_reply5
()
if
options
[
"mvest"
]
==
"answer_reply7"
:
answer_reply7
.
answer_reply7
()
if
options
[
"mvest"
]
==
"reply_comment1"
:
reply_comment3
.
reply_comment1
()
if
options
[
"mvest"
]
==
"reply_comment2"
:
reply_comment2
.
reply_comment2
()
if
options
[
"mvest"
]
==
"reply_comment3"
:
reply_comment3
.
reply_comment3
()
if
options
[
"mvest"
]
==
"reply_comment5"
:
reply_comment2
.
reply_comment5
()
if
options
[
"mvest"
]
==
"reply_comment7"
:
reply_comment3
.
reply_comment7
()
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
vest/reply_answer/answer_reply1.py
View file @
8a12c69a
...
@@ -2,9 +2,9 @@ import pymysql
...
@@ -2,9 +2,9 @@ import pymysql
import
traceback
import
traceback
import
logging
import
logging
import
json
import
json
import
random
from
vest.request.auto_request
import
time_conv_minute
,
get_answer_data
,
reply_answer
,
set_reply_to_redis
,
\
from
vest.request.auto_request
import
time_conv_minute
,
get_answer_data
,
reply_answer
,
set_reply_to_redis
,
\
reply2
,
logins
,
\
reply2
,
logins
,
time_convs
,
get_majia
,
get_majia_reply
get_majia
,
get_majia_reply
from
vest.request.auto_request
import
host
,
user
,
db
,
passwd
from
vest.request.auto_request
import
host
,
user
,
db
,
passwd
from
libs.error
import
logging_exception
from
libs.error
import
logging_exception
...
@@ -15,47 +15,72 @@ def get_data(numtime, numtime2):
...
@@ -15,47 +15,72 @@ def get_data(numtime, numtime2):
cursor
=
pc
.
cursor
()
cursor
=
pc
.
cursor
()
cursor
.
execute
(
cursor
.
execute
(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time > '
%
s' and create_time < '
%
s' )"
%
(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time > '
%
s' and create_time < '
%
s' )"
%
(
numtime
,
numtime2
))
numtime
2
,
numtime
))
data
=
cursor
.
fetchall
()
data
=
cursor
.
fetchall
()
topic_id
=
list
(
data
)
topic_id_list
=
list
(
data
)
topic_id_list
=
[]
try
:
for
i
in
topic_id
and
topic_id
:
cursor
.
execute
(
"select user_id,is_shadow from user_extra where user_id ="
+
str
(
i
[
0
])
+
" and is_online =1 and is_deleted =0"
)
data
=
cursor
.
fetchall
()
user_id
=
list
(
data
)
if
(
user_id
and
user_id
[
0
][
1
]
==
0
)
or
len
(
user_id
)
==
0
:
topic_id_list
.
append
(
i
)
logging
.
info
(
"Database version :
%
s "
%
topic_id_list
)
pc
.
close
()
except
:
logging
.
error
(
"catch exception,get_data:
%
s"
%
traceback
.
format_exc
())
return
topic_id_list
return
topic_id_list
except
:
except
:
logging
.
error
(
"catch exception,get_data:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,get_data:
%
s"
%
traceback
.
format_exc
())
return
[]
return
[]
#
# def answer_reply1():
# try:
# logging.info("answer_reply_one")
# numtime1, numtime2, minute = time_conv_minute(5, 0)
# user_id = get_data(numtime1, numtime2)
# redis_key1 = "cybertron:set_reply_id:one"
# reply_data_comment = []
# if user_id:
# for i in user_id:
# majia_user_id = get_majia()
# logging.info("get majia_user-id:%s" % majia_user_id)
# cook = logins(majia_user_id)
# comment1, comment2 = get_answer_data()
# if cook is not None:
# response = reply_answer(cook, i[1], comment1)
# if len(response) > 1:
# data_dict = json.loads(response)
# reply_id = data_dict["data"]["id"]
# reply_user_id = data_dict["data"]["user"]["id"]
# topic_id = i[1]
# reply_data_comment.append(
# {"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": topic_id,
# "majia_user_id": majia_user_id})
#
# redis_client = set_reply_to_redis()
# redis_client.hset(redis_key1, str(minute), json.dumps(reply_data_comment))
# logging.info("get eeeeeeee:%s" % str(minute - 5))
# have_reply1 = redis_client.hget(redis_key1, str(minute - 5))
# logging.info("get have_reply1:%s" % have_reply1)
# if have_reply1:
# result = json.loads(str(have_reply1, encoding="utf-8"))
# redis_client.hdel(redis_key1, str(minute - 5))
# if result:
# for item in result:
# majia_user_id = get_majia_reply(item["majia_user_id"])
# cook = logins(majia_user_id)
# reply2(cook, item["topic_id"], item["answer"], item["id"])
#
# except:
# logging_exception()
# logging.error("catch exception,main:%s" % traceback.format_exc())
def
answer_reply1
():
def
answer_reply1
():
try
:
try
:
logging
.
info
(
"answer_reply_one"
)
logging
.
info
(
"answer_reply_one"
)
numtime1
,
numtime2
,
minute
=
time_conv
_minute
(
5
,
0
)
numtime1
,
numtime2
,
minute
=
time_conv
s
(
1
,
1
)
user_id
=
get_data
(
numtime1
,
numtime2
)
user_id
=
get_data
(
numtime1
,
numtime2
)
redis_key1
=
"cybertron:set_reply_id:one"
redis_key1
=
"cybertron:set_reply_id:one"
reply_data_comment
=
[]
reply_data_comment
=
[]
if
user_id
:
if
user_id
:
for
i
in
user_id
:
for
i
in
user_id
:
majia_user_id
=
get_majia
()
random_num
=
random
.
randint
(
0
,
2
)
logging
.
info
(
"get majia_user-id:
%
s"
%
majia_user_id
)
logging
.
info
(
"get random_num:
%
s"
%
random_num
)
for
num
in
range
(
random_num
):
majia_user_id
=
get_majia_reply
(
i
[
0
])
cook
=
logins
(
majia_user_id
)
cook
=
logins
(
majia_user_id
)
comment1
,
comment2
=
get_answer_data
()
comment1
,
comment2
=
get_answer_data
()
logging
.
info
(
"get comment1:
%
s"
%
comment1
)
logging
.
info
(
"get comment2:
%
s"
%
comment2
)
if
cook
is
not
None
:
if
cook
is
not
None
:
response
=
reply_answer
(
cook
,
i
[
1
],
comment1
)
response
=
reply_answer
(
cook
,
i
[
1
],
comment1
)
if
len
(
response
)
>
1
:
if
len
(
response
)
>
1
:
...
@@ -64,22 +89,12 @@ def answer_reply1():
...
@@ -64,22 +89,12 @@ def answer_reply1():
reply_user_id
=
data_dict
[
"data"
][
"user"
][
"id"
]
reply_user_id
=
data_dict
[
"data"
][
"user"
][
"id"
]
topic_id
=
i
[
1
]
topic_id
=
i
[
1
]
reply_data_comment
.
append
(
reply_data_comment
.
append
(
{
"id"
:
reply_id
,
"reply_user_id"
:
reply_user_id
,
"answer"
:
comment2
,
"topic_id"
:
topic_id
,
{
"id"
:
reply_id
,
"reply_user_id"
:
reply_user_id
,
"answer"
:
comment2
,
"topic_id"
:
topic_id
,
"majia_user_id"
:
majia_user_id
})
"majia_user_id"
:
majia_user_id
})
redis_client
=
set_reply_to_redis
()
redis_client
=
set_reply_to_redis
()
redis_client
.
hset
(
redis_key1
,
str
(
minute
),
json
.
dumps
(
reply_data_comment
))
redis_client
.
set
(
redis_key1
,
json
.
dumps
(
reply_data_comment
))
logging
.
info
(
"get eeeeeeee:
%
s"
%
str
(
minute
-
5
))
have_reply1
=
redis_client
.
hget
(
redis_key1
,
str
(
minute
-
5
))
logging
.
info
(
"get have_reply1:
%
s"
%
have_reply1
)
if
have_reply1
:
result
=
json
.
loads
(
str
(
have_reply1
,
encoding
=
"utf-8"
))
redis_client
.
hdel
(
redis_key1
,
str
(
minute
-
5
))
if
result
:
for
item
in
result
:
majia_user_id
=
get_majia_reply
(
item
[
"majia_user_id"
])
cook
=
logins
(
majia_user_id
)
reply2
(
cook
,
item
[
"topic_id"
],
item
[
"answer"
],
item
[
"id"
])
except
:
except
:
logging_exception
()
logging_exception
()
...
...
vest/reply_answer/answer_reply2.py
View file @
8a12c69a
...
@@ -2,10 +2,11 @@ import pymysql
...
@@ -2,10 +2,11 @@ import pymysql
import
traceback
import
traceback
import
logging
import
logging
import
json
import
json
from
vest.request.auto_request
import
logins
,
time_conv
,
get_answer_data
,
reply_answer
,
get_majia
,
\
from
vest.request.auto_request
import
logins
,
time_conv
s
,
get_answer_data
,
reply_answer
,
get_majia
,
\
set_reply_to_redis
set_reply_to_redis
from
vest.request.auto_request
import
host
,
user
,
db
,
passwd
from
vest.request.auto_request
import
host
,
user
,
db
,
passwd
from
libs.error
import
logging_exception
from
libs.error
import
logging_exception
import
random
def
get_data
(
numtime
,
numtime2
):
def
get_data
(
numtime
,
numtime2
):
...
@@ -13,27 +14,10 @@ def get_data(numtime, numtime2):
...
@@ -13,27 +14,10 @@ def get_data(numtime, numtime2):
pc
=
pymysql
.
connect
(
host
=
host
,
user
=
user
,
passwd
=
passwd
,
db
=
db
,
port
=
3306
)
pc
=
pymysql
.
connect
(
host
=
host
,
user
=
user
,
passwd
=
passwd
,
db
=
db
,
port
=
3306
)
cursor
=
pc
.
cursor
()
cursor
=
pc
.
cursor
()
cursor
.
execute
(
cursor
.
execute
(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time >
'
%
s' and create_time <
'
%
s' )"
%
(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time >
= '
%
s' and create_time <=
'
%
s' )"
%
(
numtime
,
numtime2
))
numtime
2
,
numtime
))
data
=
cursor
.
fetchall
()
data
=
cursor
.
fetchall
()
topic_id
=
list
(
data
)
topic_id_list
=
list
(
data
)
topic_id_list
=
[]
try
:
for
i
in
topic_id
and
topic_id
:
cursor
.
execute
(
"select user_id,is_shadow from user_extra where user_id ="
+
str
(
i
[
0
])
+
" and is_online =1 and is_deleted =0"
)
data
=
cursor
.
fetchall
()
user_id
=
list
(
data
)
print
(
user_id
)
if
(
user_id
and
user_id
[
0
][
1
]
==
0
)
or
len
(
user_id
)
==
0
:
topic_id_list
.
append
(
i
)
logging
.
info
(
"Database version :
%
s "
%
topic_id_list
)
pc
.
close
()
except
:
logging
.
error
(
"catch exception,get_data:
%
s"
%
traceback
.
format_exc
())
return
topic_id_list
return
topic_id_list
except
:
except
:
...
@@ -43,13 +27,16 @@ def get_data(numtime, numtime2):
...
@@ -43,13 +27,16 @@ def get_data(numtime, numtime2):
def
answer_reply2
():
def
answer_reply2
():
try
:
try
:
logging
.
info
(
"comment answer
one
"
)
logging
.
info
(
"comment answer
two
"
)
numtime1
,
numtime2
=
time_conv
(
27
,
17
)
numtime1
,
numtime2
=
time_conv
s
(
2
,
2
)
user_id
=
get_data
(
numtime1
,
numtime2
)
user_id
=
get_data
(
numtime1
,
numtime2
)
redis_key
=
"cybertron:set_reply_id:two"
redis_key
=
"cybertron:set_reply_id:two"
reply_data_comment
=
[]
reply_data_comment
=
[]
if
user_id
:
if
user_id
:
for
i
in
user_id
:
for
i
in
user_id
:
random_num
=
random
.
randint
(
0
,
2
)
logging
.
info
(
"get random_num:
%
s"
%
random_num
)
for
num
in
range
(
random_num
):
majia_user_id
=
get_majia
()
majia_user_id
=
get_majia
()
cook
=
logins
(
majia_user_id
)
cook
=
logins
(
majia_user_id
)
comment1
,
comment2
=
get_answer_data
()
comment1
,
comment2
=
get_answer_data
()
...
...
vest/reply_answer/answer_reply3.py
View file @
8a12c69a
...
@@ -2,9 +2,11 @@ import pymysql
...
@@ -2,9 +2,11 @@ import pymysql
import
traceback
import
traceback
import
logging
import
logging
import
json
import
json
from
vest.request.auto_request
import
logins
,
time_conv
,
get_answer_data
,
reply_answer
,
set_reply_to_redis
,
get_majia
from
vest.request.auto_request
import
logins
,
time_convs
,
get_answer_data
,
reply_answer
,
get_majia
,
\
set_reply_to_redis
from
vest.request.auto_request
import
host
,
user
,
db
,
passwd
from
vest.request.auto_request
import
host
,
user
,
db
,
passwd
from
libs.error
import
logging_exception
from
libs.error
import
logging_exception
import
random
def
get_data
(
numtime
,
numtime2
):
def
get_data
(
numtime
,
numtime2
):
...
@@ -12,27 +14,10 @@ def get_data(numtime, numtime2):
...
@@ -12,27 +14,10 @@ def get_data(numtime, numtime2):
pc
=
pymysql
.
connect
(
host
=
host
,
user
=
user
,
passwd
=
passwd
,
db
=
db
,
port
=
3306
)
pc
=
pymysql
.
connect
(
host
=
host
,
user
=
user
,
passwd
=
passwd
,
db
=
db
,
port
=
3306
)
cursor
=
pc
.
cursor
()
cursor
=
pc
.
cursor
()
cursor
.
execute
(
cursor
.
execute
(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time >
'
%
s' and create_time <
'
%
s' )"
%
(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time >
= '
%
s' and create_time <=
'
%
s' )"
%
(
numtime
,
numtime2
))
numtime
2
,
numtime
))
data
=
cursor
.
fetchall
()
data
=
cursor
.
fetchall
()
topic_id
=
list
(
data
)
topic_id_list
=
list
(
data
)
topic_id_list
=
[]
try
:
for
i
in
topic_id
and
topic_id
:
cursor
.
execute
(
"select user_id,is_shadow from user_extra where user_id ="
+
str
(
i
[
0
])
+
" and is_online =1 and is_deleted =0"
)
data
=
cursor
.
fetchall
()
user_id
=
list
(
data
)
print
(
user_id
)
if
(
user_id
and
user_id
[
0
][
1
]
==
0
)
or
len
(
user_id
)
==
0
:
topic_id_list
.
append
(
i
)
logging
.
info
(
"Database version :
%
s "
%
topic_id_list
)
pc
.
close
()
except
:
logging
.
error
(
"catch exception,get_data:
%
s"
%
traceback
.
format_exc
())
return
topic_id_list
return
topic_id_list
except
:
except
:
...
@@ -40,15 +25,18 @@ def get_data(numtime, numtime2):
...
@@ -40,15 +25,18 @@ def get_data(numtime, numtime2):
return
[]
return
[]
def
answer_reply
3
():
def
answer_reply
2
():
try
:
try
:
logging
.
info
(
"comment answer
on
e"
)
logging
.
info
(
"comment answer
thre
e"
)
numtime1
,
numtime2
=
time_conv
(
45
,
35
)
numtime1
,
numtime2
=
time_conv
s
(
3
,
3
)
user_id
=
get_data
(
numtime1
,
numtime2
)
user_id
=
get_data
(
numtime1
,
numtime2
)
redis_key
1
=
"cybertron:set_reply_id:three"
redis_key
=
"cybertron:set_reply_id:three"
reply_data_comment
=
[]
reply_data_comment
=
[]
if
user_id
:
if
user_id
:
for
i
in
user_id
:
for
i
in
user_id
:
random_num
=
random
.
randint
(
0
,
2
)
logging
.
info
(
"get random_num:
%
s"
%
random_num
)
for
num
in
range
(
random_num
):
majia_user_id
=
get_majia
()
majia_user_id
=
get_majia
()
cook
=
logins
(
majia_user_id
)
cook
=
logins
(
majia_user_id
)
comment1
,
comment2
=
get_answer_data
()
comment1
,
comment2
=
get_answer_data
()
...
@@ -63,7 +51,7 @@ def answer_reply3():
...
@@ -63,7 +51,7 @@ def answer_reply3():
"majia_user_id"
:
majia_user_id
})
"majia_user_id"
:
majia_user_id
})
redis_client
=
set_reply_to_redis
()
redis_client
=
set_reply_to_redis
()
redis_client
.
set
(
redis_key
1
,
json
.
dumps
(
reply_data_comment
))
redis_client
.
set
(
redis_key
,
json
.
dumps
(
reply_data_comment
))
except
:
except
:
logging_exception
()
logging_exception
()
...
...
vest/reply_answer/answer_reply5.py
0 → 100644
View file @
8a12c69a
import
pymysql
import
traceback
import
logging
import
json
from
vest.request.auto_request
import
logins
,
time_convs
,
get_answer_data
,
reply_answer
,
get_majia
,
\
set_reply_to_redis
from
vest.request.auto_request
import
host
,
user
,
db
,
passwd
from
libs.error
import
logging_exception
import
random
def
get_data
(
numtime
,
numtime2
):
try
:
pc
=
pymysql
.
connect
(
host
=
host
,
user
=
user
,
passwd
=
passwd
,
db
=
db
,
port
=
3306
)
cursor
=
pc
.
cursor
()
cursor
.
execute
(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time >= '
%
s' and create_time <= '
%
s' )"
%
(
numtime2
,
numtime
))
data
=
cursor
.
fetchall
()
topic_id_list
=
list
(
data
)
return
topic_id_list
except
:
logging
.
error
(
"catch exception,get_data:
%
s"
%
traceback
.
format_exc
())
return
[]
def
answer_reply2
():
try
:
logging
.
info
(
"comment answer five"
)
numtime1
,
numtime2
=
time_convs
(
5
,
5
)
user_id
=
get_data
(
numtime1
,
numtime2
)
redis_key
=
"cybertron:set_reply_id:five"
reply_data_comment
=
[]
if
user_id
:
for
i
in
user_id
:
random_num
=
random
.
randint
(
0
,
2
)
logging
.
info
(
"get random_num:
%
s"
%
random_num
)
for
num
in
range
(
random_num
):
majia_user_id
=
get_majia
()
cook
=
logins
(
majia_user_id
)
comment1
,
comment2
=
get_answer_data
()
if
cook
is
not
None
:
response
=
reply_answer
(
cook
,
i
[
1
],
comment1
)
if
len
(
response
)
>
1
:
data_dict
=
json
.
loads
(
response
)
reply_id
=
data_dict
[
"data"
][
"id"
]
reply_user_id
=
data_dict
[
"data"
][
"user"
][
"id"
]
reply_data_comment
.
append
(
{
"id"
:
reply_id
,
"reply_user_id"
:
reply_user_id
,
"answer"
:
comment2
,
"topic_id"
:
i
[
1
],
"majia_user_id"
:
majia_user_id
})
redis_client
=
set_reply_to_redis
()
redis_client
.
set
(
redis_key
,
json
.
dumps
(
reply_data_comment
))
except
:
logging_exception
()
logging
.
error
(
"catch exception,main:
%
s"
%
traceback
.
format_exc
())
vest/reply_answer/answer_reply7.py
0 → 100644
View file @
8a12c69a
import
pymysql
import
traceback
import
logging
import
json
from
vest.request.auto_request
import
logins
,
time_convs
,
get_answer_data
,
reply_answer
,
get_majia
,
\
set_reply_to_redis
from
vest.request.auto_request
import
host
,
user
,
db
,
passwd
from
libs.error
import
logging_exception
import
random
def
get_data
(
numtime
,
numtime2
):
try
:
pc
=
pymysql
.
connect
(
host
=
host
,
user
=
user
,
passwd
=
passwd
,
db
=
db
,
port
=
3306
)
cursor
=
pc
.
cursor
()
cursor
.
execute
(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time >= '
%
s' and create_time <= '
%
s' )"
%
(
numtime2
,
numtime
))
data
=
cursor
.
fetchall
()
topic_id_list
=
list
(
data
)
return
topic_id_list
except
:
logging
.
error
(
"catch exception,get_data:
%
s"
%
traceback
.
format_exc
())
return
[]
def
answer_reply2
():
try
:
logging
.
info
(
"comment answer seven"
)
numtime1
,
numtime2
=
time_convs
(
7
,
7
)
user_id
=
get_data
(
numtime1
,
numtime2
)
redis_key
=
"cybertron:set_reply_id:seven"
reply_data_comment
=
[]
if
user_id
:
for
i
in
user_id
:
random_num
=
random
.
randint
(
0
,
2
)
logging
.
info
(
"get random_num:
%
s"
%
random_num
)
for
num
in
range
(
random_num
):
majia_user_id
=
get_majia
()
cook
=
logins
(
majia_user_id
)
comment1
,
comment2
=
get_answer_data
()
if
cook
is
not
None
:
response
=
reply_answer
(
cook
,
i
[
1
],
comment1
)
if
len
(
response
)
>
1
:
data_dict
=
json
.
loads
(
response
)
reply_id
=
data_dict
[
"data"
][
"id"
]
reply_user_id
=
data_dict
[
"data"
][
"user"
][
"id"
]
reply_data_comment
.
append
(
{
"id"
:
reply_id
,
"reply_user_id"
:
reply_user_id
,
"answer"
:
comment2
,
"topic_id"
:
i
[
1
],
"majia_user_id"
:
majia_user_id
})
redis_client
=
set_reply_to_redis
()
redis_client
.
set
(
redis_key
,
json
.
dumps
(
reply_data_comment
))
except
:
logging_exception
()
logging
.
error
(
"catch exception,main:
%
s"
%
traceback
.
format_exc
())
vest/reply_answer/reply_comment1.py
0 → 100644
View file @
8a12c69a
import
traceback
import
logging
import
json
from
vest.request.auto_request
import
set_reply_to_redis
,
reply2
,
logins
,
get_majia_reply
from
libs.error
import
logging_exception
def
reply_comment1
():
try
:
redis_key1
=
"cybertron:set_reply_id:one"
redis_client
=
set_reply_to_redis
()
have_reply1
=
redis_client
.
get
(
redis_key1
)
result
=
json
.
loads
(
str
(
have_reply1
,
encoding
=
"utf-8"
))
if
result
:
for
item
in
result
:
majia_user_id
=
get_majia_reply
(
item
[
"majia_user_id"
])
cook
=
logins
(
majia_user_id
)
reply2
(
cook
,
item
[
"topic_id"
],
item
[
"answer"
],
item
[
"id"
])
redis_client
.
delete
(
redis_key1
)
except
:
logging_exception
()
logging
.
error
(
"catch exception,main:
%
s"
%
traceback
.
format_exc
())
vest/reply_answer/reply_comment5.py
0 → 100644
View file @
8a12c69a
import
traceback
import
logging
import
json
from
vest.request.auto_request
import
set_reply_to_redis
,
reply2
,
logins
,
get_majia_reply
from
libs.error
import
logging_exception
def
reply_comment1
():
try
:
redis_key1
=
"cybertron:set_reply_id:five"
redis_client
=
set_reply_to_redis
()
have_reply1
=
redis_client
.
get
(
redis_key1
)
result
=
json
.
loads
(
str
(
have_reply1
,
encoding
=
"utf-8"
))
if
result
:
for
item
in
result
:
majia_user_id
=
get_majia_reply
(
item
[
"majia_user_id"
])
cook
=
logins
(
majia_user_id
)
reply2
(
cook
,
item
[
"topic_id"
],
item
[
"answer"
],
item
[
"id"
])
redis_client
.
delete
(
redis_key1
)
except
:
logging_exception
()
logging
.
error
(
"catch exception,main:
%
s"
%
traceback
.
format_exc
())
vest/reply_answer/reply_comment7.py
0 → 100644
View file @
8a12c69a
import
traceback
import
logging
import
json
from
vest.request.auto_request
import
set_reply_to_redis
,
reply2
,
logins
,
get_majia_reply
from
libs.error
import
logging_exception
def
reply_comment1
():
try
:
redis_key1
=
"cybertron:set_reply_id:seven"
redis_client
=
set_reply_to_redis
()
have_reply1
=
redis_client
.
get
(
redis_key1
)
result
=
json
.
loads
(
str
(
have_reply1
,
encoding
=
"utf-8"
))
if
result
:
for
item
in
result
:
majia_user_id
=
get_majia_reply
(
item
[
"majia_user_id"
])
cook
=
logins
(
majia_user_id
)
reply2
(
cook
,
item
[
"topic_id"
],
item
[
"answer"
],
item
[
"id"
])
redis_client
.
delete
(
redis_key1
)
except
:
logging_exception
()
logging
.
error
(
"catch exception,main:
%
s"
%
traceback
.
format_exc
())
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment