from ftplib import FTP import sys, os from wxPython.wx import * import Mk4py import string mk = Mk4py Starport_db = mk.Storage('c:' + os.sep + 'Starport' + os.sep + 'People.mk',1) Starport_vw = Starport_db.getas('starpeople[Name:S,Birthday:S,Time:S,AMPM:S,City:S,State:S,Countries:S,Province:S,name2:S,birthday2:S,time2:S,AMPM2:S,city2:S,state2:S,countrie2:S,province2:S,Email:S,BillingName:S,BillingEmail:S,Comments:S,StartTime:S,EndTime:S,NewCity:S,NewState:S,NewCountrie:S,NewProvince:S,ReportName:S,Sex:S,Preference:S]') #------------------- def starline(starstring): # Strips Quouts,(Spaces) and commas then sepparate from commas into list newword=('') tmpfile =('') linelist = ([]) for x in range(len(starstring)): tmpfile = starstring[x] if starstring[x] == '"':# or starstring[x] == ' ': tmpfile =('') if starstring[x] == ',': linelist.append(newword) newword=('') tmpfile =('') newword = (newword) + (tmpfile) return linelist #------------------- class TomFrame(wx.wxFrame): def __init__(self, parent, id, title): # First, call the base class' __init__ method to create the frame wx.wxFrame.__init__(self, parent, id, title,wxPoint(100, 100), wxSize(800, 500)) if wxPlatform == '__WXMSW__': icon = wxIcon('Starport.ico', wxBITMAP_TYPE_ICO) self.SetIcon(icon) EVT_SIZE(self, self.OnSize)# Associate some events with methods of this class EVT_MOVE(self, self.OnMove) self.main_menu = wxMenuBar()# Make a File menu menu = wxMenu() exitID = wxNewId() menu.Append(exitID, 'Load Local Files', 'Load files from hard drive') EVT_MENU(self, exitID, self.OnFileLoadLocal) exitID = wxNewId() menu.Append(exitID, 'Download Files', 'Get the heck outta here!') EVT_MENU(self, exitID, self.OnFileDownload) exitID = wxNewId() menu.Append(exitID, 'Clear Online Files', 'Get the heck outta here!') EVT_MENU(self, exitID, self.OnFileClear) exitID = wxNewId() menu.Append(exitID, 'E&xit\tAlt-X', 'Get the heck outta here!') EVT_MENU(self, exitID, self.OnFileExit) self.main_menu.Append(menu, '&File') self.SetMenuBar(self.main_menu) #make a notebook and 7 lists and one text window self.Note_Window = wxNotebook(self, -1, wxPoint(0,0),wxDefaultSize,wxSUNKEN_BORDER | wxEXPAND) self.Carrer_list = wxListCtrl(self, -1, wxDefaultPosition, wxDefaultSize,wxLC_REPORT) for x in range(50):# add 50 items to each list testi = wxListItem() self.Carrer_list.InsertItem(testi) self.Compatibility_list = wxListCtrl(self, -1, wxDefaultPosition, wxDefaultSize,wxLC_REPORT) for x in range(50): testi = wxListItem() self.Compatibility_list.InsertItem(testi) self.Forcast_list = wxListCtrl(self, -1, wxDefaultPosition, wxDefaultSize,wxLC_REPORT) for x in range(50): testi = wxListItem() self.Forcast_list.InsertItem(testi) self.CompatibilityForcast_list = wxListCtrl(self, -1, wxDefaultPosition, wxDefaultSize,wxLC_REPORT) for x in range(50): testi = wxListItem() self.CompatibilityForcast_list.InsertItem(testi) self.Comments_Window = wxTextCtrl(self, -1,'', wxPoint(0, 0), wxSize(500,500), wxSUNKEN_BORDER | wxEXPAND | wxTE_MULTILINE) self.Relocation_list = wxListCtrl(self, -1, wxDefaultPosition, wxDefaultSize,wxLC_REPORT) for x in range(50): testi = wxListItem() self.Relocation_list.InsertItem(testi) self.Birth_list = wxListCtrl(self, -1, wxDefaultPosition, wxDefaultSize,wxLC_REPORT ) for x in range(50): testi = wxListItem() self.Birth_list.InsertItem(testi) self.Starport_list = wxListCtrl(self, -1, wxDefaultPosition, wxDefaultSize,wxLC_REPORT) for x in range(50): testi = wxListItem() self.Starport_list.InsertItem(testi) colum_list = ("Name","Birthday","Time","AM/PM","City","State","Countries","Province","Email","BillingName","BillingEmail","Comments") for x in range(len(colum_list)):# set the captions for each list self.Birth_list.InsertColumn(x, colum_list[x]) self.Birth_list.SetColumnWidth(x,120) colum_list = ("Name","Birthday","Time","AM/PM","City","State","Countries","Province","Email","BillingName","BillingEmail","Comments") for x in range(len(colum_list)): self.Carrer_list.InsertColumn(x, colum_list[x]) self.Carrer_list.SetColumnWidth(x,120) colum_list = ("Name 1","Birthday","Time","AM/PM","City","State","Countries","Province","Name 2","Birthday","Time","AM/PM","City","State","Countrie","Province","Email","BillingName","BillingEmail","Comments") for x in range(len(colum_list)): self.Compatibility_list.InsertColumn(x, colum_list[x]) self.Compatibility_list.SetColumnWidth(x,120) colum_list = ("Name","Birthday","Time","AM/PM","City","State","Countries","Province","Start Time","End Time","City","State","Countrie","Province","Email","BillingName","BillingEmail","Comments") for x in range(len(colum_list)): self.Forcast_list.InsertColumn(x, colum_list[x]) self.Forcast_list.SetColumnWidth(x,120) colum_list = ("Name","Birthday","Time","AM/PM","City","State","Countries","Province","$name2","$birthday2","time2","AM/PM","city2","state2","countrie2","province2","Start Time","End Time","New State","New Countrie","New Province","Email","BillingName","BillingEmail","Comments") for x in range(len(colum_list)): self.CompatibilityForcast_list.InsertColumn(x, colum_list[x]) self.CompatibilityForcast_list.SetColumnWidth(x,120) colum_list = ("Name","Birthday","Time","AM/PM","City","State","Countries","Province","New City","New State","new Countrie","New Province","Email","BillingName","BillingEmail","Comments") for x in range(len(colum_list)): self.Relocation_list.InsertColumn(x, colum_list[x]) self.Relocation_list.SetColumnWidth(x,120) colum_list = ("Name","Birthday","Time","AM/PM","City","State","Countries","Province","Sex","Preferance","Email","Comments") for x in range(len(colum_list)): self.Starport_list.InsertColumn(x, colum_list[x]) self.Starport_list.SetColumnWidth(x,120) self.Note_Window.AddPage(self.Birth_list,'Birth')# add the 7 lists and text window self.Note_Window.AddPage(self.Carrer_list,'Carrer')#to the notebook self.Note_Window.AddPage(self.Compatibility_list,'Compatibility') self.Note_Window.AddPage(self.Forcast_list,'Forcast') self.Note_Window.AddPage(self.CompatibilityForcast_list,'CompatibilityForcast') self.Note_Window.AddPage(self.Relocation_list,'Relocation') self.Note_Window.AddPage(self.Starport_list,'Starport') self.Note_Window.AddPage(self.Comments_Window,'Comments') def OnCloseWindow(self, event): # tell the window to kill itself self.Destroy() def OnSize(self, event):#called by the System when the window is resized (see events above) size = event.GetSize()# tell the event system to continue looking for an event handler, event.Skip()# so the default handler will get called. def OnMove(self, event):# This method is called by the System when the window is moved pos = event.GetPosition() def OnFileExit(self,event):# exit event from file menu above self.Destroy()# tell the window to kill itself def OnFileClear(self,event): pass #self.close() def OnFileDownload(self,event):#download event from file menu above get_ftp(self)#call function to download files def OnFileLoadLocal(self,event):#local event from file menu above get_local(self)#call function to get local files def get_local(self):# display local files data_thing = open('c:' + os.sep + 'Starport' + os.sep + 'burth.txt','r')# open file file_data = data_thing.readline()#read first line star_list = starline(file_data)#call starline function (see top) count = 0 #set up a row counter while file_data<>'':# go until the end of file for x in range(len(star_list)): self.Birth_list.SetStringItem(count,x, star_list[x], -1) file_data = data_thing.readline() star_list = starline(file_data) count = count + 1 data_thing.close() data_thing = open('c:' + os.sep + 'Starport' + os.sep + 'carrer.txt','r') file_data = data_thing.readline() star_list = starline(file_data) count = 0 while file_data<>'': for x in range(len(star_list)): self.Carrer_list.SetStringItem(count,x, star_list[x], -1) file_data = data_thing.readline() star_list = starline(file_data) count = count + 1 data_thing.close() data_thing = open('c:' + os.sep + 'Starport' + os.sep + 'comfor.txt','r') file_data = data_thing.readline() star_list = starline(file_data) count = 0 while file_data<>'': for x in range(len(star_list)): self.CompatibilityForcast_list.SetStringItem(count,x, star_list[x], -1) file_data = data_thing.readline() star_list = starline(file_data) count = count + 1 data_thing.close() data_thing = open('c:' + os.sep + 'Starport' + os.sep + 'compatib.txt','r') file_data = data_thing.readline() star_list = starline(file_data) count = 0 while file_data<>'': for x in range(len(star_list)): self.Compatibility_list.SetStringItem(count,x, star_list[x], -1) file_data = data_thing.readline() star_list = starline(file_data) count = count + 1 data_thing.close() data_thing = open('c:' + os.sep + 'Starport' + os.sep + 'forcast.txt','r') file_data = data_thing.readline() star_list = starline(file_data) count = 0 while file_data<>'': for x in range(len(star_list)): self.Forcast_list.SetStringItem(count,x, star_list[x], -1) file_data = data_thing.readline() star_list = starline(file_data) count = count + 1 data_thing.close() data_thing = open('c:' + os.sep + 'Starport' + os.sep + 'relocat.txt','r') file_data = data_thing.readline() star_list = starline(file_data) count = 0 while file_data<>'': for x in range(len(star_list)): self.Relocation_list.SetStringItem(count,x, star_list[x], -1) file_data = data_thing.readline() star_list = starline(file_data) count = count + 1 data_thing.close() data_thing = open('c:' + os.sep + 'Starport' + os.sep + 'starport.txt','r') file_data = data_thing.readline() star_list = starline(file_data) count = 0 while file_data<>'': for x in range(len(star_list)): self.Starport_list.SetStringItem(count,x, star_list[x], -1) file_data = data_thing.readline() star_list = starline(file_data) count = count + 1 data_thing.close() data_thing = open('c:' + os.sep + 'Starport' + os.sep + 'comments.txt','r') file_data = data_thing.readline() while file_data<>'': self.Comments_Window.WriteText(file_data) file_data = data_thing.readline() data_thing.close() def set_local_db(self):# display local files data_thing = open('c:' + os.sep + 'Starport' + os.sep + 'burth.txt','r')# open file file_data = data_thing.readline()#read first line star_list = starline(file_data)#call starline function (see top) count = 0 #set up a row counter while file_data<>'':# go until the end of file Starport_vw.append(Name = star_list[0],Birthday = star_list[1],Time = star_list[2],AMPM = star_list[3],City = star_list[4],State = star_list[5],Countries = star_list[6],Province = star_list[7],name2 = '',birthday2 = '',time2 = '',AMPM2 = '',city2 = '',state2 = '',countrie2 = '',province2 = '',Email = star_list[8],BillingName = star_list[9],BillingEmail = star_list[10],Comments = star_list[11],StartTime = '',EndTime = '',NewCity = '',NewState = '',NewCountrie = '',NewProvince = '',ReportName = 'Birth',Sex = '',Preference = '') Starport_db.commit() for x in range(len(star_list)): self.Birth_list.SetStringItem(count,x, star_list[x], -1) file_data = data_thing.readline() star_list = starline(file_data) count = count + 1 data_thing.close() data_thing = open('c:' + os.sep + 'Starport' + os.sep + 'carrer.txt','r') file_data = data_thing.readline() star_list = starline(file_data) count = 0 while file_data<>'': Starport_vw.append(Name = star_list[0],Birthday = star_list[1],Time = star_list[2],AMPM = star_list[3],City = star_list[4],State = star_list[5],Countries = star_list[6],Province = star_list[7],name2 = '',birthday2 = '',time2 = '',AMPM2 = '',city2 = '',state2 = '',countrie2 = '',province2 = '',Email = star_list[8],BillingName = star_list[9],BillingEmail = star_list[10],Comments = star_list[11],StartTime = '',EndTime = '',NewCity = '',NewState = '',NewCountrie = '',NewProvince = '',ReportName = 'Carrer',Sex = '',Preference = '') Starport_db.commit() for x in range(len(star_list)): self.Carrer_list.SetStringItem(count,x, star_list[x], -1) file_data = data_thing.readline() star_list = starline(file_data) count = count + 1 data_thing.close() data_thing = open('c:' + os.sep + 'Starport' + os.sep + 'comfor.txt','r') file_data = data_thing.readline() star_list = starline(file_data) count = 0 while file_data<>'': Starport_vw.append(Name = star_list[0],Birthday = star_list[1],Time = star_list[2],AMPM = star_list[3],City = star_list[4],State = star_list[5],Countries = star_list[6],Province = star_list[7],name2 = star_list[8],birthday2 = star_list[9],time2 = star_list[10],AMPM2 = star_list[11],city2 = star_list[12],state2 = star_list[13],countrie2 = star_list[14],province2 = star_list[15],Email = star_list[22],BillingName = star_list[23],BillingEmail = star_list[24],Comments = star_list[25],StartTime = star_list[16],EndTime = star_list[17],NewCity = star_list[18],NewState = star_list[19],NewCountrie = star_list[20],NewProvince = star_list[21],ReportName = 'Compatibility Forcast',Sex = '',Preference = '') Starport_db.commit() for x in range(len(star_list)): self.CompatibilityForcast_list.SetStringItem(count,x, star_list[x], -1) file_data = data_thing.readline() star_list = starline(file_data) count = count + 1 data_thing.close() data_thing = open('c:' + os.sep + 'Starport' + os.sep + 'compatib.txt','r') file_data = data_thing.readline() star_list = starline(file_data) count = 0 while file_data<>'': Starport_vw.append(Name = star_list[0],Birthday = star_list[1],Time = star_list[2],AMPM = star_list[3],City = star_list[4],State = star_list[5],Countries = star_list[6],Province = star_list[7],name2 = star_list[8],birthday2 = star_list[9],time2 = star_list[10],AMPM2 = star_list[11],city2 = star_list[12],state2 = star_list[13],countrie2 = star_list[14],province2 = star_list[15],Email = star_list[16],BillingName = star_list[17],BillingEmail = star_list[18],Comments = star_list[19],StartTime = '',EndTime = '',NewCity = '',NewState = '',NewCountrie = '',NewProvince = '',ReportName = 'Compatibility Forcast',Sex = '',Preference = '') Starport_db.commit() for x in range(len(star_list)): self.Compatibility_list.SetStringItem(count,x, star_list[x], -1) file_data = data_thing.readline() star_list = starline(file_data) count = count + 1 data_thing.close() data_thing = open('c:' + os.sep + 'Starport' + os.sep + 'forcast.txt','r') file_data = data_thing.readline() star_list = starline(file_data) count = 0 while file_data<>'': Starport_vw.append(Name = star_list[0],Birthday = star_list[1],Time = star_list[2],AMPM = star_list[3],City = star_list[4],State = star_list[5],Countries = star_list[6],Province = star_list[7],name2 = '',birthday2 = '',time2 = '',AMPM2 = '',city2 = '',state2 = '',countrie2 = '',province2 = '',Email = star_list[14],BillingName = star_list[15],BillingEmail = star_list[16],Comments = star_list[17],StartTime = star_list[8],EndTime = star_list[9],NewCity = star_list[10],NewState = star_list[11],NewCountrie = star_list[12],NewProvince = star_list[13],ReportName = 'Forcast',Sex = '',Preference = '') Starport_db.commit() for x in range(len(star_list)): self.Forcast_list.SetStringItem(count,x, star_list[x], -1) file_data = data_thing.readline() star_list = starline(file_data) count = count + 1 data_thing.close() data_thing = open('c:' + os.sep + 'Starport' + os.sep + 'relocat.txt','r') file_data = data_thing.readline() star_list = starline(file_data) count = 0 while file_data<>'': Starport_vw.append(Name = star_list[0],Birthday = star_list[1],Time = star_list[2],AMPM = star_list[3],City = star_list[4],State = star_list[5],Countries = star_list[6],Province = star_list[7],name2 = '',birthday2 = '',time2 = '',AMPM2 = '',city2 = '',state2 = '',countrie2 = '',province2 = '',Email = star_list[12],BillingName = star_list[13],BillingEmail = star_list[14],Comments = star_list[15],StartTime = '',EndTime = '',NewCity = star_list[8],NewState = star_list[9],NewCountrie = star_list[10],NewProvince = star_list[11],ReportName = 'Relocation',Sex = '',Preference = '') Starport_db.commit() for x in range(len(star_list)): self.Relocation_list.SetStringItem(count,x, star_list[x], -1) file_data = data_thing.readline() star_list = starline(file_data) count = count + 1 data_thing.close() data_thing = open('c:' + os.sep + 'Starport' + os.sep + 'starport.txt','r') file_data = data_thing.readline() star_list = starline(file_data) count = 0 while file_data<>'': Starport_vw.append(Name = star_list[0],Birthday = star_list[1],Time = star_list[2],AMPM = star_list[3],City = star_list[4],State = star_list[5],Countries = star_list[6],Province = star_list[7],name2 = '',birthday2 = '',time2 = '',AMPM2 = '',city2 = '',state2 = '',countrie2 = '',province2 = '',Email = star_list[10],BillingName = '',BillingEmail = '',Comments = star_list[11],StartTime = '',EndTime = '',NewCity = '',NewState = '',NewCountrie = '',NewProvince = '',ReportName = 'Starport Entry',Sex = star_list[8],Preference = star_list[9]) Starport_db.commit() for x in range(len(star_list)): self.Starport_list.SetStringItem(count,x, star_list[x], -1) file_data = data_thing.readline() star_list = starline(file_data) count = count + 1 data_thing.close() data_thing = open('c:' + os.sep + 'Starport' + os.sep + 'comments.txt','r') file_data = data_thing.readline() while file_data<>'': Starport_vw.append(Name = 'Comments',Birthday = '',Time = '',AMPM = '',City = '',State = '',Countries = '',Province = '',name2 = '',birthday2 = '',time2 = '',AMPM2 = '',city2 = '',state2 = '',countrie2 = '',province2 = '',Email = '',BillingName = '',BillingEmail = '',Comments = file_data,StartTime = '',EndTime = '',NewCity = '',NewState = '',NewCountrie = '',NewProvince = '',ReportName = '',Sex = '',Preference = '') Starport_db.commit() self.Comments_Window.WriteText(file_data) file_data = data_thing.readline() data_thing.close() #--------------------------------------------------------------------------- def get_ftp(self):#function to download files, first start a progress dialog dlg = wxProgressDialog("Downloading Starport Report Files","Birth Reports",8,self,wxPD_CAN_ABORT | wxPD_APP_MODAL) starsite = FTP('starport86331.htmlplanet.com','francesca1','conly')# open the site, starsite.retrbinary('RETR burth.txt',open('c:' + os.sep + 'Starport' + os.sep + 'burth.txt','w+').write) dlg.Update(0, "Career Report")# reteve file , write into local file , update dialog starsite.retrbinary('RETR carrer.txt',open('c:' + os.sep + 'Starport' + os.sep + 'carrer.txt','w+').write) dlg.Update(1, "Compatibility Forcast Report") starsite.retrbinary('RETR comfor.txt',open('c:' + os.sep + 'Starport' + os.sep + 'comfor.txt','w+').write) dlg.Update(2, "Compatibility Report") starsite.retrbinary('RETR compatib.txt',open('c:' + os.sep + 'Starport' + os.sep + 'compatib.txt','w+').write) dlg.Update(3, "Forcast Report") starsite.retrbinary('RETR forcast.txt',open('c:' + os.sep + 'Starport' + os.sep + 'forcast.txt','w+').write) dlg.Update(4, "Comments") starsite.retrbinary('RETR comments.txt',open('c:' + os.sep + 'Starport' + os.sep + 'comments.txt','w+').write) dlg.Update(5, "Emter Starport") starsite.retrbinary('RETR starport.txt',open('c:' + os.sep + 'Starport' + os.sep + 'starport.txt','w+').write) dlg.Update(6, "Relocation Report") starsite.retrbinary('RETR relocat.txt',open('c:' + os.sep + 'Starport' + os.sep + 'relocat.txt','w+').write) dlg.Update(7, "Closeing Connection") dlg.Destroy()# close the progress dialog set_local_db(self)#call the display local files routeen #------------------- #---------------------------------------------------------------------- class TomApp(wxApp):# Every wxWindows application must have a class derived from wxApp # wxWindows calls this method to initialize the application def OnInit(self):# Create an instance of our customized Frame class frame = TomFrame(NULL, -1, "Starport Online Assistant") frame.Show(true)# Tell wxWindows that this is our main window self.SetTopWindow(frame)# Return a success flag return true #--------------------------------------------------------------------------- app = TomApp(0)# Create an instance of the application class app.MainLoop()# Tell it to start processing events del Starport_db