def find_item(): form_id = request.form['ID'] _, ids = find.findItem(form_id) if len(ids)!=0: print("IDs being sent:", ids) find.writeRFIDs(ids) sendFile.sendFile() msg = find.updateDatabase() print("After updates") else: msg = "Product not found" print(msg) flash(msg) return redirect("/")
def upload_page(request): if not request.user.is_authenticated(): return HttpResponseRedirect(reverse("index")) context = {} if request.method == 'GET': return render(request, 'upload.html', context) if request.method == 'POST': uf = UserForm(request.POST, request.FILES) if uf.is_valid(): username = uf.cleaned_data['username'] uploadfile = uf.cleaned_data['uploadfile'] print uploadfile user = User() user.username = username user.uploadFile = uploadfile user.save() sendFile("upload/" + str(uploadfile)) #fp = file('/uploadFile/' + uf.cleaned_data['uploadfile'].name, 'wb') #s = uf.cleaned_data['uploadfile'].read() #fp.write(s) #fp.close() #print HttpResponse('File Uploaded') return render_to_response('upload.html', {'uf':uf})
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("8.8.8.8", 80)) ip = s.getsockname()[0] id = socket.gethostname() s.close() MainNodeIP = "10.10.2.192" node = ClientNode.ClientNode(ip, 10002, id) # node2 = ClientNode.ClientNode("127.0.0.1", 10002, id) time.sleep(1) # Do not forget to start your node! node.start() # node2.start() time.sleep(1) # Connect with another node, otherwise you do not create any network! node.connect_with_node(MainNodeIP, 10001) time.sleep(2) # Example of sending a message to the nodes (dict). node.send_to_nodes({"message": "Hi there!"}) sendFile.sendFile('test.txt') time.sleep(5) # Create here your main loop of the application node.stop() # node2.stop()
def transmitFile(self, source): sendFile.sendFile(source,self.address,self.port) print 'Dialing on port',self.port,'..' reactor.run(installSignalHandlers=0)
return motives[motive] else: raise KeyError motive = "achats" motiveCheckboxName = chooseMotiveCheckbox(motive) checkBox = driver.find_element_by_id(motiveCheckboxName) checkBox.click() generateAttestation = driver.find_element_by_id("generate-btn") generateAttestation.click() time.sleep(5) if os.path.exists(downloadPath) and len(os.listdir(downloadPath)) != 0: os.chdir(downloadPath) if len(os.listdir(os.getcwd())) == 1: os.system('mv * attestation.pdf') os.chdir(os.path.dirname(os.getcwd())) assert "No results found." not in driver.page_source driver.close() sendFile.sendFile()