Commit 3349b44f by logesh.n

still in progess

parents
# Default ignored files
/shelf/
/workspace.xml
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredIdentifiers">
<list>
<option value="random.random.randint" />
</list>
</option>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (mqtt_redis_ticket)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/mqtt_redis_ticket.iml" filepath="$PROJECT_DIR$/.idea/mqtt_redis_ticket.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
[mqtt]
broker = 192.168.0.220
port_mqtt = 1883
username = "logeshn"
password = "WZ24KjETY88CZNT"
[redis]
redis_host = 127.0.0.1
redis_database_one = 1
redis_database_two = 2
redis_port = 6379
[postgres]
postgres_port = 5433
postgres_password = admin
postgres_username = postgres
postgres_host = localhost
postgres_database = postgres
redis~=4.5.1
psycopg2~=2.9.5
\ No newline at end of file
from configparser import ConfigParser
try:
config = ConfigParser()
config.read(r'C:\Users\logesh.n\PycharmProjects\mqtt_redis_ticket\conf\application.conf')
# postgres connection
postgres_host = config.get('postgres', 'postgres_host')
postgres_port = config.get('postgres', 'postgres_port')
postgres_database = config.get('postgres', 'postgres_database')
postgres_username = config.get('postgres', 'postgres_username')
postgres_password = config.get('postgres', 'postgres_password')
# redis connection
redis_host = config.get('redis', 'redis_host')
redis_port = config.get('redis', 'redis_port')
redis_database_one = config.get('redis', 'redis_database_one')
redis_database_two = config.get('redis', 'redis_database_two')
print("Postgres success!")
except Exception as e:
print("Exception occurred due to >> ", e)
import psycopg2
from scripts.config.configuration import postgres_host, postgres_database, postgres_username, \
postgres_port, postgres_password
try:
connection = psycopg2.connect(host=postgres_host,
dbname=postgres_database,
port=postgres_port,
user=postgres_username,
password=postgres_password)
# Creating a cursor object using the cursor() method
cursor = connection.cursor()
# Executing an MYSQL function using the execute() method
cursor.execute("select version()")
# Fetch a single row using fetchone() method.
data = cursor.fetchone()
print("Connection established to: ", data)
# Closing the connection
connection.close()
except Exception as e:
print("err >> ", e)
# Importing redis library
import redis as r
from scripts.config.configuration import redis_host, redis_port, redis_database_one, redis_database_two
try:
connection_one = r.Redis(host=redis_host, port=redis_port, db=redis_database_one)
connection_two = r.Redis(host=redis_host, port=redis_port, db=redis_database_two)
except Exception as e:
print("Error in Connection >> ", e)
from scripts.core.handlers.counter import t
def check_ticket(ticket_no):
from scripts.core.handlers.ticket_booking import book_tickets, option
from scripts.config.databases.redis.redis_connection import connection_one
import json
def counter():
tickets_list = []
no_of_tickets = int(input("\nEnter the number of tickets you need to book min (1) and max (5) >> "))
if no_of_tickets > 5:
print("You can book only maximum 5 tickets!")
book_tickets(option)
else:
for _ in (0, no_of_tickets):
ticket = int(input("Choose your seat number (Gold class starts from 1 to 300) >> "))
tickets_list.append(ticket)
print("Seats numbers booked are >> ", tickets_list)
ticket_class = "Gold"
customer_mobile = int(input("Enter your mobile number >> "))
ticket_booking_details = {
'ticket_class': ticket_class,
'customer_mobile': customer_mobile,
'no_of_tickets': no_of_tickets,
}
print("")
import json
from scripts.config.databases.redis.redis_connection import connection_one
pipe = connection_one.pipeline()
ni = ['1', '2', '3']
for _ in range(len(ni)):
data_list = [{"key": ni[0], "value": "apple"},
{"key": ni[1], "value": "mango"},
{"key": ni[2], "value": "grapes"}
]
for item in data_list:
pipe.set(item['key'], json.dumps({item['key']: item['value']}))
set_response = pipe.execute()
print("bulk insert response : ", set_response)
from scripts.config.databases.redis.redis_connection import connection_one, connection_two
from scripts.core.handlers.counter import counter
option = int(input("Welcome to PVR Cinemas!\nChoose:\n1) Gold Class\n Silver class\n Enter >> "))
try:
def book_tickets(option):
if option == 1:
print("Your gold class ticket booking has started")
counter_choice = int(input("\nChoose your counter (1/2) >> "))
if counter_choice == 1 or 2:
counter()
else:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment