<commit_before>from specifics import *
import urllib
import urllib2
import json
import praw
import time
urltocheck = "b-15.net http://google.com http://172.16.58.3 https://172.16.58.3"

def runcheck(url):
    serverstried = 0
    httpup = 0
    dnsresolve = 0
    serverconnected = 0
    servercities = ""

    for server in servers:
        serverstried += 1
        try:
            data = {"url": url,"api":apikey}
            data = urllib.urlencode(data)
            request = urllib2.Request(server + '?' + data)
            response = urllib2.urlopen(request)
            page = response.read()
            j = json.loads(page)
            if j:
                servercities += " "+j['city']+", "+j['country']+"."
                serverconnected += 1
                if j['http'] == 200:
                    httpup += 1
                if j['dns'] == True:
                    dnsresolve += 1
        except:
             pass

    serverstried = str(serverstried)
    serverconnected = str(serverconnected)
    dnsresolve = str(dnsresolve)
    httpup = str(httpup)
    response = ""
    response += "Hello! I\'m the IsItUpBot!\n\nResults:"
    response +="\n\nOf the "+serverstried+" servers tried, I connected to "+serverconnected+". They were located in: "+servercities
    response += "\n\n"+dnsresolve+"/"+serverconnected+" servers indicated "+url+" resolved with DNS"
    response += "\n\n"+httpup+"/"+serverconnected+" servers indicated "+url+" is up."
    response += "\n\n"+footerGen()
    return response

def footerGen(permalink):
    return '[report a mistake](http://www.reddit.com/message/compose/?to=chpwssn&subject=IsItUpBot%20Error%20Report&message='+permalink+')'


r = praw.Reddit('ChemBot v2.0 by u/chpwssn. Responds to username mentions with information on chemical compounds listed in the comment.')
r.login(botuser,botpass)
#Open the file used to keep track of the mentions we've already scanned for words
with open("isitupbotscanned.txt") as scannedfile:
    scanned = scannedfile.read().splitlines()
print scanned
done_this_time = set()
loop = True
loops = 0
while loop:
    loops += 1
    if loops%100 == 0:
        print "Done "+str(loops)+" loops, completed: "+str(done_this_time)
    #Get the username mentions we have in our inbox
    mentions = r.get_mentions()
    for mention in mentions:
        #If we haven't scanned the mention yet previously or in this time running the script
        if mention.id not in scanned and mention.id not in done_this_time:
            #Record the mention as scanned in the file and the set
            with open("isitupbotscanned.txt", "a") as scannedfile:
                scannedfile.write(mention.id+'\n')
                done_this_time.add(mention.id)
            print mention<commit_msg>Fixed issue that caused a crash when running the footerGen<commit_after>from specifics import *
import urllib
import urllib2
import json
import praw
import time
urltocheck = "b-15.net http://google.com http://172.16.58.3 https://172.16.58.3"

def runcheck(url):
    serverstried = 0
    httpup = 0
    dnsresolve = 0
    serverconnected = 0
    servercities = ""

    for server in servers:
        serverstried += 1
        try:
            data = {"url": url,"api":apikey}
            data = urllib.urlencode(data)
            request = urllib2.Request(server + '?' + data)
            response = urllib2.urlopen(request)
            page = response.read()
            j = json.loads(page)
            if j:
                servercities += " "+j['city']+", "+j['country']+"."
                serverconnected += 1
                if j['http'] == 200:
                    httpup += 1
                if j['dns'] == True:
                    dnsresolve += 1
        except:
             pass

    serverstried = str(serverstried)
    serverconnected = str(serverconnected)
    dnsresolve = str(dnsresolve)
    httpup = str(httpup)
    response = ""
    response += "Hello! I\'m the IsItUpBot!\n\nResults:"
    response +="\n\nOf the "+serverstried+" servers tried, I connected to "+serverconnected+". They were located in: "+servercities
    response += "\n\n"+dnsresolve+"/"+serverconnected+" servers indicated "+url+" resolved with DNS"
    response += "\n\n"+httpup+"/"+serverconnected+" servers indicated "+url+" is up."
    response += "\n\n"+footerGen(mention.permalink)
    return response

def footerGen(permalink):
    return '[report a mistake](http://www.reddit.com/message/compose/?to=chpwssn&subject=IsItUpBot%20Error%20Report&message='+permalink+')'


r = praw.Reddit('ChemBot v2.0 by u/chpwssn. Responds to username mentions with information on chemical compounds listed in the comment.')
r.login(botuser,botpass)
#Open the file used to keep track of the mentions we've already scanned for words
with open("isitupbotscanned.txt") as scannedfile:
    scanned = scannedfile.read().splitlines()
print scanned
done_this_time = set()
loop = True
loops = 0
while loop:
    loops += 1
    if loops%100 == 0:
        print "Done "+str(loops)+" loops, completed: "+str(done_this_time)
    #Get the username mentions we have in our inbox
    mentions = r.get_mentions()
    for mention in mentions:
        #If we haven't scanned the mention yet previously or in this time running the script
        if mention.id not in scanned and mention.id not in done_this_time:
            #Record the mention as scanned in the file and the set
            with open("isitupbotscanned.txt", "a") as scannedfile:
                scannedfile.write(mention.id+'\n')
                done_this_time.add(mention.id)
            print mention
{'fraction_non_alphanumeric': 0.11673221308544869, 'fraction_numerical': 0.015731140507686807, 'mean_word_length': 2.626053143227479, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '148093', 'n_tokens_mistral': 1771, 'n_tokens_neox': 1653, 'n_words': 496}