-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
156 lines (135 loc) · 3.2 KB
/
test.py
File metadata and controls
156 lines (135 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
"""
checked files:
obtain.py all_checked [still_complete:get_nics()]
sockops.py all_checked
fileops.py all_checked [check the issue]
integrated testing:
Finished
check with multiple nics in windows
check custom exception raise and handling in session managers
Issues:
fileops.py
Thread exception handling
Enhancments:
1.Add file control
2.Make UI
3.Access from cmd
4.Working in linux
5.Variable buff size
6.Resume incomplete download
code to complete:
bandwidth_check.py
"""
#ports explanation
#udp 10,000 server listen for request
#udp 10,001-10,010 client udp request send
#tcp 1000-1010 client-server interaction
"""
Completed integration testing on the module, working fine
"""
"""
#fileops.py [check_file,read_file,write_file]
import fileops
print(fileops.check_file("suva.mp4"))
print(fileops.check_file("suva_modified.mp4"))
readers=fileops.read_file("suva.mp4",[1,1,1],1024)
print(readers)
file_data=[]
for reader in readers:
file_data.append([])
for data in reader:
file_data[-1].append(data)
print("pointer position : ",reader.file_ptr.tell())
fileops.write_file("suva_modified.mp4",file_data)
print(fileops.check_file("suva_modified.mp4"))
--
included for verbosing in read_file
#for verbose
print("filename : ",filename)
print("ratio : ",ratio)
print("total of ratio : ",total)
print("size of file : ",size)
print("chunk : ",chunk)
for i in readers:
print("start : ",i.start)
print("end : ",i.end)
--
--output--
1
0
filename : suva.mp4
ratio : [1, 1, 1]
total of ratio : 3
size of file : 12861924
chunk : 4287308
start : 0
end : 4287308
start : 4287309
end : 8574617
start : 8574618
end : 12861924
[<fileops.read_class object at 0x7fa65e38d358>, <fileops.read_class object at 0x7fa65e38d2e8>, <fileops.read_class object at 0x7fa65d259d68>]
pointer position : 4287309
pointer position : 8574618
pointer position : 12861924
1 #File is error free
"""
"""
sockops.py [udp_send,udp_recv]
import socket
import sockops
import threading
import time
def op1(sock):
data=sockops.udp_recv(sock,1024)
print(data)
s1=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s1.bind(("127.0.0.1",500))
s2=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s2.bind(("127.0.0.1",502))
t1=threading.Thread(target=op1,args=(s2,))
t1.start()
sockops.udp_send(s1,"hello",("127.0.0.1",502))
s1.close()
s2.close()
--output--
(('127.0.0.1', 500), 'hello')
"""
"""
sockops.py [tcp_send,tcp_recv]
import socket
import sockops
import threading
import time
def op1(sock):
sock.listen(1)
print("listening")
client,addr=sock.accept()
data=sockops.tcp_recv(client,1024)
print(data)
s1=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s1.bind(("127.0.0.1",500))
s2=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s2.bind(("127.0.0.1",502))
t1=threading.Thread(target=op1,args=(s2,))
t1.start()
time.sleep(2)
s1.connect(("127.0.0.1",502))
sockops.tcp_send(s1,"hello")
s1.close()
s2.close()
--output--
listening
hello
"""
"""
obtain.py
import obtain
print(obtain.get_token())
print(obtain.get_port())
print(obtain.get_port(True))
--output--
client#2020-01-19 19:08:53.220132
1000
(<socket.socket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('0.0.0.0', 1000)>, 1000)
"""