Skip to main content

Metro Train Management System

Project description

Metro Train Management System (MTMS)

A School Project in Python (CBSE India)



Table of contents

Quick Start

Several quick start options are available:

  • Install from pip: pip install mtms
  • Clone the repo: gh repo clone govindgrover/mtms
  • Clone the repo: https://github.com/govindgrover/mtms.git

Then to run the system,

>>> import mtms
>>> mtms.run()

Configuration

You can change the default configurations in the file:

<python-path>/Lib/site-packages/mtms/base/config.py

The default configuration is as follow:

# DATABASE INITIALS
__DB_USER__ = 'root'
__DB_PASS__ = 'password'
__DB_HOST__ = 'localhost'
__DB_NAME__ = 'metro_db'

# MUST BE IN 24-hour FORMAT
# AT WHICH OF CLOCK THE STATIONS WILL OPEN
__TRAIN_TIME_START__ = 9
# AT WHICH OF CLOCK THE STATIONS WILL CLOSE
__TRAIN_TIME_END__ = 23

# SECURITY AMOUNT TO BE TAKEN FROM THE CUSTOMER
__NEW_CARD_SECURITY__ = 50
# MINIMUM AMOUNT TO BE RECHARGED
__MIN_CARD_RECHARGE_AMOUNT__ = 200
# MAXIMUM AMOUNT TO BE RECHARGED
__MAX_CARD_RECHARGE_AMOUNT__ = 2000

# TIME FOR WHICH ONE CAN STAY AT STATION WHICH BEING ON THE TRAIN
__IN_STATION_TIME_DIFF__ = '00:20:00'

# WANT TO USE QR OR NOT
__USE_QR__ = True

In the above __DB_NAME__ the database name must match which is given in the initial database file. so it will be good if you take care of it. Otherwise if you really want to change it, you can do it at:

<python path>/Lib/site-packages/mtms/initials/database/metro_db_struct.sql


Description


Hardware Requirements

Hardware Requirements
PC or Laptop satisfying the below software requirements

Software Requirements

Software Requirements
OS Any; Preferred: Windows 10
Python >= 3.8
pip >= 20.1
MySQL >= 15.1
Command Prompt Yes; Preferred: Windows Terminal from Windows 10 Store - download
Font Any; Preferred: Consolas or any other Hindi supporting font

Understanding the System


Aim of this module is to bring easiness for everyone who works as a staff member at metro or a daily job person who uses metro as transport.

Metro Train Management System helps one to manage different stations and their routes along with the counter system and customer booking system.


Limitations

  • Line Routes are mentioned but there is no use of them because then it will become more tedious on our hand.
  • Customer cannot view his/her journey going on screen.
  • Customer has to remember a 36-character long token/card ID.

Module Dependencies

  • OS
  • mysql.connection
  • uuid
  • time
  • datetime
  • sys
  • traceback
  • json
  • pickle
  • pyqrcode

User-defined Functions


/__init__.py

Function Name Parameter(s) Return Description
run Void None Starts the main system

/base/classes/Admin.py

Function Name Parameter(s) Return Description
__addFareForStation station_info : dict Boolean Assign fare for the added station whose station_id is given through the parameter
login username : str, password : str dict Login the admin user if the credentials matched
logout Void dict Logout the admin user
addAccount username : str, email : str, password : str, role : int dict Adds new user account based on the given data.Role is 0 for admin and 1 for counter
addRoute route_name : str dict Adds new route
addStation station_name : str, route_id : str dict Adds new station and assign it on the provided route
renameRoute _id : str, new_name : str dict Rename the provided route
renameStation _id : str, new_name : str dict Rename the provided station
modifyStationFares f_id : str, t_id : str, amt : float dict Modify the fare charges for the provided pair of stations
getAllRoutesAndStations Void dict Gives all of the stations name and their assigned route names
getAllUsers Void dict Gives a list of users their emails and roles
backupDatabase Void dict Backup the current database to the location:<Python folder>/Lib/mtms/_backups/db_backup.sql
resetDatabase Void dict It will reset the database and recreate it from the initial file
changeStationStatus sid : str, status : int, reason : str dict It will set the station closure status as specified with a reason to the provided station
viewStationStatus sid : str dict It will tell the station closure station for the provided station

/base/classes/CardOperation.py

Function Name Parameter(s) Return Description
__isActive cid : str Boolean Checks weather the provided Card - ID is valid or not
__doCardChecks cid : str dict Performs checks on the provided Card – ID
__isInStation cid : str Boolean Checks weather the provided card has checked-in a station or not
__stationEntry cid : str, entry_sid : str dict Mark the provided card as in-station for the provided station and make a new booking
__stationExit cid : str, exit_sid : str dict Mark the provided card as out-station for the provided station and make a complete the opened booking
isCard cid : str Boolean Tells weather the provided Card-ID is valid and original or not
onTouch cid : str, cur_stat : str dict It performs action on the provided Card-ID according to the state which it is in with respect to the current station

/base/classes/ConsoleTable.py

Function Name Parameter(s) Return Description
__sumUpLengths Void int It tells the number of columns in total for the provided data for creatin the table borders
__makeListOfLengthOfEachInnerListItem Void list It makes a list which contains length of all columns data provided
__getListOfThisIndexFromInnerLists arr : list, index : int list It calculates the maximum number of characters occurring in the respected column at that index
__setAutoMaxLengths Void None It sets the maximum character length needed for a good looking table
__checkData Void Boolean It checks weather the number of provided columns and rows is greater than zero or not
setColumnHeaders cols : list None Set headers
setRows rows : list None Set rows
createTable Void None Prints a final table output

/base/classes/Counter.py

Function Name Parameter(s) Return Description
__isCardExists card_id Boolean Checks weather the provided Card-ID exists or not
login username : str, password : str dict Login the counter user if the credentials matched
logout Void dict Logout the counter user
getCardBalance cid : str, amt_only : bool = False dict Gives card balance for the provided card and if amt_onlysets to Truethen it will return only float amount
printCard cid : str str Prints the provided Card-ID with its amount into a text file
buyNewCard Void dict Create a new metro card
rechargeCard cid : str dict Recharge the card
refundCard cid : str dict Disable the card when refunded successfully

/base/classes/Payment.py

Function Name Parameter(s) Return Description
__selectMode Void None Sets the current payment mode as per user's choice
__takeAmount_and_Proceed Void None Asks to user to enter the amount and do some checks then accordingly approves or disapproves the transaction
__confirmAmt_and_Proceed Void None Asks the user for confirmation for the transaction of pre-defined balance
setAmount to_charge : float None Sets the pre-defined amount
setMaxAmount max_to_charge : float None Sets the max amount that the users can enter
amountRecived Void Float Returns the amount entered by the user
creditAmount Void None Performs the main transaction with user interaction

/base/classes/TokenOperation.py

Function Name Parameter(s) Return Description
__isActive tid : str Boolean Checks weather the provided Token - ID is valid or not
__doTokenChecks tid : str dict Performs checks on the provided Token – ID
__isTimeOut tid : str Boolean Checks weather the token is expired or not
__isInStation tid : str Boolean Checks weather the provided token has checked-in a station or not
__stationEntry tid : str dict Mark the provided token as in-station and make a new booking
__stationExit tid : str dict Mark the provided token as out-station and make a complete the opened booking
__makeBooking info : dict str Makes a new booking when a token is purchased based on the provided data
__markJourney f : str, t : str dict Helps to fetch the fare for the provided pair of stations
isToken tid : str Boolean Tells weather the provided Token-ID is valid and original or not
onTouch cid : str dict It performs action on the provided Token - ID according to the state which it is in
printTicket bid : str str Prints the ticket into a text file based on the booking data
buyToken _from : str, _to : str dict Makes a new token and assign a new booking to it for the provided pair of stations

/base/functions/functions.py

Function Name Parameter(s) Return Description
get_runs_upto Void int Tells how many time the system is ran till now from the time of setup
showCountDown text : strt : int None It shows a countdown for t time with the provided text
ask q : str Boolean Asks the user provided question and tells weather he said yes or no
printHeading tree : list, width : int, sep_times : int = 5 None Print a heading at top of the console screen after clearing all the past printed lines
insertInTableCmd tbl_name : str, arr_col : list, arr_val : list str Returns a SQL insert query based on the data provided
generateId Void str Generates a unique id through the python's UUID module
isInDB db : object, tbl_name : str, col_name : str, val : any Boolean Checks weather the provided record is exists or not
checkStationTimmings Void dict Checks and tells weather the station is opened or closed during the hours
getAllRoutes db : object dict Fetch all of routes
getAllStations db : object dict Fetch all of stations
searchStations db : object, like_text : str str Helps the user to search the stations based on the provided input and return the station_id for the selected station
searchRoutes db : object, like_text : str str Helps the user to search the routes based on the provided input and return the route_id for the selected route
showQR txt : str, showTxt : str None Generates and show the QR Code for thr provided text string
checkStationClosure db : object, sid : str dict Checks weather a specific station is closed or not
makeErrorLog Void str Makes an error log file for the errors raised during the execution of the program through the traceback module
setWorkingLang dft : bool = False dict Return a dictionary of lines used in the program by reading a language file from users' choice
importInitials db : object = None, isReset : bool = False Boolean it imports and sets important data at its place
isFirstLanuch Void Boolean Tells weather the system is running for the first time or not
firstThingsFirst Void None The very first function to be executed for the system

/base/menu/admin_menu.py

Function Name Parameter(s) Return Description
login Void None Login the admin user if the credentials matched
logout Void None Logout the admin user
addNewUser Void None Adds new user account based on the given data.Role is 0 for admin and 1 for counter
addNewRoute Void None Adds new route
addNewStation Void None Adds new station and assign it on the provided route
renameTheRoute Void None Rename the provided route
renameTheStation Void None Rename the provided station
changeFares Void None Modify the fare charges for the provided pair of stations
showAllRoutesAndStations Void None Gives all of the stations name and their assigned route names
showAllUsers Void None Gives a list of users their emails and roles
takeBackup Void None Backup the current database to the location:<Python folder>/Lib/mtms/_backups/db_backup.sql
modifyStationStatus Void None It will set the station closure status as specified with a reason to the provided station
viewStationStatus Void None It will tell the station closure station for the provided station
resetEverthing Void None It will drop the current database and then recreate it from the initials

/base/menu/counter_menu.py

Function Name Parameter(s) Return Description
login Void None Login the counter user if the credentials matched
logout Void None Logout the counter user
getBalance Void None Gives card balance for the provided card and if amt_onlysets to Truethen it will return only float amount
buyCard Void None Create a new metro card
rechargeTheCard Void None Recharge the card
refundTheCard Void None Disable the card when refunded successfully

/base/menu/customer_menu.py

Function Name Parameter(s) Return Description
touch Void None Performs functionalities according to the type of touch
getToken Void None Performs functionalities for buying a new token

/base/menu/customer_menu.py

Function Name Parameter(s) Return Description
showMenu module : object, view : dict, tree : list None Show menu depending on the provided information

Data Files

File Name Location Description
mtms_run_info.bin <Python folder>/Lib/mtms/ Stores number of times the system is ran from the first setup

Copyright and license

Code and documentation copyright 2021-22 Govind Grover Code released under the GPL License. Docs released under Creative Commons.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mtms-1.0.3.tar.gz (46.6 kB view hashes)

Uploaded Source

Built Distribution

mtms-1.0.3-py3-none-any.whl (52.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page