WildBamaBoy 19 Junior Poster

Maybe this thread has a bad name lol...
While the server is listening for a connection it needs to continue on with the code.

#[LISTENER]
    print "Initializing Listener..."
    Listener.Listen(server_ip, int(server_port))

    #[Run this code after Listener is waiting for a connection] 
    os.system("cls")

    print "Server IP: %s"  % server_ip + ":" + server_port
    print "Level Name: %s" % level_name
    print "Public IP: %s"  % public_ip
    print "-------------------------------------------"

    os.system("pause")

But it will never get to that part after calling the Listener, because it is stuck in a while loop listening for connections.

WildBamaBoy 19 Junior Poster

I'm attempting to write a game server and I need it to continue on with the code while listening for a connection. I know this is done with the threading module but I don't know how exactly to do this. Python documentation didn't work for me.

#[LISTENER]
    print "Initializing Listener..."
    Listener.Listen(server_ip, int(server_port))

    #(AFTER LISTENER HAS STARTED WAITING FOR A CONNECTION)
    os.system("cls")

    print "Server IP: %s"  % server_ip + ":" + server_port
    print "Level Name: %s" % level_name
    print "Public IP: %s"  % public_ip
    print "-------------------------------------------"

    os.system("pause")

Listener code

import os, socket
import Interpreter

class Listen:
    def __init__(self, server_ip, server_port):
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.bind((socket.gethostname(), server_port))
        s.listen(5)

        while 1:
            (clientsocket, address) = s.accept()
            if clientsocket and address:
                Interpreter.newConnection(clientsocket, address)
WildBamaBoy 19 Junior Poster

No, no. The table isn't code it's just part of a table listing what all of the packets do. I just have it there as an example of what I want to do, get the "Reason" from the packet and change it to something else.

Here is my code as of now. Some of it is not mine, copied from another script that handled a previous version of this game.

import os, time
import subprocess as sub


class AlphaServer(object):
    def __init__(self, process):
        self.process = process

    def say(self, message):
        self.stdin("say %s\n" % message)

    def stop(self):
        self.stdin("stop")

    def forceStop(self):
        self.process.terminate()

    def stdin(self, input):
        self.process.stdin.write(input)

    @property
    def stdout(self):
        return self.process.stdout.readline().strip()

    @property
    def stderr(self):
        return self.process.stderr.readline().strip()

class Output(object):
    def __init__(self, output):
        self.output = output.split()

    @property
    def DateTime(self):
        return self.output[0:2]

    @property
    def Type(self):
        return self.output[2]

    @property
    def Message(self):
        return " ".join(self.output[3:])

    @property
    def Player(self):
        if "".join(self.output[3::4]) == "WildBamaBoy":
            return "WildBamaBoy"
        else:
            return None

def read_config():
    """
        Read settings from Server Config.ini
    """

    try:
        if not os.path.isfile("Server Config.ini"):
            config      = open("Server Config.ini", "w")
            properties  = open("server.properties", "r").read()

            config.write("#################\n")
            config.write("Original Settings\n")
            config.write("#################\n\n")
            config.write(properties)

            config.write("\n###################\n")
            config.write("Additional Settings\n")
            config.write("###################\n")
            config.write("reserved_memory(MB) = 1024")
            config.close()

        config       = open("Server Config.ini", "r").read().splitlines()

        server_ip    = config[6][10:].rstrip()
        server_port  = config[7][12:].rstrip()
        level_name   = config[8][11:].rstrip()
        reserved_mem = config[13][22:].rstrip()

        print "Server IP:",           server_ip
        print "Server Port:",         server_port
        print "Level Name:",          level_name
        print "Reserved Memory(MB):", reserved_mem
        print "----------------------------------------\n"

        return server_ip, server_port, level_name, reserved_mem

    except Exception as error:
        print "Error occured while reading configuration: %s" % error
        time.sleep(1)
        raise SystemExit


def StartServer():
    """
        Start up the server and …
WildBamaBoy 19 Junior Poster

I don't really know how to word what I want to ask so please bear with me.

I'm making a program that will start up a game server written in Java and read the outputs and edit the packets so that I can modify this game. It will read outputs from the server just fine. Now I need to read and edit packets that are sent and received.

I'm looking at a whole list of packets that go from the client to the server and vice-versa. Like below,

Packet ID      Purpose       Field Description      Field Type
------------------------------------------------------------------------------
  0xFF        Disconnect         Packet ID            Byte
                                 Reason               String

I want to intercept this packet with and change the "Reason" to..I don't know...Bacon.

WildBamaBoy 19 Junior Poster

Yes..That seems to have worked. Thank you

WildBamaBoy 19 Junior Poster

In this program I have a lot of game directories in a list like so:

base = "C:/Program Files/Game"
expansion  = "C:/Program Files/Game/Expansion"

Games = [(base, "Base Game"),(expansion, "Expansion 1")]
Installed = []

The program then sees if they are installed like this:

for path, name in Games:      #For every path and name in Games list,
        if os.path.isdir(path):     #If the path exists,
            Installed.append(name)  #Add its NAME to the Installed list.      
    print "\n----------- Games Installed ------------"
    for name in Installed: print name

Now it must check to see if a file is in the games that are in the Installed list. If it is not there, the name of the game must be printed and the file copied to the game's directory.

for path in Installed:
        if not os.path.isfile(path + "d3dx9_31.dll"):
            Ok = False
            print "DLL not found in %s. Installing..." % name
            shutil.copy2(programRoot + "d3dx9_31.dll", path + "d3dx9_31.dll")
            
            if os.path.isfile(path + "d3dx9_31.dll"): print "DLL sucessfully installed.\n"    
            else: raise NotFoundError("Couldn't find DLL after copying to %s" % name)
            #Custom error class

In order for that to work correctly, the path AND name of the game must be added to the Installed list just like it is in the Games list.


Well that's simple. Just change the second block of code to this:

for path, name in Games:      #For every path and name in Games list,
        if os.path.isdir(path):     #If the path exists,
            Installed.append(path, name)  #Add its path and name to the Installed list.      
    print "\n----------- …
WildBamaBoy 19 Junior Poster

How do I get the same result from this Python script in Visual Basic?

import os
username = os.getenv("USERNAME")
desktop = "C:\\Documents and Settings\\%s\\Desktop\\" % username
print desktop 
#Result = C:\Documents and Settings\<MY USERNAME>\Desktop\

I already have this,

Public Shared username As String = My.User.Name 'Gives computer name then username. That isn't going to work
Public Shared desktop As String = "C:\Documents and Settings\<USERNAME>\Desktop"
WildBamaBoy 19 Junior Poster

Huh...much easier than what I came up with! I learned something. Thank you.

WildBamaBoy 19 Junior Poster

I figured this out, thanks. But what do you mean by

First answer is not to reinvent the wheel: use os.makedirs():

Why use that instead of the code I already have?

WildBamaBoy 19 Junior Poster

I just learned about dictionaries in Python and tried to implement them into a program I developed.

The folders in the dictionary absolutely MUST be created in the listed order. But if for whatever reason they cannot be created, I want the name I specify to be printed instead of the entire directory name, like it did when I a list in this section of code. If that doesn't make much sense you'll see what I mean in the code...I hope.

Using a dictionary would be perfect for doing what I want, except it automatically sorts the contents! This totally breaks the program! :confused:

FrameFolders = {modsDir:"Mods", Packages:"Packages", DCCache:"DCCache"}

for path in FrameFolders:
    if not os.path.isdir(path):
        Ok = False
        print "%s folder does not exist. Creating..." % FrameFolders[path]
        #Just using % path prints the ENTIRE directory name
        os.mkdir(path)

        if os.path.isdir(path): print "Folder sucessfully created.\n"
        else: raise NotFoundError("Could not create %s folder!" % FrameFolders[path])

Is there some workaround or something I can use in the place of a dictionary to get the results I want?

WildBamaBoy 19 Junior Poster

YES! That is exactly what I was trying to do. Thank you!

WildBamaBoy 19 Junior Poster

In the code below I have a class that handles what folder the user is in, so they can browse through multiple folders. I know that this isn't going to work right just yet.

This is the first time I've tried using classes and I don't understand them so well. So I probably mucked something up somewhere.

This code seems like it's going to work, but I get an odd error when it tries to print the contents of the folder the user types.

class GetFoldersInDir:
    def DirName(self,directory):
        os.system("cls")
        self.directory = directory
        print "Folders in %s\n" % directory
        for folder in os.listdir(directory):
            print folder
        return self.directory

def delete():

    Get = GetFoldersInDir()
    Get.DirName("R:/")
    choice = raw_input("\nType del to delete something, type a folder's name to open it.\n")

    if choice == "del":
        print "@@@@@@"
    elif choice in os.listdir(Get.directory):
        Get.DirName(choice)
    else:
        print "Folder not found."
        print Get.directory

WindowsError: [Error 3] The system cannot find the path specified: 'Old/*.*'
Why does it add /*.* to what I type? :?:

WildBamaBoy 19 Junior Poster

There we go! All folders and files copied sucessfully. Thank you!

WildBamaBoy 19 Junior Poster

I had the error in my first post.
IOError: [Errno 13] Permission denied: 'C:\\ABCD123'

Anyways, changing WindowsError to IOError gives me that same result.

WildBamaBoy 19 Junior Poster

No...It does this with every folder I try.

I'm on Windows XP by the way.

WildBamaBoy 19 Junior Poster

I cannot get shutil to copy one folder to another.
This code results in the error below. What am I doing wrong?

if os.path.exists(backup + "\\Safety Backup"):
    pass
else:
    print "Backing up original music. . ."
    os.mkdir(backup + "\\Safety Backup")
    for folder in musicFolders:
        shutil.copy2("C:\ABCD123", backup + "\\Safety Backup") 
    print "Backup complete."
    os.system("cls")

IOError: [Errno 13] Permission denied: 'C:\\ABCD123'

WildBamaBoy 19 Junior Poster

SOLVED!!!

I finally got it working after reading this.

"The main limitation of the UnRAR.dll library is that it cannot be used to extract or access individual files in archive. The whole archive must always be processed in one pass."

I understand it like this: It was only extracting .package files because that was all that UnRAR.dll allowed to be processed. I added archive = UnRAR2.RarFile(filename) to the beginning of the for loop so the archive is opened again so it can look for the next file extension.

def unrar():

    try:
        os.chdir(fileDir)
        
        archive = UnRAR2.RarFile(filename)
        print "\n-------------"
        print "Installing..."
        print "-------------\n"

        for fileInArchive in UnRAR2.RarFile(filename).infoiter():
            archive = UnRAR2.RarFile(filename) 
            file = os.path.split(fileInArchive.filename)[-1]			
            basename, ext = os.path.splitext(file)

            if ext == ".package":
                print "Found %s. Extracting to \\Packages." % file
                archive.extract("*.package", modDir + "\\Packages")
                found = True

            elif ext == ".dbc":
                print "Found %s. Extracting to \\DCCache." % file
                archive.extract("*.dbc", modDir + "\\DCCache")
                found = True
                
        if found == True:
            print "\nInstallation successful!"
            os.system("pause")
            
        else:
            print "\nThere was a problem with the installation."
            os.system("pause")
            
    except WindowsError:
        print "File not found."
        os.system("pause")
        os.system("cls")
        checkExtension()
WildBamaBoy 19 Junior Poster
archive.extract(file_archive, modDir + "\\Packages", False)
  File "C:\Python26\lib\site-packages\UnRAR2\__init__.py", line 154, in extract
    checker = condition2checker(condition)
  File "C:\Python26\lib\site-packages\UnRAR2\__init__.py", line 170, in condition2checker
    raise TypeError
TypeError
WildBamaBoy 19 Junior Poster

That's perfectly fine.

Finally it detects both files! It still won't extract though. I'm gonna keep messing with it, I think I can figure it out.

WildBamaBoy 19 Junior Poster

That's ok don't worry about it. This doesn't have to be finished immediately or anything.

EDIT: Didn't realize that you edited the code above.

Now it just does the same thing it's been doing.. :-\

Drag and drop the file into this window and press enter.
C:\123.rar

-------------
Installing...
-------------

Found Package.package. Extracting to \Packages.
No valid files found.
WildBamaBoy 19 Junior Poster

Uh oh, another error..

basename, ext = os.path.splitext(file)
  File "C:\Python26\lib\ntpath.py", line 190, in splitext
    return genericpath._splitext(p, sep, altsep, extsep)
  File "C:\Python26\lib\genericpath.py", line 91, in _splitext
    sepIndex = p.rfind(sep)
AttributeError: 'RarInfo' object has no attribute 'rfind'

Now that REALLY doesn't make sense.

WildBamaBoy 19 Junior Poster

Alright now this just outright doesn't make sense to me...

for filename in UnRAR2.RarFile(filename).infoiter():
UnboundLocalError: local variable 'filename' referenced before assignment

:confused:

WildBamaBoy 19 Junior Poster

I'm on Windows XP.

Ok I'm looking through that...I think I can do this now.

WildBamaBoy 19 Junior Poster

Just a thought...

for rarinfo in archive.infoiter():
            name = rarinfo.filename # <--------- Here
            found = False
            
            if name.find(".package") != -1:
                print "Found %s. Extracting to \Packages." % name
                archive.extract(name, modDir + "\\Packages")
                found = True

            if name.find(".dbc") != -1:
                print "Found %s. Extracting to \DCCache." % name
                archive.extract(name, modDir + "\\DCCache")
                found = True

            if not found:
                print "No valid files found."
                os.system("pause")
                os.system("cls")
                checkExtension()

Could the program be finding Package.package first (it is the first file in the archive) and then keep checking for it instead of looking for the next file extension? I think that's what I'm trying to say. :?:

WildBamaBoy 19 Junior Poster

Tony I believe they are path directories names, but if it is so they should be doubled.

Yes, they are path names. Strange, though. They've been working the way I've had them since I started working on this. :-O
Oh well, I changed them anyway.

Change your code to use only if statements.

This is strange, too. My code to unzip a file at the top used if elif and else and it works just fine. Anyways I tried that and it still only finds the .package file and still does not extract it.

WildBamaBoy 19 Junior Poster

Thanks for both replies. Both of the codes seem to do their job...Here is the code I have now. I tried to make it handle just like my program handles .zip files since now I know how to get the file name. It sort of works...

def unrar():

    try:
        os.chdir(fileDir)
        
        archive = UnRAR2.RarFile(filename)
        print "\n-------------"
        print "Installing..."
        print "-------------\n"

        for rarinfo in archive.infoiter():
            name = rarinfo.filename
            
            if name.find(".package") != -1:
                print "Found %s. Extracting to \Packages." % name
                archive.extract(name, modDir + "\Packages")

            elif name.find(".dbc") != -1:
                print "Found %s. Extracting to \DCCache." % name
                archive.extract(name, modDir + "\DCCache")

            else:
                print "No valid files found."
                os.system("pause")
                os.system("cls")
                checkExtension()

        print "\nInstallation successful!"
        os.system("pause")

Result using my test archive. It has two files, Package.package and dbda.dbc, so it should print that it has found both files to the console and extract them to the appropriate location.

Drag and drop the file into this window and press enter.
C:\123.rar

-------------
Installing...
-------------

Found Package.package. Extracting to \Packages.

Installation successful!
>>>

Why is it skipping the check for a .dbc file? I even added another check for a text file and it still only detected the .package. And it's not even extracting the .package file even though it was found.

WildBamaBoy 19 Junior Poster

Does anyone here know how to use the UnRAR2 module?
http://code.google.com/p/py-unrar2/downloads/list

I can't for the life of me I can't figure out how get it to do the same thing that zipfile does in a project I am working on. I want it to look for all files of a specific file type, print their name, and extract them to a specific directory. And do this for 4 different file types.

Here is the working code using zipfile:

def unzip():

    try:
        os.chdir(fileDir)

        zip = zipfile.ZipFile(filename, "r")
        print "\n---------------------------"
        print "Installing..."
        
        for name in zip.namelist():
            
            if name.find(".package") != -1:
                print "Found %s. Extracting to \Packages." % name
                zip.extract(name, modDir + "\Packages")

            elif name.find(".dbc") != -1:
                print "Found %s. Extracting to \DCCache." % name
                zip.extract(name, modDir + "\DCCache")
            else:
                print "No valid files found."

Now here is the test code I came up with when reading the module docs. I didn't really understand it.

def unrar():
    
    try:
        os.chdir(fileDir)

        archive = UnRAR2.RarFile(filename)
        print "\n---------------------------"
        print "Installing..."

        for fileInArchive in archive.infoiter():
            os.path.split(fileInArchive.filename)[1]

            if fileInArchive.filename == "*.txt":
                print "That is a text file."

Of course, it doesn't work. Does anyone know how to make UnRAR2 do this? Or is there something better to use when working with .rar files?

WildBamaBoy 19 Junior Poster

Thank you, that worked. I knew there had to be an easier way to do that. :$

WildBamaBoy 19 Junior Poster

How do you make Python distinguish from files and folders if they are dragged and dropped into the program's window?

import os
import string

newDrag = raw_input("Drag and drop the file or folder you want to add.\n")
newStrip = newDrag.strip('"')
#Removes the quotes Windows randomly adds for some reason

if string.find(newStrip, "."): 
#Checks for the period that precedes the file extension
    print "That is a file."
else:
#There is no period, no file extension, it is a folder.
    print "That is a folder."

os.system("pause")

I drop a new folder from Program Files into the program and...

Drag and drop the file or folder you want to add.
C:\Program Files\New Folder
That is a file.

Why doesn't this work right? It still prints "That is a file." even if nothing is typed in. It's just skipping the else: for some reason.

WildBamaBoy 19 Junior Poster

Thank you! That worked.

WildBamaBoy 19 Junior Poster

This is a section of a program I made that keeps track of some money I'm saving. :cool:
When I enter how much I want to add it saves what I enter to a file and updates the current amount I have saved, also in the file.

When I enter 0 I want the program to go back to the main function which asks what I want to do, (Code below else: ) but it does not work. It still writes that I entered 0 into the file. It just seems to skip the code that checks if amount is 0.

I don't see why this doesn't work. I also tried putting it right below 'amount' and the program still skipped it.

def add():
    while True:
        try:
            amount = float(raw_input("How much do you want to add? Enter 0 to cancel.\n"))
                
        except ValueError:
            print "Invalid input."
            os.system("pause")

        else:
                if amount == "0":
                print "test: float is 0"
                os.system("pause")
                os.system("cls")
                main()

            ####Write to file and return to main####
WildBamaBoy 19 Junior Poster

Thank you, tonyjv. The program finally works.

WildBamaBoy 19 Junior Poster

Thank you, d5e5. That worked perfectly! Now I'm having problems when I need to skip a day. (The worker did not work that day.)

I tried to add the only kind of error checking I know and it does not work. The program will start but still gives me a ValueError if I leave the clock in time blank or type something random.

import time

mininhr = 60.0
secinhr = mininhr * 60
#-------------------------------------------------------------------------------
def Monday():
    valid = False
    while valid == False:
        try:            
            print "When did they clock in Monday? Use HH:MMtt format. Leave blank to skip."
            clockInM = raw_input()   #Monday's clock in time is what you type in.
            valid = True             #It is valid.
            if clockInM == None:     #If you didn't type anything,
                valid = True         #It is still valid. This skips the day and ends the loop.
                Tuesday()            #Goes to Tuesday
        except ValueError:           #You typed it incorrectly
            print "Incorrect format."#Tell them so and start over at try:
    
    timeString1 = "05/23/10 " + clockInM
    timeTuple1 = time.strptime(timeString1, "%m/%d/%y %I:%M%p")

    print "When did they clock out Monday?"
    clockOutM = raw_input()

    timeString2 = "05/23/10 " + clockOutM
    timeTuple2 = time.strptime(timeString2, "%m/%d/%y %I:%M%p")

    totalTimeM = time.mktime(timeTuple2) - time.mktime(timeTuple1)
#-------------------------------------------------------------------------------
def Tuesday():
    print "When did they clock in Tuesday? Use HH:MMtt format."
    clockInT = raw_input()

    timeString1 = "05/23/10 " + clockInT
    timeTuple1 = time.strptime(timeString1, "%m/%d/%y %I:%M%p")

    print "When did they clock out Tuesday?"
    clockOutT = raw_input()

    timeString2 = "05/23/10 " + clockOutT
    timeTuple2 = time.strptime(timeString2, "%m/%d/%y %I:%M%p")

    totalTimeT = time.mktime(timeTuple2) …
WildBamaBoy 19 Junior Poster

Thanks tonyjv, but I just can't figure this out. Using my incredible genius, (sarcasm) it finally clicked in my brain that the code in red cannot possibly give me how many minutes are left along with the hours. Because the code there now is meant to show me how many minutes are in the number of hours they worked! :$

It's supposed to show how many hours they worked, and then how many minutes are left.
Like, if the clock in time is 11:20AM, and clock out time is 9:15PM. The program should say that they worked 9 hours and 55 minutes that day.

import time

print "When did they clock in? Use HH:MMtt format."
clockIn = raw_input()

timeString1 = "05/23/10 " + clockIn
timeTuple1 = time.strptime(timeString1, "%m/%d/%y %I:%M%p")

print "When did they clock out?"
clockOut = raw_input()

timeString2 = "05/23/10 " + clockOut
timeTuple2 = time.strptime(timeString2, "%m/%d/%y %I:%M%p")

totalTime = time.mktime(timeTuple2) - time.mktime(timeTuple1)

print "They worked",totalTime//(60.0*60),"hours and",totalTime/60.0,"minutes today."

Here is what happens when I enter the clock in and clock out time I said above.

IDLE 2.6.5 ==== No Subprocess ====
>>>
When did they clock in? Use HH:MMtt format.
11:20AM
When did they clock out?
9:15PM
They worked 9.0 hours and 595.0 minutes today.
>>>

I don't know where to go from here to make this work...

WildBamaBoy 19 Junior Poster

I got the hours to show correctly. Floor division! But the minutes are still messed up.
I don't understand why print totalTime("%M") doesn't work. Even if I change it to a string or integer it still says 'float' object is not callable.

WildBamaBoy 19 Junior Poster

Alright here is the code now.

from string import *
import os
import sys
import time

def main():
    
    #-----------------------------------------------------------------------
    print "When did they clock in Monday? Format is HH:MMP"
    clockinM = raw_input()
    
    timeString1 = "05/23/10 " + clockinM
    timeTuple1 = time.strptime(timeString1, "%m/%d/%y %I:%M%p")
    
    print "When did they clock out Monday?"
    clockoutM = raw_input()
    timeString2 = "05/23/10 " + clockoutM
    timeTuple2 = time.strptime(timeString2, "%m/%d/%y %I:%M%p")
    
    totalTimeM = time.mktime(timeTuple2) - time.mktime(timeTuple1)
    print "They worked",totalTimeM/(60.0*60),"hours and",totalTimeM/60.0,"minutes on Monday."
    #----------------------------------------------------------------------

When I type in what is on the time card, 11:20AM to 9:15PM, I get this.

When did they clock in Monday? Format is HH:MMP
11:20AM
When did they clock out Monday?
9:10PM
They worked 9.83333333333 hours and 590.0 minutes on Monday.
When did they clock in Tuesday?

And I have this at the bottom to show me the total.

#------------------------------------------------------------------------
    totalTime = totalTimeM/(60.0*60) + totalTimeT/(60.0*60) + totalTimeW/(60.0*60) + totalTimeH/(60.0*60) + totalTimeF/(60.0*60) + totalTimeS/(60.0*60) + totalTimeU/(60.0*60)
    round(totalTime)
    print "They worked a total of",totalTime,"hours and",totalTime("%M"),"this week."
    
main()

When I start the program and get to the end (Entered the hours for every day) I get this error.

They worked a total of 52.75 hours and
Traceback (most recent call last):
    print "They worked a total of",totalTime,"hours and",totalTime("%M"),"this week."
TypeError: 'float' object is not callable
>>>

How can I get the hours and minutes to display correctly? It should tell me 9 hours and 55 minutes if I type 11:20AM and 9:15PM.

WildBamaBoy 19 Junior Poster

Nevermind what was here before. I figured out my stupid mistake.

It works now but gives me a stupid high number of minutes. I think I can figure this out...

WildBamaBoy 19 Junior Poster

Hi, I'm writing a program that totals how long someone has worked by the starting time and the ending time.

It DOES work if the times entered are both AM or PM. Like if they worked from 2:00 to 9:10, it tells me the right answer of 7 hours and 10 minutes. But if they work from 11:20 to 9:15 it tells me that they worked -2 hours and -5 minutes, and gives me the incorrect total at the end of the code after the hours have been entered for every day.

Here the code. I don't know how to go about adding AM and PM. I'm very new to Python (1 week) but I catch on fast.

Can anyone help?

from string import *
import os

print "When did they clock in Monday? Use HH:MM format."             
#Clock in time is what you type in. Entered as HH:MM.
clockinM = (raw_input())                                                

print "When did they clock out Monday?"
#Clock out time is what you type in.
clockoutM = (raw_input())                                               

#Splits the clock in time at the :
SsplitM = (split(clockinM,":"))                                         

#Splits the clock out time at the :
EsplitM = (split(clockoutM,":"))                                     

#The starting hours for Monday is part 0 of the split; the section in bracket. [HH]:MM
startHrsM = int(SsplitM[0])                                             
#The starting minutes for Monday is part 1 of the split; the section in brackets.HH:[MM]
startMinM = int(SsplitM[1])                                             

endHrsM = int(EsplitM[0])
endMinM = int(EsplitM[1])

#The total minutes worked on Monday is the ending minutes minus the …