-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5184486
Showing
48 changed files
with
1,837 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:"#dddddd"</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:"#dddddd"</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:"#dddddd"</string> | ||
</property> | ||
<property name="text"> | ||
<string>30%</string> | ||
</property> | ||
<property name="alignment"> | ||
<set>Qt::AlignCenter</set> | ||
</property> | ||
</widget> | ||
</widget> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
Oops, something went wrong.