Skip to content

Commit

Permalink
v1.0
Browse files Browse the repository at this point in the history
 v1.0
  • Loading branch information
Sniper970119 authored Feb 19, 2019
2 parents 22715ae + 20089ab commit d5acce1
Show file tree
Hide file tree
Showing 145 changed files with 1,752 additions and 123 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
(前几天参加完华为的敏捷开发的培训,本来想试试敏捷,结果好像变成原型了可还行x


比较详尽的说明请点[这里](http://www.sniper97.cn/index.php/memoryAssist/)
比较详尽的说明和更详细的开发文档请点[这里](http://www.sniper97.cn/index.php/memoryAssist/)

API帮助文档请点[这里](http://www.sniper97.cn/MemoryAssist/API)

Expand All @@ -24,7 +24,17 @@ API帮助文档请点[这里](http://www.sniper97.cn/MemoryAssist/API)

2019-2-12: 完成第二次迭代。

2019-2-12:开始第三次迭代,代码整理,增加程序鲁棒性,错误日志生成系统。
2019-2-12:开始第三次迭代,代码整理,增加程序鲁棒性,错误日志生成系统,用户行为统计功能(用于在发生错误时,将用户操作日志与错误日志对照)。

2019-2-12: 第三次迭代完成。

2019-2-12:文档整理,api生成与上传。

2019-2-15:开始第四次迭代,计划完成更新系统。更新系统独立于主系统之外,主要对主系统中的任何文件,根据服务器返回信息进行更改或添加。版本编号v1.0,是第一个发行版本。

2019-2-18: 更新索引文件以及其他相关文件的热更新完成以及整体冷更新基本完成。下一步添加更加完善的服务器端验证以及客户端更新选择。




## 动态展示
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions VerifyTec/messageTransferTest/test.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ĂÜÂë
pwd=pw
#´Ťľ˝Äĸö¡žś
v0.3.zip=./ReceiveFile/
v0.3.exe=./ReceiveFile/
31 changes: 31 additions & 0 deletions VerifyTec/messageTransferTest/test10.py
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')
14 changes: 14 additions & 0 deletions VerifyTec/messageTransferTest/test11.py
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'))

11 changes: 11 additions & 0 deletions VerifyTec/messageTransferTest/test12.py
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)

100 changes: 100 additions & 0 deletions VerifyTec/messageTransferTest/test13.py
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()
39 changes: 39 additions & 0 deletions VerifyTec/messageTransferTest/test14.py
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 added VerifyTec/messageTransferTest/v0.3.exe
Binary file not shown.
Binary file added VerifyTec/messageTransferTest/v0.3.zip
Binary file not shown.
File renamed without changes.
33 changes: 33 additions & 0 deletions VerifyTec/updateFileTest/test15.py
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')
41 changes: 41 additions & 0 deletions codeNum.py
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)
4 changes: 3 additions & 1 deletion conf/main.ini
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
version=v0.1
[VERSION]
version = v0.1

2 changes: 2 additions & 0 deletions conf/server.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[VERSION]
lastest_version = v1.0
3 changes: 3 additions & 0 deletions data/fileIndex.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#´«µ½Äĸö·¾¶
update.zip=./
#main.ini=./data/
2 changes: 1 addition & 1 deletion data/mission.dat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
286c70300a286470310a53276e65787454696d65270a70320a5327323031392d30322d3132270a70330a7353276c6f6f7054696d65270a70340a49350a7353276d697373696f6e4964270a70350a5327303030303031270a70360a735327626f6f6b4e616d65270a70370a5327626f6f6b270a70380a7353277374617465270a70390a49310a735327697346696e697368270a7031300a4930300a7353276d697373696f6e52616e6765270a7031310a532772616e6765270a7031320a73612e
286c70300a286470310a53276e65787454696d65270a70320a5327323031392d30322d3230270a70330a735327697346696e697368270a70340a4930310a7353276d697373696f6e4964270a70350a5327303030303031270a70360a735327626f6f6b4e616d65270a70370a5327626f6f6b270a70380a7353277374617465270a70390a49320a7353276d697373696f6e52616e6765270a7031300a532772616e6765270a7031310a7353276c6f6f7054696d65270a7031320a49350a73612e
7 changes: 7 additions & 0 deletions data/userAction.dat
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
10 changes: 4 additions & 6 deletions data/wrongMessage.dat
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, '')}
3 changes: 3 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding:utf-8 -*-
from src.Client.View.MainFrame import mainFrame

3 changes: 1 addition & 2 deletions mainT.py → mainC.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding:utf-8 -*-
from src.View.MainFrame import mainFrame

from src.Client.View.MainFrame import mainFrame
# 主界面
if __name__ == '__main__':
mainFrame.MainFrame()
Expand Down
10 changes: 10 additions & 0 deletions mainS.py
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()


5 changes: 2 additions & 3 deletions src/main.py → mainU.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding:utf-8 -*-
from src.View.MainFrame import mainFrame

from src.Update.VersionControlSystem import versionControl
# 主界面
if __name__ == '__main__':
mainFrame.MainFrame()
versionControl.VersionControl().handle()
# f = open('./../data/mission.dat')
# print(f.read())

Expand Down
File renamed without changes.
Loading

0 comments on commit d5acce1

Please sign in to comment.