-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.py
39 lines (31 loc) · 867 Bytes
/
lib.py
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
import os
class Lib(object):
@staticmethod
def extractFilename(fileName):
return fileName[fileName.rfind("/", 0, len(fileName))+1:]
@staticmethod
def check_File_Exists(fileName):
try:
size = os.stat(fileName).st_size
except:
size = 0
return size
@staticmethod
def readTextTCP(client):
text = ""
ch = client.recv(1)
while ch != b'\0':
text += ch.decode()
ch = client.recv(1)
return text
@staticmethod
def writeTextTCP(text, client):
client.send((text+"\0").encode())
@staticmethod
def getFileSizeTCP(client):
filesize = 0
try:
filesize = int(Lib.readTextTCP(client))
except:
filesize = -1
return filesize