use same rabittmq connection
This commit is contained in:
+2
-12
@@ -4,7 +4,6 @@ import string
|
|||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import pika
|
|
||||||
from playwright.sync_api import sync_playwright
|
from playwright.sync_api import sync_playwright
|
||||||
|
|
||||||
import params
|
import params
|
||||||
@@ -136,25 +135,17 @@ class CommandorPage:
|
|||||||
id = url.split("/")[-1]
|
id = url.split("/")[-1]
|
||||||
result = ReserveResultPojo(type=PublishType.SUCCESS, phone=contact.phone, message=message, url=url,
|
result = ReserveResultPojo(type=PublishType.SUCCESS, phone=contact.phone, message=message, url=url,
|
||||||
firstName=contact.first_name, lastName=contact.last_name, email=contact.mail,
|
firstName=contact.first_name, lastName=contact.last_name, email=contact.mail,
|
||||||
passport=contact.passport)
|
passport=contact.passport, ccid=contact.ccid)
|
||||||
result.id = id
|
result.id = id
|
||||||
_credentials = pika.PlainCredentials('scrapy_rabbitmq', '4x!hReCbA5v3heKWfPJV-Y')
|
channel = params.rabittmq_connection.channel()
|
||||||
connection = pika.BlockingConnection(
|
|
||||||
pika.ConnectionParameters(host=params.rabittMQ_host,
|
|
||||||
port=params.rabittMQ_port,
|
|
||||||
credentials=_credentials))
|
|
||||||
channel = connection.channel()
|
|
||||||
# default exchange, for 'hello' queue
|
# default exchange, for 'hello' queue
|
||||||
print("will publish message:" + result.to_json())
|
print("will publish message:" + result.to_json())
|
||||||
channel.basic_publish(exchange='', routing_key=APPOINTMENT_QUEUE,
|
channel.basic_publish(exchange='', routing_key=APPOINTMENT_QUEUE,
|
||||||
body=result.to_json())
|
body=result.to_json())
|
||||||
connection.close()
|
|
||||||
|
|
||||||
|
|
||||||
def get_random_id_number_for_proxy() -> str:
|
def get_random_id_number_for_proxy() -> str:
|
||||||
# write_the_valid_profiles_to_excel()
|
|
||||||
S = 8 # number of characters in the string.
|
S = 8 # number of characters in the string.
|
||||||
# call random.choices() string module to find the string in Uppercase + numeric data.
|
|
||||||
ran = ''.join(random.choices(string.digits, k=S))
|
ran = ''.join(random.choices(string.digits, k=S))
|
||||||
id_number = str(ran)
|
id_number = str(ran)
|
||||||
print("The randomly generated string is : " + str(ran)) # print the random data
|
print("The randomly generated string is : " + str(ran)) # print the random data
|
||||||
@@ -162,7 +153,6 @@ def get_random_id_number_for_proxy() -> str:
|
|||||||
|
|
||||||
|
|
||||||
def get_random_id_number() -> str:
|
def get_random_id_number() -> str:
|
||||||
# write_the_valid_profiles_to_excel()
|
|
||||||
S = 8 # number of characters in the string.
|
S = 8 # number of characters in the string.
|
||||||
ran = ''.join(random.choices(string.digits, k=S))
|
ran = ''.join(random.choices(string.digits, k=S))
|
||||||
id_number = "57" + str(ran)
|
id_number = "57" + str(ran)
|
||||||
|
|||||||
+1
-1
@@ -67,7 +67,7 @@ class ModemPool:
|
|||||||
ccid_group = re.search("[0-9F]+", response)
|
ccid_group = re.search("[0-9F]+", response)
|
||||||
ccid = ccid_group.group(0)
|
ccid = ccid_group.group(0)
|
||||||
sim_position = index + 1
|
sim_position = index + 1
|
||||||
position = (slot_position - 1) * 15 + sim_position
|
position = (slot_position - 1) * len(self._port_list) + sim_position
|
||||||
if phone_number:
|
if phone_number:
|
||||||
self._db_manager.save_sim_info(SimInfoPojo(phone=phone_number, ccid=ccid, position=position))
|
self._db_manager.save_sim_info(SimInfoPojo(phone=phone_number, ccid=ccid, position=position))
|
||||||
self._log_sender.send_log(phone_number, source=self.TAG, subject=SUBJECT_SIM_INFO,
|
self._log_sender.send_log(phone_number, source=self.TAG, subject=SUBJECT_SIM_INFO,
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import pika
|
||||||
|
|
||||||
from db.DbManager import DataManager
|
from db.DbManager import DataManager
|
||||||
from logs.LogSender import LogSender
|
from logs.LogSender import LogSender
|
||||||
|
|
||||||
@@ -33,3 +35,6 @@ PROXY_PASSWORD = "M3PZAXgW5V27"
|
|||||||
# rabittmq
|
# rabittmq
|
||||||
rabittMQ_host = "rabbitmq.lpaconsulting.fr"
|
rabittMQ_host = "rabbitmq.lpaconsulting.fr"
|
||||||
rabittMQ_port = 6672
|
rabittMQ_port = 6672
|
||||||
|
_credentials = pika.PlainCredentials('scrapy_rabbitmq', '4x!hReCbA5v3heKWfPJV-Y')
|
||||||
|
rabittmq_connection = pika.BlockingConnection(
|
||||||
|
pika.ConnectionParameters(host='rabbitmq.lpaconsulting.fr', port=6672, credentials=_credentials))
|
||||||
@@ -23,6 +23,7 @@ class ReserveResultPojo:
|
|||||||
passport: str = ""
|
passport: str = ""
|
||||||
slot_position = None
|
slot_position = None
|
||||||
sim_position = None
|
sim_position = None
|
||||||
|
ccid: str = ""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_firestore_dict(source):
|
def from_firestore_dict(source):
|
||||||
@@ -49,6 +50,9 @@ class ReserveResultPojo:
|
|||||||
if 'passport' in source:
|
if 'passport' in source:
|
||||||
passport = source['passport']
|
passport = source['passport']
|
||||||
result.passport = passport
|
result.passport = passport
|
||||||
|
if 'ccid' in source:
|
||||||
|
ccid = source['ccid']
|
||||||
|
result.ccid = ccid
|
||||||
result.id = id
|
result.id = id
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -64,7 +68,8 @@ class ReserveResultPojo:
|
|||||||
u'passport': self.passport,
|
u'passport': self.passport,
|
||||||
u'url': self.url,
|
u'url': self.url,
|
||||||
u'sim_position': self.sim_position,
|
u'sim_position': self.sim_position,
|
||||||
u'slot_position': self.slot_position
|
u'slot_position': self.slot_position,
|
||||||
|
u'ccid': self.ccid
|
||||||
}
|
}
|
||||||
|
|
||||||
return dest
|
return dest
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ def read_all_the_phone_number():
|
|||||||
params.oracle_log_sender.send_log(msg="SIM卡自检开始", subject=LOG_SUBJECT_EVENT, type=TYPE_EVENT_RESET_ALL_SIM_CARDS)
|
params.oracle_log_sender.send_log(msg="SIM卡自检开始", subject=LOG_SUBJECT_EVENT, type=TYPE_EVENT_RESET_ALL_SIM_CARDS)
|
||||||
slot_number = 16
|
slot_number = 16
|
||||||
slot_sum = 27
|
slot_sum = 27
|
||||||
# card_pool.switch_to_slot(29)
|
|
||||||
params.firebase_store_manager.clear_all_sim_info()
|
params.firebase_store_manager.clear_all_sim_info()
|
||||||
for i in range(slot_number, slot_sum + 1):
|
for i in range(slot_number, slot_sum + 1):
|
||||||
card_pool.reset()
|
card_pool.reset()
|
||||||
|
|||||||
@@ -1,24 +1,19 @@
|
|||||||
import logging
|
|
||||||
import threading
|
import threading
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
import pika
|
from params import rabittmq_connection
|
||||||
|
|
||||||
APPOINTMENT_QUEUE = "APPOINTMENT_QUEUE"
|
APPOINTMENT_QUEUE = "APPOINTMENT_QUEUE"
|
||||||
|
|
||||||
|
|
||||||
class MessageReceiver:
|
class MessageReceiver:
|
||||||
def __init__(self):
|
|
||||||
self._credentials = pika.PlainCredentials('scrapy_rabbitmq', '4x!hReCbA5v3heKWfPJV-Y')
|
|
||||||
|
|
||||||
def start_listener(self, callback):
|
def start_listener(self, callback):
|
||||||
t = threading.Thread(target=self._run, args=(callback,))
|
t = threading.Thread(target=self._run, args=(callback,))
|
||||||
t.start()
|
t.start()
|
||||||
|
|
||||||
def _run(self, callback):
|
def _run(self, callback):
|
||||||
connection = pika.BlockingConnection(
|
|
||||||
pika.ConnectionParameters(host='rabbitmq.lpaconsulting.fr', port=6672, credentials=self._credentials))
|
channel = rabittmq_connection.channel()
|
||||||
channel = connection.channel()
|
|
||||||
channel.queue_declare(queue=APPOINTMENT_QUEUE)
|
channel.queue_declare(queue=APPOINTMENT_QUEUE)
|
||||||
channel.basic_consume(queue=APPOINTMENT_QUEUE,
|
channel.basic_consume(queue=APPOINTMENT_QUEUE,
|
||||||
auto_ack=True,
|
auto_ack=True,
|
||||||
|
|||||||
Reference in New Issue
Block a user