def filed1(self, name,filepath): idee = self.id c = mehar1.Client(self.id, self, self.port) f1=c.calid(name) #print f1 xxx = self.suitable("a", self.id, f1, self.id, name,self.port,self.host) #print xxx c.run(xxx,self,filepath)
def upload(self,fileName): c2 = mehar1.Client(self.id, self,self.port) lo=c2.calid(fileName) if int(self.id)==int(self.finger[0]["id"]): with open("esoteric"+str(self.id)+".csv","a") as f: print "file opened" f.write(fileName+","+"H\n") f.write(fileName+","+"NH"+","+str(lo)+","+str(self.port)+","+str(self.id)+","+str(self.host)+"\n") print "written" f.close() else: self.filed(fileName,"abc")
def filed(self, name,filepath): idee = self.id with open("esoteric"+str(idee)+".csv","a") as f: print "file opened" f.write(name+","+"H\n") print "written" f.close() c = mehar1.Client(self.id, self, self.port) f1=c.calid(name) #print f1 xxx = self.suitable("a", self.id, f1, self.id, name,self.port,self.host) #print xxx c.run(xxx,self,filepath)
def basicGUI(self,S): '''print "dakbhklgligb" panel=wx.Panel(self) menuBar=wx.MenuBar() fileButton=wx.Menu() editButton=wx.Menu() exitItem=fileButton.Append(wx.ID_EXIT,'Exit','status msg...') #exitItem.SetBitmap(wx.Bitmap("gfvgfj.png")) fileButton.AppendItem(exitItem) menuBar.Append(fileButton,'File') menuBar.Append(editButton,'Edit') self.SetMenuBar(menuBar) self.Bind(wx.EVT_MENU,self.Quit,exitItem)''' while True: chooseOneBox=wx.SingleChoiceDialog(None,'Please select one option from below', 'choice',['add a new file','download a file']) option=[] if chooseOneBox.ShowModal()==wx.ID_OK: option=chooseOneBox.GetStringSelection() if chooseOneBox.ShowModal()==wx.ID_CANCEL: break if option=="add a new file": nameBox=wx.TextEntryDialog(None,'Please enter the name of file you wish to add','welcome') if nameBox.ShowModal()==wx.ID_OK: fileName=nameBox.GetValue() '''s=socket.socket() host='192.168.43.148' port=1776 s.connect((host,port)) s.send('161') if s.recv(100)=="ok": s.send(fileName) s.close()''' #fileName=nameBox.GetValue() #S=Node(a,b,c) c2 = mehar1.Client(S.id, S,S.port) lo=c2.calid(fileName) if int(S.id)==int(S.finger[0]["id"]): with open("esoteric"+str(S.id)+".csv","a") as f: print "file opened" f.write(fileName+","+"H\n") f.write(fileName+","+"NH"+","+str(S.id)+","+str(S.port)+","+str(lo)+","+str(S.host)+"\n") print "written" f.close() else: S.filed(fileName) if option=="download a file": #nameBox1=wx.TextEntryDialog(None,'Please enter the name of file you wish to download','welcome') #if nameBox1.ShowModal()==wx.ID_OK: #fileName1=nameBox1.GetValue() '''s=socket.socket() host='192.168.43.148' port=1776 s.connect((host,port)) s.send('162') fs = s.recv(1024) listp=fs.split("_")''' '''j = 0 for i in listn: listp[j] = i['filename'] j = j print listp''' #s.close() '''app=wx.App()
def handleclient3(a): #print "handleclient" if int(self.id)!=int(self.finger[0]["id"]): c1=mehar1.Client(self.id,self,self.port) c1.update(self.finger[0]["port"],self.id,self.finger[0]["id"],self.finger[0]["host"])
def download(self,fileName,filepath): c=mehar1.Client(self.id, self,self.port) c.run3(fileName,self,filepath)