def __init__(self,text="",timeout=1): self.soc=stdout_colors(colors_active=1,output_caller=0,show_lineno_write=0,show_lineno_caller=0,break_all=0) self.FAIL="FAIL" self.text=text self.timeout=timeout self.text="".join(self.text.split(" ")) self.text=list(self.text) self.banner_text="" self.colori=0 self.color="" #google colors in reverse and forwards self.color_order=["red","green","blue","yellow","red","blue","red","yellow","blue","green","red"]
def __init__(self,opt): self.func_me_color=opt['colors']['caller_color'] self.soc=stdout_colors(colors_active=opt['colors']['colors_active'], output_caller=opt['colors']['output_caller'], caller_color=opt['colors']['caller_color'], show_lineno_write=opt['colors']['show_lineno_write'], show_lineno_caller=opt['colors']['show_lineno_caller'], break_all=opt['colors']['break_all']) self.soc.me_him(['ENTER:',__name__],self.func_me_color) self.jar_=jar_controller(opt) self.soc.me_him(['EXIT:',__name__],self.func_me_color)
def __init__(self, h, u, p, d): self.func_me_color = "white_on_black" self.soc = stdout_colors(colors_active=1, output_caller=0, caller_color=self.func_me_color) self.soc.me_him(["ENTER:", __name__], self.func_me_color) self.h = h self.u = u self.p = p self.d = d self.MYSQL = None # used to determine if we should use MySQLdb or _mysql: True for MySQLdb and False for _mysql self.data = [] self.connection(self.h, self.u, self.p, self.d) self.soc.me_him(["EXIT:", __name__], self.func_me_color)
def __init__(self, base_url=""): self.func_me_color="white_on_black" self.soc=stdout_colours.stdout_colors() self.soc.me_him(['ENTER:',__name__],self.func_me_color) # These members might be set. self.base_url = base_url self.verbose = 0 self.response = "" self.headers = {'User-agent' : 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'} self.PYCURL=None try: import pycurl self.PYCURL = True except ImportError,e: import cookielib import urllib import urllib2 self.PYCURL = False
def __init__(self,filepath="",filespath="",filename=""): """ filepath = fullpath to file location filespath = fullpath to other file location if not existant in filepath filename = filename of file to parse, filepath+filename """ self.func_me_color="white_on_black" self.soc=stdout_colours.stdout_colors(colors_active=1,output_caller=1,caller_color=self.func_me_color) self.soc.me_him(['ENTER:',__name__],self.func_me_color) self.filename = filename self.filepath = filepath self.filespath= filespath if self.filepath[-1] is not "/": self.filepath=self.filepath+"/" if self.filespath[-1] is not "/": self.filespath=self.filepath+"/" self.buffer = [] self.bufferp= [] self.header = [] if self.filename.find("http") != -1: print "\n\nFOUND http IN FILENAME\nDOWNLOADING FILE AND PARSING!\n%s\n" % self.filename try: resp=urllib2.urlopen(self.filename) except urllib2.URLError, e: self.soc.w(["\n\nERROR: %s\nCANT READ URL %s\nPLEASE CHECK THAT IT IS CORRECT!\n" % (e,self.filename)],"white_on_red") sys.exit(1) file=resp.read() parts = self.filename.split("/") #self.filepath=self.filespath self.filename = self.filepath+parts[-1] f=open(self.filename,"w") f.write(file) f.close self.parse(self.filename)
def __init__(self,opt): self.func_me_color=opt['colors']['func_me_color'] self.soc=stdout_colors(colors_active=opt['colors']['colors_active'], output_caller=opt['colors']['output_caller'], caller_color=opt['colors']['func_me_color']) self.soc.me_him(['ENTER:',__name__],self.func_me_color) self.opt=opt#options value/index dict self.opt['data']={}#stores line/header field/function parsed value, used for import of product data self.field="" #used in map functions, field of func mapped value self.value=[] #used in map functions, value of func mapped field self.files=self.opt['files'] #csv files from jar configuration self.site=self.opt['site_name'] #site url schema://domain/dir self.options={}# form field options self.__options__={} #fresh set of options for each line self.order=self.opt['order'] self._optv=self.opt['options']# options param self.final_funcs=self.opt['final_funcs'] self.headers={} self.lines={} self.parsed={} self.__headers={} self.__lines={} self.__parsed={} #print "optv",self._optv #print self.opt,sys.exit(1) for file in self.files.keys(): if file == "files": for f in self.files[file].keys(): if self.files[file][f]=="main": self.headers = self.files[f].buffer[0] # file headers list self.lines = self.files[f].buffer #file list self.parsed = self.files[f].bufferp # file list of dict self.__headers[f]=self.files[f].buffer[0] self.__lines[f] = self.files[f].buffer #file list self.__parsed[f] = self.files[f].bufferp # file list of dict self.set_defaults() try: try: if int(self.opt['flavors']['pcreamysql']) == 1: import pcreamysql h=urlparse.urlparse(self.opt['site_name'])[1].split("www.")[1] u=os.environ["USER"] db_host_=raw_input("\nDB Host("+h+"): ") if not db_host_: db_host_ = h db_user_=raw_input("\nDB User("+u+"): ") if not db_user_: db_user_ = u db_pass_=getpass.getpass() #raw_input("DB Pass: "******"\nDB: ") self.opt['dbc'] = pcreamysql.pcreamysql(db_host_,db_user_,db_pass_,db_db_) else: self.opt['dbc'] = None except (KeyboardInterrupt): print("\nCTRL-C PRESSED....DOING NOTHING HERE") except (EOFError): print ("\n\nBYPASS MYSQL LOGIN.") self.opt['environ']['mysql_login_bypass']=1 #print self._optv,sys.exit(1) #send options/mappings/configuratoins to be used in functions self.fun=spread(self.opt) self.loop_lines() self.soc.me_him(['EXIT:',__name__],self.func_me_color)
if __name__ == "__main__": #todo: cleanup opt of all duplicate variables, store in opt['settings']? #added feature for when inside of loop and posting forms. pressing ctrl-c #brings up a web browser window with the current form being filled out #alternatively you can supply a different url for the browser to open #NOTE: webbrowser always, opens a new window, in my case konqueror opt={} opt['colors']={} c=caller_color=opt['colors']['caller_color']=opt['colors']['func_me_color']="white_on_blue" a=opt['colors']['colors_active'] = 1 #display stdout output with colors b=opt['colors']['output_caller'] = 0 #display function caller and called/current function d=opt['colors']['show_lineno_write'] = 0 e=opt['colors']['show_lineno_caller'] = 1 f=opt['colors']['break_all']=1 soc=stdout_colors(colors_active=a,output_caller=b,caller_color=c,show_lineno_write=d,show_lineno_caller=e,break_all=f) soc.me(['ENTER:',__name__],caller_color) opt['source'] = sys.argv[0] print (label.label(text=opt['source'],timeout=.5)) print ("\n%s BEST VIEWED IN FULLSCREEN"%opt['source']) try: time.sleep(2) except (KeyboardInterrupt,EOFError,e): pass opts, args = getopt.getopt(sys.argv[1:], 'j:f:s:v:o:k:',['jars=','files=', 'sites=','verbose=','options=','flavors=']) _help_ =format_help_message(opt['source']) if len(args) < 1: print format_help_message(opt['source']),sys.exit()