How do I continue after the error?

chad cdalten at gmail.com
Thu Jun 4 21:26:49 EDT 2009


Let's say I have a list of 5 files. Now lets say that one of the files
reads nude333.txt instead of nude3.txt. When this happens, the program
generates an error and quits. What I want it to do is just skip over
the bad file and continue on with the next one.  Below is the actual
code. It only works on the local bbs that I hang out on. Sorry. I
couldn't think of the simple case that could isolate my problem.

#!/usr/bin/python

#The original code was written by Mr.Pardue, which sounds a lot like
#fuck you

import telnetlib, os
import time
import glob

my_porn_collection = ["nude.txt", "nude2.txt", "nude333.txt",
                      "nude4.txt", "nude5.txt"]

path = 'porn/'

#my_porn_collection = []

def get_files():
    for infile in glob.glob( os.path.join(path, '*.txt*')):
        my_porn_collection.append(infile)

def generate(some_naked_bitches):
    try:
        f = open(some_naked_bitches, "r")
    except:
        pass
    art = f.read()
    f.close()
    return art

def get_name():
    user = raw_input("\nUsername: ")
    password = raw_input("Password: ")
    enter_party(user, password)

def enter_party(user, password):
    now = telnetlib.Telnet("m-net.arbornet.org")
    now.read_until("login: ")
    print "\nEntered username.."
    now.write(user + "\n")
    now.read_until("Password:")
    now.write(password + "\n" )
    print "Entered pass.."
    now.read_until("m-net%")
    now.write("party\n")
    print "Entered into party.."
    scroll_some_porn(now)

def scroll_some_porn(now):
    while 1:
        for some_titty_porn in my_porn_collection:
            now.write(" \n")
            bitch_please = generate(some_titty_porn)
            now.write(bitch_please)
            time.sleep(10)
            now.write(" \n")

if __name__ == "__main__":
    #get_files()
    get_name()



More information about the Python-list mailing list