import sys import uuid import random import httplib, urllib, urllib2, re class progress: def calc(self, fcurrent, fcomplete): self.prog = (float(fcurrent) / float(fcomplete)) * 100.0 return self.prog def display(self): sys.stdout.write ('\b' * (int(self.prog / 2) + 4)) sys.stdout.write ('#' * int(self.prog / 2) ) sys.stdout.write (' ' + str(int(self.prog)) + '%') sys.stdout.flush() class generators: def __init__ (self): pass def uuid(self): return uuid.uuid4() def rand_chars(self, length): chars = '' lchars = [] for i in range (97, 123): lchars += chr(i) for item in range(0, length): n = random.randint(0, 2) r = random.randint(0, 25) if n == 0: chars += lchars[r] elif n == 1: chars += lchars[r].upper() elif n == 2: chars += str(random.randint(0, 10)) return chars class generic: def __init__(self): pass def string_cleanup(self, string): return re.compile('[^a-zA-Z0-9_\. -]').sub('', string) class http_retiever: def post(self, url, port = 80, path = '/', params = {}): headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"} conn = httplib.HTTPConnection(url + ':' + str(port)) conn.request("POST", path, urllib.urlencode(params), headers) response = conn.getresponse() data = response.read() conn.close() return data def fetchtitle(self, page): t = urllib2.urlopen(page).read() return re.compile('(.*?)', re.M|re.S).findall(t, 1)[0].strip()