Professional Documents
Culture Documents
CHAPTER 1
INTRODUCTION
Prison management system is made to keep records about the prisoners and about the
guards. Jailor can log in as a user and can add the details of prisoners like name, age,
address, crime, and punishment.Jailors can also add the details about the different guards
that are on duty. Jailors can change attributes like time-shift duty hours of guards. Prison
means jail or any place which is used for the detention of prisoners permanently or
temporarily under the general and special orders of a Local Government.
Jailor can also write the First Information Report and can save it. FIR’s date, time,
number, and details can be seen anytime if required by the registered user. This system
gives the unique id to every FIR as required and the prisoner number will also be
unique.This system has one more user which is an admin. Admin can add the user(jailor)
and delete the user. All other attributes can only be changed by Jailor. This system talks
about when any prisoner gets their punishment period over so that he/she can be released.
The prison management system can be implemented in every prison without any
problem.This system has the-the capability to maintain an infinite number of records. It
is very useful as the written papers have a limited time period and can get lost but in the
prison management system, this is not possible as a backup file will be created
automatically and also updated automatically when any change is made in any record.
There is no option to delete a prisoner’s record because it may be required later by the
government to know any details about the person and can help in the tracking of the
prisoner. The system is simple and quite easy to use. Here, in this system, the admin
plays a huge role in maintaining the system. He/she is responsible to handle all the
requests from the user. This project is aimed at developing a prison management system
that is the collection of details of the prisoner and his details.With hardcopy of records it
is hard to search report or record about a particular criminal in prison. The purpose of
this document is to present a detailed description of the Prison Management System.This
software will be a Prison Management System for Prison Department. This system will
be efficient collection of records and details about the prisoners in prison.
CHAPTER 2
REQUIREMENTS ANALYSIS
The requirement analysis specifies the requirements needed to develop a graphic
project. In this phase, we collect the requirements needed for designing the project.
The requirements collected are then analyzed and carried to the next phase.
CHAPTER 3
DESIGN
3.1 Use Case Diagram
A use case diagram depicts the interaction between the users and the system. It
shows the functions of the system from the user ’s point of view and the various
actions the user as the actor carries out. The below UML diagram depicts that the
Police can have a access to all the operations of a Prision System where they can
perform multiple operations.
PRISON MAINTENANCE
CHAPTER 4
IMPLEMENTATION
Python is known as an interpreted scripting language. Gudo van Rossum designed it. It
was released in the year 1991. The different versions were released for Python like
python 1, python 2, and python 3. It is one of the most used scripting languages for
automating the modules and tools, development of web applications, handling big data,
complex calculations, workflow creation, rapid prototyping, and other software
development purposes.
Characteristics of Python
• Easy to Learn and Use: There is no use of the semicolon or curly-bracket, the
indentation defines the code block. It is the recommended programming
language for beginners.
• Expressive Language: Python can perform complex tasks using a few lines of
code.
• Interpreted Language: It means the Python program is executed one line at a
time.
• Cross-Platform Language: Python can run equally on different platforms such
as Windows, Linux, UNIX, and Macintosh, etc. So, we can say that Python is a
portable language. It enables programmers to develop the software for several
competing platforms by writing a program only once.
• Free and Open Space: It has a large community across the world that is
dedicatedly working towards make new python modules and functions. Anyone
can contribute to the Python community.
• Object Oriented Language: Python supports object-oriented language and
concepts of classes and objects come into existence. It supports inheritance,
polymorphism, and encapsulation, etc.
• Extensible: It implies that other languages such as C/C++ can be used to
compile the code and thus it can be used further in our Python code. It converts
the program into byte code, and any platform can use that byte code.
• GUI Programming Support: Graphical User Interface is used for the
developing Desktop application. PyQT5, Tkinter, Kivy are the libraries which
are used for developing the web application.
• Large Standard Library: It provides a vast range of libraries for the various
fields such as machine learning, web developer, and also for the scripting. There
are various machine learning libraries, such as Tensor flow, Pandas, Numpy,
Keras, and Pytorch, etc. Django, flask, pyramids are the popular framework for
Python web development.
• Dynamically typed and Type checking: This is one of the great features of
python that one need not declare the data type of a variable before using it. Once
the value is assigned to a variable, its datatype gets defined. Thus, type checking
in python is done at a run time, unlike other programming languages.
as websites, web apps, web services and mobile apps. Visual Studio uses Microsoft
software development platforms such as Windows API, Windows Forms, Windows
Presentation Foundation, Windows Store and Microsoft Silverlight. It can produce both
native code and managed code.
• Window management
The graphical user interface (GUI)is a form of user interface that allows users to interact
with electronic devices through graphical icons and visual indicators such as secondary
notation, instead of text-based user interfaces, typed command labels or text navigation.
GUIs were introduced in reaction to the perceived steep learning curve of commandline
interfaces (CLIs), which require commands to be typed on a computer keyboard.
Index: A structure containing a set of entries, each consisting of a key field and a
reference field, which is used to locate records in a data file.
Reference Field: The part of an index which contains information to locate records.
Indexing works by indirection.
Primary Indexing concept uses two types of files to store data. They are:
• Index file
• Record file
• Simple indexing can be useful when the entire index can be held in memory.
• Changes (additions and deletions) require both the index and the data file to be
changed.
• Updates affect the index if the key field is changed, or if the record is moved.
There is an index record for every search key value in the database. This makes
searching faster but requires more space to store the index itself.
Sparse Indexing
Sparse indexes only contain entries for documents that have the indexed field, even if
the index field contains a null value. The index skips over any document that is missing
the indexed field. The index is “sparse” because it does not include all documents of a
collection.
4.3 MODULES
1. Administrator login
The first page is of the options to login, quit and if the new user using the system
then he/she can signup using specific user id and user name.
Code: logingui.py
import sys
import os
from tkinter import *
import textwrap
def sin():
os.system("python AddguiT.py")
def printtext():
global entry_1,entry_2
uname = entry_1.get()
password = entry_2.get()
entry_1.delete(first=0,last=100)
entry_2.delete(first=0,last=100)
string = uname+"|"+password
print(string)
string= (''.join(format(ord(x), 'b') for x in string))
hashrec(string)
def dest():
ahead.close()
root.destroy()
def wordret(wa,wb,wc):
a=int(wa,2)^int(wb,2)^int(wc,2)
return '{0:032b}'.format(a)
def F1(S2,S3,S4):
return (S2&S3)|(~S2&S4)
def F2(S2,S3,S4):
return S2^S3^S4
def F3(S2,S3,S4):
return (S2&S3)|(S2&S4)|(S3&S4)
def F4(S2,S3,S4):
return S2^S3^S4
def process(chunk):
words=[]
# print(chunk)
words=textwrap.wrap(chunk, 32)
# print(words)
# for i in range(0,3):
words.append(wordret(words[0],words[1],words[2]))
return words
def compress(words):
k1=0x5A827999
k2=0x6ED9EBA1
k3=0x8F1BBCDC
k4=0xCA62C1D6
s1 = 0x67452301
s2 = 0xEFCDAB89
s3 = 0x98BADCFE
s4 = 0x10325476
s5 = 0xC3D2E1F0
h1=s1
h2=s2
h3=s3
h4=s4
h5=s5
for i in range(0,3):
temp=s5+(s1<<5)+F1(s2,s3,s4)+k1+int(words[i],2)
s5=s4
s4=s3
s3=s2
s2=s1
s1=temp
h1 = h1 + s1 & 0xffffffff
return h1
def hashrec(string):
length=len(string)
print(string)
low=0
high=20
while(length>20):
chunk=string[low:high]
binlength='{0:064b}'.format(20)
chunk+=binlength
obj1=process(chunk)
length=length-20
low=low+20
high=high+20
obj2=compress(obj1)
# print("inside while")
if(length==20):
# print("testing inside 20")
string+='1'
#append length
length='{0:064b}'.format(length)
string+=length
obj1=process(string)
obj2=compress(obj1)
elif(length<20):
#string='{0:b}'.format(ord(x) for x in message
string+='1'
length=len(string)
for i in range(length,20):
string+='0'
#append length
length='{0:064b}'.format(length)
# print("lenght 2 :",length)
# print("str",string)
string+=length
#print(string)
#print(len(string))
obj1=process(string)
obj2=compress(obj1)
hashis= '%08x' % (obj2)
print("Hash Generated :",hashis)
flag = 0
for lines in ahead:
words = lines.split("|")
if words[0] == hashis:
flag = 1
root.withdraw()
command = 'python page3.py'
caller(command)
root.update()
root.deiconify()
if flag == 0:
print("not found")
# printtext()
def caller(command):
os.system(command)
# ahead = open("hashcontnet.txt","r")
ahead = open("hashcontent.txt","r")
root = Tk()
root.configure(background='black')
root.geometry('1000x1000')
root.title("Login GUI")
label_0 = Label(root, text="LOGIN",width=20,font=("bold", 20),
background='yellow')
label_0.place(x=80,y=53)
label_1 = Label(root, text="Username",width=20,font=("bold", 10),
background='yellow')
label_1.place(x=68,y=130)
entry_1 = Entry(root)
entry_1.pack()
entry_1.focus_set()
entry_1.place(x=240,y=130)
label_2 = Label(root, text="Password",width=20,font=("bold", 10),
background='yellow')
label_2.place(x=68,y=180)
entry_2 = Entry(root)
entry_2.pack()
entry_2.focus_set()
entry_2.place(x=240,y=180)
b = Button(root, text='Login',width=20,height=2,bg='yellow',fg='black',
command=printtext).place(x=180,y=300)
Button(root,
text='Quit',width=20,height=2,bg='yellow',fg='black',command=dest).plac
e(x=180,y=360)
Button(root,text='Signup',width=20,height=2,bg='yellow',fg='black',coma
nd=sin).place(x=180,420)
root.mainloop()
2. Selection Page
After login it welcome us with the 4 options:
1.Add
2.Search
3.Delete
4.modify
Code:page3.py
frame.pack_forget()
delete_frame = Frame(root)
button = ['Delete Prisoner Details','Go to Main Menu']
function = [delete_victim,back]
for i in range(len(button)) :
Button(delete_frame,text=button[i],command=function[i],height=1
,width=20).pack(side=TOP, expand=YES ,padx=20, pady=30)
display_frame(delete_frame)
def modify() :
global frame,root,modify_frame
frame.pack_forget()
modify_frame = Frame(root)
button = ['Modify Prisoner Details','Go to Main Menu']
function = [modify_victim,back]
for i in range(len(button)) :
Button(modify_frame,text=button[i],command=function[i],height=1
,width=20).pack(side=TOP, expand=YES ,padx=20, pady=30)
display_frame(modify_frame)
#Add Menu
def add_victim() :
global add_frame,root,add_victim_frame
global v1,v2,v3,v4,v5,v6,v7
add_frame.pack_forget()
add_victim_frame = Frame(root)
label1=Label(add_victim_frame,text="Enter the Prisoner NO.")
label1.pack()
v1=Entry(add_victim_frame)
v1.pack()
label2=Label(add_victim_frame,text="Enter the Prisoner name")
label2.pack()
v2=Entry(add_victim_frame)
v2.pack()
label3=Label(add_victim_frame,text="Enter the Crime")
label3.pack()
v3=Entry(add_victim_frame)
v3.pack()
label4=Label(add_victim_frame,text="Enter the CASE DATE")
label4.pack()
v4=Entry(add_victim_frame)
v4.pack()
label5=Label(add_victim_frame,text="Enter the CASE TIME")
label5.pack()
v5=Entry(add_victim_frame)
v5.pack()
label6=Label(add_victim_frame,text="Enter the CASE DESCRIPTION")
label6.pack()
v7=Entry(add_victim_frame)
v7.pack()
label7=Label(add_victim_frame,text="Enter the CASE STATUS")
label7.pack()
v6=Entry(add_victim_frame)
v6.pack()
b1=Button(add_victim_frame,text="Enter",command=gett)
b1.pack(side = LEFT)
b2=Button(add_victim_frame,text="Back",command=back)
b2.pack(side = RIGHT)
display_frame(add_victim_frame)
def gett():
command='python case_insert1.py '+v1.get()+" "+v2.get()+"
"+v3.get()+" "+v4.get()+" "+v5.get()+" "+v6.get()+" "+v7.get()
os.system(command)
print(command)
#Search
def search_victim() :
global search_frame,root,search_victim_frame
global vs1,vs2,vs3,vs4
global lbl
search_frame.pack_forget()
search_victim_frame = Frame(root)
global vs1,vs2,vs3
lbl = Label(search_victim_frame, text='')
lbl.pack()
key=Label(search_victim_frame,text="Enter Prisoner NO.")
key.pack()
vs3=Entry(search_victim_frame)
vs3.pack()
b1=Button(search_victim_frame,text="Enter",command=get1)
b1.pack(side=LEFT)
b2=Button(search_victim_frame,text="Back",command=back)
b2.pack(side = RIGHT)
display_frame(search_victim_frame)
def get1():
command='python case_search.py '+" "+vs3.get()
output = subprocess.check_output(command, shell=True)
lbl['text'] = output.strip()
os.system(command)
print(command)
#Delete
def delete_victim() :
#global add_frame
global delete_frame,root,delete_victim_frame
global vd1,vd2,vd3
global lbl1
delete_frame.pack_forget()
delete_victim_frame = Frame(root)
# global vs1,vs2,vs3
global lbl
lbl1 = Label(delete_victim_frame, text='')
lbl1.pack()
key=Label(delete_victim_frame,text="Enter Prisoner NO.")
key.pack()
vd3=Entry(delete_victim_frame)
vd3.pack()
b1=Button(delete_victim_frame,text="Enter",command=delete1)
b1.pack(side=LEFT)
b2=Button(delete_victim_frame,text="Back",command=back)
b2.pack(side = RIGHT)
display_frame(delete_victim_frame)
def delete1():
command='python case_delete.py '+" "+vd3.get()
output = subprocess.check_output(command, shell=True)
lbl1['text'] = output.strip()
os.system(command)
print(command)
display_frame(delete_victim_frame)
def get_modify():
command='python case_modify1.py '+" "+v3.get()+" "+vs4.get()
print("modified")
output = subprocess.check_output(command, shell=True)
lbl1['text'] = output.strip()
os.system(command)
print(command)
display_frame(modify_victim_frame)
#Modify
def modify_victim():
global modify_frame,root,modify_victim_frame
global v1,v2,v3,v4,v5,vs4
global lbl1
modify_frame.pack_forget()
modify_victim_frame = Frame(root)
lbl1 = Label(modify_victim_frame, text='')
lbl1.pack()
label3=Label(modify_victim_frame,text="Enter Prisoner NO.")
label3.pack()
v3=Entry(modify_victim_frame)
v3.pack()
key1=Label(modify_victim_frame,text="Enter new Status.")
key1.pack()
vs4=Entry(modify_victim_frame)
vs4.pack()
b1=Button(modify_victim_frame,text="Enter",command=get_modify)
b1.pack(side = LEFT)
b2=Button(modify_victim_frame,text="Back",command=back)
b2.pack(side = RIGHT)
display_frame(modify_victim_frame)
#Main Program
root = Tk(className = "GUI")
frame=add_frame=search_frame=delete_frame=modify_frame = Frame(root)
root.minsize(200,200)
root.geometry("1000x1000")
root.title("Crime Files")
bg=PhotoImage(file="")
add_victim_frame = add_case_frame = Frame(root)
search_victim_frame = Frame(root)
delete_victim_frame = Frame(root)
modify_victim_frame = Frame(root)
#Creating Main_Menu Frame
button = ['Add','Search','Delete','Modify']
function = [add,search,delete,modify]
for i in range(len(button)) :
Button(frame,text=button[i],command=function[i],height=1,width=20).
pack(side=TOP, expand=YES ,padx=20, pady=30)
#Display
display_frame(frame)
root.mainloop()
word_occurrences = dict()
line_num = 0
for lin in txt_fil:
line_num += 1
# Split the line into words delimited by whitespace.
#words = lin.split()
words=re.findall('F...',lin)
# Remove unwanted delimiter characters adjoining words.
words2 = [ word.strip(delimiter_chars) for word in words ]
# Find and save the occurrences of each word in the line.
for word in words2:
if word in word_occurrences:
word_occurrences[word].append(line_num)
else:
word_occurrences[word] = [ line_num ]
if (line_num < 1):
print("No lines found in text file, no index file created.")
txt_fil.close()
sys.exit(0)
# Display results.
print(word_occurrences)
word_keys=list()
word_keys = list(word_occurrences.keys())
print(word_keys)
#print "{} unique words found.".format(len(word_keys))
#word_keys = word_occurrences.keys()
# Sort the words in the word_keys list.
word_keys.sort()
# Create the index file.
idx_fil = open(idx_filename, "w")
for word in word_keys:
line_nums = word_occurrences[word]
idx_fil.write(word + " ")
for line_num in line_nums:
idx_fil.write(str(line_num) + " ")
idx_fil.write("\n")
txt_fil.close()
idx_fil.close()
if __name__ == '__main__':
case_desc1=""
txt_filename="victim.txt"
txt_fil = open(txt_filename, "a")
txt_indexname="index_file.idx"
n=len(sys.argv)
FIR_no=sys.argv[1]
vic_name=sys.argv[2]
acc_name=sys.argv[3]
case_date=sys.argv[4]
case_time=sys.argv[5]
case_stat=sys.argv[6]
for i in range(7,n):
case_desc1=case_desc1+sys.argv[i]+" "
case_desc1=case_desc1.strip()
entry=FIR_no+'|'+vic_name+'|'+acc_name+'|'+case_date+'|'+case_time+
'|'+case_desc1+'|'+case_stat+'|'+'\n'
txt_fil.write(entry)
txt_fil.close()
index_text_file(txt_filename, txt_indexname)
for i in range(1,n):
l2.append(int(l[i]))
file1=open("victim.txt","w")
n=len(record)
record2=[]
for i in range(1,n+1): #line number in the original file(1
to ...)
if i not in l2:
record2.append(record[i-1])
print("Record deleted.\n")
file1.writelines(record2)
file1.close()
index_text_file("victim.txt","index_file.idx")
if(flag==0):
print("No such record exist")
idx_f.close()
search("victim.txt","index_file.idx",sys.argv[1])
search("victim.txt","index_file.idx",sys.argv[1])
CHAPTER 5
SNAPSHOTS
This let the user to perform function like login or quit or new user can signup using id.
This page will let new user to register with the new username and user id.
This lets the user choose what operation is to be done on the required record in the file.
After clicking on add button user will get this page. Here if user want to add data the
click add Prisoner details otherwise he can go back to Go to Main Menu.
This lets the user to enter the required details into the given file.
This fig lets the user search the required details on the basis of entered Prisoner No.
This fig lets the user search the required details on the basis of entered Prisoner No.
Display the record searched by the user with respect to particular id.
This window lets the user to delete the record on the basis of entered Prisoner No.
This window shows the deleted record details and delete the particular record.
This window user to click the modify button to modify the data and may go back.
This window allows user to modify the Prisoner Number and may go back.
CHAPTER 6
To conclude the description about the project: Prison Maintenance is made successful
using python framework. In File Structures, we use primary indexing concept where
the data that the user enters will be stored in a index file with primary key and record
file having all the contained data. The data is retrieved using Prisoner No. as primary
key. Hence, indexing is used to access the records quickly and easily.
REFERENCES
1) File Structures by Pearsons
2) Wikipedia
3) www.google.com
4) www.openwho.org
5) www.cdc.gov/
6) www.geeksforgeeks.org/
7) www.w3schools.com/python/
8) www.stackoverflow.com/