Merge remote-tracking branch 'origin/master'
This commit is contained in:
+1
-1
@@ -18,4 +18,4 @@ RUN pip3 install --upgrade pip
|
|||||||
RUN pip3 install -r requirements.txt
|
RUN pip3 install -r requirements.txt
|
||||||
COPY src src
|
COPY src src
|
||||||
COPY server.py server.py
|
COPY server.py server.py
|
||||||
CMD [ "python3", "server.py", "--host=0.0.0.0"]
|
CMD [ "python3","-u", "server.py"]
|
||||||
+5
-2
@@ -7,7 +7,7 @@ dataclasses~=0.6
|
|||||||
SpeechRecognition==3.8.1
|
SpeechRecognition==3.8.1
|
||||||
pymongo==4.1.1
|
pymongo==4.1.1
|
||||||
wget==3.2.0
|
wget==3.2.0
|
||||||
#pocketsphinx==0.1.15
|
pocketsphinx==0.1.15
|
||||||
oci~=2.54.1
|
oci~=2.54.1
|
||||||
XlsxWriter~=3.0.3
|
XlsxWriter~=3.0.3
|
||||||
boto3~=1.21.13
|
boto3~=1.21.13
|
||||||
@@ -15,4 +15,7 @@ openpyxl==3.0.9
|
|||||||
google-cloud-firestore==2.4.0
|
google-cloud-firestore==2.4.0
|
||||||
PySimpleGUI==4.60.1
|
PySimpleGUI==4.60.1
|
||||||
requests~=2.27.1
|
requests~=2.27.1
|
||||||
Mako~=1.2.0
|
Mako~=1.2.0
|
||||||
|
Flask~=2.2.2
|
||||||
|
flask_httpauth~=4.7.0
|
||||||
|
APScheduler~=3.9.1
|
||||||
@@ -5,15 +5,25 @@ from flask import Flask
|
|||||||
from flask import jsonify
|
from flask import jsonify
|
||||||
from flask import request
|
from flask import request
|
||||||
from flask_cors import CORS, cross_origin
|
from flask_cors import CORS, cross_origin
|
||||||
|
from flask_httpauth import HTTPTokenAuth
|
||||||
|
|
||||||
from src.workers.SpeechToText import SpeechToText
|
from src.workers.SpeechToText import SpeechToText
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
cors = CORS(app)
|
cors = CORS(app)
|
||||||
app.config['CORS_HEADERS'] = 'Content-Type'
|
app.config['CORS_HEADERS'] = 'Content-Type'
|
||||||
|
auth = HTTPTokenAuth(scheme='Bearer')
|
||||||
|
|
||||||
|
secret_token = "97e36f7e-340e-4c02-b329-9415faee38c3"
|
||||||
|
|
||||||
|
|
||||||
|
@auth.verify_token
|
||||||
|
def verify_token(token):
|
||||||
|
return token == secret_token
|
||||||
|
|
||||||
|
|
||||||
@app.route('/', methods=['POST'])
|
@app.route('/', methods=['POST'])
|
||||||
|
@auth.login_required
|
||||||
@cross_origin()
|
@cross_origin()
|
||||||
def post():
|
def post():
|
||||||
file_name = str(uuid.uuid4()) + ".wav"
|
file_name = str(uuid.uuid4()) + ".wav"
|
||||||
@@ -21,13 +31,13 @@ def post():
|
|||||||
vid.write(request.data)
|
vid.write(request.data)
|
||||||
speech_to_text = SpeechToText()
|
speech_to_text = SpeechToText()
|
||||||
result = speech_to_text.to_text(file_name)
|
result = speech_to_text.to_text(file_name)
|
||||||
print(result)
|
app.logger.info(result)
|
||||||
try:
|
try:
|
||||||
os.remove(file_name)
|
os.remove(file_name)
|
||||||
except OSError:
|
except OSError:
|
||||||
print(OSError)
|
app.logger.info(OSError)
|
||||||
return jsonify(result)
|
return jsonify(result)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(host='0.0.0.0', port=8000, debug=True)
|
app.run(host='0.0.0.0', port=8000, debug=False)
|
||||||
|
|||||||
@@ -233,8 +233,10 @@ class MongoDbManager:
|
|||||||
|
|
||||||
def save_links_to_validate(self, link: str):
|
def save_links_to_validate(self, link: str):
|
||||||
collection_to_use = self.db[LINKS_TO_VALIDATE]
|
collection_to_use = self.db[LINKS_TO_VALIDATE]
|
||||||
|
updated_at = time.strftime("%H:%M:%S", time.localtime())
|
||||||
collection_to_use.replace_one(filter={'_id': link, }, replacement={
|
collection_to_use.replace_one(filter={'_id': link, }, replacement={
|
||||||
u'url': link
|
u'url': link,
|
||||||
|
"updated_at": updated_at
|
||||||
},
|
},
|
||||||
upsert=True)
|
upsert=True)
|
||||||
|
|
||||||
|
|||||||
@@ -70,23 +70,6 @@ class InvoiceGetter():
|
|||||||
mails_messages.extend(mail_list)
|
mails_messages.extend(mail_list)
|
||||||
return mail_list
|
return mail_list
|
||||||
|
|
||||||
# def downloadAllAttachmentsInInbox(self, imap):
|
|
||||||
# typ, items = imap.search(None, '(SUBJECT "{}" SINCE "{}")'.format(INVOICE_SUBJECT_fr,
|
|
||||||
# datetime.datetime.today().strftime(
|
|
||||||
# date_format)))
|
|
||||||
# items = items[0].split()
|
|
||||||
# self.downloaAttachmentsInEmail(imap, "./")
|
|
||||||
#
|
|
||||||
# def downloaAttachmentsInEmail(self, imap, outputdir):
|
|
||||||
# resp, data = imap.fetch(HERMES_INVOICE_EMAIL, "(BODY.PEEK[])")
|
|
||||||
# email_body = data[0][1]
|
|
||||||
# mail = email.message_from_string(email_body)
|
|
||||||
# if mail.get_content_maintype() != 'multipart':
|
|
||||||
# return
|
|
||||||
# for part in mail.walk():
|
|
||||||
# if part.get_content_maintype() != 'multipart' and part.get('Content-Disposition') is not None:
|
|
||||||
# open(outputdir + '/' + part.get_filename(), 'wb').write(part.get_payload(decode=True))
|
|
||||||
|
|
||||||
def _get_messages_from_folder(self, imap, subject, folder="INBOX") -> list:
|
def _get_messages_from_folder(self, imap, subject, folder="INBOX") -> list:
|
||||||
imap.select(folder)
|
imap.select(folder)
|
||||||
mail_messages = []
|
mail_messages = []
|
||||||
@@ -141,36 +124,7 @@ class InvoiceGetter():
|
|||||||
return mail_messages
|
return mail_messages
|
||||||
|
|
||||||
|
|
||||||
def clean(text):
|
|
||||||
# clean text for creating a folder
|
|
||||||
return "".join(c if c.isalnum() else "_" for c in text)
|
|
||||||
|
|
||||||
|
|
||||||
def need_to_valid_url(url: str, successful_items) -> bool:
|
|
||||||
if len(successful_items) == 0:
|
|
||||||
return False
|
|
||||||
print("url is :" + url)
|
|
||||||
parts = url.split('/')
|
|
||||||
id = parts[5]
|
|
||||||
if len(id) == 6:
|
|
||||||
for item in successful_items:
|
|
||||||
# if item.url_validated is not None:
|
|
||||||
# print("id:{}, status:{} ".format(id, str(item.url_validated)))
|
|
||||||
if item.id == id:
|
|
||||||
if item.url_validated is not None:
|
|
||||||
return not item.url_validated
|
|
||||||
else:
|
|
||||||
# if url_validated is None
|
|
||||||
return True
|
|
||||||
# return True by default
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
print("id not valid:{}".format(id))
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def get_invoices():
|
def get_invoices():
|
||||||
# check time before start checking emails
|
|
||||||
# get email address
|
# get email address
|
||||||
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
|
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
|
||||||
mail_list_to_check = []
|
mail_list_to_check = []
|
||||||
|
|||||||
@@ -131,11 +131,6 @@ class MailReader():
|
|||||||
return mail_messages
|
return mail_messages
|
||||||
|
|
||||||
|
|
||||||
def clean(text):
|
|
||||||
# clean text for creating a folder
|
|
||||||
return "".join(c if c.isalnum() else "_" for c in text)
|
|
||||||
|
|
||||||
|
|
||||||
def need_to_valid_url(url: str, successful_items) -> bool:
|
def need_to_valid_url(url: str, successful_items) -> bool:
|
||||||
if len(successful_items) == 0:
|
if len(successful_items) == 0:
|
||||||
return False
|
return False
|
||||||
@@ -167,7 +162,7 @@ def need_to_check_email(mail: str, successful_items) -> bool:
|
|||||||
for item in successful_items:
|
for item in successful_items:
|
||||||
if mail in item.email:
|
if mail in item.email:
|
||||||
if item.url_validated is not None:
|
if item.url_validated is not None:
|
||||||
print("url_validated for {} is {}".format(item.url_validated, mail))
|
print("url_validated for {} is {}".format(mail, item.url_validated))
|
||||||
return not item.url_validated
|
return not item.url_validated
|
||||||
else:
|
else:
|
||||||
# if url-validated is none, need to check email
|
# if url-validated is none, need to check email
|
||||||
@@ -205,10 +200,10 @@ def read_mails():
|
|||||||
if match:
|
if match:
|
||||||
url = match.group(0)
|
url = match.group(0)
|
||||||
if need_to_valid_url(url, successful_items):
|
if need_to_valid_url(url, successful_items):
|
||||||
# MONGO_STORE_MANAGER.save_links_to_validate(url)
|
MONGO_STORE_MANAGER.save_links_to_validate(url)
|
||||||
url_validator = LinkValidator(url)
|
# url_validator = LinkValidator(url)
|
||||||
print("need to validate url: " + url)
|
print("need to validate url: " + url)
|
||||||
executor.submit(url_validator.start_page, params.get_proxy(ProxyType.OXYLABS), True)
|
# executor.submit(url_validator.start_page, params.get_proxy(ProxyType.OXYLABS), False)
|
||||||
else:
|
else:
|
||||||
print("do not need to click url --> {}".format(mail.mail_address))
|
print("do not need to click url --> {}".format(mail.mail_address))
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,22 @@ api_secret = "edac41f0e1726ba49808dfb12204ecd6"
|
|||||||
mailjet = Client(auth=(api_key, api_secret), version='v3.1')
|
mailjet = Client(auth=(api_key, api_secret), version='v3.1')
|
||||||
from_email = "no-reply@lpaconsulting.fr"
|
from_email = "no-reply@lpaconsulting.fr"
|
||||||
# store = "Hermès Paris Faubourg"
|
# store = "Hermès Paris Faubourg"
|
||||||
store = "Hermès Paris Sèvres"
|
store = "Hermès Paris George V"
|
||||||
# store = "Hermès Paris George V"
|
# store = "Hermès Paris Sèvres"
|
||||||
# dest_email = "0429xiaohan@gmail.com" #小萝卜
|
# dest_email = "928490803@qq.com"
|
||||||
# dest_email = "1340219934@qq.com" #小于
|
# dest_email = "1757344572@qq.com"
|
||||||
|
# dest_email = "392417782@qq.com"
|
||||||
# dest_email = "linghuili@hotmail.com"
|
# dest_email = "linghuili@hotmail.com"
|
||||||
dest_email = "landdu@outlook.com"
|
# dest_email = "fanfan19810617@icloud.com"
|
||||||
contact_name = "LI Jiaxi"
|
# dest_email = "fanchunying323@163.com"
|
||||||
|
# dest_email = "lytlaure@gmail.com"
|
||||||
|
dest_email = "arianezhangsn@yahoo.com"
|
||||||
|
# dest_email = "sunrose75015@gmail.com"
|
||||||
|
# dest_email = "1340219934@qq.com"
|
||||||
|
# dest_email = "lytlaure@gmail.com"
|
||||||
|
# dest_email = "m13805869912@163.com"
|
||||||
|
# dest_email = "tangliang0411@gmail.com"
|
||||||
|
contact_name = "LU yaping"
|
||||||
|
|
||||||
f = open(config.ROOT_DIR + "/templates/confirmed_rdv.html", "r")
|
f = open(config.ROOT_DIR + "/templates/confirmed_rdv.html", "r")
|
||||||
email_body = f.read()
|
email_body = f.read()
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class CommandorPage:
|
|||||||
self.otp_value = None
|
self.otp_value = None
|
||||||
# device = None
|
# device = None
|
||||||
device_key = random.choice(params.DEVICES)
|
device_key = random.choice(params.DEVICES)
|
||||||
device_key = random.sample(list(self.tls.playwright.devices), 1)[0]
|
# device_key = random.sample(list(self.tls.playwright.devices), 1)[0]
|
||||||
device = self.tls.playwright.devices[device_key]
|
device = self.tls.playwright.devices[device_key]
|
||||||
# while device is None:
|
# while device is None:
|
||||||
# device_key = random.sample(list(self.tls.playwright.devices), 1)[0]
|
# device_key = random.sample(list(self.tls.playwright.devices), 1)[0]
|
||||||
@@ -417,7 +417,6 @@ class CommandorPage:
|
|||||||
|
|
||||||
def handle_captcha_error(self):
|
def handle_captcha_error(self):
|
||||||
MONGO_STORE_MANAGER.insert_captcha_error_contact(self.contact)
|
MONGO_STORE_MANAGER.insert_captcha_error_contact(self.contact)
|
||||||
params.oracle_log_sender.send_captcha_error(self.contact)
|
|
||||||
|
|
||||||
def check_is_blocked(self) -> bool:
|
def check_is_blocked(self) -> bool:
|
||||||
iframe = self.page.query_selector('iframe').content_frame()
|
iframe = self.page.query_selector('iframe').content_frame()
|
||||||
|
|||||||
Reference in New Issue
Block a user