Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
MRTamalampudi authored Feb 14, 2022
0 parents commit 5184486
Show file tree
Hide file tree
Showing 48 changed files with 1,837 additions and 0 deletions.
Binary file added Ready to go/662632-iiit.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __pycache__/class_receive.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/class_send.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/send.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/ui_receive.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/ui_send.cpython-39.pyc
Binary file not shown.
70 changes: 70 additions & 0 deletions class_receive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import json
import socket
from ui_receive import Ui_MainWindow
filer=[]
class receive:
def __init__(self):
self.filecount=0
self.filename="filename"
self.filepercent="0%"
self.complete=1
def estcon(self,ip):
self.s = socket.socket()
self.s.connect(("127.0.0.1",60323))


def recievelist(self,file):

jdata=json.loads(self.s.recv(1024).decode())
filearray=jdata.get('filenames')
for i in filearray:
file.append(i)

def receivefiledetails(self):
jdata = json.loads(self.s.recv(1024).decode())
filenames = jdata.get('filenames')
return filenames

def receiveFile(self, filename):
self.filepercent="0%"
self.filename=filename[0]
buffc=0
buff = 2 ** 20
file = open("Received Files/" + filename[0], 'wb')
filesize = filename[1]
# ----------------------------------------------------
# if file size is less than buff size
if buff > filesize:
rbytes = self.s.recv(filesize)
file.write(rbytes)
self.filepercent="100%"
return
# -----------------------------------------------------
# if file size is greater than buff
for i in range(filesize // buff):
buffc=buffc+buff
rbytes = self.s.recv(buff)
file.write(rbytes)
self.filepercent=str("%.2f"%((buffc/filesize)*100))+"%"
self.filepercent = "100%"
rbytes = self.s.recv(filesize % buff)

file.write(rbytes)

return
# ------------------------------------------------------

def receive1(self,filename):
for i in filename:
self.receiveFile(i)
self.filecount = self.filecount + 1
self.filename="All Fragments are assembled"
self.filepercent=""
self.complete = 0

# if __name__ == "__main__":
# a = receive()
# a.estcon("127.0.0.1")
# filename=a.receivefiledetails()
# print(filename)
# a.receive1(filename)
52 changes: 52 additions & 0 deletions class_send.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import socket
import json
import os
import threading

filesarray =os.listdir("Ready to go/")
class send:
def __init__(self):
self.filesent="Files Sent: 00"
self.complete=1

def estcon(self):
self.s = socket.socket()
port = 60323
self.s.bind(('', port))
self.s.listen(5)
self.connection, address = self.s.accept()

def sendlist(self,file):
self.connection.send(json.dumps({"filenames":file}).encode())


def filenameextractor(self, filesarray):
filenamesarray = []
for i in range(len(filesarray)):
filenamesarray.append([os.path.split(filesarray[i])[1], os.path.getsize("Ready to go/"+filesarray[i])])
self.connection.send(json.dumps({"filenames": filenamesarray}).encode())

def sendfile(self, filepath):
buff = 2 ** 20
file = open("Ready to go/"+filepath, 'rb')
re = file.read(buff)
while len(re):
self.connection.send(re)
re = file.read(buff)
# print(filepath)
return
def sendfiles(self,filesarray):
count=0
for i in filesarray:
self.sendfile(i)
count=count+1
self.filesent="Files Sent: "+str(count)
self.filesent="All Fragments are Sent\nYou can close now"
self.complete=0
self.connection.close()

# if __name__ == "__main__":
# a=send()
# a.estcon()
# a.filenameextractor(filesarray)
# a.sendfiles(filesarray)
150 changes: 150 additions & 0 deletions filereceive.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>900</width>
<height>675</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>900</width>
<height>675</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>main bg.svg</pixmap>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>45</x>
<y>45</y>
<width>112</width>
<height>13</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>filereceive/SVG/filesreceived.svg</pixmap>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>370</x>
<y>230</y>
<width>160</width>
<height>214</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>filereceive/SVG/filesvg.svg</pixmap>
</property>
</widget>
<widget class="QLabel" name="filename">
<property name="geometry">
<rect>
<x>0</x>
<y>458</y>
<width>900</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<family>SF Pro Display</family>
<pointsize>12</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:&quot;#dddddd&quot;</string>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="filecount">
<property name="geometry">
<rect>
<x>160</x>
<y>35</y>
<width>100</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<family>SF Pro Display</family>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:&quot;#dddddd&quot;</string>
</property>
<property name="text">
<string>0/10</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="filepercent">
<property name="geometry">
<rect>
<x>0</x>
<y>490</y>
<width>900</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<family>SF Pro Display</family>
<pointsize>10</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:&quot;#dddddd&quot;</string>
</property>
<property name="text">
<string>30%</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>
Loading

0 comments on commit 5184486

Please sign in to comment.