-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.0
- Loading branch information
Showing
145 changed files
with
1,752 additions
and
123 deletions.
There are no files selected for viewing
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
File renamed without changes.
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,5 @@ | ||
#ĂÜÂë | ||
pwd=pw | ||
#´Ťľ˝Äĸö¡žś | ||
v0.3.zip=./ReceiveFile/ | ||
v0.3.exe=./ReceiveFile/ |
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,31 @@ | ||
# coding=utf-8 | ||
import socket as s | ||
from urlparse import urlparse | ||
|
||
|
||
def getUrl(url): | ||
# 通过socket请求url | ||
url = urlparse(url) | ||
host = url.netloc | ||
path = url.path | ||
if path == '': | ||
path = '/' | ||
# 建立socket链接 | ||
client = s.socket(s.AF_INET, s.SOCK_STREAM) | ||
client.connect((host, 80)) | ||
|
||
client.send('GET {} HTTP/1.1\r\nHost:{}\r\nConnection:close\r\n\r\n'.format(path, host).encode('utf-8')) | ||
data = b'' | ||
while True: | ||
# 一次获取多少数据 | ||
d = client.recv(1024) | ||
if d: | ||
data += d | ||
else: | ||
break | ||
data = data.decode('utf-8') | ||
print(data) | ||
client.close() | ||
|
||
if __name__ == '__main__': | ||
getUrl('http://www.baidu.com') |
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,14 @@ | ||
# coding=utf-8 | ||
import socket | ||
|
||
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
server.bind(('0.0.0.0', 8000)) | ||
server.listen(10) | ||
sock, addr = server.accept() | ||
|
||
while True: | ||
data = sock.recv(1024) | ||
print(data.decode('utf-8')) | ||
returnData = raw_input() | ||
sock.send(returnData.encode('utf-8')) | ||
|
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,11 @@ | ||
# coding=utf-8 | ||
import socket | ||
|
||
|
||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
client.connect(('127.0.0.1', 8000)) | ||
f = client.makefile(mode='r') | ||
while True: | ||
line = f.readline() | ||
f.write(line) | ||
|
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,100 @@ | ||
# coding=utf-8 | ||
import re | ||
import socket | ||
import threading | ||
import time | ||
import sys | ||
import os | ||
import struct | ||
|
||
import re | ||
import os | ||
import tempfile | ||
|
||
|
||
def socket_service(): | ||
try: | ||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | ||
s.bind(('127.0.0.1', 9000)) | ||
s.listen(10) | ||
except socket.error as msg: | ||
print(msg) | ||
sys.exit(1) | ||
print('Waiting client connection...') | ||
while 1: | ||
conn, addr = s.accept() | ||
t = threading.Thread(target=deal_data, args=(conn, addr)) | ||
t.start() | ||
|
||
|
||
def deal_data(conn, addr): | ||
print('Accept new connection from {0}'.format(addr)) | ||
# conn.settimeout(500) | ||
conn.send(b'Hi, Welcome to the server!') | ||
while 1: | ||
fileinfo_size = struct.calcsize('128si2s') | ||
buf = conn.recv(fileinfo_size) | ||
if buf: | ||
filename, filesize, pwd = struct.unpack('128si2s', buf) | ||
print("pwd : " + bytes.decode(pwd)) | ||
# 判定密码是否正确 | ||
file_path = './test.properties' | ||
property = Properties(file_path) # 读取文件 | ||
if property.get("pwd") == bytes.decode(pwd): | ||
print("password validate success!") | ||
else: | ||
print("password validate error") | ||
break | ||
# 删除byte转为str后的\x00 用strip也可以 | ||
newFileName = bytes.decode(filename).rstrip('\x00') | ||
# 得到文件路径前缀 | ||
dirPrefix = property.get(newFileName) | ||
if dirPrefix == None or dirPrefix == "": | ||
dirPrefix = property.get("defaultDir") | ||
new_filename = os.path.join(dirPrefix, '' + newFileName) | ||
print('file new name is {0}, filesize if {1}'.format(new_filename, filesize)) | ||
|
||
recvd_size = 0 # 定义已接收文件的大小 | ||
fp = open(new_filename, 'wb') | ||
print('start receiving...') | ||
while not recvd_size == filesize: | ||
if filesize - recvd_size > 1024: | ||
data = conn.recv(1024) | ||
recvd_size += len(data) | ||
else: | ||
data = conn.recv(filesize - recvd_size) | ||
recvd_size = filesize | ||
fp.write(data) | ||
fp.close() | ||
print('end receive...') | ||
conn.close() | ||
break | ||
|
||
|
||
class Properties: | ||
def __init__(self, file_name): | ||
self.file_name = file_name | ||
self.properties = {} | ||
try: | ||
fopen = open(self.file_name, 'r') | ||
for line in fopen: | ||
line = line.strip() | ||
if line.find('=') > 0 and not line.startswith('#'): | ||
strs = line.split('=') | ||
self.properties[strs[0].strip()] = strs[1].strip() | ||
except Exception: | ||
# raise Exception | ||
print("read file exception ...") | ||
else: | ||
fopen.close() | ||
|
||
def get(self, key, default_value=''): | ||
if key in self.properties: | ||
return self.properties[key] | ||
return default_value | ||
|
||
|
||
|
||
if __name__ == '__main__': | ||
socket_service() |
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,39 @@ | ||
# coding=utf-8 | ||
import socket | ||
import os | ||
import sys | ||
import struct | ||
|
||
|
||
def socket_client(): | ||
try: | ||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
s.connect(('127.0.0.1', 9000)) | ||
except socket.error as msg: | ||
print(msg) | ||
sys.exit(1) | ||
print(s.recv(1024)) | ||
while 1: | ||
# filepath = input('please input file path: ') | ||
filepath = "./v0.3.zip" | ||
if os.path.isfile(filepath): | ||
# 定义定义文件信息。128s表示文件名为128bytes长,l表示一个int或log文件类型,在此为文件大小 2s 代表的是2个字节的字符串长度 | ||
# 定义文件头信息,包含文件名和文件大小 | ||
fhead = struct.pack('128si2s', bytes(os.path.basename(filepath).encode('utf-8')), os.stat(filepath).st_size, | ||
b'pw') | ||
s.send(fhead) | ||
print('client filepath: {0}'.format(filepath)) | ||
|
||
fp = open(filepath, 'rb') | ||
while 1: | ||
data = fp.read(1024) | ||
if not data: | ||
print('{0} file send over...'.format(filepath)) | ||
break | ||
s.send(data) | ||
s.close() | ||
break | ||
|
||
|
||
if __name__ == '__main__': | ||
socket_client() |
Binary file not shown.
Binary file not shown.
File renamed without changes.
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,33 @@ | ||
# -*- coding:utf-8 -*- | ||
import zipfile | ||
import shutil | ||
import os | ||
|
||
|
||
def un_zip(file_name): | ||
"""unzip zip file""" | ||
zip_file = zipfile.ZipFile(file_name) | ||
if os.path.isdir(file_name + "_files"): | ||
pass | ||
else: | ||
os.mkdir(file_name + "_files") | ||
for names in zip_file.namelist(): | ||
zip_file.extract(names, file_name + "_files/") | ||
zip_file.close() | ||
moveFile() | ||
|
||
|
||
def moveFile(): | ||
for filename in os.listdir('./testPck1.zip_files/testPck1/'): | ||
print(filename) | ||
try: | ||
os.remove('./testPck/' + filename) | ||
except: | ||
shutil.rmtree('./testPck/'+filename) | ||
pass | ||
shutil.move('./testPck1.zip_files/testPck1/' + filename, './testPck/') | ||
shutil.rmtree('./testPck1.zip_files') | ||
|
||
|
||
if __name__ == '__main__': | ||
un_zip('testPck1.zip') |
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,41 @@ | ||
# coding=utf-8 | ||
import os | ||
import time | ||
|
||
basedir = './' | ||
filelists = [] | ||
# 指定想要统计的文件类型 | ||
whitelist = ['php', 'py'] | ||
|
||
|
||
# 遍历文件, 递归遍历文件夹中的所有 | ||
def getFile(basedir): | ||
global filelists | ||
for parent, dirnames, filenames in os.walk(basedir): | ||
# for dirname in dirnames: | ||
# getFile(os.path.join(parent,dirname)) #递归 | ||
for filename in filenames: | ||
ext = filename.split('.')[-1] | ||
# 只统计指定的文件类型,略过一些log和cache文件 | ||
if ext in whitelist: | ||
filelists.append(os.path.join(parent, filename)) | ||
|
||
|
||
# 统计一个文件的行数 | ||
def countLine(fname): | ||
count = 0 | ||
for file_line in open(fname).xreadlines(): | ||
# if file_line != '' and file_line != '\n': # 过滤掉空行 | ||
count += 1 | ||
print fname + '----', count | ||
return count | ||
|
||
|
||
if __name__ == '__main__': | ||
startTime = time.clock() | ||
getFile(basedir) | ||
totalline = 0 | ||
for filelist in filelists: | ||
totalline = totalline + countLine(filelist) | ||
print '总行数:', totalline | ||
print '完成时间: %0.2f s' % (time.clock() - startTime) |
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
version=v0.1 | ||
[VERSION] | ||
version = v0.1 | ||
|
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,2 @@ | ||
[VERSION] | ||
lastest_version = v1.0 |
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,3 @@ | ||
#´«µ½Äĸö·¾¶ | ||
update.zip=./ | ||
#main.ini=./data/ |
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 |
---|---|---|
@@ -1 +1 @@ | ||
286c70300a286470310a53276e65787454696d65270a70320a5327323031392d30322d3132270a70330a7353276c6f6f7054696d65270a70340a49350a7353276d697373696f6e4964270a70350a5327303030303031270a70360a735327626f6f6b4e616d65270a70370a5327626f6f6b270a70380a7353277374617465270a70390a49310a735327697346696e697368270a7031300a4930300a7353276d697373696f6e52616e6765270a7031310a532772616e6765270a7031320a73612e | ||
286c70300a286470310a53276e65787454696d65270a70320a5327323031392d30322d3230270a70330a735327697346696e697368270a70340a4930310a7353276d697373696f6e4964270a70350a5327303030303031270a70360a735327626f6f6b4e616d65270a70370a5327626f6f6b270a70380a7353277374617465270a70390a49320a7353276d697373696f6e52616e6765270a7031300a532772616e6765270a7031310a7353276c6f6f7054696d65270a7031320a49350a73612e |
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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
{2019-02-12 22:44:52} add button has been pressed | ||
{2019-02-12 22:45:24} add button has been pressed | ||
{2019-02-12 22:45:37} edit button has been pressed | ||
{2019-02-16 18:57:33} view button has been pressed | ||
{2019-02-19 11:12:12} treeview has been double click at 000001 | ||
{2019-02-19 11:12:12} user select True | ||
{2019-02-19 11:12:13} view button has been pressed | ||
{2019-02-19 11:34:45} add button has been pressed | ||
{2019-02-19 11:34:50} edit button has been pressed | ||
{2019-02-19 13:44:37} view button has been pressed |
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 |
---|---|---|
@@ -1,6 +1,4 @@ | ||
{'|data': '', '|file': 'MissionSystem-LoadMission-decodeText', '|currentTime': '2019-02-12 22:45:24', '|wrongMessage': ''} | ||
{'|data': '', '|file': 'MissionSystem-LoadMission-decodeText', '|currentTime': '2019-02-12 22:45:24', '|wrongMessage': ''} | ||
{'|data': '', '|file': 'MissionSystem-LoadMission-decodeText', '|currentTime': '2019-02-12 22:45:24', '|wrongMessage': ''} | ||
{'|data': '', '|file': 'MissionSystem-LoadMission-decodeText', '|currentTime': '2019-02-12 22:45:24', '|wrongMessage': ''} | ||
{'|data': '', '|file': 'MissionSystem-LoadMission-decodeText', '|currentTime': '2019-02-12 22:45:24', '|wrongMessage': ''} | ||
{'|data': '', '|file': 'MissionSystem-LoadMission-decodeText', '|currentTime': '2019-02-12 22:45:24', '|wrongMessage': ''} | ||
{'|file': 'VersionControlSystem-GetNewFile-doUpdate', '|currentTime': '2019-02-19 13:09:22', '|wrongMessage': error(10061, '')} | ||
{'|file': 'VersionControlSystem-GetNewFile-doUpdate', '|currentTime': '2019-02-19 13:11:13', '|wrongMessage': error(10061, '')} | ||
{'|file': 'VersionControlSystem-GetNewFile-doUpdate', '|currentTime': '2019-02-19 13:11:27', '|wrongMessage': error(10061, '')} | ||
{'|file': 'VersionControlSystem-GetNewFile-judgeNeedUpdate', '|currentTime': '2019-02-19 13:12:32', '|wrongMessage': error(10061, '')} |
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,3 @@ | ||
# -*- coding:utf-8 -*- | ||
from src.Client.View.MainFrame import mainFrame | ||
|
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
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,10 @@ | ||
# -*- coding:utf-8 -*- | ||
from src.Server.MessageTransferSystem.VersionControlSystem import versionControl | ||
|
||
import os | ||
|
||
# 主界面 | ||
if __name__ == '__main__': | ||
versionControl.VersionControl() | ||
|
||
|
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
File renamed without changes.
Oops, something went wrong.