├── .idea └── inspectionProfiles │ └── Project_Default.xml ├── LICENSE ├── MemortAssit.zip ├── MemoryAssist.spec ├── README.md ├── VerifyTec ├── __init__.py ├── messageTransferTest │ ├── __init__.py │ ├── test.properties │ ├── test10.py │ ├── test11.py │ ├── test11.spec │ ├── test12.py │ ├── test12.spec │ ├── test13.py │ └── test14.py ├── test01.py ├── test02.py ├── test03.py ├── test04.py ├── test05.py ├── test06.py ├── test07.py ├── test08.py ├── test09.py ├── test10.spec ├── test11.spec ├── test16.py ├── test17.py ├── test18.py └── updateFileTest │ ├── __init__.py │ ├── test15.py │ ├── testPck │ ├── fileOne.ini │ ├── fileOne1.ini │ ├── fileThree.ini │ ├── fileTwo.ini │ ├── fileTwo2.ini │ └── ummm │ │ └── hahaah │ │ └── ojbk.ini │ ├── testPck1.zip │ └── testPck1 │ ├── fileOne.ini │ ├── fileTwo.ini │ └── ummm │ └── hahaah │ └── ojbk.ini ├── codeNum.py ├── conf ├── main.ini ├── mission.ini ├── recitation.ini ├── server.ini └── user.ini ├── data ├── bkup │ └── mbk │ │ ├── 20190201.dat │ │ ├── 20190202.dat │ │ ├── 20190203...dat │ │ ├── 20190203..dat │ │ ├── 20190203.dat │ │ ├── 20190204..dat │ │ └── 20190204.dat ├── fileIndex.properties ├── mission.dat ├── recitation.dat ├── userAction.dat └── wrongMessage.dat ├── icon.ico ├── images ├── icon.gif ├── icon.ico ├── icon.jpg ├── search.gif └── search.jpg ├── main.py ├── mainC.py ├── mainC.spec ├── mainS.py ├── mainS.spec ├── mainU.py ├── mainU.spec ├── run.spec ├── showPic └── show.gif └── src ├── Client ├── Conf │ ├── __init__.py │ ├── config.py │ └── language.py ├── MessageTransferSystem │ ├── MarkUser │ │ ├── __init__.py │ │ └── markUser.py │ ├── VersionControl │ │ ├── __init__.py │ │ └── versionControl.py │ └── __init__.py ├── MissionSystem │ ├── AddMission │ │ ├── __init__.py │ │ ├── addMission.py │ │ └── tools │ │ │ ├── __init__.py │ │ │ ├── addMissionToList.py │ │ │ ├── loadConfigFile.py │ │ │ └── saveConfigFile.py │ ├── BackupMission │ │ ├── __init__.py │ │ ├── backupMission.py │ │ └── tools │ │ │ ├── __init__.py │ │ │ ├── backupFile.py │ │ │ ├── backupManage.py │ │ │ └── chooseRecoverFile.py │ ├── EditMission │ │ ├── __init__.py │ │ ├── editMission.py │ │ └── tools │ │ │ ├── __init__.py │ │ │ ├── computeNextMissionTime.py │ │ │ ├── editMissionList.py │ │ │ ├── finishMission.py │ │ │ └── removeMission.py │ ├── __init__.py │ └── missionSystem.py ├── SearchSystem │ ├── SearchMission │ │ ├── __init__.py │ │ └── searchMission.py │ ├── TranslateTools │ │ ├── __init__.py │ │ └── translateInWebXml.py │ ├── __init__.py │ └── searchSystem.py ├── SystemTools │ ├── ChangeLanguage │ │ ├── __init__.py │ │ └── changeLanguage.py │ ├── ConfFileRead │ │ ├── Tools │ │ │ ├── __init__.py │ │ │ ├── readConfigFile.py │ │ │ └── saveConfigFile.py │ │ ├── __init__.py │ │ └── configFileRead.py │ ├── LoadFiles │ │ ├── __init__.py │ │ ├── loadFiles.py │ │ └── tools │ │ │ ├── __init__.py │ │ │ ├── decodeText.py │ │ │ └── loadFiles.py │ ├── SaveFiles │ │ ├── __init__.py │ │ ├── saveFiles.py │ │ └── tools │ │ │ ├── __init__.py │ │ │ ├── encodeText.py │ │ │ └── saveToFiles.py │ └── __init__.py ├── TranslateSystem │ ├── Tools │ │ ├── __init__.py │ │ └── translateInBaidu.py │ ├── __init__.py │ └── translateSystem.py ├── VersionControlSystem │ ├── GetNewFile │ │ ├── Tools │ │ │ ├── __init__.py │ │ │ ├── getIndexFile.py │ │ │ └── getUpdateFile.py │ │ ├── __init__.py │ │ └── doUpdate.py │ ├── JudgeNeedUpdate │ │ ├── __init__.py │ │ └── judgeNeedUpdate.py │ ├── __init__.py │ └── versionControl.py ├── View │ ├── MainFrame │ │ ├── ReserveFrame │ │ │ ├── __init__.py │ │ │ └── reserveFrame.py │ │ ├── SearchAndSettingFrame │ │ │ ├── ShowSearchResultTools │ │ │ │ ├── __init__.py │ │ │ │ ├── showMission.py │ │ │ │ └── showWord.py │ │ │ ├── ShowSettingTools │ │ │ │ ├── Util │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── showCN.py │ │ │ │ │ └── showEN.py │ │ │ │ ├── __init__.py │ │ │ │ └── showEdit.py │ │ │ ├── __init__.py │ │ │ └── searchAndSettingFrame.py │ │ ├── TabFrame │ │ │ ├── FirstTabFrame │ │ │ │ ├── __init__.py │ │ │ │ ├── firstTabFrame.py │ │ │ │ ├── messageFrame.py │ │ │ │ ├── selectFrame.py │ │ │ │ └── subWindows │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── addWindow.py │ │ │ │ │ ├── editWindow.py │ │ │ │ │ └── viewAllWindow.py │ │ │ ├── SecondTabFrame │ │ │ │ ├── __init__.py │ │ │ │ └── translateFrame.py │ │ │ ├── ThirdFrame │ │ │ │ ├── __init__.py │ │ │ │ ├── messageFrame.py │ │ │ │ ├── selectFrame.py │ │ │ │ ├── subWindows │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── addWindow.py │ │ │ │ │ ├── editWindow.py │ │ │ │ │ └── viewAllWindow.py │ │ │ │ └── thirdTabFrame.py │ │ │ ├── __init__.py │ │ │ └── tabFrame.py │ │ ├── __init__.py │ │ └── mainFrame.py │ └── __init__.py ├── __init__.py └── recitationSystem │ ├── __init__.py │ ├── addRecitation │ ├── __init__.py │ ├── addRecitation.py │ └── tools │ │ ├── __init__.py │ │ ├── addRecitationToList.py │ │ ├── loadConfigFile.py │ │ └── saveConfigFile.py │ ├── editRecitation │ ├── __init__.py │ ├── editRecitation.py │ └── tools │ │ ├── __init__.py │ │ ├── editRecitationList.py │ │ └── removeRecitation.py │ └── recitationSystem.py ├── Server ├── Conf │ ├── __init__.py │ └── config.py ├── DatabaseSystem │ ├── Tools │ │ ├── __init__.py │ │ ├── areaStatistics.py │ │ ├── delWeeklyData.py │ │ ├── editUserCodeAndLogTime.py │ │ ├── returnAllCount.py │ │ ├── returnAllLog.py │ │ └── saveNewUserCodeToDatabase.py │ ├── __init__.py │ └── databaseSystem.py ├── MessageReportSystem │ ├── Tools │ │ ├── __init__.py │ │ └── sendEmail.py │ ├── __init__.py │ └── messageReportSystem.py ├── MessageTransferSystem │ ├── MarkUserSystem │ │ ├── Tools │ │ │ └── __init__.py │ │ ├── __init__.py │ │ └── markUserSystem.py │ ├── Tools │ │ ├── CodeHandle │ │ │ ├── Code100.py │ │ │ ├── Code101.py │ │ │ ├── Code102.py │ │ │ └── __init__.py │ │ ├── __init__.py │ │ └── handleReceiveCode.py │ ├── VersionControlSystem │ │ ├── Tools │ │ │ ├── __init__.py │ │ │ ├── returnLastestVersion.py │ │ │ ├── sendInexFile.py │ │ │ └── sendUpdateFile.py │ │ ├── __init__.py │ │ └── versionControl.py │ └── __init__.py ├── SystemTools │ ├── ConfFileRead │ │ ├── Tools │ │ │ ├── __init__.py │ │ │ ├── readConfigFile.py │ │ │ └── saveConfigFile.py │ │ ├── __init__.py │ │ └── configFileRead.py │ └── __init__.py └── __init__.py ├── Update ├── Conf │ ├── __init__.py │ └── config.py ├── SystemTools │ ├── ConfFileRead │ │ ├── Tools │ │ │ ├── __init__.py │ │ │ ├── readConfigFile.py │ │ │ └── saveConfigFile.py │ │ ├── __init__.py │ │ └── configFileRead.py │ └── __init__.py ├── VersionControlSystem │ ├── GetNewFile │ │ ├── Tools │ │ │ ├── __init__.py │ │ │ ├── getIndexFile.py │ │ │ ├── getUpdateFile.py │ │ │ └── unZipFile.py │ │ ├── __init__.py │ │ └── doUpdate.py │ ├── JudgeNeedUpdate │ │ ├── __init__.py │ │ └── judgeNeedUpdate.py │ ├── __init__.py │ └── versionControl.py └── __init__.py └── __init__.py /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Yu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MemortAssit.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/MemortAssit.zip -------------------------------------------------------------------------------- /MemoryAssist.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python -*- 2 | 3 | block_cipher = None 4 | 5 | 6 | a = Analysis(['mainU.py'], 7 | pathex=['F:\\python17\\pythonPro\\MemortAssit'], 8 | binaries=[], 9 | datas=[], 10 | hiddenimports=[], 11 | hookspath=[], 12 | runtime_hooks=[], 13 | excludes=[], 14 | win_no_prefer_redirects=False, 15 | win_private_assemblies=False, 16 | cipher=block_cipher, 17 | noarchive=False) 18 | pyz = PYZ(a.pure, a.zipped_data, 19 | cipher=block_cipher) 20 | exe = EXE(pyz, 21 | a.scripts, 22 | a.binaries, 23 | a.zipfiles, 24 | a.datas, 25 | [], 26 | name='MemoryAssist', 27 | debug=False, 28 | bootloader_ignore_signals=False, 29 | strip=False, 30 | upx=True, 31 | runtime_tmpdir=None, 32 | console=False , icon='images\\icon.ico') 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sniper 2 | 3 | *免责声明:仅供研究使用,请勿进行非法用途。 4 | 5 | 6 | 996.icu 7 | [![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE) 8 | 9 | 10 | ## 环境要求 11 | 12 | 1.python 3 13 | 14 | 15 | (前几天参加完华为的敏捷开发的培训,本来想试试敏捷,结果好像变成原型了可还行x 16 | 17 | 18 | 比较详尽的说明和更详细的开发文档请点[这里](http://www.sniper97.cn/index.php/memoryAssist/) 19 | 20 | API帮助文档请点[这里](http://www.sniper97.cn/MemoryAssist/API) 21 | 22 | 2019-2-1:技术验证阶段,主要测试GUI页面是否能达到预期要求。 23 | 24 | 2019-2-2:初步完成GUI部分框架,尽力改回敏捷模型,先开发一部分功能 25 | 26 | 2019-2-6: 第一次迭代完成。 27 | 28 | 2019-2-10: 开始第二次迭代,计划完成搜索系统和翻译系统。 29 | 30 | 2019-2-12: 完成第二次迭代。 31 | 32 | 2019-2-12:开始第三次迭代,代码整理,增加程序鲁棒性,错误日志生成系统,用户行为统计功能(用于在发生错误时,将用户操作日志与错误日志对照)。 33 | 34 | 2019-2-12: 第三次迭代完成。 35 | 36 | 2019-2-12:文档整理,api生成与上传。 37 | 38 | 2019-2-15:开始第四次迭代,计划完成更新系统。更新系统独立于主系统之外,主要对主系统中的任何文件,根据服务器返回信息进行更改或添加。版本编号v1.0,是第一个发行版本。 39 | 40 | 2019-2-18: 更新索引文件以及其他相关文件的热更新完成以及整体冷更新基本完成。下一步添加更加完善的服务器端验证以及客户端更新选择。 41 | 42 | 2019-2-19:完成第四次迭代。客户端与服务器端消息已经文件互传完成。可以进行程序热更新。v1.0发行。同时暂缓迭代,只进行小规模bug修复。复试完成下面的迭代~ 43 | 44 | 2019-2-20:v1.0.1发布。服务器端已经在服务器上运行,可以进行远程自动更新与文件互传。 45 | 46 | 2019-2-21:v1.0.2发布。修复服务器可能返回错误的版本号的问题。 47 | 48 | 2019-3-05:开始第五次迭代。计划完成服务器端对用户的唯一标识,方便以后的个性化服务。 49 | 50 | 2019-3-11:完成第五次迭代。完成服务器对客户端的标识、登录数据统计以及定时的邮件回报。 51 | 52 | 2019-3-28: 开始修复服务器端wq已知bug。 53 | 54 | 2019-3-28: 修复已知bug,开始第六次迭代。计划完成软件设置模块,完成语言切换。 55 | 56 | 2019-4-07: 完成第六次迭代。完成客户端语言中英切换。 57 | 58 | 2019-4-07: 开始第七次迭代。添加提问模块。用户添加问题后会根据问题权值(软件争取做到自适应)来对用户进行提问(例如提问政治背诵等)。 59 | 同时由于比较忙,可能会显著延长迭代周期。 60 | 61 | 2019-5-20: 完成第七次迭代。添加了提问模块,优化显示,修复服务器端邮箱授权码被盗用后导致不能再发送邮件的问题。 62 | 63 | ## 动态展示(v0.2) 64 | 65 | ![gif展示](https://github.com/Sniper970119/MemoryAssistInPython/blob/master/showPic/show.gif) 66 | -------------------------------------------------------------------------------- /VerifyTec/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/VerifyTec/__init__.py -------------------------------------------------------------------------------- /VerifyTec/messageTransferTest/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/VerifyTec/messageTransferTest/__init__.py -------------------------------------------------------------------------------- /VerifyTec/messageTransferTest/test.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/VerifyTec/messageTransferTest/test.properties -------------------------------------------------------------------------------- /VerifyTec/messageTransferTest/test10.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | import socket as s 3 | from urlparse import urlparse 4 | 5 | 6 | def getUrl(url): 7 | # 通过socket请求url 8 | url = urlparse(url) 9 | host = url.netloc 10 | path = url.path 11 | if path == '': 12 | path = '/' 13 | # 建立socket链接 14 | client = s.socket(s.AF_INET, s.SOCK_STREAM) 15 | client.connect(('140.143.147.128', 9000)) 16 | 17 | client.send('100'.encode('utf-8')) 18 | data = b'' 19 | while True: 20 | # 一次获取多少数据 21 | d = client.recv(1024) 22 | if d: 23 | data += d 24 | else: 25 | break 26 | data = data.decode('utf-8') 27 | print(data) 28 | client.close() 29 | 30 | if __name__ == '__main__': 31 | getUrl('http://www.baidu.com') -------------------------------------------------------------------------------- /VerifyTec/messageTransferTest/test11.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | import socket 3 | 4 | server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 5 | server.bind(('0.0.0.0', 8000)) 6 | server.listen(10) 7 | sock, addr = server.accept() 8 | while True: 9 | data = sock.recv(1024) 10 | data = str(addr) + ':' + str(data) 11 | print(data.decode('utf-8')) 12 | returnData = raw_input() 13 | sock.send(returnData.encode('utf-8')) 14 | 15 | -------------------------------------------------------------------------------- /VerifyTec/messageTransferTest/test11.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python -*- 2 | 3 | block_cipher = None 4 | 5 | 6 | a = Analysis(['test11.py'], 7 | pathex=['F:\\python17\\pythonPro\\MemortAssit\\VerifyTec\\messageTransferTest'], 8 | binaries=[], 9 | datas=[], 10 | hiddenimports=[], 11 | hookspath=[], 12 | runtime_hooks=[], 13 | excludes=[], 14 | win_no_prefer_redirects=False, 15 | win_private_assemblies=False, 16 | cipher=block_cipher, 17 | noarchive=False) 18 | pyz = PYZ(a.pure, a.zipped_data, 19 | cipher=block_cipher) 20 | exe = EXE(pyz, 21 | a.scripts, 22 | [], 23 | exclude_binaries=True, 24 | name='test11', 25 | debug=False, 26 | bootloader_ignore_signals=False, 27 | strip=False, 28 | upx=True, 29 | console=True ) 30 | coll = COLLECT(exe, 31 | a.binaries, 32 | a.zipfiles, 33 | a.datas, 34 | strip=False, 35 | upx=True, 36 | name='test11') 37 | -------------------------------------------------------------------------------- /VerifyTec/messageTransferTest/test12.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | import socket 3 | 4 | 5 | client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 6 | client.connect(('127.0.0.1', 8000)) 7 | while True: 8 | message = raw_input() 9 | client.send(message.encode('utf-8')) 10 | data = client.recv(1024) 11 | print(data.decode('utf-8')) 12 | 13 | -------------------------------------------------------------------------------- /VerifyTec/messageTransferTest/test12.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python -*- 2 | 3 | block_cipher = None 4 | 5 | 6 | a = Analysis(['test12.py'], 7 | pathex=['F:\\python17\\pythonPro\\MemortAssit\\VerifyTec\\messageTransferTest'], 8 | binaries=[], 9 | datas=[], 10 | hiddenimports=[], 11 | hookspath=[], 12 | runtime_hooks=[], 13 | excludes=[], 14 | win_no_prefer_redirects=False, 15 | win_private_assemblies=False, 16 | cipher=block_cipher, 17 | noarchive=False) 18 | pyz = PYZ(a.pure, a.zipped_data, 19 | cipher=block_cipher) 20 | exe = EXE(pyz, 21 | a.scripts, 22 | [], 23 | exclude_binaries=True, 24 | name='test12', 25 | debug=False, 26 | bootloader_ignore_signals=False, 27 | strip=False, 28 | upx=True, 29 | console=True ) 30 | coll = COLLECT(exe, 31 | a.binaries, 32 | a.zipfiles, 33 | a.datas, 34 | strip=False, 35 | upx=True, 36 | name='test12') 37 | -------------------------------------------------------------------------------- /VerifyTec/messageTransferTest/test13.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | import re 3 | import socket 4 | import threading 5 | import time 6 | import sys 7 | import os 8 | import struct 9 | 10 | import re 11 | import os 12 | import tempfile 13 | 14 | 15 | def socket_service(): 16 | try: 17 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 18 | s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 19 | s.bind(('127.0.0.1', 9000)) 20 | s.listen(10) 21 | except socket.error as msg: 22 | print(msg) 23 | sys.exit(1) 24 | print('Waiting client connection...') 25 | while 1: 26 | conn, addr = s.accept() 27 | t = threading.Thread(target=deal_data, args=(conn, addr)) 28 | t.start() 29 | 30 | 31 | def deal_data(conn, addr): 32 | print('Accept new connection from {0}'.format(addr)) 33 | # conn.settimeout(500) 34 | conn.send(b'Hi, Welcome to the server!') 35 | while 1: 36 | fileinfo_size = struct.calcsize('128si2s') 37 | buf = conn.recv(fileinfo_size) 38 | if buf: 39 | filename, filesize, pwd = struct.unpack('128si2s', buf) 40 | print("pwd : " + bytes.decode(pwd)) 41 | # 判定密码是否正确 42 | file_path = './test.properties' 43 | property = Properties(file_path) # 读取文件 44 | if property.get("pwd") == bytes.decode(pwd): 45 | print("password validate success!") 46 | else: 47 | print("password validate error") 48 | break 49 | # 删除byte转为str后的\x00 用strip也可以 50 | newFileName = bytes.decode(filename).rstrip('\x00') 51 | # 得到文件路径前缀 52 | dirPrefix = property.get(newFileName) 53 | if dirPrefix == None or dirPrefix == "": 54 | dirPrefix = property.get("defaultDir") 55 | new_filename = os.path.join(dirPrefix, '' + newFileName) 56 | print('file new name is {0}, filesize if {1}'.format(new_filename, filesize)) 57 | 58 | recvd_size = 0 # 定义已接收文件的大小 59 | fp = open(new_filename, 'wb') 60 | print('start receiving...') 61 | while not recvd_size == filesize: 62 | if filesize - recvd_size > 1024: 63 | data = conn.recv(1024) 64 | recvd_size += len(data) 65 | else: 66 | data = conn.recv(filesize - recvd_size) 67 | recvd_size = filesize 68 | fp.write(data) 69 | fp.close() 70 | print('end receive...') 71 | conn.close() 72 | break 73 | 74 | 75 | class Properties: 76 | def __init__(self, file_name): 77 | self.file_name = file_name 78 | self.properties = {} 79 | try: 80 | fopen = open(self.file_name, 'r') 81 | for line in fopen: 82 | line = line.strip() 83 | if line.find('=') > 0 and not line.startswith('#'): 84 | strs = line.split('=') 85 | self.properties[strs[0].strip()] = strs[1].strip() 86 | except Exception: 87 | # raise Exception 88 | print("read file exception ...") 89 | else: 90 | fopen.close() 91 | 92 | def get(self, key, default_value=''): 93 | if key in self.properties: 94 | return self.properties[key] 95 | return default_value 96 | 97 | 98 | 99 | if __name__ == '__main__': 100 | socket_service() 101 | -------------------------------------------------------------------------------- /VerifyTec/messageTransferTest/test14.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | import socket 3 | import os 4 | import sys 5 | import struct 6 | 7 | 8 | def socket_client(): 9 | try: 10 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 11 | s.connect(('140.143.147.128', 9000)) 12 | except socket.error as msg: 13 | print(msg) 14 | sys.exit(1) 15 | print(s.recv(1024)) 16 | while 1: 17 | # filepath = input('please input file path: ') 18 | filepath = "./v0.3.zip" 19 | if os.path.isfile(filepath): 20 | # 定义定义文件信息。128s表示文件名为128bytes长,l表示一个int或log文件类型,在此为文件大小 2s 代表的是2个字节的字符串长度 21 | # 定义文件头信息,包含文件名和文件大小 22 | fhead = struct.pack('128si2s', bytes(os.path.basename(filepath).encode('utf-8')), os.stat(filepath).st_size, 23 | b'pw') 24 | s.send(fhead) 25 | print('client filepath: {0}'.format(filepath)) 26 | 27 | fp = open(filepath, 'rb') 28 | while 1: 29 | data = fp.read(1024) 30 | if not data: 31 | print('{0} file send over...'.format(filepath)) 32 | break 33 | s.send(data) 34 | s.close() 35 | break 36 | 37 | 38 | if __name__ == '__main__': 39 | socket_client() 40 | -------------------------------------------------------------------------------- /VerifyTec/test02.py: -------------------------------------------------------------------------------- 1 | import tkinter 2 | from tkinter import ttk # 导入内部包 3 | 4 | li = ['王记', '12', '男'] 5 | li1 = ['王记1', '12', '男'] 6 | root = tkinter.Tk() 7 | root.title('测试') 8 | tree = ttk.Treeview(root, columns=['1', '2', '3'], show='headings') 9 | tree.column('1', width=100, anchor='center') 10 | tree.column('2', width=100, anchor='center') 11 | tree.column('3', width=100, anchor='center') 12 | tree.heading('1', text='姓名') 13 | tree.heading('2', text='学号') 14 | tree.heading('3', text='性别') 15 | tree.insert('', 'end', values=li) 16 | tree.insert('', 'end', values=li1) 17 | tree.grid() 18 | 19 | 20 | def delButton(tree): 21 | x = tree.get_children() 22 | for item in x: 23 | tree.delete(item) 24 | 25 | 26 | def treeviewClick(event): # 单击 27 | print('单击') 28 | for item in tree.selection(): 29 | item_text = tree.item(item, "values") 30 | print(item_text[0]) # 输出所选行的第一列的值 31 | 32 | 33 | # delButton(tree) 34 | tree.bind('', treeviewClick) # 鼠标双击事件 35 | 36 | root.mainloop() 37 | -------------------------------------------------------------------------------- /VerifyTec/test03.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | root = Tk() 4 | 5 | for r in ['raised', 'sunken', 'groove', 'ridge']: 6 | Button(root, 7 | text=r, 8 | relief=r, 9 | width=30).pack() 10 | 11 | 12 | root.mainloop() -------------------------------------------------------------------------------- /VerifyTec/test04.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | import os, sys 4 | 5 | if sys.version_info[0] == 2: 6 | from tkinter import * 7 | from tkinter.ttk import * 8 | # Usage:showinfo/warning/error,askquestion/okcancel/yesno/retrycancel 9 | from tkinter.messagebox import * 10 | # Usage:f=tkFileDialog.askopenfilename(initialdir='E:/Python') 11 | # import tkFileDialog 12 | # import tkSimpleDialog 13 | else: # Python 3.x 14 | from tkinter import * 15 | from tkinter.font import Font 16 | from tkinter.ttk import * 17 | from tkinter.messagebox import * 18 | # import tkinter.filedialog as tkFileDialog 19 | # import tkinter.simpledialog as tkSimpleDialog #askstring() 20 | 21 | 22 | class Application_ui(Frame): 23 | # 这个类仅实现界面生成功能,具体事件处理代码在子类Application中。 24 | def __init__(self, master=None): 25 | Frame.__init__(self, master) 26 | self.master.title('Form1') 27 | self.master.geometry('389x339') 28 | self.createWidgets() 29 | 30 | def createWidgets(self): 31 | self.top = self.winfo_toplevel() 32 | 33 | self.style = Style() 34 | 35 | self.TabStrip1 = Notebook(self.top) 36 | self.TabStrip1.place(relx=0.062, rely=0.071, relwidth=0.887, relheight=0.876) 37 | 38 | self.TabStrip1__Tab1 = Frame(self.TabStrip1) 39 | self.TabStrip1__Tab1Lbl = Label(self.TabStrip1__Tab1, text='Please add widgets in code.1') 40 | self.TabStrip1__Tab1Lbl.place(relx=0.1, rely=0.5) 41 | self.TabStrip1.add(self.TabStrip1__Tab1, text='我的快玩') 42 | 43 | self.TabStrip1__Tab2 = Frame(self.TabStrip1) 44 | self.TabStrip1__Tab2Lbl = Label(self.TabStrip1__Tab2, text='Please add widgets in code.2') 45 | self.TabStrip1__Tab2Lbl.place(relx=0.1, rely=0.5) 46 | self.TabStrip1.add(self.TabStrip1__Tab2, text='找游戏') 47 | 48 | 49 | class Application(Application_ui): 50 | # 这个类实现具体的事件处理回调函数。界面生成代码在Application_ui中。 51 | def __init__(self, master=None): 52 | Application_ui.__init__(self, master) 53 | 54 | 55 | if __name__ == "__main__": 56 | top = Tk() 57 | Application(top).mainloop() 58 | -------------------------------------------------------------------------------- /VerifyTec/test05.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | import binascii 3 | 4 | # from idna import unichr 5 | # 6 | # key = 0xff 7 | # 8 | # 9 | # def encrypt(src): 10 | # return ''.join([unichr(ord(x) ^ key) for x in src]).encode('utf-8').encode('hex').upper() 11 | # 12 | # 13 | # def decrypt(src): 14 | # return ''.join([unichr(ord(x) ^ key) for x in src.decode('hex').decode('utf-8')]) 15 | # 16 | # 17 | # a = u'中国' 18 | # print(encrypt(a)) 19 | # print(decrypt(encrypt(a))) 20 | import pickle 21 | 22 | text = [{'1': 1}] 23 | dic = {'age': 23, 'job': 'student'} 24 | byte_data = pickle.dumps(dic) 25 | print(byte_data) 26 | # print(text) 27 | # print(text.encode()) 28 | # print(binascii.b2a_hex(text.encode())) 29 | print(binascii.b2a_hex(byte_data)) 30 | # print(binascii.a2b_hex(binascii.b2a_hex(text.encode()))) 31 | print(binascii.a2b_hex(binascii.b2a_hex(byte_data))) 32 | print(pickle.loads(byte_data)) 33 | 34 | 35 | -------------------------------------------------------------------------------- /VerifyTec/test06.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | import datetime 3 | import time 4 | 5 | localtime = time.asctime(time.localtime(time.time())) 6 | t = time.gmtime() 7 | print(t.tm_year) 8 | print ("时间:" + localtime) 9 | 10 | # 格式化日期 11 | print (time.strftime("%Y-%m-%d", time.localtime())) 12 | time_ = '2019-02-01' 13 | a1 = datetime.datetime.strptime(time_, '%Y-%m-%d') 14 | a2 = datetime.datetime.strptime(time.strftime("%Y-%m-%d", time.localtime()), '%Y-%m-%d') 15 | 16 | print('s_time is:', a1 + datetime.timedelta(days=1)) 17 | print('s_time is:', a1) 18 | print('e_time is:', a2) 19 | print(a2.strftime("%Y-%m-%d")) 20 | print(a1 - a2) 21 | 22 | currentDate = datetime.datetime.strptime(time.strftime("%Y-%m-%d", time.localtime()), '%Y-%m-%d').strftime( 23 | "%Y%m%d") 24 | print(currentDate) 25 | -------------------------------------------------------------------------------- /VerifyTec/test07.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | path = 'F:\python17\pythonPro\MemortAssit\data/bkup' 4 | files = os.listdir(path) 5 | minFileName = None 6 | minFileTime = 0 7 | for file in files: 8 | if minFileTime == 0: 9 | minFileTime = os.path.getctime(path + '/' + file) 10 | minFileName = file 11 | else: 12 | if minFileTime > os.path.getctime(path + '/' + file): 13 | minFileTime = os.path.getctime(path + '/' + file) 14 | minFileName = file 15 | print(minFileName) 16 | 17 | -------------------------------------------------------------------------------- /VerifyTec/test08.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | import datetime 3 | import time 4 | import win32clipboard 5 | 6 | import win32con 7 | 8 | 9 | def settext(aString): 10 | try: 11 | win32clipboard.OpenClipboard() 12 | win32clipboard.EmptyClipboard() 13 | win32clipboard.SetClipboardData(win32con.CF_TE1XT, aString) 14 | win32clipboard.CloseClipboard() 15 | except Exception, e: 16 | wrongFile = open('../data/wrongMessage.dat', 'a+') 17 | # 获取当前时间 18 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 19 | '%Y-%m-%d-%H-%M-%S')) 20 | # 生成报错的错误信息 21 | wrongMessage = { 22 | '|currentTime': currentTime, 23 | '|file': 'MissionSystem-AddMission-saveConfigFile', 24 | '|wrongMessage': str(e) 25 | } 26 | # 存入文件 27 | wrongFile.write(str(wrongMessage)) 28 | # 增加换行符 29 | wrongFile.write('\n') 30 | wrongFile.close() 31 | 32 | a = "hello python" 33 | # nextTime = datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), '%Y-%m-%d-%H-%M-%S') 34 | # print(nextTime) 35 | # 36 | settext(a) 37 | 38 | -------------------------------------------------------------------------------- /VerifyTec/test09.py: -------------------------------------------------------------------------------- 1 | list1 = [1, 2, 3] 2 | list2 = list1[:] 3 | list2.remove(2) 4 | print(list1) 5 | print(list2) -------------------------------------------------------------------------------- /VerifyTec/test10.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python -*- 2 | 3 | block_cipher = None 4 | 5 | 6 | a = Analysis(['test10.py'], 7 | pathex=['F:\\python17\\pythonPro\\MemortAssit\\VerifyTec'], 8 | binaries=[], 9 | datas=[], 10 | hiddenimports=[], 11 | hookspath=[], 12 | runtime_hooks=[], 13 | excludes=[], 14 | win_no_prefer_redirects=False, 15 | win_private_assemblies=False, 16 | cipher=block_cipher, 17 | noarchive=False) 18 | pyz = PYZ(a.pure, a.zipped_data, 19 | cipher=block_cipher) 20 | exe = EXE(pyz, 21 | a.scripts, 22 | [], 23 | exclude_binaries=True, 24 | name='test10', 25 | debug=False, 26 | bootloader_ignore_signals=False, 27 | strip=False, 28 | upx=True, 29 | console=True ) 30 | coll = COLLECT(exe, 31 | a.binaries, 32 | a.zipfiles, 33 | a.datas, 34 | strip=False, 35 | upx=True, 36 | name='test10') 37 | -------------------------------------------------------------------------------- /VerifyTec/test11.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python -*- 2 | 3 | block_cipher = None 4 | 5 | 6 | a = Analysis(['test11.py'], 7 | pathex=['F:\\python17\\pythonPro\\MemortAssit\\VerifyTec'], 8 | binaries=[], 9 | datas=[], 10 | hiddenimports=[], 11 | hookspath=[], 12 | runtime_hooks=[], 13 | excludes=[], 14 | win_no_prefer_redirects=False, 15 | win_private_assemblies=False, 16 | cipher=block_cipher, 17 | noarchive=False) 18 | pyz = PYZ(a.pure, a.zipped_data, 19 | cipher=block_cipher) 20 | exe = EXE(pyz, 21 | a.scripts, 22 | a.binaries, 23 | a.zipfiles, 24 | a.datas, 25 | [], 26 | name='test11', 27 | debug=False, 28 | bootloader_ignore_signals=False, 29 | strip=False, 30 | upx=True, 31 | runtime_tmpdir=None, 32 | console=True ) 33 | -------------------------------------------------------------------------------- /VerifyTec/test16.py: -------------------------------------------------------------------------------- 1 | import random 2 | import string 3 | import re 4 | 5 | # salt = ''.join(random.sample(string.ascii_letters + string.digits, 32)) 6 | # print(salt) 7 | address = "('127.0.0.1', 63087)" 8 | address = re.findall('\'(.*?)\'', address)[0] 9 | address = address.replace('.', '\\') 10 | print(address) 11 | 12 | 13 | # import pymongo 14 | # 15 | # myclient = pymongo.MongoClient("localhost:27017") 16 | # mydb = myclient["MemoryAssist"] 17 | # totalCol = mydb["total_user"] 18 | # weeklyCol = mydb["weekly_user"] 19 | # dictInTotal = { 20 | # 'user_code': '123456', 21 | # 'total_time': '1', 22 | # 'user_ip': {'127/0/0/1': '1'}, 23 | # } 24 | # totalCol.insert_one(dictInTotal) -------------------------------------------------------------------------------- /VerifyTec/test17.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | import smtplib 3 | from email.mime.text import MIMEText 4 | 5 | msg_from = 'MemoryAssist@sniper97.cn' # 发送方邮箱 6 | passwd = 'ysqmxpfdkxhsbigd' # 填入发送方邮箱的授权码 7 | msg_to = 'zhaoyu@sniper97.cn' # 收件人邮箱 8 | 9 | subject = "python邮件测试" # 主题 10 | content = "这是我使用python smtplib及\nemail模块发送的邮件1111" 11 | msg = MIMEText(content) 12 | msg['Subject'] = subject 13 | msg['From'] = msg_from 14 | msg['To'] = msg_to 15 | try: 16 | s = smtplib.SMTP_SSL("smtp.qq.com", 465) 17 | s.login(msg_from, passwd) 18 | s.sendmail(msg_from, msg_to, msg.as_string()) 19 | print("发送成功") 20 | except s.SMTPException, e: 21 | print("发送失败") 22 | finally: 23 | s.quit() -------------------------------------------------------------------------------- /VerifyTec/test18.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | import simplejson as simplejson 5 | 6 | # url = 'http://ip.taobao.com/service/getIpInfo.php?ip=127.0.0.1' 7 | # r = requests.get(url) 8 | # mes = r.text 9 | # # a = dict(r.text) 10 | # a = json.loads(r.text) 11 | # b = a['data']['country'] + a['data']['area'] + a['data']['region'] + a['data']['city'] 12 | # print(b) 13 | # print(type(str(a['data']['city']))) 14 | # from src.Server.DatabaseSystem.Tools.areaStatistics import AreaStatistics 15 | # 16 | # areaTools = AreaStatistics() 17 | # weeklyArea, totalArea = areaTools.statistics() 18 | # a = json.dumps(weeklyArea).encode('utf-8').decode('unicode_escape') 19 | # print(a) 20 | print('testvar' in dir()) 21 | testvar = True 22 | print('testvar' in dir()) 23 | -------------------------------------------------------------------------------- /VerifyTec/updateFileTest/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/VerifyTec/updateFileTest/__init__.py -------------------------------------------------------------------------------- /VerifyTec/updateFileTest/test15.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | import zipfile 3 | import shutil 4 | import os 5 | 6 | 7 | def un_zip(file_name): 8 | """unzip zip file""" 9 | zip_file = zipfile.ZipFile(file_name) 10 | if os.path.isdir(file_name + "_files"): 11 | pass 12 | else: 13 | os.mkdir(file_name + "_files") 14 | for names in zip_file.namelist(): 15 | zip_file.extract(names, file_name + "_files/") 16 | zip_file.close() 17 | moveFile() 18 | 19 | 20 | def moveFile(): 21 | for filename in os.listdir('./testPck1.zip_files/testPck1/'): 22 | print(filename) 23 | try: 24 | os.remove('./testPck/' + filename) 25 | except: 26 | shutil.rmtree('./testPck/'+filename) 27 | pass 28 | shutil.move('./testPck1.zip_files/testPck1/' + filename, './testPck/') 29 | shutil.rmtree('./testPck1.zip_files') 30 | 31 | 32 | if __name__ == '__main__': 33 | un_zip('testPck1.zip') 34 | -------------------------------------------------------------------------------- /VerifyTec/updateFileTest/testPck/fileOne.ini: -------------------------------------------------------------------------------- 1 | 123 -------------------------------------------------------------------------------- /VerifyTec/updateFileTest/testPck/fileOne1.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/VerifyTec/updateFileTest/testPck/fileOne1.ini -------------------------------------------------------------------------------- /VerifyTec/updateFileTest/testPck/fileThree.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/VerifyTec/updateFileTest/testPck/fileThree.ini -------------------------------------------------------------------------------- /VerifyTec/updateFileTest/testPck/fileTwo.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/VerifyTec/updateFileTest/testPck/fileTwo.ini -------------------------------------------------------------------------------- /VerifyTec/updateFileTest/testPck/fileTwo2.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/VerifyTec/updateFileTest/testPck/fileTwo2.ini -------------------------------------------------------------------------------- /VerifyTec/updateFileTest/testPck/ummm/hahaah/ojbk.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/VerifyTec/updateFileTest/testPck/ummm/hahaah/ojbk.ini -------------------------------------------------------------------------------- /VerifyTec/updateFileTest/testPck1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/VerifyTec/updateFileTest/testPck1.zip -------------------------------------------------------------------------------- /VerifyTec/updateFileTest/testPck1/fileOne.ini: -------------------------------------------------------------------------------- 1 | 123 -------------------------------------------------------------------------------- /VerifyTec/updateFileTest/testPck1/fileTwo.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/VerifyTec/updateFileTest/testPck1/fileTwo.ini -------------------------------------------------------------------------------- /VerifyTec/updateFileTest/testPck1/ummm/hahaah/ojbk.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/VerifyTec/updateFileTest/testPck1/ummm/hahaah/ojbk.ini -------------------------------------------------------------------------------- /codeNum.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | import os 3 | import time 4 | 5 | basedir = './' 6 | filelists = [] 7 | # 指定想要统计的文件类型 8 | whitelist = ['php', 'py'] 9 | 10 | 11 | # 遍历文件, 递归遍历文件夹中的所有 12 | def getFile(basedir): 13 | global filelists 14 | for parent, dirnames, filenames in os.walk(basedir): 15 | # for dirname in dirnames: 16 | # getFile(os.path.join(parent,dirname)) #递归 17 | for filename in filenames: 18 | ext = filename.split('.')[-1] 19 | # 只统计指定的文件类型,略过一些log和cache文件 20 | if ext in whitelist: 21 | filelists.append(os.path.join(parent, filename)) 22 | 23 | 24 | # 统计一个文件的行数 25 | def countLine(fname): 26 | count = 0 27 | for file_line in open(fname).xreadlines(): 28 | # if file_line != '' and file_line != '\n': # 过滤掉空行 29 | count += 1 30 | print fname + '----', count 31 | return count 32 | 33 | 34 | if __name__ == '__main__': 35 | startTime = time.clock() 36 | getFile(basedir) 37 | totalline = 0 38 | for filelist in filelists: 39 | totalline = totalline + countLine(filelist) 40 | print '总行数:', totalline 41 | print '完成时间: %0.2f s' % (time.clock() - startTime) 42 | -------------------------------------------------------------------------------- /conf/main.ini: -------------------------------------------------------------------------------- 1 | [VERSION] 2 | version = v1.3.2 3 | 4 | [USER_CODE] 5 | user_code = 6 | user_time = 0 7 | 8 | -------------------------------------------------------------------------------- /conf/mission.ini: -------------------------------------------------------------------------------- 1 | [MISSION] 2 | missionid = 000000 3 | 4 | -------------------------------------------------------------------------------- /conf/recitation.ini: -------------------------------------------------------------------------------- 1 | [RECITATION] 2 | recitationid = 000001 3 | 4 | -------------------------------------------------------------------------------- /conf/server.ini: -------------------------------------------------------------------------------- 1 | [VERSION] 2 | lastest_version = v1.3.2 3 | [MESSAGE] 4 | send_message = True 5 | [USER] 6 | last_week_user_account = 0 7 | [EMAIL] 8 | email_code = jndmaedgdbkpbigc -------------------------------------------------------------------------------- /conf/user.ini: -------------------------------------------------------------------------------- 1 | [USER_CODE] 2 | user_code = VptBC73mvbFuSGIZYzRKq9OxAwnsUD6E 3 | user_time = 0 4 | 5 | [LANGUAGE] 6 | language = CN 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /data/fileIndex.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/data/fileIndex.properties -------------------------------------------------------------------------------- /data/mission.dat: -------------------------------------------------------------------------------- 1 | 286c70300a286470310a53276e65787454696d65270a70320a5327323031392d30352d3231270a70330a7353276c6f6f7054696d65270a70340a49350a7353276d697373696f6e4964270a70350a5327303030303031270a70360a735327626f6f6b4e616d65270a70370a5327626f6f6b270a70380a7353277374617465270a70390a49330a735327697346696e697368270a7031300a4930310a7353276d697373696f6e52616e6765270a7031310a532772616e6765270a7031320a736128647031330a53276e65787454696d65270a7031340a5327323031392d30342d3036270a7031350a735327697346696e697368270a7031360a4930300a7353276d697373696f6e4964270a7031370a5327303030303032270a7031380a735327626f6f6b4e616d65270a7031390a532731270a7032300a7353277374617465270a7032310a49310a7353276d697373696f6e52616e6765270a7032320a6732300a7353276c6f6f7054696d65270a7032330a49350a736128647032340a53276e65787454696d65270a7032350a5327323031392d30362d3132270a7032360a7353276d697373696f6e52616e6765270a7032370a532732270a7032380a7353276d697373696f6e4964270a7032390a5327303030303033270a7033300a735327626f6f6b4e616d65270a7033310a532731270a7033320a7353277374617465270a7033330a49370a7353276c6f6f7054696d65270a7033340a49340a735327697346696e697368270a7033350a4930310a73612e -------------------------------------------------------------------------------- /data/recitation.dat: -------------------------------------------------------------------------------- 1 | 286c70300a286470310a5327616e73776572270a70320a53275c7865375c7839345c7862315c7865345c7862615c7838655c7865365c7839665c7839305c7865375c7861375c7838645c7865355c7838655c7839665c7865355c7839625c7861305c7865665c7862635c7838635c7865365c7839635c7838305c7865355c7861355c7862645c7865345c7862385c7838645c7865385c7861365c7838315c7865355c7862305c7838365c7865365c7838395c7838305c7865365c7839635c7838395c7865375c7839615c7838345c7865385c7838335c7838635c7865385c7861665c7862355c7865365c7862385c7838355c7865375c7861395c7862615c7865665c7862635c7838635c7865385c7861665c7862375c7865345c7862665c7839645c7865375c7839355c7839395c7865365c7839635c7861635c7865365c7839645c7861315c7865665c7862635c7838635c7865365c7839635c7861635c7865365c7839645c7861315c7865365c7839645c7838335c7865395c7838375c7838645c7865355c7862375c7862325c7865375c7862625c7838665c7865385c7861655c7862655c7865345c7862385c786261305c7865665c7862635c7838635c7865345c7862385c7838645c7865345c7862635c7839615c7865355c7839635c7861385c7865365c7838665c7839305c7865395c7839375c7861655c7865345c7862385c7861645c7865355c7838375c7862615c7865375c7838655c7862305c7865665c7862635c7838385c7865355c7838665c7861615c7865345c7862635c7839615c7865355c7839635c7861385c7865355c7838665c7861615c7865355c7838395c7861395c7865365c7839635c7861635c7865365c7839645c7861315c7865365c7839375c7862365c7865355c7838375c7862615c7865375c7838655c7862305c7865665c7862635c7838395c7865665c7862635c7838635c7865395c7838325c7861335c7865345c7862395c7838385c7865355c7862305c7862315c7865385c7861665c7862375c7865345c7862625c7838655c7865355c7838665c7862335c7865345c7862655c7861375c7865365c7862375c7862625c7865355c7838615c7861305c7865385c7838335c7838635c7865385c7861665c7862355c7865355c7862635c7838305c7865355c7861375c7838625c7865355c7839305c7861377e270a70330a73532772656369746174696f6e4964270a70340a5327303030303031270a70350a7353277175657374696f6e270a70360a53275c7865365c7862335c7861385c7865365c7838345c783866270a70370a735327776569676874270a70380a49300a73612e -------------------------------------------------------------------------------- /icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/icon.ico -------------------------------------------------------------------------------- /images/icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/images/icon.gif -------------------------------------------------------------------------------- /images/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/images/icon.ico -------------------------------------------------------------------------------- /images/icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/images/icon.jpg -------------------------------------------------------------------------------- /images/search.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/images/search.gif -------------------------------------------------------------------------------- /images/search.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/images/search.jpg -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.View.MainFrame import mainFrame 3 | from src.Client.View.MainFrame.SearchAndSettingFrame.ShowSettingTools.showEdit import ShowEdit 4 | from src.Client.recitationSystem.recitationSystem import RecitationSystem 5 | from src.Server.MessageReportSystem.Tools.sendEmail import SendEmail 6 | from src.Server.SystemTools.ConfFileRead import configFileRead 7 | from src.Client.SystemTools.LoadFiles import loadFiles 8 | 9 | if __name__ == '__main__': 10 | list1 = loadFiles.LoadFiles('./data/recitation.dat').loadFiles(missionType='recitation') 11 | print(list1) 12 | # m = RecitationSystem() 13 | # 添加 14 | # m.addRecitation('注意', '', weight=0) 15 | # m.addRecitation('question2', 'answer2', weight=20) 16 | # 获取一条 17 | # print(m.loadRecitation()) 18 | # m.editRecitation(recitationId='000001', 19 | # answer='由于某种原因,最好不要将所有的背诵清空,请保留本条,本条权重已经设为0,不会在提问中出现(只会在只剩本条时出现),那么就请从右侧添加背诵开始吧~',weight=0,isEdit=True) 20 | # print(m.getOneRecitation()) 21 | # print(type(configFileRead.ConfigFileRead().readFile('EMAIL', 'email_code')) 22 | # str = ''' 23 | # 哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈''' 24 | # print(len(str)) 25 | 26 | 27 | 28 | pass -------------------------------------------------------------------------------- /mainC.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.View.MainFrame import mainFrame 3 | from src.Client.SystemTools.ConfFileRead import configFileRead 4 | from src.Client.MessageTransferSystem.MarkUser import markUser 5 | 6 | # 主界面 7 | if __name__ == '__main__': 8 | """ 9 | 程序开始前的准备 10 | """ 11 | # 对登录次数进行更新 12 | configFileReadTools = configFileRead.ConfigFileRead(fileName="./conf/user.ini") 13 | logTime = configFileReadTools.readFile('USER_CODE', 'user_time') 14 | logTime = int(logTime) 15 | logTime = str(logTime + 1) 16 | configFileReadTools.saveFile('USER_CODE', 'user_time', logTime) 17 | # 尝试向服务器请求用户识别码或者想服务器发送当前登录次数 18 | markUserTools = markUser.MarkUser() 19 | markUserTools.judge() 20 | """ 21 | 调用主窗口 22 | """ 23 | mainFrame.MainFrame() 24 | # f = open('./../data/mission.dat') 25 | # print(f.read()) 26 | 27 | """ 28 | 打包用语句 29 | """ 30 | # sphinx-apidoc -o ./source ../src 31 | 32 | # pyinstaller mainS.py -i ./images/icon.ico 33 | 34 | # pyinstaller mainC.py -i ./images/icon.ico -w -n run 35 | 36 | # pyinstaller mainU.py -i ./images/icon.ico -w -n MemoryAssist -F -------------------------------------------------------------------------------- /mainC.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python -*- 2 | 3 | block_cipher = None 4 | 5 | 6 | a = Analysis(['mainC.py'], 7 | pathex=['F:\\python17\\pythonPro\\MemortAssit'], 8 | binaries=[], 9 | datas=[], 10 | hiddenimports=[], 11 | hookspath=[], 12 | runtime_hooks=[], 13 | excludes=[], 14 | win_no_prefer_redirects=False, 15 | win_private_assemblies=False, 16 | cipher=block_cipher, 17 | noarchive=False) 18 | pyz = PYZ(a.pure, a.zipped_data, 19 | cipher=block_cipher) 20 | exe = EXE(pyz, 21 | a.scripts, 22 | [], 23 | exclude_binaries=True, 24 | name='mainC', 25 | debug=False, 26 | bootloader_ignore_signals=False, 27 | strip=False, 28 | upx=True, 29 | console=False , icon='images\\icon.ico') 30 | coll = COLLECT(exe, 31 | a.binaries, 32 | a.zipfiles, 33 | a.datas, 34 | strip=False, 35 | upx=True, 36 | name='mainC') 37 | -------------------------------------------------------------------------------- /mainS.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | from src.Server.MessageTransferSystem.VersionControlSystem import versionControl 4 | from src.Server.MessageReportSystem.messageReportSystem import MessageReportSystem 5 | 6 | import os 7 | 8 | # 主界面 9 | if __name__ == '__main__': 10 | versionControl.VersionControl() 11 | threading.Thread(target=MessageReportSystem().run()).start() 12 | # schedule.every().monday.at("00:00").do(MessageReportSystem().run()) 13 | # while True: -------------------------------------------------------------------------------- /mainS.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python -*- 2 | 3 | block_cipher = None 4 | 5 | 6 | a = Analysis(['mainS.py'], 7 | pathex=['F:\\python17\\pythonPro\\MemortAssit'], 8 | binaries=[], 9 | datas=[], 10 | hiddenimports=[], 11 | hookspath=[], 12 | runtime_hooks=[], 13 | excludes=[], 14 | win_no_prefer_redirects=False, 15 | win_private_assemblies=False, 16 | cipher=block_cipher, 17 | noarchive=False) 18 | pyz = PYZ(a.pure, a.zipped_data, 19 | cipher=block_cipher) 20 | exe = EXE(pyz, 21 | a.scripts, 22 | [], 23 | exclude_binaries=True, 24 | name='mainS', 25 | debug=False, 26 | bootloader_ignore_signals=False, 27 | strip=False, 28 | upx=True, 29 | console=True , icon='images\\icon.ico') 30 | coll = COLLECT(exe, 31 | a.binaries, 32 | a.zipfiles, 33 | a.datas, 34 | strip=False, 35 | upx=True, 36 | name='mainS') 37 | -------------------------------------------------------------------------------- /mainU.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Update.VersionControlSystem import versionControl 3 | # 主界面 4 | if __name__ == '__main__': 5 | versionControl.VersionControl().handle() 6 | # f = open('./../data/mission.dat') 7 | # print(f.read()) 8 | 9 | 10 | -------------------------------------------------------------------------------- /mainU.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python -*- 2 | 3 | block_cipher = None 4 | 5 | 6 | a = Analysis(['mainU.py'], 7 | pathex=['F:\\python17\\pythonPro\\MemortAssit'], 8 | binaries=[], 9 | datas=[], 10 | hiddenimports=[], 11 | hookspath=[], 12 | runtime_hooks=[], 13 | excludes=[], 14 | win_no_prefer_redirects=False, 15 | win_private_assemblies=False, 16 | cipher=block_cipher, 17 | noarchive=False) 18 | pyz = PYZ(a.pure, a.zipped_data, 19 | cipher=block_cipher) 20 | exe = EXE(pyz, 21 | a.scripts, 22 | a.binaries, 23 | a.zipfiles, 24 | a.datas, 25 | [], 26 | name='mainU', 27 | debug=False, 28 | bootloader_ignore_signals=False, 29 | strip=False, 30 | upx=True, 31 | runtime_tmpdir=None, 32 | console=True ) 33 | -------------------------------------------------------------------------------- /run.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python -*- 2 | 3 | block_cipher = None 4 | 5 | 6 | a = Analysis(['mainC.py'], 7 | pathex=['F:\\python17\\pythonPro\\MemortAssit'], 8 | binaries=[], 9 | datas=[], 10 | hiddenimports=[], 11 | hookspath=[], 12 | runtime_hooks=[], 13 | excludes=[], 14 | win_no_prefer_redirects=False, 15 | win_private_assemblies=False, 16 | cipher=block_cipher, 17 | noarchive=False) 18 | pyz = PYZ(a.pure, a.zipped_data, 19 | cipher=block_cipher) 20 | exe = EXE(pyz, 21 | a.scripts, 22 | [], 23 | exclude_binaries=True, 24 | name='run', 25 | debug=False, 26 | bootloader_ignore_signals=False, 27 | strip=False, 28 | upx=True, 29 | console=False , icon='images\\icon.ico') 30 | coll = COLLECT(exe, 31 | a.binaries, 32 | a.zipfiles, 33 | a.datas, 34 | strip=False, 35 | upx=True, 36 | name='run') 37 | -------------------------------------------------------------------------------- /showPic/show.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/showPic/show.gif -------------------------------------------------------------------------------- /src/Client/Conf/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/Conf/__init__.py -------------------------------------------------------------------------------- /src/Client/Conf/config.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | import tkinter 4 | from tkinter import ttk 5 | from tkinter import messagebox 6 | # import configparser as ConfigParser 7 | import ConfigParser 8 | import time 9 | import datetime 10 | import os 11 | import threading 12 | import requests 13 | import re 14 | import win32clipboard 15 | import win32con 16 | import socket 17 | import struct 18 | """ 19 | 该类负责导入包、debug开关 20 | """ 21 | 22 | # 服务器端口 23 | SERVER_FILE_PORT = 9000 24 | SERVER_MES_PORT = 9001 25 | 26 | 27 | VERSION = 1.3 28 | 29 | 30 | 31 | # 调试模式总开关 32 | # DEBUG = True 33 | DEBUG = False 34 | # GUI部分调试开关 35 | VIEW_DEBUG = True 36 | # 任务系统调试开关 37 | MISSION_DEBUG = True 38 | # 搜索系统调试开关 39 | SEARCH_DEBUG = True 40 | # 系统工具调试开关 41 | SYSTEM_TOOLS_DEBUG = True 42 | # 版本控制调试开关 43 | VERSION_CONTROL_DEBUG = True 44 | 45 | VERSION_CODE = "v1.3" 46 | 47 | 48 | if DEBUG: 49 | # 服务器ip 50 | SERVER_IP = '127.0.0.1' 51 | else: 52 | # 服务器ip 53 | SERVER_IP = 'memoryassist.sniper97.cn' 54 | 55 | -------------------------------------------------------------------------------- /src/Client/Conf/language.py: -------------------------------------------------------------------------------- 1 | # # -*- coding:utf-8 -*- 2 | # import tkinter as tk 3 | # 4 | # window = tk.Tk() 5 | # # 主搜索框架的搜索按钮 (搜索 search) 6 | # SERRCH_VAR = tk.StringVar() 7 | # 8 | # # 主搜索框架的设置按钮 (搜索 setting) 9 | # SETTING_VAR = tk.StringVar() 10 | # 11 | # print('?') -------------------------------------------------------------------------------- /src/Client/MessageTransferSystem/MarkUser/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/MessageTransferSystem/MarkUser/__init__.py -------------------------------------------------------------------------------- /src/Client/MessageTransferSystem/MarkUser/markUser.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | from src.Client.SystemTools.ConfFileRead import configFileRead 4 | 5 | 6 | class MarkUser(): 7 | def __init__(self): 8 | try: 9 | self.configFileReadTools = configFileRead.ConfigFileRead(fileName='./conf/user.ini') 10 | self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 11 | self.s.connect((SERVER_IP, SERVER_MES_PORT)) 12 | print(SERVER_IP) 13 | 14 | 15 | except socket.error as msg: 16 | # 打开错误日志文件 17 | wrongFile = open('data/wrongMessage.dat', 'a+') 18 | # 获取当前时间 19 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 20 | '%Y-%m-%d-%H-%M-%S')) 21 | # 生成报错的错误信息 22 | wrongMessage = { 23 | '|currentTime': currentTime, 24 | '|file': 'MessageTransferSystem-MarkUser-markUser', 25 | '|wrongMessage': msg 26 | } 27 | # 存入文件 28 | wrongFile.write(str(wrongMessage)) 29 | # 增加换行符 30 | wrongFile.write('\n') 31 | wrongFile.close() 32 | 33 | def judge(self): 34 | """ 35 | 读取用户识别码,如果没有识别码向服务器发送请求,如果有识别码,向服务器发送识别码和访问次数。 36 | :return: 37 | """ 38 | try: 39 | userCode = self.configFileReadTools.readFile('USER_CODE', 'user_code') 40 | print('|' + userCode + '|') 41 | if userCode == '': 42 | # 如果当前没有用户识别码,向服务器请求识别码,并写回配置文件 43 | # 发送代码101 作为向服务器请求新的用户识别码 44 | code = '101'.encode('utf-8') 45 | self.s.send(code) 46 | returnData = self.s.recv(1024) 47 | returnData = bytes.decode(returnData) 48 | print(returnData) 49 | # 写回配置文件 50 | self.configFileReadTools.saveFile('USER_CODE', 'user_code', returnData) 51 | else: 52 | # 如果有识别码,则向服务器发送识别码和当前记录的登录次数 53 | logTime = self.configFileReadTools.readFile('USER_CODE', 'user_time') 54 | code = '102'.encode('utf-8') 55 | self.s.send(code) 56 | returnData = self.s.recv(1024) 57 | returnData = bytes.decode(returnData) 58 | if returnData == 'user_code': 59 | # 发送用户识别码 60 | self.s.send(userCode.encode('utf-8')) 61 | returnData = self.s.recv(1024) 62 | returnData = bytes.decode(returnData) 63 | if returnData == 'time': 64 | # 发送登录次数,发送成功则将配置文件中的属性清零 65 | self.s.send(logTime.encode('utf-8')) 66 | self.configFileReadTools.saveFile('USER_CODE', 'user_time', '0') 67 | except socket.error as msg: 68 | print('no network') 69 | # 打开错误日志文件 70 | wrongFile = open('data/wrongMessage.dat', 'a+') 71 | # 获取当前时间 72 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 73 | '%Y-%m-%d-%H-%M-%S')) 74 | # 生成报错的错误信息 75 | wrongMessage = { 76 | '|currentTime': currentTime, 77 | '|file': 'VersionControlSystem-versionControl', 78 | '|wrongMessage': msg, 79 | '|没有互联网连接|': '没有互联网连接', 80 | } 81 | # 存入文件 82 | wrongFile.write(str(wrongMessage)) 83 | # 增加换行符 84 | wrongFile.write('\n') 85 | wrongFile.close() 86 | -------------------------------------------------------------------------------- /src/Client/MessageTransferSystem/VersionControl/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/MessageTransferSystem/VersionControl/__init__.py -------------------------------------------------------------------------------- /src/Client/MessageTransferSystem/VersionControl/versionControl.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | from src.Client.SystemTools.ConfFileRead import configFileRead 4 | 5 | class VersionControl(): 6 | def __init__(self): 7 | try: 8 | self.configFileReadTools = configFileRead.ConfigFileRead(fileName='./conf/main.ini') 9 | self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 10 | self.s.connect((SERVER_IP, SERVER_MES_PORT)) 11 | 12 | 13 | except socket.error as msg: 14 | # 打开错误日志文件 15 | wrongFile = open('data/wrongMessage.dat', 'a+') 16 | # 获取当前时间 17 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 18 | '%Y-%m-%d-%H-%M-%S')) 19 | # 生成报错的错误信息 20 | wrongMessage = { 21 | '|currentTime': currentTime, 22 | '|file': 'MessageTransferSystem-VersionControl-versionControl', 23 | '|wrongMessage': msg 24 | } 25 | # 存入文件 26 | wrongFile.write(str(wrongMessage)) 27 | # 增加换行符 28 | wrongFile.write('\n') 29 | wrongFile.close() 30 | 31 | def judge(self): 32 | vision = self.configFileReadTools.readFile('VERSION', 'version') 33 | # 请求码为100时 返回最新版本号 34 | self.s.send('100') 35 | returnData = self.s.recv(1024) 36 | if vision == returnData: 37 | return True 38 | else: 39 | return False 40 | pass 41 | -------------------------------------------------------------------------------- /src/Client/MessageTransferSystem/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/MessageTransferSystem/__init__.py -------------------------------------------------------------------------------- /src/Client/MissionSystem/AddMission/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/MissionSystem/AddMission/__init__.py -------------------------------------------------------------------------------- /src/Client/MissionSystem/AddMission/addMission.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.MissionSystem.AddMission.tools import saveConfigFile, loadConfigFile, addMissionToList 3 | from src.Client.SystemTools.SaveFiles import saveFiles 4 | 5 | 6 | class AddMission(): 7 | """ 8 | 该类负责增加任务相关事宜,属于调用类,调用各种方法完成目的。 9 | """ 10 | def __init__(self, confFileName='../conf/mission.ini', dataFileName='../data/mission.dat'): 11 | # 初始化工具 12 | self.loadConfigTools = loadConfigFile.LoadConfigFile(fileName=confFileName) 13 | self.addMissionTools = addMissionToList.AddMissionToList() 14 | self.saveConfigTools = saveConfigFile.SaveConfigFile(fileName=confFileName) 15 | self.saveMissionTools = saveFiles.SaveFiles(filename=dataFileName) 16 | pass 17 | 18 | def addMission(self, list, bookName, missionRange, missionId=None, nextTime=None, state=1, loopTime=5, 19 | isFinish=False): 20 | """ 21 | 22 | :param list: 目标list 23 | :param missionId: 任务id(string 24 | :param bookName: 书名 25 | :param missionRange: 任务范围 26 | :param nextTime: 下次任务时间 27 | :param state: 任务状态 28 | :param loopTime: 剩余迭代次数 29 | :param isFinish: 任务是否完成 30 | :return: 添加后的list 31 | """ 32 | if missionId is None: 33 | # 读取配置文件并自增+1 34 | nextMissionId = self.loadConfigTools.loadConfigFile() 35 | nextMissionId = nextMissionId + 1 36 | # 写回到配置文件 37 | self.saveConfigTools.saveConfigFile(nextMissionId) 38 | missionId = nextMissionId 39 | # 添加到列表并获取到返回列表 40 | list = self.addMissionTools.addMission(list=list, missionId=missionId, bookName=bookName, 41 | missionRange=missionRange, nextTime=nextTime, state=state, 42 | loopTime=loopTime, 43 | isFinish=isFinish) 44 | # 保存到文件 45 | self.saveMissionTools.saveFiles(list) 46 | return list 47 | 48 | 49 | # 对添加任务子系统的测试 50 | if __name__ == '__main__': 51 | a = AddMission() 52 | # l = loadMission.LoadFiles("F:\python17\pythonPro\MemortAssit\data\mission.dat") 53 | # list = l.loadMission() 54 | # 55 | # a = AddMission(confFileName='F:\python17\pythonPro\MemortAssit\conf\mission.ini', 56 | # dataFileName='F:\python17\pythonPro\MemortAssit\data\mission.dat') 57 | # a.addMission(list=list, bookName='testBook', missionRange='testMission') 58 | -------------------------------------------------------------------------------- /src/Client/MissionSystem/AddMission/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/MissionSystem/AddMission/tools/__init__.py -------------------------------------------------------------------------------- /src/Client/MissionSystem/AddMission/tools/addMissionToList.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | 4 | 5 | class AddMissionToList(): 6 | """ 7 | 该类负责将任务添加到列表,属于实际操作类 8 | """ 9 | 10 | def addMission(self, list, missionId, bookName, missionRange, nextTime=None, state=1, loopTime=5, isFinish=False): 11 | """ 12 | 添加任务 13 | :param list: 目标list 14 | :param missionId: 任务id(string 15 | :param bookName: 书名 16 | :param missionRange: 任务范围 17 | :param nextTime: 下次任务时间 18 | :param state: 任务状态 19 | :param loopTime: 剩余迭代次数 20 | :param isFinish: 任务是否完成 21 | :return: 插入后的list 22 | """ 23 | # 首先将列表备份,以便添加失败时返回最近正常的点 24 | backupList = list[:] 25 | try: 26 | # 如果新建任务时没有指定日期,则生成当前日期 27 | if nextTime is None: 28 | nextTime = datetime.datetime.strptime(time.strftime("%Y-%m-%d", time.localtime()), '%Y-%m-%d').strftime( 29 | "%Y-%m-%d") 30 | # 构造任务字典 31 | missionDir = { 32 | 'missionId': str(missionId).zfill(6), 33 | 'bookName': bookName, 34 | 'missionRange': missionRange, 35 | 'nextTime': nextTime, 36 | 'state': state, 37 | 'loopTime': loopTime, 38 | 'isFinish': isFinish 39 | } 40 | # 将任务字典添加到列表中 41 | list.append(missionDir) 42 | # 打印debug日志 43 | if DEBUG and MISSION_DEBUG: 44 | print('{SYS}{MISSION_DEBUG} mission has been add to list successfully, id is ' + str(missionId)) 45 | return list 46 | except Exception as e: 47 | # 打开错误日志文件 48 | wrongFile = open('data/wrongMessage.dat', 'a+') 49 | # 获取当前时间 50 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 51 | '%Y-%m-%d-%H-%M-%S')) 52 | # 生成报错的错误信息 53 | wrongMessage = { 54 | '|currentTime': currentTime, 55 | '|file': 'MissionSystem-AddMission-addMissionToList', 56 | '|list': list, 57 | '|missionId': missionId, 58 | '|bookName': bookName, 59 | '|missionRange': missionRange, 60 | '|nextTime': nextTime, 61 | '|state': state, 62 | '|loopTime': loopTime, 63 | '|isFinish': isFinish, 64 | '|wrongMessage': str(e) 65 | } 66 | # 存入文件 67 | wrongFile.write(str(wrongMessage)) 68 | # 增加换行符 69 | wrongFile.write('\n') 70 | wrongFile.close() 71 | return backupList 72 | -------------------------------------------------------------------------------- /src/Client/MissionSystem/AddMission/tools/loadConfigFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | 4 | from src.Client.Conf.config import * 5 | 6 | 7 | class LoadConfigFile(): 8 | """ 9 | 该类负责读取配置文件,属于实际操作类 10 | """ 11 | def __init__(self, fileName='../conf/mission.ini'): 12 | self.config = ConfigParser.ConfigParser() 13 | self.fileName = fileName 14 | 15 | def loadConfigFile(self): 16 | """ 17 | 读取配置文件 18 | :return:下个id(int) 19 | """ 20 | try: 21 | # 读取配置文件 22 | self.config.readfp(open(self.fileName)) 23 | missionId = self.config.get('MISSION', 'missionId') 24 | # 打印debug日志 25 | if DEBUG and MISSION_DEBUG: 26 | print('{SYS}{MISSION_DEBUG} config has been load from file successfully') 27 | return int(missionId) 28 | except Exception as e: 29 | # 打开错误日志文件 30 | wrongFile = open('data/wrongMessage.dat', 'a+') 31 | # 获取当前时间 32 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 33 | '%Y-%m-%d-%H-%M-%S')) 34 | # 生成报错的错误信息 35 | wrongMessage = { 36 | '|currentTime': currentTime, 37 | '|file': 'MissionSystem-AddMission-loadConfigFile', 38 | '|wrongMessage': str(e) 39 | } 40 | # 存入文件 41 | wrongFile.write(str(wrongMessage)) 42 | # 增加换行符 43 | wrongFile.write('\n') 44 | wrongFile.close() 45 | return None 46 | 47 | 48 | 49 | # 配置文件读取测试 50 | if __name__ == '__main__': 51 | l = LoadConfigFile(fileName='F:\python17\pythonPro\MemortAssit\conf\mession.ini') 52 | print(l.loadConfigFile()) 53 | -------------------------------------------------------------------------------- /src/Client/MissionSystem/AddMission/tools/saveConfigFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | 4 | from src.Client.Conf.config import * 5 | 6 | 7 | class SaveConfigFile(): 8 | """ 9 | 该类负责保存配置文件,属于实际操作类 10 | """ 11 | def __init__(self, fileName='../conf/mission.ini'): 12 | self.config = ConfigParser.ConfigParser() 13 | self.fileName = fileName 14 | 15 | def saveConfigFile(self, missionId): 16 | """ 17 | 18 | :param missionId: 需要保存的任务id (int 或者 string) 19 | :return: 20 | """ 21 | try: 22 | # 防御编程 若messionId不是string,转换则在这转换 23 | if type(missionId).__name__ != 'string': 24 | missionId = str(missionId).zfill(6) 25 | # 写回配置文件 26 | self.config.read(self.fileName) 27 | self.config.set("MISSION", "missionId", missionId) 28 | self.config.write(open(self.fileName, "r+")) 29 | # 打印debug日志 30 | if DEBUG and MISSION_DEBUG: 31 | print('{SYS}{MISSION_DEBUG} config has been save in file successfully') 32 | except Exception as e: 33 | # 打开错误日志文件 34 | wrongFile = open('data/wrongMessage.dat', 'a+') 35 | # 获取当前时间 36 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 37 | '%Y-%m-%d-%H-%M-%S')) 38 | # 生成报错的错误信息 39 | wrongMessage = { 40 | '|currentTime': currentTime, 41 | '|file': 'MissionSystem-AddMission-saveConfigFile', 42 | '|missionId': missionId, 43 | '|wrongMessage': str(e) 44 | } 45 | # 存入文件 46 | wrongFile.write(str(wrongMessage)) 47 | # 增加换行符 48 | wrongFile.write('\n') 49 | wrongFile.close() 50 | 51 | 52 | # 配置文件读取测试 53 | if __name__ == '__main__': 54 | s = SaveConfigFile(fileName='F:\python17\pythonPro\MemortAssit\conf\mession.ini') 55 | print(s.saveConfigFile(1)) 56 | -------------------------------------------------------------------------------- /src/Client/MissionSystem/BackupMission/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/MissionSystem/BackupMission/__init__.py -------------------------------------------------------------------------------- /src/Client/MissionSystem/BackupMission/backupMission.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | from src.Client.Conf.config import * 4 | from src.Client.SystemTools.SaveFiles import saveFiles 5 | from src.Client.SystemTools.LoadFiles import loadFiles 6 | from src.Client.MissionSystem.BackupMission.tools import backupFile, backupManage, chooseRecoverFile 7 | 8 | 9 | class BackupMission(): 10 | """ 11 | 备份系统,负责文件的备份、恢复等。调用类,任务由被调用者完成。 12 | """ 13 | def __init__(self, fileLimit=7, backupFilePath='../data/bkup/mbk/', missionFileName='../data/bkup/mission.dat'): 14 | # 初始化工具 15 | self.missionFileName = missionFileName 16 | self.fileLimit = fileLimit 17 | self.filePath = backupFilePath 18 | self.backupFileTools = backupFile.BackupFile() 19 | self.backupManageTools = backupManage.BackupManage(filePath=backupFilePath) 20 | self.chooseRecoverFileTools = chooseRecoverFile.ChooseRecoverFile(filePath=backupFilePath) 21 | pass 22 | 23 | def backup(self, list): 24 | """ 25 | 备份文件 26 | :param list: 需要备份的列表 27 | :return: 28 | """ 29 | # 使用当前时间作为备份文件名 30 | currentTime = datetime.datetime.strptime(time.strftime("%Y-%m-%d", time.localtime()), '%Y-%m-%d').strftime( 31 | "%Y%m%d") 32 | fileName = self.filePath + currentTime + '.dat' 33 | # 由于文件名发生变化,只能在这里初始化保存工具 34 | saveMissionTools = saveFiles.SaveFiles(filename=fileName) 35 | # 打印debug日志 36 | if DEBUG and MISSION_DEBUG: 37 | print('{SYS}{MISSION_DEBUG} save backup file') 38 | 39 | # 保存备份文件 40 | saveMissionTools.saveFiles(list=list) 41 | 42 | # 调用备份管理,管理备份文件 43 | self.backupManageTools.manage() 44 | 45 | 46 | def recover(self): 47 | """ 48 | 从备份文件中回复文件 49 | :return: 50 | """ 51 | fileName = self.chooseRecoverFileTools.choose() 52 | fileName = self.filePath + fileName 53 | # 获取最新备份文件的文件名 54 | backupFileNeedToLoad = True # 循环读取备份文件标记,直到正确读取 55 | while (backupFileNeedToLoad): 56 | try: 57 | loadMissionTools = loadFiles.LoadFiles(filename=fileName) 58 | list = loadMissionTools.loadFiles(missionType='mission') 59 | # 读取成功则跳出循环 60 | backupFileNeedToLoad = False 61 | # 判断文件是否真的读取成功了(读取失败返回None) 62 | if list is None: 63 | # 打印debug日志 64 | if DEBUG and MISSION_DEBUG: 65 | print('{SYS}{W}{MISSION_DEBUG} load backup file fail, return list is None, file name is ' 66 | + fileName) 67 | # 如果是读取失败将循环标记改回,继续下次读取 68 | backupFileNeedToLoad = True 69 | except: 70 | # 打印debug日志 71 | if DEBUG and MISSION_DEBUG: 72 | print('{SYS}{W}{MISSION_DEBUG} backup file load fail,name is ' + fileName) 73 | 74 | # 将从配置文件读取的信息保存 75 | saveMissionTools = saveFiles.SaveFiles(filename=self.missionFileName) 76 | saveMissionTools.saveFiles(list=list) 77 | 78 | 79 | 80 | if __name__ == '__main__': 81 | dataList = [] 82 | for i in range(1, 21): 83 | # 先封装成字典,方便后期删除 84 | dir = { 85 | 'missionId': str(i).zfill(6), 86 | 'bookName': 'bookName' + str(i).zfill(2), 87 | 'missionRange': 'missionRange' + str(i).zfill(2), 88 | 'nextTime': 'nextTime' + str(i).zfill(2), 89 | 'missionState': 'state' + str(i).zfill(2), 90 | 'loopTime': 5, 91 | 'isFinish': False 92 | } 93 | 94 | dataList.append(dir) 95 | 96 | b = BackupMission(backupFilePath='F:\python17\pythonPro\MemortAssit\data/bkup/mbk/', 97 | missionFileName='F:\python17\pythonPro\MemortAssit\data\mission.dat') 98 | # 测试备份 99 | # b.backup(dataList) 100 | # 测试读取备份 101 | b.recover() 102 | -------------------------------------------------------------------------------- /src/Client/MissionSystem/BackupMission/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/MissionSystem/BackupMission/tools/__init__.py -------------------------------------------------------------------------------- /src/Client/MissionSystem/BackupMission/tools/backupFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | class BackupFile(): 4 | """ 5 | 该类负责备份文件,目前由保存文件模块完成 6 | """ 7 | def __init__(self): 8 | pass 9 | 10 | def backup(self): 11 | pass 12 | -------------------------------------------------------------------------------- /src/Client/MissionSystem/BackupMission/tools/backupManage.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | from src.Client.Conf.config import * 4 | 5 | 6 | class BackupManage(): 7 | """ 8 | 该类负责备份管理,维护备份文件的个数,属于实际操作类 9 | """ 10 | def __init__(self, filePath='../data/bkup/mbk/'): 11 | self.filePath = filePath 12 | pass 13 | 14 | def manage(self): 15 | """ 16 | 文件管理 17 | :return: 18 | """ 19 | try: 20 | files = os.listdir(self.filePath) 21 | minFileName = None 22 | minFileTime = 0 23 | # 保持7个备份 24 | if len(files) > 7: 25 | # 打印debug日志 26 | if DEBUG and MISSION_DEBUG: 27 | print('{SYS}{MISSION_DEBUG} backup file need to delete') 28 | # 遍历目的中的文件,找出存在时间最长的文件名 29 | for file in files: 30 | # 初始化为第一个目录的修改时间的时间戳 31 | if minFileTime == 0: 32 | minFileTime = os.path.getctime(self.filePath + '/' + file) 33 | minFileName = file 34 | else: 35 | # 比较时间戳 36 | if minFileTime > os.path.getctime(self.filePath + '/' + file): 37 | minFileTime = os.path.getctime(self.filePath + '/' + file) 38 | minFileName = file 39 | # 删除时间戳最大的文件 40 | self.deleteBackupFile(minFileName) 41 | else: 42 | # 打印debug日志 43 | if DEBUG and MISSION_DEBUG: 44 | print('{SYS}{MISSION_DEBUG} backup file do not need to delete') 45 | except Exception as e: 46 | # 打开错误日志文件 47 | wrongFile = open('data/wrongMessage.dat', 'a+') 48 | # 获取当前时间 49 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 50 | '%Y-%m-%d-%H-%M-%S')) 51 | # 生成报错的错误信息 52 | wrongMessage = { 53 | '|currentTime': currentTime, 54 | '|file': 'MissionSystem-BackupMission-backupManage', 55 | '|wrongMessage': str(e) 56 | } 57 | # 存入文件 58 | wrongFile.write(str(wrongMessage)) 59 | # 增加换行符 60 | wrongFile.write('\n') 61 | wrongFile.close() 62 | 63 | 64 | def deleteBackupFile(self, fileName): 65 | """ 66 | 删除旧的备份信息 67 | :param fileName: 68 | :return: 69 | """ 70 | # 删除文件 71 | os.remove(self.filePath + fileName) 72 | # 打印debug日志 73 | if DEBUG and MISSION_DEBUG: 74 | print('{SYS}{MISSION_DEBUG} backup file has been delete,file name is ' + fileName) 75 | pass 76 | -------------------------------------------------------------------------------- /src/Client/MissionSystem/BackupMission/tools/chooseRecoverFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | from src.Client.Conf.config import * 4 | 5 | 6 | class ChooseRecoverFile(): 7 | """ 8 | 该类负责选择恢复文件,即选择一个最合适的文件作为数据恢复样本。实际操作类 9 | """ 10 | def __init__(self, filePath='../data/bkup/mbk/'): 11 | self.filePath = filePath 12 | pass 13 | 14 | def choose(self): 15 | """ 16 | 选择最新的备份作为备份文件 17 | :return: 18 | """ 19 | try: 20 | # 获取备份文件列表 21 | files = os.listdir(self.filePath) 22 | maxFileName = None 23 | maxFileTime = 0 24 | # 寻找最新的备份文件 25 | for file in files: 26 | # 初始化为第一个文件最后修改时间的时间戳 27 | if maxFileTime == 0: 28 | maxFileTime = os.path.getctime(self.filePath + '/' + file) 29 | maxFileName = file 30 | # 寻找最小时间戳 31 | else: 32 | if maxFileTime < os.path.getctime(self.filePath + '/' + file): 33 | maxFileTime = os.path.getctime(self.filePath + '/' + file) 34 | maxFileName = file 35 | if DEBUG and MISSION_DEBUG: 36 | print('{SYS}{MISSION_DEBUG} latest backup file has been chosen' + maxFileName) 37 | # 返回最小时间戳的文件名 38 | return maxFileName 39 | except Exception as e: 40 | # 打开错误日志文件 41 | wrongFile = open('data/wrongMessage.dat', 'a+') 42 | # 获取当前时间 43 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 44 | '%Y-%m-%d-%H-%M-%S')) 45 | # 生成报错的错误信息 46 | wrongMessage = { 47 | '|currentTime': currentTime, 48 | '|file': 'MissionSystem-BackupMission-chooseRecoverFile', 49 | '|wrongMessage': str(e) 50 | } 51 | # 存入文件 52 | wrongFile.write(str(wrongMessage)) 53 | # 增加换行符 54 | wrongFile.write('\n') 55 | wrongFile.close() 56 | return None 57 | -------------------------------------------------------------------------------- /src/Client/MissionSystem/EditMission/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/MissionSystem/EditMission/__init__.py -------------------------------------------------------------------------------- /src/Client/MissionSystem/EditMission/editMission.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | from src.Client.Conf.config import * 4 | 5 | from src.Client.MissionSystem.EditMission.tools import editMissionList, computeNextMissionTime, removeMission, \ 6 | finishMission 7 | from src.Client.SystemTools.SaveFiles import saveFiles 8 | 9 | 10 | class EditMission(): 11 | """ 12 | 编辑任务子系统。调用类,任务由被调用者完成。 13 | """ 14 | def __init__(self, filename='../data/mission.dat'): 15 | # 初始化工具 16 | self.computeNextTimeTools = computeNextMissionTime.ComputeNextMissionTime() 17 | self.editMissionTools = editMissionList.EditMissionList() 18 | self.finishMissionTools = finishMission.FinishMission() 19 | self.removeMissionTools = removeMission.RemoveMission() 20 | self.saveMissionTools = saveFiles.SaveFiles(filename=filename) 21 | pass 22 | 23 | def edit(self, list, missionId, bookName=None, missionRange=None, nextTime=None, state=None, loopTime=None, 24 | isEdit=False, isFinish=False, isDelete=False): 25 | """ 26 | 27 | :param list: 需要被编辑的列表 28 | :param missionId: 任务id 29 | :param bookName: 书名 30 | :param missionRange: 任务范围 31 | :param nextTime: 下次时间 32 | :param state: 任务状态 33 | :param loopTime: 迭代次数 34 | :param isEdit: 执行编辑任务标记 35 | :param isFinish: 执行完成任务标记 36 | :param isDelete: 执行删除任务标记 37 | :return: 编辑后的list 38 | """ 39 | try: 40 | # 对不同的编辑命令做出不同的响应 41 | if isEdit: 42 | # 调用编辑子系统 43 | list = self.editMissionTools.edit(list=list, missionId=missionId, bookName=bookName, 44 | missionRange=missionRange, 45 | nextTime=nextTime, state=state, loopTime=loopTime, isFinish=isFinish) 46 | self.saveMissionTools.saveFiles(list) 47 | if isFinish: 48 | # 调用完成子系统 49 | list = self.finishMissionTools.finish(list=list, missionId=missionId) 50 | list = self.computeNextTimeTools.compute(list=list, missionId=missionId) 51 | self.saveMissionTools.saveFiles(list) 52 | if isDelete: 53 | # 调用删除子系统 54 | list = self.removeMissionTools.remove(list=list, missionId=missionId) 55 | self.saveMissionTools.saveFiles(list) 56 | except: 57 | # 打印debug日志 58 | if DEBUG and MISSION_DEBUG: 59 | print('{SYS}{W}{MISSION_DEBUG} can not edit mission') 60 | 61 | 62 | # 测试任务编辑系统 63 | if __name__ == '__main__': 64 | from src.Client.SystemTools.LoadFiles import loadFiles 65 | 66 | l = loadFiles.LoadFiles("F:\python17\pythonPro\MemortAssit\data\mission.dat") 67 | list = l.loadFiles(missionType='mission') 68 | print(list) 69 | print() 70 | e = EditMission('F:\python17\pythonPro\MemortAssit\data\mission.dat') 71 | # 测试更改完成状态 72 | # e.edit(list, '000025', isFinish=True) 73 | # 测试更改 74 | # e.edit(list, '000025', isEdit=True, bookName='bookTest') 75 | # 测试删除 76 | e.edit(list, '000025', isDelete=True) 77 | print(list) 78 | -------------------------------------------------------------------------------- /src/Client/MissionSystem/EditMission/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/MissionSystem/EditMission/tools/__init__.py -------------------------------------------------------------------------------- /src/Client/MissionSystem/EditMission/tools/editMissionList.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | 4 | 5 | class EditMissionList(): 6 | """ 7 | 负责编辑任务,实际操作类 8 | """ 9 | def edit(self, list, missionId, bookName=None, missionRange=None, nextTime=None, state=None, loopTime=None, 10 | isFinish=None): 11 | """ 12 | 编辑任务 13 | :param list: 目标list 14 | :param missionId: 任务id(string 15 | :param bookName: 书名 16 | :param missionRange: 任务范围 17 | :param nextTime: 下次任务时间 18 | :param state: 任务状态 19 | :param loopTime: 剩余迭代次数 20 | :param isFinish: 任务是否完成 21 | :return: 插入后的list 22 | """ 23 | # 首先将列表备份,以便添加失败时返回最近正常的点 24 | backupList = list[:] 25 | try: 26 | # 转换任务id,防御编程 27 | missionId = str(missionId).zfill(6) 28 | # 遍历任务列表寻找目标任务 29 | for each in list: 30 | if each['missionId'] == missionId: 31 | # 对目标任务进行更新 32 | if bookName != None: 33 | each['bookName'] = bookName 34 | if missionRange != None: 35 | each['missionRange'] = missionRange 36 | if nextTime != None: 37 | each['nextTime'] = nextTime 38 | if state != None: 39 | each['state'] = state 40 | if loopTime != None: 41 | each['loopTime'] = loopTime 42 | if isFinish != None: 43 | each['isFinish'] = isFinish 44 | # 打印debug日志 45 | if DEBUG and MISSION_DEBUG: 46 | print('{SYS}{MISSION_DEBUG} mission has been edit finish successfully id is ' + missionId) 47 | 48 | return list 49 | except Exception as e: 50 | # 打开错误日志文件 51 | wrongFile = open('data/wrongMessage.dat', 'a+') 52 | # 获取当前时间 53 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 54 | '%Y-%m-%d-%H-%M-%S')) 55 | # 生成报错的错误信息 56 | wrongMessage = { 57 | '|currentTime': currentTime, 58 | '|file': 'MissionSystem-EditMission-editMissionList', 59 | '|list': list, 60 | '|missionId': missionId, 61 | '|bookName': bookName, 62 | '|missionRange': missionRange, 63 | '|nextTime': nextTime, 64 | '|state': state, 65 | '|loopTime': loopTime, 66 | '|isFinish': isFinish, 67 | '|wrongMessage': str(e) 68 | } 69 | # 存入文件 70 | wrongFile.write(str(wrongMessage)) 71 | # 增加换行符 72 | wrongFile.write('\n') 73 | wrongFile.close() 74 | return backupList 75 | 76 | -------------------------------------------------------------------------------- /src/Client/MissionSystem/EditMission/tools/finishMission.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | from src.Client.Conf.config import * 4 | 5 | 6 | class FinishMission(): 7 | """ 8 | 该类负责完成任务,即将任务标记为完成状态。实际操作类。 9 | """ 10 | def finish(self, list, missionId): 11 | """ 12 | 完成任务 13 | :param list: 列表 14 | :param missionId: 完成的任务编号 15 | :return: list列表 16 | """ 17 | # 首先将列表备份,以便添加失败时返回最近正常的点 18 | backupList = list[:] 19 | try: 20 | # 转换任务id,防御编程 21 | missionId = str(missionId).zfill(6) 22 | # 遍历任务列表找到目标任务 23 | for each in list: 24 | if each['missionId'] == missionId: 25 | # 完成状态置为True 26 | each['isFinish'] = True 27 | # 打印debug日志 28 | if DEBUG and MISSION_DEBUG: 29 | print('{SYS}{MISSION_DEBUG} mission has been set finish successfully id is ' + missionId) 30 | return list 31 | except Exception as e: 32 | # 打开错误日志文件 33 | wrongFile = open('data/wrongMessage.dat', 'a+') 34 | # 获取当前时间 35 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 36 | '%Y-%m-%d-%H-%M-%S')) 37 | # 生成报错的错误信息 38 | wrongMessage = { 39 | '|currentTime': currentTime, 40 | '|file': 'MissionSystem-EditMission-finishMission', 41 | '|list': list, 42 | '|missionId': missionId, 43 | '|wrongMessage': str(e) 44 | } 45 | # 存入文件 46 | wrongFile.write(str(wrongMessage)) 47 | # 增加换行符 48 | wrongFile.write('\n') 49 | wrongFile.close() 50 | return backupList 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/Client/MissionSystem/EditMission/tools/removeMission.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | 4 | 5 | class RemoveMission(): 6 | """ 7 | 移除任务类,负责将任务删除。实际操作类 8 | """ 9 | def remove(self, list, missionId): 10 | """ 11 | 删除任务 12 | :param list: 列表 13 | :param missionId: 完成的任务编号 14 | :return: list列表 15 | """ 16 | # 首先将列表备份,以便添加失败时返回最近正常的点 17 | backupList = list[:] 18 | try: 19 | # 转换任务id,防御编程 20 | missionId = str(missionId).zfill(6) 21 | # 遍历任务列表找到目标任务 22 | for each in list: 23 | if each['missionId'] == missionId: 24 | # 从列表中删除任务 25 | list.remove(each) 26 | # 打印debug日志 27 | if DEBUG and MISSION_DEBUG: 28 | print('{SYS}{MISSION_DEBUG} mission has been delete successfully,id is '+missionId) 29 | return list 30 | except Exception as e: 31 | # 打开错误日志文件 32 | wrongFile = open('data/wrongMessage.dat', 'a+') 33 | # 获取当前时间 34 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 35 | '%Y-%m-%d-%H-%M-%S')) 36 | # 生成报错的错误信息 37 | wrongMessage = { 38 | '|currentTime': currentTime, 39 | '|file': 'MissionSystem-EditMission-removeMission', 40 | '|list': list, 41 | '|missionId': missionId, 42 | '|wrongMessage': str(e) 43 | } 44 | # 存入文件 45 | wrongFile.write(str(wrongMessage)) 46 | # 增加换行符 47 | wrongFile.write('\n') 48 | wrongFile.close() 49 | return backupList 50 | 51 | -------------------------------------------------------------------------------- /src/Client/MissionSystem/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/MissionSystem/__init__.py -------------------------------------------------------------------------------- /src/Client/SearchSystem/SearchMission/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/SearchSystem/SearchMission/__init__.py -------------------------------------------------------------------------------- /src/Client/SearchSystem/SearchMission/searchMission.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | -------------------------------------------------------------------------------- /src/Client/SearchSystem/TranslateTools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/SearchSystem/TranslateTools/__init__.py -------------------------------------------------------------------------------- /src/Client/SearchSystem/TranslateTools/translateInWebXml.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | 4 | 5 | class Translate(): 6 | """ 7 | 翻译类,负责单词的中英互译。具体操作类。 8 | """ 9 | def translate(self, word): 10 | """ 11 | 翻译单词(返回详细的单词翻译) 12 | :param word: 需要被翻译的文本(英汉均可) 13 | :return: 14 | """ 15 | try: 16 | translateURL = 'http://fy.webxml.com.cn/webservices/EnglishChinese.asmx/Translator?wordKey=' + str(word) 17 | r = requests.get(translateURL) 18 | text = r.text 19 | # 判断翻译类型,调用不同的解析方案 20 | if self.isChinese(word): 21 | message = self.handleCNRequest(text) 22 | else: 23 | message = self.handleENRequest(text) 24 | return message 25 | except Exception as e: 26 | # 打开错误日志文件 27 | wrongFile = open('data/wrongMessage.dat', 'a+') 28 | # 获取当前时间 29 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 30 | '%Y-%m-%d-%H-%M-%S')) 31 | # 生成报错的错误信息 32 | wrongMessage = { 33 | '|currentTime': currentTime, 34 | '|file': 'SearchSystem-TranslateTools-translateInWebXml', 35 | '|word': word, 36 | '|wrongMessage': str(e) 37 | } 38 | # 存入文件 39 | wrongFile.write(str(wrongMessage)) 40 | # 增加换行符 41 | wrongFile.write('\n') 42 | wrongFile.close() 43 | return None 44 | 45 | 46 | def handleCNRequest(self, text): 47 | """ 48 | 处理中文的翻译响应 49 | :param text: 响应 50 | :return: 解析后生成字典 51 | """ 52 | wordDir = { 53 | 'word': re.findall('(.*?)', text)[0], 54 | 'pron': '[' + re.findall('(.*?)', text)[0] + ']', 55 | 'translation': re.findall('(.*?)', text)[0], 56 | 'sentenceOneOrig': re.findall('(.*?)', text)[0], 57 | 'sentenceOneTrans': re.findall('(.*?)', text)[0], 58 | 'sentenceTwoOrig': re.findall('(.*?)', text)[1], 59 | 'sentenceTwoTrans': re.findall('(.*?)', text)[1], 60 | } 61 | # 打印debug日志 62 | if DEBUG and SEARCH_DEBUG: 63 | print('{SYS}{SEARCH_DEBUG} translate CN into EN, result is ' + wordDir['translation']) 64 | return wordDir 65 | 66 | def handleENRequest(self, text): 67 | """ 68 | 处理英文的翻译响应 69 | :param text: 响应 70 | :return: 解析后生成字典 71 | """ 72 | wordDir = { 73 | 'word': re.findall('(.*?)', text)[0], 74 | 'pron': '[' + re.findall('(.*?)', text)[0] + ']', 75 | 'translation': re.findall('(.*?)', text)[0], 76 | 'sentenceOneOrig': re.findall('(.*?)', text)[0], 77 | 'sentenceOneTrans': re.findall('(.*?)', text)[0], 78 | 'sentenceTwoOrig': re.findall('(.*?)', text)[1], 79 | 'sentenceTwoTrans': re.findall('(.*?)', text)[1], 80 | } 81 | # 打印debug日志 82 | if DEBUG and SEARCH_DEBUG: 83 | print('{SYS}{SEARCH_DEBUG} translate EN into CN, result is ' + wordDir['translation']) 84 | return wordDir 85 | 86 | def isChinese(self, word): 87 | """ 88 | 判断是否是中文 89 | :param word: 需要被判断的字符 90 | :return: 是否是中文 91 | """ 92 | for ch in word.decode('utf-8'): 93 | if u'\u4e00' <= ch <= u'\u9fff': 94 | return True 95 | return False 96 | 97 | 98 | if __name__ == '__main__': 99 | # print(Translate().isChinese('aa')) 100 | # print(Translate().isChinese('火车')) 101 | Translate().translate('applee') 102 | pass 103 | -------------------------------------------------------------------------------- /src/Client/SearchSystem/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/SearchSystem/__init__.py -------------------------------------------------------------------------------- /src/Client/SearchSystem/searchSystem.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | 4 | from src.Client.MissionSystem import missionSystem 5 | from src.Client.SearchSystem.TranslateTools import translateInWebXml 6 | 7 | 8 | class SearchSystem(): 9 | """ 10 | 搜索子系统。区分搜索的类型,分别调用查词或者任务系统的任务搜索方法。 11 | """ 12 | def __init__(self, dataFileName='data\mission.dat'): 13 | # 初始化工具 14 | self.missionSystemTools = missionSystem.MissionSystem(dataFileName=dataFileName) 15 | self.translateTools = translateInWebXml.Translate() 16 | 17 | def search(self, words): 18 | """ 19 | 查找单词或者搜索任务id 20 | :param words: 单词或id 21 | :return: 单词的翻译信息或者id的任务信息 22 | """ 23 | result = None 24 | # 判断是不是单词,来区分单词和任务的区分调用 25 | if self.isWord(words): 26 | # 打印debug日志 27 | if DEBUG and SEARCH_DEBUG: 28 | print('{SYS}{SEARCH_DEBUG} word translate') 29 | result = self.translateTools.translate(words) 30 | # 应对无法完成翻译,翻译模块无法解析返回文本,错误处理返回None作为无法处理信息 31 | if result is None: 32 | # 继续向调用者反馈无法翻译的信息,以便向用户做出说明 33 | return None, True 34 | return result, True 35 | else: 36 | # 打印debug日志 37 | if DEBUG and SEARCH_DEBUG: 38 | print('{SYS}{SEARCH_DEBUG} mission search') 39 | result = self.missionSystemTools.searchMission(words) 40 | return result, False 41 | 42 | def isWord(self, word): 43 | """ 44 | 判断是否是单词 45 | :param word: 需要判断的文本 46 | :return: 是否是单词(所有非纯数字均认为是单词) 47 | """ 48 | try: 49 | int(word) 50 | return False 51 | except: 52 | return True 53 | 54 | 55 | if __name__ == '__main__': 56 | # print(SearchSystem('F:\python17\pythonPro\MemortAssit\data\mission.dat').isWord('aa')) 57 | SearchSystem('F:\python17\pythonPro\MemortAssit\data\mission.dat').search('banana') 58 | pass 59 | -------------------------------------------------------------------------------- /src/Client/SystemTools/ChangeLanguage/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/SystemTools/ChangeLanguage/__init__.py -------------------------------------------------------------------------------- /src/Client/SystemTools/ChangeLanguage/changeLanguage.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | 4 | from src.Client.Conf.config import * 5 | 6 | 7 | class ChangeLanguage(): 8 | def change(self, languageType): 9 | pass 10 | -------------------------------------------------------------------------------- /src/Client/SystemTools/ConfFileRead/Tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/SystemTools/ConfFileRead/Tools/__init__.py -------------------------------------------------------------------------------- /src/Client/SystemTools/ConfFileRead/Tools/readConfigFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | 4 | from src.Client.Conf.config import * 5 | 6 | 7 | class ReadConfigFile(): 8 | """ 9 | 该类负责读取配置文件,属于实际操作类 10 | """ 11 | 12 | def __init__(self, fileName='../conf/main.ini'): 13 | self.config = ConfigParser.ConfigParser() 14 | self.fileName = fileName 15 | 16 | def readConfigFile(self, configMainName, configSubName): 17 | """ 18 | 19 | :param configMainName:配置信息主属性名 20 | :param configSubName:配置信息副属性名 21 | :return:配置信息(str) 22 | """ 23 | try: 24 | # 读取配置文件 25 | self.config.readfp(open(self.fileName)) 26 | message = self.config.get(configMainName, configSubName) 27 | # 打印debug日志 28 | if DEBUG and SYSTEM_TOOLS_DEBUG: 29 | print('{SYS}{MISSION_DEBUG} config has been load from file successfully') 30 | return str(message) 31 | except Exception as e: 32 | # 打开错误日志文件 33 | wrongFile = open('data/wrongMessage.dat', 'a+') 34 | # 获取当前时间 35 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 36 | '%Y-%m-%d-%H-%M-%S')) 37 | # 生成报错的错误信息 38 | wrongMessage = { 39 | '|currentTime': currentTime, 40 | '|configMainName': configMainName, 41 | '|configSubName': configSubName, 42 | '|file': 'SystemTools-ConfFileRead-readConfigFile', 43 | '|wrongMessage': str(e) 44 | } 45 | # 存入文件 46 | wrongFile.write(str(wrongMessage)) 47 | # 增加换行符 48 | wrongFile.write('\n') 49 | wrongFile.close() 50 | return None 51 | 52 | 53 | # 配置文件读取测试 54 | if __name__ == '__main__': 55 | l = ReadConfigFile(fileName='F:\python17\pythonPro\MemortAssit\conf\main.ini') 56 | print(l.readConfigFile('VERSION', 'version')) 57 | -------------------------------------------------------------------------------- /src/Client/SystemTools/ConfFileRead/Tools/saveConfigFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | 4 | from src.Client.Conf.config import * 5 | 6 | 7 | class SaveConfigFile(): 8 | """ 9 | 该类负责保存配置文件,属于实际操作类 10 | """ 11 | 12 | def __init__(self, fileName='../conf/main.ini'): 13 | self.config = ConfigParser.ConfigParser() 14 | self.fileName = fileName 15 | 16 | def saveConfigFile(self, configMainName, configSubName, value): 17 | """ 18 | 19 | :param missionId: 需要保存的任务id (int 或者 string) 20 | :return: 21 | """ 22 | try: 23 | # 防御编程 若value不是string,转换则在这转换 24 | if configMainName is None or configSubName is None: 25 | return None 26 | # 写回配置文件 27 | self.config.read(self.fileName) 28 | self.config.set(configMainName, configSubName, value) 29 | self.config.write(open(self.fileName, "r+")) 30 | # 打印debug日志 31 | if DEBUG and SYSTEM_TOOLS_DEBUG: 32 | print('{SYS}{MISSION_DEBUG} config has been save in file successfully') 33 | except Exception as e: 34 | # 打开错误日志文件 35 | wrongFile = open('data/wrongMessage.dat', 'a+') 36 | # 获取当前时间 37 | currentTime = str( 38 | datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), '%Y-%m-%d-%H-%M-%S')) 39 | # 生成报错的错误信息 40 | wrongMessage = { 41 | '|currentTime': currentTime, 42 | '|file': 'SystemTools-ConfFileRead-saveConfigFile', 43 | '|configMainName': configMainName, 44 | '|configSubName': configSubName, 45 | '|value': value, 46 | '|wrongMessage': str(e) 47 | } 48 | # 存入文件 49 | wrongFile.write(str(wrongMessage)) 50 | # 增加换行符 51 | wrongFile.write('\n') 52 | wrongFile.close() 53 | 54 | 55 | # 配置文件读取测试 56 | if __name__ == '__main__': 57 | s = SaveConfigFile(fileName='F:\python17\pythonPro\MemortAssit\conf\main.ini') 58 | print(s.saveConfigFile('VERSION', 'version', 'v1.0')) 59 | -------------------------------------------------------------------------------- /src/Client/SystemTools/ConfFileRead/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/SystemTools/ConfFileRead/__init__.py -------------------------------------------------------------------------------- /src/Client/SystemTools/ConfFileRead/configFileRead.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | 4 | from src.Client.Conf.config import * 5 | from src.Client.SystemTools.ConfFileRead.Tools import readConfigFile 6 | from src.Client.SystemTools.ConfFileRead.Tools import saveConfigFile 7 | 8 | 9 | class ConfigFileRead(): 10 | def __init__(self, fileName): 11 | # 因为用户自定义配置应该排除在版本控制文件之外,所以为了防止出现差错,要求配置文件读写全部指定文件,禁止使用默认 12 | # def __init__(self, fileName='./conf/main.ini'): 13 | self.readConfigFileTools = readConfigFile.ReadConfigFile(fileName=fileName) 14 | self.saveConfigFileTools = saveConfigFile.SaveConfigFile(fileName=fileName) 15 | pass 16 | 17 | def readFile(self, configMainName, configSubName): 18 | """ 19 | 读取配置文件 20 | :param configMainName: 配置文件主名称 21 | :param configSubName: 配置文件副名称 22 | :return: 配置信息的值 23 | """ 24 | message = self.readConfigFileTools.readConfigFile(configMainName=configMainName, configSubName=configSubName) 25 | return message 26 | 27 | def saveFile(self, configMainName, configSubName, value): 28 | """ 29 | 保存到配置文件 30 | :param configMainName: 配置文件主名称 31 | :param configSubName: 配置文件副名称 32 | :param value: 配置文件的值 33 | :return: 34 | """ 35 | self.saveConfigFileTools.saveConfigFile(configMainName=configMainName, configSubName=configSubName, value=value) 36 | 37 | 38 | if __name__ == '__main__': 39 | print(ConfigFileRead().readFile('USER_CODE', 'user_code')) 40 | -------------------------------------------------------------------------------- /src/Client/SystemTools/LoadFiles/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/SystemTools/LoadFiles/__init__.py -------------------------------------------------------------------------------- /src/Client/SystemTools/LoadFiles/loadFiles.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | from src.Client.SystemTools.LoadFiles.tools import loadFiles, decodeText 4 | 5 | 6 | class LoadFiles(): 7 | """ 8 | 读取文件子系统。调用类,任务由被调用者完成。 9 | """ 10 | 11 | def __init__(self, filename='data/mission.dat'): 12 | self.fileName = filename 13 | # 初始化解密工具 14 | self.decodeTools = decodeText.DecodeText() 15 | # 初始化读取工具 16 | self.loadTools = loadFiles.LoadFiles(fileName=filename) 17 | 18 | def loadFiles(self, missionType='mission'): 19 | """ 20 | 读取任务文件,读取失败直接删除该文件 21 | :param missionType 因为读取文件时需要对任务初始化,而背诵不需要,因此增加任务类型 22 | :return: 23 | """ 24 | try: 25 | # 获取加密文件内容 26 | encodeText = self.loadTools.loadFiles() 27 | # 解密加密内容 28 | list = self.decodeTools.decodeing(encodeText) 29 | # 返回列表 30 | returnList = [] 31 | # 获取当日时间 32 | today = datetime.datetime.strptime(time.strftime("%Y-%m-%d", time.localtime()), '%Y-%m-%d').strftime( 33 | "%Y-%m-%d") 34 | if missionType == 'mission': 35 | # 对当日任务完成情况置为False 36 | for each in list: 37 | if each['nextTime'] == today: 38 | each['isFinish'] = False 39 | returnList.append(each) 40 | return returnList 41 | if missionType == 'recitation': 42 | return list 43 | 44 | except: 45 | # 处理非异常情况,即第一次打开软件的空数据文件 46 | if os.path.getsize(self.fileName) == 0: 47 | return [] 48 | # 反正读取不了 删了吧 -.- 49 | os.remove(self.fileName) 50 | # 打印debug日志 51 | if DEBUG and MISSION_DEBUG: 52 | print('{SYS}{W}{MISSION_DEBUG} can not load mission,file has been delete') 53 | # 返回None作为调用者知道读取失败的信息 54 | return None 55 | 56 | 57 | # 进行读取文件的子系统测试 58 | if __name__ == '__main__': 59 | l = LoadFiles('F:\python17\pythonPro\MemortAssit\data\mission.dat') 60 | data = l.loadFiles(missionType='mission') 61 | print(data) 62 | -------------------------------------------------------------------------------- /src/Client/SystemTools/LoadFiles/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/SystemTools/LoadFiles/tools/__init__.py -------------------------------------------------------------------------------- /src/Client/SystemTools/LoadFiles/tools/decodeText.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | import binascii 3 | import pickle 4 | 5 | from src.Client.Conf.config import * 6 | 7 | 8 | class DecodeText(): 9 | """ 10 | 负责解码文本,将加密的文档解密并解序列化。实际操作类。 11 | """ 12 | def decodeing(self, data): 13 | """ 14 | 解密 15 | :param data: 需要被解密的数据 16 | :return: 解密后的列表 17 | """ 18 | try: 19 | # 将文本转换进制 20 | byte_data = binascii.a2b_hex(data) 21 | # 反序列化 22 | list = pickle.loads(byte_data) 23 | # 打印debug日志 24 | if DEBUG and MISSION_DEBUG: 25 | print('{SYS}{SYSTEM_TOOLS_DEBUG} list has been decode successfully') 26 | return list 27 | except Exception as e: 28 | # 打开错误日志文件 29 | wrongFile = open('data/wrongMessage.dat', 'a+') 30 | # 获取当前时间 31 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 32 | '%Y-%m-%d-%H-%M-%S')) 33 | # 生成报错的错误信息 34 | wrongMessage = { 35 | '|currentTime': currentTime, 36 | '|file': 'SystemTools-LoadFiles-decodeText', 37 | '|data': data, 38 | '|wrongMessage': str(e) 39 | } 40 | # 存入文件 41 | wrongFile.write(str(wrongMessage)) 42 | # 增加换行符 43 | wrongFile.write('\n') 44 | wrongFile.close() 45 | return None 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/Client/SystemTools/LoadFiles/tools/loadFiles.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | 4 | 5 | class LoadFiles(): 6 | """ 7 | 负责读取任务文件类,实际操作类。 8 | """ 9 | def __init__(self, fileName='../data/mission.dat'): 10 | self.fileName = fileName 11 | pass 12 | 13 | def loadFiles(self): 14 | """ 15 | 读取文件 16 | :return:读取的文件结果 17 | """ 18 | try: 19 | # 读取文件,放在这而不放在构造函数中是因为这里可以catch到找不到文件的错误,以便读取备份文件 20 | self.dataFile = open(self.fileName, 'rb') 21 | # 读取文件 22 | fileData = self.dataFile.read() 23 | # 关闭文件流 24 | self.dataFile.close() 25 | # 打印debug日志 26 | if DEBUG and MISSION_DEBUG: 27 | print('{SYS}{SYSTEM_TOOLS_DEBUG} file has been load from file successfully') 28 | return fileData 29 | except Exception as e: 30 | # 打开错误日志文件 31 | wrongFile = open('data/wrongMessage.dat', 'a+') 32 | # 获取当前时间 33 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 34 | '%Y-%m-%d-%H-%M-%S')) 35 | # 生成报错的错误信息 36 | wrongMessage = { 37 | '|currentTime': currentTime, 38 | '|file': 'SystemTools-LoadFiles-loadMissionFile', 39 | '|wrongMessage': str(e) 40 | } 41 | # 存入文件 42 | wrongFile.write(str(wrongMessage)) 43 | # 增加换行符 44 | wrongFile.write('\n') 45 | wrongFile.close() 46 | return None 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/Client/SystemTools/SaveFiles/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/SystemTools/SaveFiles/__init__.py -------------------------------------------------------------------------------- /src/Client/SystemTools/SaveFiles/saveFiles.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | from src.Client.SystemTools.SaveFiles.tools import saveToFiles, encodeText 4 | 5 | 6 | class SaveFiles(): 7 | """ 8 | 保存文件子系统。调用类,任务由被调用者完成。 9 | """ 10 | 11 | def __init__(self, filename='../data/mission.dat'): 12 | # 初始化加密工具 13 | self.encodeTools = encodeText.EncodeText() 14 | # 初始化保存工具 15 | self.saveTools = saveToFiles.SaveToFile(fileName=filename) 16 | 17 | def saveFiles(self, list): 18 | """ 19 | 保存任务 20 | :param list: 需要被保存的列表 21 | :return: 22 | """ 23 | # 获取加密结果 24 | try: 25 | encodeText = self.encodeTools.encodeing(list) 26 | self.saveTools.saveToFile(encodeText) 27 | except: 28 | # 打印debug日志 29 | if DEBUG and MISSION_DEBUG: 30 | print('{SYS}{W}{MISSION_DEBUG} can not save mission file') 31 | 32 | 33 | # 进行文件存储的子系统测试 34 | if __name__ == '__main__': 35 | dataList = [] 36 | for i in range(1, 6): 37 | # 先封装成字典,方便后期删除 38 | dir = { 39 | 'missionId': str(i).zfill(6), 40 | 'bookName': 'bookName' + str(i).zfill(2), 41 | 'missionRange': 'missionRange' + str(i).zfill(2), 42 | 'nextTime': '2019-02-12', 43 | 'state': 1, 44 | 'loopTime': 5, 45 | 'isFinish': False 46 | } 47 | 48 | dataList.append(dir) 49 | s = SaveFiles('F:\python17\pythonPro\MemortAssit\data\mission.dat') 50 | s.saveFiles(list=dataList) 51 | -------------------------------------------------------------------------------- /src/Client/SystemTools/SaveFiles/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/SystemTools/SaveFiles/tools/__init__.py -------------------------------------------------------------------------------- /src/Client/SystemTools/SaveFiles/tools/encodeText.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | import binascii 3 | import pickle 4 | 5 | from src.Client.Conf.config import * 6 | 7 | 8 | 9 | class EncodeText(): 10 | """ 11 | 编码文件类,将需要保存的列表序列化并加密。实际操作类。 12 | """ 13 | def encodeing(self, data): 14 | """ 15 | 将列表加密 16 | :param data: 需要加密的列表 17 | :return: 加密后的结果 18 | """ 19 | try: 20 | # 首先将列表序列化 21 | byte_data = pickle.dumps(data) 22 | # 进制转换加密 23 | encodeText = binascii.b2a_hex(byte_data) 24 | # 打印debug日志 25 | if DEBUG and MISSION_DEBUG: 26 | print('{SYS}{SYSTEM_TOOLS_DEBUG} list has been encode successfully') 27 | return encodeText 28 | except Exception as e: 29 | # 打开错误日志文件 30 | wrongFile = open('data/wrongMessage.dat', 'a+') 31 | # 获取当前时间 32 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 33 | '%Y-%m-%d-%H-%M-%S')) 34 | # 生成报错的错误信息 35 | wrongMessage = { 36 | '|currentTime': currentTime, 37 | '|file': 'SystemTools-SaveFiles-encodeText', 38 | '|data': data, 39 | '|wrongMessage': str(e) 40 | } 41 | # 存入文件 42 | wrongFile.write(str(wrongMessage)) 43 | # 增加换行符 44 | wrongFile.write('\n') 45 | wrongFile.close() 46 | return None 47 | -------------------------------------------------------------------------------- /src/Client/SystemTools/SaveFiles/tools/saveToFiles.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | 4 | 5 | class SaveToFile(): 6 | """ 7 | 保存文件类,将列表保存到文件。实际操作类 8 | """ 9 | def __init__(self, fileName='../data/mission.dat'): 10 | self.fileName = fileName 11 | 12 | def saveToFile(self, data): 13 | """ 14 | 保存加密数据到文件 15 | :param data: 加密数据 16 | :return: 17 | """ 18 | try: 19 | # 保存到文件 20 | self.files = open(self.fileName, 'wb') 21 | self.files.write(data) 22 | # 关闭文件流 23 | self.files.close() 24 | # 打印debug日志 25 | if DEBUG and MISSION_DEBUG: 26 | print('{SYS}{SYSTEM_TOOLS_DEBUG} files has been write in file successfully') 27 | except Exception as e: 28 | # 打开错误日志文件 29 | wrongFile = open('data/wrongMessage.dat', 'a+') 30 | # 获取当前时间 31 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 32 | '%Y-%m-%d-%H-%M-%S')) 33 | # 生成报错的错误信息 34 | wrongMessage = { 35 | '|currentTime': currentTime, 36 | '|file': 'SystemTools-SaveFiles-saveToFile', 37 | '|data': data, 38 | '|wrongMessage': str(e) 39 | } 40 | # 存入文件 41 | wrongFile.write(str(wrongMessage)) 42 | # 增加换行符 43 | wrongFile.write('\n') 44 | wrongFile.close() 45 | return None 46 | 47 | 48 | 49 | if __name__ == '__main__': 50 | f = open('../../../../data/mission.dat', 'wb') 51 | print(f.read()) 52 | -------------------------------------------------------------------------------- /src/Client/SystemTools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/SystemTools/__init__.py -------------------------------------------------------------------------------- /src/Client/TranslateSystem/Tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/TranslateSystem/Tools/__init__.py -------------------------------------------------------------------------------- /src/Client/TranslateSystem/Tools/translateInBaidu.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | import httplib 3 | 4 | from src.Client.Conf.config import * 5 | 6 | # import httplib 7 | import http.client 8 | import hashlib 9 | import urllib 10 | import random 11 | import re 12 | 13 | appid = 'your appId' # 你的appid 14 | secretKey = 'your Key' # 你的密钥 15 | 16 | 17 | class Translate(): 18 | """ 19 | 负责长文本的翻译,默认中译英或者英译中,输入其他语言也可以。实际操作类。 20 | """ 21 | def translate(self, q): 22 | """ 23 | 使用百度翻译进行翻译 24 | :param q: 需要被翻译的文本(英汉均可) 25 | :return: 翻译后的文本 26 | """ 27 | httpClient = None 28 | myurl = '/api/trans/vip/translate' 29 | fromLang = 'auto' 30 | toLang = 'auto' 31 | salt = random.randint(32768, 65536) 32 | 33 | sign = appid + q + str(salt) + secretKey 34 | m1 = hashlib.md5() 35 | m1.update(sign) 36 | sign = m1.hexdigest() 37 | myurl = myurl + '?appid=' + appid + '&q=' + urllib.quote( 38 | q) + '&from=' + fromLang + '&to=' + toLang + '&salt=' + str( 39 | salt) + '&sign=' + sign 40 | 41 | try: 42 | httpClient = httplib.HTTPConnection('api.fanyi.baidu.com') 43 | httpClient.request('GET', myurl) 44 | 45 | # response是HTTPResponse对象 46 | response = httpClient.getresponse() 47 | res = response.read().encode('latin-1').decode('unicode_escape') 48 | # 分割返回结果,将unicode转化为中文并输出 49 | result = re.findall('"dst":"(.*?)"', res)[0] 50 | if DEBUG and SEARCH_DEBUG: 51 | print('{SYS}{SEARCH_DEBUG} word has been translate, result is ' + result) 52 | return result 53 | except Exception as e: 54 | # print (e) 55 | # 打开错误日志文件 56 | wrongFile = open('data/wrongMessage.dat', 'a+') 57 | # 获取当前时间 58 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 59 | '%Y-%m-%d-%H-%M-%S')) 60 | # 生成报错的错误信息 61 | wrongMessage = { 62 | '|currentTime': currentTime, 63 | '|file': 'TranslateSystem-Tools-translateInBaidu', 64 | '|translateText': q, 65 | '|wrongMessage': str(e) 66 | } 67 | # 存入文件 68 | wrongFile.write(str(wrongMessage)) 69 | # 增加换行符 70 | wrongFile.write('\n') 71 | wrongFile.close() 72 | return None 73 | finally: 74 | if httpClient: 75 | httpClient.close() 76 | 77 | 78 | if __name__ == '__main__': 79 | print(Translate().translate('火车train')) 80 | -------------------------------------------------------------------------------- /src/Client/TranslateSystem/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/TranslateSystem/__init__.py -------------------------------------------------------------------------------- /src/Client/TranslateSystem/translateSystem.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | from src.Client.TranslateSystem.Tools import translateInBaidu 4 | 5 | 6 | class TranslateSystem(): 7 | """ 8 | 翻译子系统,调用类,任务由被调用者完成。 9 | """ 10 | def __init__(self): 11 | # 初始化工具 12 | self.translateInBaiduTools = translateInBaidu.Translate() 13 | pass 14 | 15 | def translate(self, text): 16 | """ 17 | 翻译一级子系统 18 | :param text: 19 | :return: 20 | """ 21 | result = self.translateInBaiduTools.translate(text) 22 | return result 23 | 24 | 25 | if __name__ == '__main__': 26 | text = 'this is a test' 27 | res = TranslateSystem().translate(text) 28 | print(res) 29 | -------------------------------------------------------------------------------- /src/Client/VersionControlSystem/GetNewFile/Tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/VersionControlSystem/GetNewFile/Tools/__init__.py -------------------------------------------------------------------------------- /src/Client/VersionControlSystem/GetNewFile/Tools/getIndexFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | 4 | 5 | class GetIndexFile(): 6 | def __init__(self, s): 7 | self.s = s 8 | 9 | def getFile(self): 10 | fileinfo_size = struct.calcsize('128si2s') 11 | buf = self.s.recv(fileinfo_size) 12 | if buf: 13 | filename, filesize, pw = struct.unpack('128si2s', buf) 14 | # 删除byte转为str后的\x00 用strip也可以 15 | newFileName = bytes.decode(filename).rstrip('\x00') 16 | new_filename = './data/fileIndex.properties' 17 | recvd_size = 0 # 定义已接收文件的大小 18 | fp = open(new_filename, 'wb') 19 | while not recvd_size == filesize: 20 | if filesize - recvd_size > 1024: 21 | data = self.s.recv(1024) 22 | recvd_size += len(data) 23 | else: 24 | data = self.s.recv(filesize - recvd_size) 25 | recvd_size = filesize 26 | fp.write(data) 27 | fp.close() 28 | if DEBUG and VERSION_CONTROL_DEBUG: 29 | print('{SYS}{VERSION_CONTROL_DEBUG}index file has been receive, filesize is ' + str(filesize)) 30 | 31 | 32 | if __name__ == '__main__': 33 | GetIndexFile().getFile() 34 | -------------------------------------------------------------------------------- /src/Client/VersionControlSystem/GetNewFile/Tools/getUpdateFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | 4 | 5 | class GetUpdateFile(): 6 | def __init__(self, s): 7 | self.s = s 8 | pass 9 | 10 | def get(self): 11 | file_path = './data/fileIndex.properties' 12 | property = Properties(file_path) # 读取文件 13 | loopTime = property.getLength() 14 | while loopTime != 0: 15 | loopTime = loopTime - 1 16 | fileinfo_size = struct.calcsize('128si2s') 17 | buf = self.s.recv(fileinfo_size) 18 | if buf: 19 | filename, filesize, pwd = struct.unpack('128si2s', buf) 20 | 21 | 22 | # 删除byte转为str后的\x00 用strip也可以 23 | newFileName = bytes.decode(filename).rstrip('\x00') 24 | # 得到文件路径前缀 25 | dirPrefix = property.get(newFileName) 26 | new_filename = os.path.join(dirPrefix, '' + newFileName) 27 | print('file new name is {0}, filesize if {1}'.format(new_filename, filesize)) 28 | 29 | recvd_size = 0 # 定义已接收文件的大小 30 | fp = open(new_filename, 'wb') 31 | print('start receiving...') 32 | while not recvd_size == filesize: 33 | if filesize - recvd_size > 1024: 34 | data = self.s.recv(1024) 35 | recvd_size += len(data) 36 | else: 37 | data = self.s.recv(filesize - recvd_size) 38 | recvd_size = filesize 39 | fp.write(data) 40 | fp.close() 41 | print('end receive...') 42 | print('finish file receive') 43 | 44 | 45 | class Properties: 46 | def __init__(self, file_name): 47 | self.file_name = file_name 48 | self.properties = {} 49 | try: 50 | fopen = open(self.file_name, 'r') 51 | for line in fopen: 52 | line = line.strip() 53 | if line.find('=') > 0 and not line.startswith('#'): 54 | strs = line.split('=') 55 | self.properties[strs[0].strip()] = strs[1].strip() 56 | except Exception: 57 | # raise Exception 58 | print("read file exception ...") 59 | else: 60 | fopen.close() 61 | 62 | def get(self, key, default_value=''): 63 | if key in self.properties: 64 | return self.properties[key] 65 | return default_value 66 | 67 | def getLength(self): 68 | return len(self.properties) 69 | -------------------------------------------------------------------------------- /src/Client/VersionControlSystem/GetNewFile/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/VersionControlSystem/GetNewFile/__init__.py -------------------------------------------------------------------------------- /src/Client/VersionControlSystem/GetNewFile/doUpdate.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | from src.Update.Conf.config import * 4 | from src.Client.VersionControlSystem.GetNewFile.Tools import getUpdateFile, getIndexFile 5 | 6 | 7 | class GetNewFile(): 8 | def __init__(self): 9 | try: 10 | self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 11 | self.s.connect((SERVER_IP, SERVER_FILE_PORT)) 12 | self.getUpdateFileTools = getUpdateFile.GetUpdateFile(self.s) 13 | self.getIndexFileTools = getIndexFile.GetIndexFile(self.s) 14 | 15 | self.getIndexFileTools.getFile() 16 | self.getUpdateFileTools.get() 17 | except socket.error as msg: 18 | # 打开错误日志文件 19 | wrongFile = open('data/wrongMessage.dat', 'a+') 20 | # 获取当前时间 21 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 22 | '%Y-%m-%d-%H-%M-%S')) 23 | # 生成报错的错误信息 24 | wrongMessage = { 25 | '|currentTime': currentTime, 26 | '|file': 'VersionControlSystem-GetNewFile-doUpdate', 27 | '|wrongMessage': msg 28 | } 29 | # 存入文件 30 | wrongFile.write(str(wrongMessage)) 31 | # 增加换行符 32 | wrongFile.write('\n') 33 | wrongFile.close() 34 | 35 | 36 | 37 | if __name__ == '__main__': 38 | GetNewFile() -------------------------------------------------------------------------------- /src/Client/VersionControlSystem/JudgeNeedUpdate/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/VersionControlSystem/JudgeNeedUpdate/__init__.py -------------------------------------------------------------------------------- /src/Client/VersionControlSystem/JudgeNeedUpdate/judgeNeedUpdate.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.MessageTransferSystem.VersionControl.versionControl import VersionControl 3 | 4 | 5 | class JudgeNeedUpdate(): 6 | def __init__(self): 7 | pass 8 | 9 | def judge(self): 10 | return VersionControl().judge() 11 | -------------------------------------------------------------------------------- /src/Client/VersionControlSystem/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/VersionControlSystem/__init__.py -------------------------------------------------------------------------------- /src/Client/VersionControlSystem/versionControl.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | from src.Client.VersionControlSystem.GetNewFile import doUpdate 4 | from src.Client.VersionControlSystem.JudgeNeedUpdate import judgeNeedUpdate 5 | 6 | 7 | class VersionControl(): 8 | def __init__(self): 9 | self.judgeNeedUpdateTools = judgeNeedUpdate.JudgeNeedUpdate() 10 | 11 | def handle(self): 12 | if self.judgeNeedUpdateTools.judge(): 13 | if messagebox.askokcancel(title='是否更新', message='检测到有新版本,是否更新'): 14 | doUpdate.GetNewFile() 15 | -------------------------------------------------------------------------------- /src/Client/View/MainFrame/ReserveFrame/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/View/MainFrame/ReserveFrame/__init__.py -------------------------------------------------------------------------------- /src/Client/View/MainFrame/ReserveFrame/reserveFrame.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | class ReserveFrame(): 3 | """ 4 | 保留框架类,主界面底部的保留区域 5 | """ 6 | def __init__(self): 7 | pass 8 | -------------------------------------------------------------------------------- /src/Client/View/MainFrame/SearchAndSettingFrame/ShowSearchResultTools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/View/MainFrame/SearchAndSettingFrame/ShowSearchResultTools/__init__.py -------------------------------------------------------------------------------- /src/Client/View/MainFrame/SearchAndSettingFrame/ShowSettingTools/Util/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/View/MainFrame/SearchAndSettingFrame/ShowSettingTools/Util/__init__.py -------------------------------------------------------------------------------- /src/Client/View/MainFrame/SearchAndSettingFrame/ShowSettingTools/Util/showCN.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | 4 | from src.Client.Conf.config import * 5 | 6 | from src.Client.SearchSystem import searchSystem 7 | from src.Client.SystemTools.ConfFileRead import configFileRead 8 | from src.Client.View.MainFrame.SearchAndSettingFrame.ShowSearchResultTools import showMission, showWord 9 | 10 | 11 | class ShowCN(): 12 | def show(self): 13 | """ 14 | 切换中文 15 | :return: 16 | """ 17 | configFileRead.ConfigFileRead(fileName='./conf/user.ini').saveFile('LANGUAGE', 'language', 'CN') 18 | print("显示中文") 19 | pass 20 | -------------------------------------------------------------------------------- /src/Client/View/MainFrame/SearchAndSettingFrame/ShowSettingTools/Util/showEN.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | 4 | from src.Client.Conf.config import * 5 | 6 | from src.Client.SearchSystem import searchSystem 7 | from src.Client.SystemTools.ConfFileRead import configFileRead 8 | from src.Client.View.MainFrame.SearchAndSettingFrame.ShowSearchResultTools import showMission, showWord 9 | 10 | 11 | class ShowEN(): 12 | def show(self): 13 | """ 14 | 切换英文 15 | :return: 16 | """ 17 | configFileRead.ConfigFileRead(fileName='./conf/user.ini').saveFile('LANGUAGE', 'language', 'EN') 18 | print("显示英文") 19 | 20 | pass 21 | -------------------------------------------------------------------------------- /src/Client/View/MainFrame/SearchAndSettingFrame/ShowSettingTools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/View/MainFrame/SearchAndSettingFrame/ShowSettingTools/__init__.py -------------------------------------------------------------------------------- /src/Client/View/MainFrame/SearchAndSettingFrame/ShowSettingTools/showEdit.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | 4 | from src.Client.SearchSystem import searchSystem 5 | from src.Client.SystemTools.ConfFileRead import configFileRead 6 | from src.Client.View.MainFrame.SearchAndSettingFrame.ShowSearchResultTools import showMission, showWord 7 | from src.Client.View.MainFrame.SearchAndSettingFrame.ShowSettingTools.Util import showCN, showEN 8 | 9 | 10 | class ShowEdit(): 11 | """ 12 | 本类负责显示设置页面的具体显示以及提交操作。 13 | """ 14 | 15 | def __init__(self): 16 | self.windowTitleVar = tkinter.StringVar() 17 | self.languageSettingVar = tkinter.StringVar() 18 | self.acceptButtonVar = tkinter.StringVar() 19 | self.language() 20 | pass 21 | 22 | def language(self): 23 | """ 24 | 语言切换,暂时不做外部调用(即每次重启生效) 25 | :return: 26 | """ 27 | languageType = configFileRead.ConfigFileRead(fileName='./conf/user.ini').readFile("LANGUAGE", 'language') 28 | if languageType == 'CN': 29 | self.windowTitleVar.set('设置') 30 | self.languageSettingVar.set('语言设置(部分页面将在下次启动时生效)') 31 | self.acceptButtonVar.set('确定') 32 | elif languageType == 'EN': 33 | self.windowTitleVar.set('edit') 34 | self.languageSettingVar.set('language setting (some page need to restart)') 35 | self.acceptButtonVar.set('OK') 36 | else: 37 | self.windowTitleVar.set('设置') 38 | self.languageSettingVar.set('语言设置(部分页面将在下次启动时生效)') 39 | self.acceptButtonVar.set('确定') 40 | 41 | def window(self): 42 | """ 43 | 负责绘制具体的设置页面 44 | :return: 45 | """ 46 | showWindow = tkinter.Toplevel() 47 | screenWidth = showWindow.winfo_screenwidth() 48 | screenHeight = showWindow.winfo_screenheight() 49 | showWindow.geometry( 50 | '300x250+' + str(int((screenWidth - 300) / 2)) + '+' + str(int((screenHeight - 250) / 2))) 51 | showWindow.resizable(width=False, height=False) 52 | showWindow.title(self.windowTitleVar.get()) 53 | showWindow.iconbitmap('images/icon.ico') 54 | 55 | def settingHandle(): 56 | """ 57 | 负责点击确定按钮后的提交操作 58 | :return: 59 | """ 60 | # print(varSelect) 61 | if varSelect.get() == 'CN': 62 | showCN.ShowCN().show() 63 | elif varSelect.get() == 'EN': 64 | showEN.ShowEN().show() 65 | showWindow.after(300, showWindow.destroy) 66 | pass 67 | 68 | varSelect = tkinter.StringVar() 69 | languageType = configFileRead.ConfigFileRead(fileName='./conf/user.ini').readFile("LANGUAGE", 'language') 70 | varSelect.set(languageType) 71 | 72 | languageLabel = tkinter.Label(showWindow, text=self.languageSettingVar.get()) 73 | languageLabel.place(x=20, y=20, anchor='nw') 74 | radioButtonCN = tkinter.Radiobutton(showWindow, text='简体中文', variable=varSelect, value="CN") 75 | radioButtonCN.place(x=50, y=50, anchor='nw') 76 | radioButtonEN = tkinter.Radiobutton(showWindow, text='English', variable=varSelect, value='EN') 77 | radioButtonEN.place(x=150, y=50, anchor='nw') 78 | 79 | settingButton = tkinter.Button(showWindow, textvariable=self.acceptButtonVar, command=settingHandle, width=8, height=1) 80 | settingButton.place(x=210, y=200, anchor='nw') 81 | 82 | pass 83 | -------------------------------------------------------------------------------- /src/Client/View/MainFrame/SearchAndSettingFrame/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/View/MainFrame/SearchAndSettingFrame/__init__.py -------------------------------------------------------------------------------- /src/Client/View/MainFrame/TabFrame/FirstTabFrame/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/View/MainFrame/TabFrame/FirstTabFrame/__init__.py -------------------------------------------------------------------------------- /src/Client/View/MainFrame/TabFrame/FirstTabFrame/firstTabFrame.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | from src.Client.Conf.config import * 4 | from src.Client.SystemTools.ConfFileRead import configFileRead 5 | from src.Client.View.MainFrame.TabFrame.FirstTabFrame import messageFrame 6 | from src.Client.View.MainFrame.TabFrame.FirstTabFrame import selectFrame 7 | 8 | 9 | class FirstTabFrame(): 10 | """ 11 | 第一个Tab框架,负责显示任务信息等GUI界面。 12 | """ 13 | 14 | def __init__(self, tab): 15 | """ 16 | 17 | :param tab: tab 为当前frame的父容器 18 | """ 19 | if DEBUG and VIEW_DEBUG: 20 | self.firstTabFrame = tkinter.Frame(tab, height=350, width=700, bg='Thistle') 21 | else: 22 | self.firstTabFrame = tkinter.Frame(tab, height=350, width=700) 23 | 24 | self.firstTabFrame.place(x=0, y=30, anchor='nw') 25 | 26 | # 调用子组件 27 | messageFrame.MessageFrame(firstTabFrame=self.firstTabFrame) 28 | selectFrame.SelectFrame(firstTabFrame=self.firstTabFrame) 29 | 30 | # 语言自定义 31 | languageType = configFileRead.ConfigFileRead(fileName='./conf/user.ini').readFile("LANGUAGE", 'language') 32 | if languageType == 'CN': 33 | tab.add(self.firstTabFrame, text='我的计划') 34 | elif languageType == 'EN': 35 | tab.add(self.firstTabFrame, text='my plan') 36 | else: 37 | tab.add(self.firstTabFrame, text='我的计划') 38 | -------------------------------------------------------------------------------- /src/Client/View/MainFrame/TabFrame/FirstTabFrame/subWindows/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/View/MainFrame/TabFrame/FirstTabFrame/subWindows/__init__.py -------------------------------------------------------------------------------- /src/Client/View/MainFrame/TabFrame/SecondTabFrame/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/View/MainFrame/TabFrame/SecondTabFrame/__init__.py -------------------------------------------------------------------------------- /src/Client/View/MainFrame/TabFrame/ThirdFrame/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/View/MainFrame/TabFrame/ThirdFrame/__init__.py -------------------------------------------------------------------------------- /src/Client/View/MainFrame/TabFrame/ThirdFrame/subWindows/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/View/MainFrame/TabFrame/ThirdFrame/subWindows/__init__.py -------------------------------------------------------------------------------- /src/Client/View/MainFrame/TabFrame/ThirdFrame/thirdTabFrame.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | from src.Client.SystemTools.ConfFileRead import configFileRead 4 | from src.Client.View.MainFrame.TabFrame.ThirdFrame import selectFrame, messageFrame 5 | 6 | 7 | class ReciterFrame(): 8 | def __init__(self, tab): 9 | """ 10 | 11 | :param tab: tab 为当前frame的父容器 12 | """ 13 | if DEBUG and VIEW_DEBUG: 14 | self.thirdTabFrame = tkinter.Frame(tab, height=350, width=700, bg='Thistle') 15 | else: 16 | self.thirdTabFrame = tkinter.Frame(tab, height=350, width=700) 17 | 18 | self.thirdTabFrame.place(x=0, y=30, anchor='nw') 19 | 20 | # 调用子组件 21 | selectFrame.SelectFrame(thirdTabFrame=self.thirdTabFrame) 22 | self.messageFrame = messageFrame.MessageFrame(thirdTabFrame=self.thirdTabFrame) 23 | 24 | # 语言自定义 25 | languageType = configFileRead.ConfigFileRead(fileName='./conf/user.ini').readFile("LANGUAGE", 'language') 26 | if languageType == 'CN': 27 | tab.add(self.thirdTabFrame, text='我的背诵') 28 | elif languageType == 'EN': 29 | tab.add(self.thirdTabFrame, text='recitation') 30 | else: 31 | tab.add(self.thirdTabFrame, text='我的背诵') 32 | 33 | # def showQuestion(self, recitationId): 34 | # self.messageFrame.showAssignQuestion(recitationId) 35 | -------------------------------------------------------------------------------- /src/Client/View/MainFrame/TabFrame/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/View/MainFrame/TabFrame/__init__.py -------------------------------------------------------------------------------- /src/Client/View/MainFrame/TabFrame/tabFrame.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | from src.Client.Conf.config import * 4 | from src.Client.View.MainFrame.TabFrame.FirstTabFrame import firstTabFrame 5 | from src.Client.View.MainFrame.TabFrame.SecondTabFrame import translateFrame 6 | from src.Client.View.MainFrame.TabFrame.ThirdFrame import thirdTabFrame 7 | 8 | 9 | class TabFrame(): 10 | """ 11 | tab框架的主框架。 12 | """ 13 | def __init__(self, rootFrame): 14 | """ 15 | 16 | :param rootFrame: 根框架 17 | """ 18 | self.tab = ttk.Notebook(rootFrame, height=350, width=700) 19 | 20 | self.tab.place(x=0, y=50, anchor='nw') 21 | 22 | # 调用子组件 23 | firstTabFrame.FirstTabFrame(tab=self.tab) 24 | thirdTabFrame.ReciterFrame(tab=self.tab) 25 | translateFrame.TranslateFrame(tab=self.tab) 26 | 27 | 28 | 29 | def getFrame(self): 30 | return self.tab 31 | -------------------------------------------------------------------------------- /src/Client/View/MainFrame/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/View/MainFrame/__init__.py -------------------------------------------------------------------------------- /src/Client/View/MainFrame/mainFrame.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | from src.Client.Conf.config import * 4 | from src.Client.View.MainFrame.TabFrame import tabFrame 5 | from src.Client.View.MainFrame.SearchAndSettingFrame import searchAndSettingFrame 6 | 7 | 8 | class MainFrame(): 9 | def __init__(self): 10 | # 添加主页面 11 | rootWindow = tkinter.Tk() 12 | screenWidth = rootWindow.winfo_screenwidth() 13 | screenHeight = rootWindow.winfo_screenheight() 14 | rootWindow.geometry('700x500+' + str(int((screenWidth - 700) / 2)) + '+' + str(int((screenHeight - 500) / 2))) 15 | rootWindow.resizable(width=False, height=False) 16 | rootWindow.title('MemoryAssist '+VERSION_CODE) 17 | rootWindow.iconbitmap('images/icon.ico') 18 | 19 | # 添加主框架 20 | if DEBUG and VIEW_DEBUG: 21 | rootFrame = tkinter.Frame(rootWindow, height=500, width=700, bg='red') 22 | else: 23 | rootFrame = tkinter.Frame(rootWindow, height=500, width=700) 24 | 25 | rootFrame.place(x=0, y=0, anchor='nw') 26 | 27 | # 调用子组件 28 | tabFrame.TabFrame(rootFrame=rootFrame) 29 | searchAndSettingFrame.SearchFrame(rootFrame=rootFrame) 30 | 31 | rootWindow.mainloop() 32 | -------------------------------------------------------------------------------- /src/Client/View/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/View/__init__.py -------------------------------------------------------------------------------- /src/Client/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/__init__.py -------------------------------------------------------------------------------- /src/Client/recitationSystem/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/recitationSystem/__init__.py -------------------------------------------------------------------------------- /src/Client/recitationSystem/addRecitation/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/recitationSystem/addRecitation/__init__.py -------------------------------------------------------------------------------- /src/Client/recitationSystem/addRecitation/addRecitation.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.recitationSystem.addRecitation.tools import loadConfigFile, saveConfigFile, addRecitationToList 3 | from src.Client.SystemTools.SaveFiles import saveFiles 4 | 5 | 6 | class AddRecitation(): 7 | """ 8 | 该类负责增加任务相关事宜,属于调用类,调用各种方法完成目的。 9 | """ 10 | 11 | def __init__(self, confFileName='../conf/recitation.ini', dataFileName='../data/recitation.dat'): 12 | # 初始化工具 13 | self.loadConfigTools = loadConfigFile.LoadConfigFile(fileName=confFileName) 14 | self.addMissionTools = addRecitationToList.AddRecitationToList() 15 | self.saveConfigTools = saveConfigFile.SaveConfigFile(fileName=confFileName) 16 | self.saveMissionTools = saveFiles.SaveFiles(filename=dataFileName) 17 | pass 18 | 19 | def addRecitation(self, list, recitationId, question, answer, weight): 20 | """ 21 | 22 | :param list: 目标list 23 | :param recitationId: 任务id(string 24 | :param question: 问题 25 | :param answer: 答案 26 | :param weight: 权重 27 | :return: 添加后的list 28 | """ 29 | if recitationId is None: 30 | # 读取配置文件并自增+1 31 | nextRecitationId = self.loadConfigTools.loadConfigFile() 32 | nextRecitationId = nextRecitationId + 1 33 | # 写回到配置文件 34 | self.saveConfigTools.saveConfigFile(nextRecitationId) 35 | recitationId = nextRecitationId 36 | # 添加到列表并获取到返回列表 37 | list = self.addMissionTools.addRecitation(list=list, recitationId=recitationId, question=question, 38 | answer=answer, weight=weight) 39 | # 保存到文件 40 | self.saveMissionTools.saveFiles(list) 41 | return list 42 | 43 | 44 | # 对添加任务子系统的测试 45 | if __name__ == '__main__': 46 | pass 47 | # a = AddMission() 48 | # l = loadMission.LoadFiles("F:\python17\pythonPro\MemortAssit\data\mission.dat") 49 | # list = l.loadMission() 50 | # 51 | # a = AddMission(confFileName='F:\python17\pythonPro\MemortAssit\conf\mission.ini', 52 | # dataFileName='F:\python17\pythonPro\MemortAssit\data\mission.dat') 53 | # a.addMission(list=list, bookName='testBook', missionRange='testMission') 54 | -------------------------------------------------------------------------------- /src/Client/recitationSystem/addRecitation/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/recitationSystem/addRecitation/tools/__init__.py -------------------------------------------------------------------------------- /src/Client/recitationSystem/addRecitation/tools/addRecitationToList.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | 4 | 5 | class AddRecitationToList(): 6 | """ 7 | 该类负责将背诵任务添加到列表,属于实际操作类 8 | """ 9 | 10 | def addRecitation(self, list, recitationId, question, answer, weight=10): 11 | """ 12 | 添加任务 13 | :param list: 目标list 14 | :param recitationId: 任务id(string 15 | :param question: 书名 16 | :param answer: 任务范围 17 | :param weight: 权重 18 | :return: 插入后的list 19 | """ 20 | # 首先将列表备份,以便添加失败时返回最近正常的点 21 | backupList = list[:] 22 | try: 23 | # 构造任务字典 24 | recitationDir = { 25 | 'recitationId': str(recitationId).zfill(6), 26 | 'question': question, 27 | 'answer': answer, 28 | 'weight': int(weight) 29 | } 30 | # 将任务字典添加到列表中 31 | list.append(recitationDir) 32 | # 打印debug日志 33 | if DEBUG and MISSION_DEBUG: 34 | print('{SYS}{MISSION_DEBUG} mission has been add to list successfully, id is ' + str(recitationId)) 35 | return list 36 | except Exception as e: 37 | # 打开错误日志文件 38 | wrongFile = open('data/wrongMessage.dat', 'a+') 39 | # 获取当前时间 40 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 41 | '%Y-%m-%d-%H-%M-%S')) 42 | # 生成报错的错误信息 43 | wrongMessage = { 44 | '|currentTime': currentTime, 45 | '|file': 'RecitationSystem-addRecitation-addRecitationToList', 46 | '|list': list, 47 | '|recitationId': recitationId, 48 | '|question': question, 49 | '|answer': answer, 50 | '|wrongMessage': str(e) 51 | } 52 | # 存入文件 53 | wrongFile.write(str(wrongMessage)) 54 | # 增加换行符 55 | wrongFile.write('\n') 56 | wrongFile.close() 57 | return backupList 58 | -------------------------------------------------------------------------------- /src/Client/recitationSystem/addRecitation/tools/loadConfigFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | 4 | from src.Client.Conf.config import * 5 | 6 | 7 | class LoadConfigFile(): 8 | """ 9 | 该类负责读取配置文件,属于实际操作类 10 | """ 11 | def __init__(self, fileName='../conf/recitation.ini'): 12 | self.config = ConfigParser.ConfigParser() 13 | self.fileName = fileName 14 | 15 | def loadConfigFile(self): 16 | """ 17 | 读取配置文件 18 | :return:下个id(int) 19 | """ 20 | try: 21 | # 读取配置文件 22 | self.config.readfp(open(self.fileName)) 23 | missionId = self.config.get('RECITATION', 'recitationId') 24 | # 打印debug日志 25 | if DEBUG and MISSION_DEBUG: 26 | print('{SYS}{RECITATION_DEBUG} config has been load from file successfully') 27 | return int(missionId) 28 | except Exception as e: 29 | # 打开错误日志文件 30 | wrongFile = open('data/wrongMessage.dat', 'a+') 31 | # 获取当前时间 32 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 33 | '%Y-%m-%d-%H-%M-%S')) 34 | # 生成报错的错误信息 35 | wrongMessage = { 36 | '|currentTime': currentTime, 37 | '|file': 'RecitationSystem-addRecitation-loadConfigFile', 38 | '|wrongMessage': str(e) 39 | } 40 | # 存入文件 41 | wrongFile.write(str(wrongMessage)) 42 | # 增加换行符 43 | wrongFile.write('\n') 44 | wrongFile.close() 45 | return None 46 | 47 | 48 | 49 | # 配置文件读取测试 50 | if __name__ == '__main__': 51 | l = LoadConfigFile(fileName='F:\python17\pythonPro\MemortAssit\conf/recitation.ini') 52 | print(l.loadConfigFile()) 53 | -------------------------------------------------------------------------------- /src/Client/recitationSystem/addRecitation/tools/saveConfigFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | 4 | from src.Client.Conf.config import * 5 | 6 | 7 | class SaveConfigFile(): 8 | """ 9 | 该类负责保存配置文件,属于实际操作类 10 | """ 11 | def __init__(self, fileName='../conf/recitation.ini'): 12 | self.config = ConfigParser.ConfigParser() 13 | self.fileName = fileName 14 | 15 | def saveConfigFile(self, recitationId): 16 | """ 17 | 18 | :param recitationId: 需要保存的任务id (int 或者 string) 19 | :return: 20 | """ 21 | try: 22 | # 防御编程 若recitationId不是string,转换则在这转换 23 | if type(recitationId).__name__ != 'string': 24 | recitationId = str(recitationId).zfill(6) 25 | # 写回配置文件 26 | self.config.read(self.fileName) 27 | self.config.set("RECITATION", "recitationId", recitationId) 28 | self.config.write(open(self.fileName, "r+")) 29 | # 打印debug日志 30 | if DEBUG and MISSION_DEBUG: 31 | print('{SYS}{RECITATION_DEBUG} config has been save in file successfully') 32 | except Exception as e: 33 | # 打开错误日志文件 34 | wrongFile = open('data/wrongMessage.dat', 'a+') 35 | # 获取当前时间 36 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 37 | '%Y-%m-%d-%H-%M-%S')) 38 | # 生成报错的错误信息 39 | wrongMessage = { 40 | '|currentTime': currentTime, 41 | '|file': 'RECITATIONSystem-addRecitation-saveConfigFile', 42 | '|missionId': recitationId, 43 | '|wrongMessage': str(e) 44 | } 45 | # 存入文件 46 | wrongFile.write(str(wrongMessage)) 47 | # 增加换行符 48 | wrongFile.write('\n') 49 | wrongFile.close() 50 | 51 | 52 | # 配置文件读取测试 53 | if __name__ == '__main__': 54 | s = SaveConfigFile(fileName='F:\python17\pythonPro\MemortAssit\conf\mession.ini') 55 | print(s.saveConfigFile(1)) 56 | -------------------------------------------------------------------------------- /src/Client/recitationSystem/editRecitation/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/recitationSystem/editRecitation/__init__.py -------------------------------------------------------------------------------- /src/Client/recitationSystem/editRecitation/editRecitation.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | from src.Client.Conf.config import * 4 | from src.Client.recitationSystem.editRecitation.tools import editRecitationList, removeRecitation 5 | from src.Client.SystemTools.SaveFiles import saveFiles 6 | 7 | 8 | class EditRecitation(): 9 | """ 10 | 编辑任务子系统。调用类,任务由被调用者完成。 11 | """ 12 | 13 | def __init__(self, filename='../data/recitation.dat'): 14 | # 初始化工具 15 | self.editRecitationListTools = editRecitationList.EditRecitationList() 16 | self.removeRecitationTools = removeRecitation.RemoveRecitation() 17 | self.saveRecitationTools = saveFiles.SaveFiles(filename=filename) 18 | pass 19 | 20 | def edit(self, list, recitationId, question=None, answer=None, isEdit=False, isDelete=False, weight=10): 21 | """ 22 | 23 | :param list: 需要被编辑的列表 24 | :param recitationId: 任务id 25 | :param question: 问题 26 | :param answer: 答案 27 | :param weight: 权重 28 | :param isEdit: 执行编辑任务标记 29 | :param isDelete: 执行删除任务标记 30 | :return: 编辑后的list 31 | """ 32 | try: 33 | # 对不同的编辑命令做出不同的响应 34 | if isEdit: 35 | # 调用编辑子系统 36 | list = self.editRecitationListTools.edit(list=list, recitationId=recitationId, question=question, 37 | answer=answer, weight=weight) 38 | self.saveRecitationTools.saveFiles(list) 39 | 40 | if isDelete: 41 | # 调用删除子系统 42 | list = self.removeRecitationTools.remove(list=list, recitationId=recitationId) 43 | self.saveRecitationTools.saveFiles(list) 44 | except: 45 | # 打印debug日志 46 | if DEBUG and MISSION_DEBUG: 47 | print('{SYS}{W}{RECITATION_DEBUG} can not edit recitation') 48 | 49 | 50 | # 测试任务编辑系统 51 | if __name__ == '__main__': 52 | from src.Client.SystemTools.LoadFiles import loadFiles 53 | 54 | l = loadFiles.LoadFiles("F:\python17\pythonPro\MemortAssit\data\mission.dat") 55 | list = l.loadFiles(missionType='mission') 56 | print(list) 57 | print() 58 | e = EditRecitation('F:\python17\pythonPro\MemortAssit\data\mission.dat') 59 | # 测试更改完成状态 60 | # e.edit(list, '000025', isFinish=True) 61 | # 测试更改 62 | # e.edit(list, '000025', isEdit=True, bookName='bookTest') 63 | # 测试删除 64 | e.edit(list, '000025', isDelete=True) 65 | print(list) 66 | -------------------------------------------------------------------------------- /src/Client/recitationSystem/editRecitation/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Client/recitationSystem/editRecitation/tools/__init__.py -------------------------------------------------------------------------------- /src/Client/recitationSystem/editRecitation/tools/editRecitationList.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | 4 | 5 | class EditRecitationList(): 6 | """ 7 | 负责编辑任务,实际操作类 8 | """ 9 | 10 | def edit(self, list, recitationId, question=None, answer=None, weight=10): 11 | """ 12 | 编辑任务 13 | :param list: 目标list 14 | :param recitationId: 任务id(string 15 | :param question: 书名 16 | :param answer: 任务范围 17 | :param weight: 权重 18 | :return: 插入后的list 19 | """ 20 | # 首先将列表备份,以便添加失败时返回最近正常的点 21 | backupList = list[:] 22 | try: 23 | # 转换任务id,防御编程 24 | recitationId = str(recitationId).zfill(6) 25 | # 遍历任务列表寻找目标任务 26 | for each in list: 27 | if each['recitationId'] == recitationId: 28 | # 对目标任务进行更新 29 | if question != None: 30 | each['question'] = question 31 | if answer != None: 32 | each['answer'] = answer 33 | if weight != None: 34 | each['weight'] = weight 35 | # 打印debug日志 36 | if DEBUG and MISSION_DEBUG: 37 | print('{SYS}{RECITATION_DEBUG} recitation has been edit finish successfully id is ' + recitationId) 38 | 39 | return list 40 | except Exception as e: 41 | # 打开错误日志文件 42 | wrongFile = open('data/wrongMessage.dat', 'a+') 43 | # 获取当前时间 44 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 45 | '%Y-%m-%d-%H-%M-%S')) 46 | # 生成报错的错误信息 47 | wrongMessage = { 48 | '|currentTime': currentTime, 49 | '|file': 'RecitationSystem-editRecitation-editRecitationList', 50 | '|list': list, 51 | '|recitationId': recitationId, 52 | '|question': question, 53 | '|answer': answer, 54 | '|wrongMessage': str(e) 55 | } 56 | # 存入文件 57 | wrongFile.write(str(wrongMessage)) 58 | # 增加换行符 59 | wrongFile.write('\n') 60 | wrongFile.close() 61 | return backupList 62 | -------------------------------------------------------------------------------- /src/Client/recitationSystem/editRecitation/tools/removeRecitation.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Client.Conf.config import * 3 | 4 | 5 | class RemoveRecitation(): 6 | """ 7 | 移除任务类,负责将任务删除。实际操作类 8 | """ 9 | def remove(self, list, recitationId): 10 | """ 11 | 删除任务 12 | :param list: 列表 13 | :param recitationId: 完成的任务编号 14 | :return: list列表 15 | """ 16 | # 首先将列表备份,以便添加失败时返回最近正常的点 17 | backupList = list[:] 18 | try: 19 | # 转换任务id,防御编程 20 | recitationId = str(recitationId).zfill(6) 21 | # 遍历任务列表找到目标任务 22 | for each in list: 23 | if each['recitationId'] == recitationId: 24 | # 从列表中删除任务 25 | print(each) 26 | list.remove(each) 27 | # 打印debug日志 28 | if DEBUG and MISSION_DEBUG: 29 | print('{SYS}{RECITATION_DEBUG} recitation has been delete successfully,id is ' + recitationId) 30 | return list 31 | except Exception as e: 32 | # 打开错误日志文件 33 | wrongFile = open('data/wrongMessage.dat', 'a+') 34 | # 获取当前时间 35 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 36 | '%Y-%m-%d-%H-%M-%S')) 37 | # 生成报错的错误信息 38 | wrongMessage = { 39 | '|currentTime': currentTime, 40 | '|file': 'MissionSystem-EditMission-removeMission', 41 | '|list': list, 42 | '|missionId': recitationId, 43 | '|wrongMessage': str(e) 44 | } 45 | # 存入文件 46 | wrongFile.write(str(wrongMessage)) 47 | # 增加换行符 48 | wrongFile.write('\n') 49 | wrongFile.close() 50 | return backupList 51 | 52 | -------------------------------------------------------------------------------- /src/Server/Conf/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Server/Conf/__init__.py -------------------------------------------------------------------------------- /src/Server/Conf/config.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | import socket 3 | import datetime 4 | import time 5 | import os 6 | import struct 7 | import threading 8 | # import configparser as ConfigParser 9 | import ConfigParser 10 | import random 11 | import string 12 | import pymongo 13 | import re 14 | import smtplib 15 | from email.mime.text import MIMEText 16 | import requests 17 | import json 18 | import sys 19 | import schedule 20 | 21 | SERVER_IP = '127.0.0.1' 22 | 23 | # 调试模式总开关 24 | DEBUG = False 25 | # 26 | VERSION_CONTROL_DEBUG = True 27 | 28 | SYSTEM_TOOLS_DEBUG = True 29 | 30 | CODE_HANDLE_DEBUG = True 31 | 32 | MEAL_SYSTEM_DEBUG = True 33 | 34 | # 邮件授权码 35 | EMAILCODE = 'jndmaedgdbkpbigc' -------------------------------------------------------------------------------- /src/Server/DatabaseSystem/Tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Server/DatabaseSystem/Tools/__init__.py -------------------------------------------------------------------------------- /src/Server/DatabaseSystem/Tools/areaStatistics.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | 4 | 5 | class AreaStatistics(): 6 | """ 7 | 用户ip地区统计 8 | """ 9 | 10 | def __init__(self): 11 | myclient = pymongo.MongoClient("localhost:27017") 12 | mydb = myclient["MemoryAssist"] 13 | self.totalCol = mydb["total_user"] 14 | self.weeklyCol = mydb["weekly_user"] 15 | pass 16 | 17 | def statistics(self): 18 | """ 19 | 统计用户ip地区 20 | :return: 周统计地区字典和全部地区统计字典 21 | """ 22 | weekly_area = {} 23 | total_area = {} 24 | ip_cache = {} 25 | for each in self.weeklyCol.find(): 26 | ips = each['user_ip'] 27 | for ip in ips: 28 | # user_ip = ip.keys()[0] 29 | user_ip = ip 30 | # 将ip转换回来 31 | user_ip = user_ip.replace('\\', '.') 32 | # 获取ip信息 33 | message = self.handleRequest(user_ip) 34 | # 将ip存入缓存,节省下次调用 35 | ip_cache[user_ip] = message 36 | # 修改地区字典 37 | if message in weekly_area: 38 | weekly_area[message] = weekly_area[message] + 1 39 | else: 40 | weekly_area[message] = 1 41 | pass 42 | 43 | for each in self.totalCol.find(): 44 | ips = each['user_ip'] 45 | for ip in ips: 46 | # user_ip = ip.keys()[0] 47 | user_ip = ip 48 | # 将ip转换回来 49 | user_ip = user_ip.replace('\\', '.') 50 | if user_ip in ip_cache: 51 | print('find cache') 52 | message = ip_cache[user_ip] 53 | else: 54 | message = self.handleRequest(user_ip) 55 | if message in total_area: 56 | total_area[message] = total_area[message] + 1 57 | else: 58 | total_area[message] = 1 59 | pass 60 | return weekly_area, total_area 61 | pass 62 | 63 | def handleRequest(self, ip): 64 | """ 65 | 处理ip 66 | :param ip: 需要识别的ip 67 | :return: ip的地区 68 | """ 69 | # ip = '124.93.200.212' 70 | url = 'http://ip.taobao.com/service/getIpInfo.php?ip=' + str(ip) 71 | print(url) 72 | r = requests.get(url) 73 | print(r.status_code) 74 | distMessage = json.loads(r.text) 75 | ipMessage = '' 76 | # 处理编码 77 | reload(sys) 78 | sys.setdefaultencoding("utf-8") 79 | # 解析字典,生成信息 80 | if r.text.find('country') != -1: 81 | ipMessage = '国家:' + str(distMessage['data']['country']) 82 | if r.text.find('area') != -1: 83 | ipMessage = ipMessage + '\t地区:' + str(distMessage['data']['area']) 84 | if r.text.find('region') != -1: 85 | ipMessage = ipMessage + '\t省份:' + str(distMessage['data']['region']) 86 | if r.text.find('city') != -1: 87 | ipMessage = ipMessage + '\t城市:' + str(distMessage['data']['city']) 88 | return ipMessage 89 | -------------------------------------------------------------------------------- /src/Server/DatabaseSystem/Tools/delWeeklyData.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | 4 | 5 | class DelWeeklyData(): 6 | """ 7 | 删除每周数据的数据库 8 | """ 9 | 10 | def __init__(self): 11 | myclient = pymongo.MongoClient("localhost:27017") 12 | mydb = myclient["MemoryAssist"] 13 | self.weeklyCol = mydb["weekly_user"] 14 | pass 15 | 16 | def handle(self): 17 | """ 18 | 删除每周数据的数据库 19 | :return: 20 | """ 21 | # 删除数据库中的所有文档 22 | self.weeklyCol.delete_many({}) 23 | -------------------------------------------------------------------------------- /src/Server/DatabaseSystem/Tools/editUserCodeAndLogTime.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | 4 | 5 | class EditUserCodeAndLogTime(): 6 | """ 7 | 处理已经有识别码的用户的登录请求,即修改数据库中的登录次数和ip(如果有必要) 8 | """ 9 | def __init__(self, totalCol, weeklyCol): 10 | self.totalCol = totalCol 11 | self.weeklyCol = weeklyCol 12 | 13 | def save(self, userCode, userIp, logTime): 14 | """ 15 | 处理旧用户的登录请求 16 | :param userCode: 用户识别码 17 | :param userIp: 用户登录ip 18 | :param logTime: 登录次数 19 | :return: 20 | """ 21 | try: 22 | userIp = userIp.replace('.', '\\') 23 | # 读取数据 24 | dataInWeekly = self.weeklyCol.find_one({'user_code': userCode}) 25 | dataInTotal = self.totalCol.find_one({'user_code': userCode}) 26 | # 对登录次数数据进行更改 27 | dataInWeekly['weekly_time'] = str(int(dataInWeekly['weekly_time']) + int(logTime)) 28 | dataInTotal['total_time'] = str(int(dataInTotal['total_time']) + int(logTime)) 29 | # 对访问ip进行更改 30 | weeklyIp = dataInWeekly['user_ip'] 31 | if userIp in weeklyIp.keys(): 32 | weeklyIp[userIp] = str(int(weeklyIp[userIp]) + 1) 33 | else: 34 | weeklyIp[userIp] = '1' 35 | totalIp = dataInTotal['user_ip'] 36 | if userIp in totalIp.keys(): 37 | totalIp[userIp] = str(int(totalIp[userIp]) + 1) 38 | else: 39 | totalIp[userIp] = '1' 40 | # 写回数据库 41 | self.weeklyCol.remove({'user_code': userCode}) 42 | self.totalCol.remove({'user_code': userCode}) 43 | self.weeklyCol.insert(dataInWeekly) 44 | self.totalCol.insert(dataInTotal) 45 | except socket.error as msg: 46 | # 打开错误日志文件 47 | wrongFile = open('data/wrongMessage.dat', 'a+') 48 | # 获取当前时间 49 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 50 | '%Y-%m-%d-%H-%M-%S')) 51 | # 生成报错的错误信息 52 | wrongMessage = { 53 | '|currentTime': currentTime, 54 | '|file': 'DatabaseSystem-editUserCodeAndLogTime', 55 | '|wrongMessage': msg, 56 | '|userCode': userCode, 57 | '|userIp': userIp, 58 | '|logTime': logTime, 59 | } 60 | # 存入文件 61 | wrongFile.write(str(wrongMessage)) 62 | # 增加换行符 63 | wrongFile.write('\n') 64 | wrongFile.close() 65 | pass 66 | 67 | -------------------------------------------------------------------------------- /src/Server/DatabaseSystem/Tools/returnAllCount.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | 4 | 5 | class ReturnAllCount(): 6 | """ 7 | 返回所有的访问次数 8 | """ 9 | def __init__(self): 10 | myclient = pymongo.MongoClient("localhost:27017") 11 | mydb = myclient["MemoryAssist"] 12 | self.totalCol = mydb["total_user"] 13 | self.weeklyCol = mydb["weekly_user"] 14 | 15 | def statistics(self): 16 | """ 17 | 返回所有的访问次数 18 | :return: 19 | """ 20 | return self.weeklyCol.count(), self.totalCol.count() 21 | -------------------------------------------------------------------------------- /src/Server/DatabaseSystem/Tools/returnAllLog.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | 4 | class ReturnAllLog(): 5 | """ 6 | 计算所有登录次数 7 | """ 8 | def __init__(self): 9 | myclient = pymongo.MongoClient("localhost:27017") 10 | mydb = myclient["MemoryAssist"] 11 | self.totalCol = mydb["total_user"] 12 | self.weeklyCol = mydb["weekly_user"] 13 | pass 14 | 15 | def statistics(self): 16 | """ 17 | 计算所有登录次数 18 | :return: 分别返回周登录次数和总登录次数 19 | """ 20 | weekLogCount = 0 21 | totalLogCount = 0 22 | for each in self.weeklyCol.find(): 23 | weekLogCount = weekLogCount + int(each['weekly_time']) 24 | pass 25 | 26 | for each in self.totalCol.find(): 27 | totalLogCount = totalLogCount + int(each['total_time']) 28 | pass 29 | 30 | return weekLogCount, totalLogCount -------------------------------------------------------------------------------- /src/Server/DatabaseSystem/Tools/saveNewUserCodeToDatabase.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | 4 | 5 | class SaveNewUserCodeToDataBase(): 6 | """ 7 | 当没有用户识别码的用户第一次访问,则将新分配的用户识别码存入数据库 8 | """ 9 | def __init__(self, totalCol, weeklyCol): 10 | self.totalCol = totalCol 11 | self.weeklyCol = weeklyCol 12 | 13 | def save(self, userCode, userIp): 14 | """ 15 | 执行新存储用户信息 16 | :param userCode: 用户识别码 17 | :param userIp: 用户登录ip 18 | :return: 19 | """ 20 | try: 21 | userIp = userIp.replace('.', '\\') 22 | dictInTotal = { 23 | 'user_code': userCode, 24 | 'total_time': '1', 25 | 'user_ip': {userIp: '1'}, 26 | } 27 | dictInWeekly = { 28 | 'user_code': userCode, 29 | 'weekly_time': '1', 30 | 'user_ip': {userIp: '1'}, 31 | } 32 | self.totalCol.insert_one(dictInTotal) 33 | self.weeklyCol.insert_one(dictInWeekly) 34 | except socket.error as msg: 35 | # 打开错误日志文件 36 | wrongFile = open('data/wrongMessage.dat', 'a+') 37 | # 获取当前时间 38 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 39 | '%Y-%m-%d-%H-%M-%S')) 40 | # 生成报错的错误信息 41 | wrongMessage = { 42 | '|currentTime': currentTime, 43 | '|file': 'DatabaseSystem-saveNewUserCodeToDatabase', 44 | '|wrongMessage': msg, 45 | '|userCode': userCode, 46 | '|userIp': userIp 47 | } 48 | # 存入文件 49 | wrongFile.write(str(wrongMessage)) 50 | # 增加换行符 51 | wrongFile.write('\n') 52 | wrongFile.close() 53 | pass 54 | -------------------------------------------------------------------------------- /src/Server/DatabaseSystem/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Server/DatabaseSystem/__init__.py -------------------------------------------------------------------------------- /src/Server/DatabaseSystem/databaseSystem.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | from src.Server.DatabaseSystem.Tools.editUserCodeAndLogTime import EditUserCodeAndLogTime 4 | from src.Server.DatabaseSystem.Tools.saveNewUserCodeToDatabase import SaveNewUserCodeToDataBase 5 | 6 | 7 | class DatabaseSystem(): 8 | def __init__(self): 9 | myclient = pymongo.MongoClient("localhost:27017") 10 | mydb = myclient["MemoryAssist"] 11 | self.totalCol = mydb["total_user"] 12 | self.weeklyCol = mydb["weekly_user"] 13 | self.editTools = EditUserCodeAndLogTime(self.totalCol, self.weeklyCol) 14 | self.saveTools = SaveNewUserCodeToDataBase(self.totalCol, self.weeklyCol) 15 | pass 16 | 17 | def newCode(self, userCode, userIp): 18 | self.saveTools.save(userCode, userIp) 19 | 20 | def editCode(self, userCode, userIp, logTime): 21 | self.editTools.save(userCode, userIp, logTime) 22 | -------------------------------------------------------------------------------- /src/Server/MessageReportSystem/Tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Server/MessageReportSystem/Tools/__init__.py -------------------------------------------------------------------------------- /src/Server/MessageReportSystem/Tools/sendEmail.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | from src.Server.SystemTools.ConfFileRead import configFileRead 4 | from src.Server.DatabaseSystem.Tools.areaStatistics import AreaStatistics 5 | from src.Server.DatabaseSystem.Tools.returnAllCount import ReturnAllCount 6 | from src.Server.DatabaseSystem.Tools.returnAllLog import ReturnAllLog 7 | from src.Server.DatabaseSystem.Tools.delWeeklyData import DelWeeklyData 8 | 9 | 10 | class SendEmail(): 11 | def __init__(self): 12 | self.areaTools = AreaStatistics() 13 | self.allCountTools = ReturnAllCount() 14 | self.allLogTools = ReturnAllLog() 15 | self.delTools = DelWeeklyData() 16 | self.emailCode = configFileRead.ConfigFileRead().readFile('EMAIL', 'email_code') 17 | pass 18 | 19 | def send(self): 20 | # 获取邮件需要的信息 21 | weeklyArea, totalArea = self.areaTools.statistics() 22 | weeklyAllCount, totalAllCount = self.allCountTools.statistics() 23 | weeklyLogCount, totalLogCount = self.allLogTools.statistics() 24 | # 发送邮件准备 25 | msg_from = 'MemoryAssist@sniper97.cn' # 发送方邮箱 26 | passwd = self.emailCode # 填入发送方邮箱的授权码 27 | msg_to = 'zhaoyu@sniper97.cn' # 收件人邮箱 28 | 29 | subject = "MemoryAssist 每周使用报告" # 主题 30 | # 生成邮件正文,并进行编码转换 31 | content = str("本周登录次数:" + str(weeklyLogCount) + "\n本周用户数量:" + str(weeklyAllCount) + "\n\n总计登录次数:" + str( 32 | totalLogCount) + "\n总计用户数量:" + str(totalAllCount) + "\n\n\n本周用户地区分布:" + 33 | json.dumps(weeklyArea).encode('utf-8').decode('unicode_escape') + "\n\n总计地区分布:" + str( 34 | json.dumps(totalArea)).encode('utf-8').decode('unicode_escape')) 35 | msg = MIMEText(content) 36 | msg['Subject'] = subject 37 | msg['From'] = msg_from 38 | msg['To'] = msg_to 39 | # 发送email 40 | try: 41 | s = smtplib.SMTP_SSL("smtp.qq.com", 465) 42 | s.login(msg_from, passwd) 43 | s.sendmail(msg_from, msg_to, msg.as_string()) 44 | print('email send') 45 | # 删除周统计数据库 46 | self.delTools.handle() 47 | except s.SMTPException as e: 48 | # 打开错误日志文件 49 | wrongFile = open('data/wrongMessage.dat', 'a+') 50 | # 获取当前时间 51 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 52 | '%Y-%m-%d-%H-%M-%S')) 53 | # 生成报错的错误信息 54 | wrongMessage = { 55 | '|currentTime': currentTime, 56 | '|file': 'DatabaseSystem-saveNewUserCodeToDatabase', 57 | '|wrongMessage': msg, 58 | } 59 | # 存入文件 60 | wrongFile.write(str(wrongMessage)) 61 | # 增加换行符 62 | wrongFile.write('\n') 63 | wrongFile.close() 64 | pass 65 | -------------------------------------------------------------------------------- /src/Server/MessageReportSystem/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Server/MessageReportSystem/__init__.py -------------------------------------------------------------------------------- /src/Server/MessageReportSystem/messageReportSystem.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | from src.Server.SystemTools.ConfFileRead import configFileRead 4 | from src.Server.MessageReportSystem.Tools.sendEmail import SendEmail 5 | 6 | class MessageReportSystem(): 7 | def __init__(self): 8 | 9 | pass 10 | 11 | def run(self): 12 | """ 13 | 定时任务开启,需要多线程执行。定时每周周一零点发送任务信息 14 | :return: 15 | """ 16 | # 任务调度,每周周一定时任务 17 | schedule.every().monday.at("00:00").do(SendEmail().send) 18 | # schedule.every().day.at("10:13").do(SendEmail().send) 19 | while True: 20 | # 启动服务 21 | schedule.run_pending() 22 | # 休眠一分钟 23 | time.sleep(60) 24 | # time.sleep(1) 25 | pass 26 | 27 | -------------------------------------------------------------------------------- /src/Server/MessageTransferSystem/MarkUserSystem/Tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Server/MessageTransferSystem/MarkUserSystem/Tools/__init__.py -------------------------------------------------------------------------------- /src/Server/MessageTransferSystem/MarkUserSystem/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Server/MessageTransferSystem/MarkUserSystem/__init__.py -------------------------------------------------------------------------------- /src/Server/MessageTransferSystem/MarkUserSystem/markUserSystem.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | -------------------------------------------------------------------------------- /src/Server/MessageTransferSystem/Tools/CodeHandle/Code100.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | from src.Server.SystemTools.ConfFileRead import configFileRead 4 | 5 | 6 | class Code100(): 7 | def __init__(self): 8 | pass 9 | 10 | def respond(self, connect): 11 | """ 12 | 响应代码100 13 | :param connect: 与客户端的连接 14 | :return: 15 | """ 16 | try: 17 | returnCode = str(configFileRead.ConfigFileRead().readFile('VERSION', 'lastest_version')) 18 | print('code is', returnCode) 19 | connect.send(returnCode.encode('utf-8')) 20 | except socket.error as msg: 21 | # 打开错误日志文件 22 | wrongFile = open('data/wrongMessage.dat', 'a+') 23 | # 获取当前时间 24 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 25 | '%Y-%m-%d-%H-%M-%S')) 26 | # 生成报错的错误信息 27 | wrongMessage = { 28 | '|currentTime': currentTime, 29 | '|file': 'MessageTransferSystem-CodeHandle-Code100', 30 | '|wrongMessage': msg, 31 | '|connect': connect 32 | } 33 | # 存入文件 34 | wrongFile.write(str(wrongMessage)) 35 | # 增加换行符 36 | wrongFile.write('\n') 37 | wrongFile.close() 38 | -------------------------------------------------------------------------------- /src/Server/MessageTransferSystem/Tools/CodeHandle/Code101.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | from src.Server.SystemTools.ConfFileRead import configFileRead 4 | from src.Server.DatabaseSystem.databaseSystem import DatabaseSystem 5 | 6 | 7 | class Code101(): 8 | def __init__(self): 9 | self.databaseTools = DatabaseSystem() 10 | pass 11 | 12 | def respond(self, connect, address): 13 | """ 14 | 响应代码101 15 | :param connect: 与客户端的连接 16 | :return: 17 | """ 18 | try: 19 | # 生成随机的32位识别码 20 | code = ''.join(random.sample(string.ascii_letters + string.digits, 32)) 21 | if DEBUG and CODE_HANDLE_DEBUG: 22 | print('{SYS}{CODE_HANDLE_DEBUG} user code has been create, is '+ str(code)) 23 | # 将随机生成码保存到数据库中 24 | # ------------------------------------------------------------------------- 25 | self.databaseTools.newCode(code, address) 26 | # 发送随机识别码 27 | connect.send(code.encode('utf-8')) 28 | except socket.error as msg: 29 | # 打开错误日志文件 30 | wrongFile = open('data/wrongMessage.dat', 'a+') 31 | # 获取当前时间 32 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 33 | '%Y-%m-%d-%H-%M-%S')) 34 | # 生成报错的错误信息 35 | wrongMessage = { 36 | '|currentTime': currentTime, 37 | '|file': 'MessageTransferSystem-CodeHandle-Code101', 38 | '|wrongMessage': msg, 39 | '|connect': connect, 40 | '|address': address 41 | } 42 | # 存入文件 43 | wrongFile.write(str(wrongMessage)) 44 | # 增加换行符 45 | wrongFile.write('\n') 46 | wrongFile.close() 47 | -------------------------------------------------------------------------------- /src/Server/MessageTransferSystem/Tools/CodeHandle/Code102.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | from src.Server.SystemTools.ConfFileRead import configFileRead 4 | from src.Server.DatabaseSystem.databaseSystem import DatabaseSystem 5 | 6 | 7 | class Code102(): 8 | def __init__(self): 9 | self.databaseTools = DatabaseSystem() 10 | pass 11 | 12 | def respond(self, connect, address): 13 | """ 14 | 响应代码102 15 | :param connect: 与客户端的连接 16 | :return: 17 | """ 18 | try: 19 | # 向客户端发送连接标记 20 | connect.send('user_code'.encode('utf-8')) 21 | userCode = connect.recv(1024) 22 | userCode = bytes.decode(userCode) 23 | connect.send('time'.encode('utf-8')) 24 | logTime = connect.recv(1024) 25 | logTime = bytes.decode(logTime) 26 | if DEBUG and CODE_HANDLE_DEBUG: 27 | print('{SYS}{CODE_HANDLE_DEBUG} user code has been receive from client,user code is ' + str( 28 | userCode) + 'log time is ' + str(logTime)) 29 | # 将数据更新到数据中 30 | # ------------------------------------------------------------------------- 31 | self.databaseTools.editCode(userCode=userCode, userIp=address, logTime=logTime) 32 | except socket.error as msg: 33 | # 打开错误日志文件 34 | wrongFile = open('data/wrongMessage.dat', 'a+') 35 | # 获取当前时间 36 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 37 | '%Y-%m-%d-%H-%M-%S')) 38 | # 生成报错的错误信息 39 | wrongMessage = { 40 | '|currentTime': currentTime, 41 | '|file': 'MessageTransferSystem-CodeHandle-Code102', 42 | '|wrongMessage': msg, 43 | '|connect': connect, 44 | '|address': address 45 | } 46 | # 存入文件 47 | wrongFile.write(str(wrongMessage)) 48 | # 增加换行符 49 | wrongFile.write('\n') 50 | wrongFile.close() 51 | -------------------------------------------------------------------------------- /src/Server/MessageTransferSystem/Tools/CodeHandle/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Server/MessageTransferSystem/Tools/CodeHandle/__init__.py -------------------------------------------------------------------------------- /src/Server/MessageTransferSystem/Tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Server/MessageTransferSystem/Tools/__init__.py -------------------------------------------------------------------------------- /src/Server/MessageTransferSystem/Tools/handleReceiveCode.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | # from src.Server.SystemTools.ConfFileRead import configFileRead 4 | from src.Server.MessageTransferSystem.Tools.CodeHandle.Code100 import Code100 5 | from src.Server.MessageTransferSystem.Tools.CodeHandle.Code101 import Code101 6 | from src.Server.MessageTransferSystem.Tools.CodeHandle.Code102 import Code102 7 | 8 | 9 | class HandleReceiveCode(): 10 | """ 11 | 处理接受的请求代码 12 | """ 13 | 14 | def __init__(self, connect, address): 15 | self.connect = connect 16 | self.address = address 17 | pass 18 | 19 | def getNumber(self): 20 | """ 21 | 获取客户端发送代码,进行返回 22 | :return: 23 | """ 24 | code = self.connect.recv(1024) 25 | if DEBUG and VERSION_CONTROL_DEBUG: 26 | print('Accept new connection(mes) from {0},code is {1}'.format(self.address, int(code))) 27 | address = re.findall('\'(.*?)\'', str(self.address))[0] 28 | address.replace('\.', '\\.') 29 | # 100代码为返回最新版本号 30 | if code == '100' or bytes.decode(code) == '100': 31 | Code100().respond(self.connect) 32 | # 101代码为返回用户识别码 33 | elif code == '101'or bytes.decode(code) == '101': 34 | Code101().respond(self.connect, address) 35 | # 102代码为处理已经拥有用户识别码的用户发送的数据 36 | elif code == '102'or bytes.decode(code) == '102': 37 | Code102().respond(self.connect, address) 38 | pass 39 | else: 40 | print('unknow code, ', code) 41 | pass 42 | 43 | def handle(self): 44 | pass 45 | -------------------------------------------------------------------------------- /src/Server/MessageTransferSystem/VersionControlSystem/Tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Server/MessageTransferSystem/VersionControlSystem/Tools/__init__.py -------------------------------------------------------------------------------- /src/Server/MessageTransferSystem/VersionControlSystem/Tools/returnLastestVersion.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | 4 | class ReturnLastestVersion(): 5 | def __init__(self): 6 | pass 7 | 8 | def returnVersion(self): 9 | pass -------------------------------------------------------------------------------- /src/Server/MessageTransferSystem/VersionControlSystem/Tools/sendInexFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | 4 | 5 | class SendIndexFile(): 6 | """ 7 | 发送更新索引文件 8 | """ 9 | def __init__(self, connect, address): 10 | if DEBUG and VERSION_CONTROL_DEBUG: 11 | print('Accept new connection from {0}'.format(address)) 12 | self.connect = connect 13 | self.address = address 14 | 15 | def sendFile(self): 16 | """ 17 | 发送更新索引文件 18 | :return: 19 | """ 20 | filepath = "./data/fileIndex.properties" 21 | if os.path.isfile(filepath): 22 | fhead = struct.pack('128si2s', bytes(os.path.basename(filepath).encode('utf-8')), os.stat(filepath).st_size, 23 | b'pw') 24 | self.connect.send(fhead) 25 | fp = open(filepath, 'rb') 26 | while 1: 27 | data = fp.read(1024) 28 | if not data: 29 | print('{0} file send over...'.format(filepath)) 30 | break 31 | self.connect.send(data) 32 | if DEBUG and VERSION_CONTROL_DEBUG: 33 | print('{SYS}{VERSION_CONTROL_DEBUG}index file has been send, filesize is '+str(os.stat(filepath).st_size)) 34 | pass -------------------------------------------------------------------------------- /src/Server/MessageTransferSystem/VersionControlSystem/Tools/sendUpdateFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | 4 | 5 | class SendUpdateFile(): 6 | """ 7 | 发送更新文件 8 | """ 9 | def __init__(self, connect, address, filePath='./updateFile/'): 10 | self.properties = {} 11 | self.connect = connect 12 | self.address = address 13 | self.filePath = filePath 14 | self.fileSize = 0 15 | pass 16 | 17 | def findFile(self): 18 | """ 19 | 发送更新文件 20 | :return: 21 | """ 22 | files = os.listdir(self.filePath) 23 | for each in files: 24 | fileAbsPath = self.filePath+each 25 | self.send(fileAbsPath) 26 | self.connect.close() 27 | print('connect close') 28 | if DEBUG and VERSION_CONTROL_DEBUG: 29 | print('{SYS}{VERSION_CONTROL_DEBUG}update file has been send, filesize is ' + str(self.fileSize)) 30 | 31 | def send(self, fileName): 32 | if os.path.isfile(fileName): 33 | fhead = struct.pack('128si2s', bytes(os.path.basename(fileName).encode('utf-8')), os.stat(fileName).st_size, 34 | b'pw') 35 | self.connect.send(fhead) 36 | self.fileSize += os.stat(fileName).st_size 37 | fp = open(fileName, 'rb') 38 | while 1: 39 | data = fp.read(1024) 40 | if not data: 41 | print('{0} file send over...'.format(fileName)) 42 | break 43 | self.connect.send(data) 44 | fp.close() 45 | # self.connect.close() 46 | 47 | pass 48 | -------------------------------------------------------------------------------- /src/Server/MessageTransferSystem/VersionControlSystem/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Server/MessageTransferSystem/VersionControlSystem/__init__.py -------------------------------------------------------------------------------- /src/Server/MessageTransferSystem/VersionControlSystem/versionControl.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Server.Conf.config import * 3 | 4 | from src.Server.MessageTransferSystem.VersionControlSystem.Tools import sendInexFile 5 | from src.Server.MessageTransferSystem.VersionControlSystem.Tools import sendUpdateFile 6 | from src.Server.MessageTransferSystem.Tools import handleReceiveCode 7 | 8 | 9 | class VersionControl(): 10 | """ 11 | 进行版本控制,调用来 12 | """ 13 | def __init__(self, filePath='./updateFile/'): 14 | self.filePath = filePath 15 | threading.Thread(target=self.listenFile).start() 16 | threading.Thread(target=self.listenMessage).start() 17 | 18 | 19 | def listenMessage(self): 20 | """ 21 | 监听消息端口,根据客户端发送的消息代码做出响应 22 | :return: 23 | """ 24 | try: 25 | self.messageSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 26 | self.messageSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 27 | host = socket.gethostname() 28 | # print(host) 29 | if DEBUG: 30 | host = '127.0.0.1' 31 | self.messageSocket.bind((host, 9001)) 32 | self.messageSocket.listen(10) 33 | except socket.error as msg: 34 | print(msg) 35 | print('message waiting for connection, ') 36 | while 1: 37 | conn, addr = self.messageSocket.accept() 38 | t = threading.Thread(target=self.handlerReceiveCode, args=(conn, addr)) 39 | t.start() 40 | 41 | pass 42 | 43 | def listenFile(self): 44 | """ 45 | 监听文件端口,向客户端发送更新文件 46 | :return: 47 | """ 48 | try: 49 | self.fileSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 50 | self.fileSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 51 | host = socket.gethostname() 52 | if DEBUG: 53 | host = '127.0.0.1' 54 | self.fileSocket.bind((host, 9000)) 55 | self.fileSocket.listen(10) 56 | except socket.error as msg: 57 | print(msg) 58 | print('file waiting for connection...') 59 | while 1: 60 | conn, addr = self.fileSocket.accept() 61 | t = threading.Thread(target=self.sendIndexFile, args=(conn, addr)) 62 | # t = threading.Thread(target=self.sendUpdateFile, args=(conn, addr)) 63 | t.start() 64 | pass 65 | 66 | def handlerReceiveCode(self, connect, address): 67 | """ 68 | 处理响应代码 69 | :param connect: socket连接 70 | :param address: socket地址 71 | :return: 72 | """ 73 | self.handleReceiveCodeTools = handleReceiveCode.HandleReceiveCode(connect, address) 74 | self.handleReceiveCodeTools.getNumber() 75 | 76 | 77 | def sendIndexFile(self, connect, address): 78 | """ 79 | 处理发送索引文件 80 | :param connect: socket连接 81 | :param address: socket地址 82 | :return: 83 | """ 84 | self.sendIndexFileTools = sendInexFile.SendIndexFile(connect, address) 85 | self.sendIndexFileTools.sendFile() 86 | self.sendUpdateFileTools = sendUpdateFile.SendUpdateFile(connect, address, filePath=self.filePath) 87 | self.sendUpdateFileTools.findFile() 88 | 89 | def sendUpdateFile(self, connect, address): 90 | """ 91 | 处理发送更新文件 92 | :param connect: socket连接 93 | :param address: socket地址 94 | :return: 95 | """ 96 | self.sendUpdateFileTools = sendUpdateFile.SendUpdateFile(connect, address, filePath=self.filePath) 97 | self.sendUpdateFileTools.findFile() 98 | 99 | 100 | if __name__ == '__main__': 101 | # VersionControl().listen() 102 | # VersionControl(filePath='F:\python17\pythonPro\MemortAssit\updateFile/').listenFile() 103 | pass 104 | -------------------------------------------------------------------------------- /src/Server/MessageTransferSystem/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Server/MessageTransferSystem/__init__.py -------------------------------------------------------------------------------- /src/Server/SystemTools/ConfFileRead/Tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Server/SystemTools/ConfFileRead/Tools/__init__.py -------------------------------------------------------------------------------- /src/Server/SystemTools/ConfFileRead/Tools/readConfigFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | 4 | from src.Server.Conf.config import * 5 | 6 | 7 | class ReadConfigFile(): 8 | """ 9 | 该类负责读取配置文件,属于实际操作类 10 | """ 11 | 12 | def __init__(self, fileName='./conf/server.ini'): 13 | self.config = ConfigParser.ConfigParser() 14 | self.fileName = fileName 15 | 16 | def readConfigFile(self, configMainName, configSubName): 17 | """ 18 | 19 | :param configMainName:配置信息主属性名 20 | :param configSubName:配置信息副属性名 21 | :return:配置信息(str) 22 | """ 23 | try: 24 | # 读取配置文件 25 | self.config.readfp(open(self.fileName)) 26 | message = self.config.get(configMainName, configSubName) 27 | # 打印debug日志 28 | if DEBUG and SYSTEM_TOOLS_DEBUG: 29 | print('{SYS}{MISSION_DEBUG} config has been load from file successfully') 30 | return str(message) 31 | except Exception as e: 32 | # 打开错误日志文件 33 | wrongFile = open('data/wrongMessage.dat', 'a+') 34 | # 获取当前时间 35 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 36 | '%Y-%m-%d-%H-%M-%S')) 37 | # 生成报错的错误信息 38 | wrongMessage = { 39 | '|currentTime': currentTime, 40 | '|configMainName': configMainName, 41 | '|configSubName': configSubName, 42 | '|file': 'SystemTools-ConfFileRead-readConfigFile', 43 | '|wrongMessage': str(e) 44 | } 45 | # 存入文件 46 | wrongFile.write(str(wrongMessage)) 47 | # 增加换行符 48 | wrongFile.write('\n') 49 | wrongFile.close() 50 | return None 51 | 52 | 53 | # 配置文件读取测试 54 | if __name__ == '__main__': 55 | l = ReadConfigFile(fileName='F:\python17\pythonPro\MemortAssit\conf\server.ini') 56 | print(l.readConfigFile('VERSION', 'lastest_version')) 57 | -------------------------------------------------------------------------------- /src/Server/SystemTools/ConfFileRead/Tools/saveConfigFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | 4 | from src.Server.Conf.config import * 5 | 6 | 7 | class SaveConfigFile(): 8 | """ 9 | 该类负责保存配置文件,属于实际操作类 10 | """ 11 | 12 | def __init__(self, fileName='./conf/server.ini'): 13 | self.config = ConfigParser.ConfigParser() 14 | self.fileName = fileName 15 | 16 | def saveConfigFile(self, configMainName, configSubName, value): 17 | """ 18 | 19 | :param missionId: 需要保存的任务id (int 或者 string) 20 | :return: 21 | """ 22 | try: 23 | # 防御编程 若value不是string,转换则在这转换 24 | if configMainName is None or configSubName is None: 25 | return None 26 | # 写回配置文件 27 | self.config.read(self.fileName) 28 | self.config.set(configMainName, configSubName, value) 29 | self.config.write(open(self.fileName, "r+")) 30 | # 打印debug日志 31 | if DEBUG and SYSTEM_TOOLS_DEBUG: 32 | print('{SYS}{MISSION_DEBUG} config has been save in file successfully') 33 | except Exception as e: 34 | # 打开错误日志文件 35 | wrongFile = open('data/wrongMessage.dat', 'a+') 36 | # 获取当前时间 37 | currentTime = str( 38 | datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), '%Y-%m-%d-%H-%M-%S')) 39 | # 生成报错的错误信息 40 | wrongMessage = { 41 | '|currentTime': currentTime, 42 | '|file': 'SystemTools-ConfFileRead-saveConfigFile', 43 | '|configMainName': configMainName, 44 | '|configSubName': configSubName, 45 | '|value': value, 46 | '|wrongMessage': str(e) 47 | } 48 | # 存入文件 49 | wrongFile.write(str(wrongMessage)) 50 | # 增加换行符 51 | wrongFile.write('\n') 52 | wrongFile.close() 53 | 54 | 55 | # 配置文件读取测试 56 | if __name__ == '__main__': 57 | s = SaveConfigFile(fileName='F:\python17\pythonPro\MemortAssit\conf\main.ini') 58 | print(s.saveConfigFile('VERSION', 'version', 'v1.0')) 59 | -------------------------------------------------------------------------------- /src/Server/SystemTools/ConfFileRead/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Server/SystemTools/ConfFileRead/__init__.py -------------------------------------------------------------------------------- /src/Server/SystemTools/ConfFileRead/configFileRead.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | 4 | from src.Server.Conf.config import * 5 | from src.Server.SystemTools.ConfFileRead.Tools import readConfigFile 6 | from src.Server.SystemTools.ConfFileRead.Tools import saveConfigFile 7 | 8 | 9 | class ConfigFileRead(): 10 | def __init__(self, fileName='./conf/server.ini'): 11 | self.readConfigFileTools = readConfigFile.ReadConfigFile(fileName=fileName) 12 | self.saveConfigFileTools = saveConfigFile.SaveConfigFile(fileName=fileName) 13 | pass 14 | 15 | def readFile(self, configMainName, configSubName): 16 | """ 17 | 读取配置文件 18 | :param configMainName: 配置文件主名称 19 | :param configSubName: 配置文件副名称 20 | :return: 配置信息的值 21 | """ 22 | message = self.readConfigFileTools.readConfigFile(configMainName=configMainName, configSubName=configSubName) 23 | return message 24 | 25 | def saveFile(self, configMainName, configSubName, value): 26 | """ 27 | 保存到配置文件 28 | :param configMainName: 配置文件主名称 29 | :param configSubName: 配置文件副名称 30 | :param value: 配置文件的值 31 | :return: 32 | """ 33 | self.saveConfigFileTools.saveConfigFile(configMainName=configMainName, configSubName=configSubName, value=value) 34 | 35 | -------------------------------------------------------------------------------- /src/Server/SystemTools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Server/SystemTools/__init__.py -------------------------------------------------------------------------------- /src/Server/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Server/__init__.py -------------------------------------------------------------------------------- /src/Update/Conf/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Update/Conf/__init__.py -------------------------------------------------------------------------------- /src/Update/Conf/config.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | import socket 3 | import datetime 4 | import time 5 | from tkinter import messagebox 6 | # import configparser as ConfigParser 7 | import ConfigParser 8 | import struct 9 | import zipfile 10 | import shutil 11 | import os 12 | 13 | # SERVER_IP = '140.143.147.128' 14 | # SERVER_IP = '127.0.0.1' 15 | SERVER_FILE_PORT = 9000 16 | SERVER_MES_PORT = 9001 17 | 18 | DEBUG = False 19 | SYSTEM_TOOLS_DEBUG = True 20 | VERSION_CONTROL_DEBUG = True 21 | 22 | if DEBUG: 23 | # 服务器ip 24 | SERVER_IP = '127.0.0.1' 25 | else: 26 | # 服务器ip 27 | SERVER_IP = 'memoryassist.sniper97.cn' 28 | -------------------------------------------------------------------------------- /src/Update/SystemTools/ConfFileRead/Tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Update/SystemTools/ConfFileRead/Tools/__init__.py -------------------------------------------------------------------------------- /src/Update/SystemTools/ConfFileRead/Tools/readConfigFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | 4 | from src.Update.Conf.config import * 5 | 6 | 7 | class ReadConfigFile(): 8 | """ 9 | 该类负责读取配置文件,属于实际操作类 10 | """ 11 | 12 | def __init__(self, fileName='./conf/main.ini'): 13 | self.config = ConfigParser.ConfigParser() 14 | self.fileName = fileName 15 | 16 | def readConfigFile(self, configMainName, configSubName): 17 | """ 18 | 19 | :param configMainName:配置信息主属性名 20 | :param configSubName:配置信息副属性名 21 | :return:配置信息(str) 22 | """ 23 | try: 24 | # 读取配置文件 25 | self.config.readfp(open(self.fileName)) 26 | message = self.config.get(configMainName, configSubName) 27 | # 打印debug日志 28 | if DEBUG and SYSTEM_TOOLS_DEBUG: 29 | print('{SYS}{MISSION_DEBUG} config has been load from file successfully') 30 | return str(message) 31 | except Exception as e: 32 | # 打开错误日志文件 33 | wrongFile = open('data/wrongMessage.dat', 'a+') 34 | # 获取当前时间 35 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 36 | '%Y-%m-%d-%H-%M-%S')) 37 | # 生成报错的错误信息 38 | wrongMessage = { 39 | '|currentTime': currentTime, 40 | '|configMainName': configMainName, 41 | '|configSubName': configSubName, 42 | '|file': 'SystemTools-ConfFileRead-readConfigFile', 43 | '|wrongMessage': str(e) 44 | } 45 | # 存入文件 46 | wrongFile.write(str(wrongMessage)) 47 | # 增加换行符 48 | wrongFile.write('\n') 49 | wrongFile.close() 50 | return None 51 | 52 | 53 | # 配置文件读取测试 54 | if __name__ == '__main__': 55 | l = ReadConfigFile(fileName='F:\python17\pythonPro\MemortAssit\conf\main.ini') 56 | print(l.readConfigFile('VERSION', 'version')) 57 | -------------------------------------------------------------------------------- /src/Update/SystemTools/ConfFileRead/Tools/saveConfigFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | 4 | from src.Update.Conf.config import * 5 | 6 | 7 | class SaveConfigFile(): 8 | """ 9 | 该类负责保存配置文件,属于实际操作类 10 | """ 11 | 12 | def __init__(self, fileName='./conf/main.ini'): 13 | self.config = ConfigParser.ConfigParser() 14 | self.fileName = fileName 15 | 16 | def saveConfigFile(self, configMainName, configSubName, value): 17 | """ 18 | 19 | :param missionId: 需要保存的任务id (int 或者 string) 20 | :return: 21 | """ 22 | try: 23 | # 防御编程 若value不是string,转换则在这转换 24 | if configMainName is None or configSubName is None: 25 | return None 26 | # 写回配置文件 27 | self.config.read(self.fileName) 28 | self.config.set(configMainName, configSubName, value) 29 | self.config.write(open(self.fileName, "r+")) 30 | # 打印debug日志 31 | if DEBUG and SYSTEM_TOOLS_DEBUG: 32 | print('{SYS}{MISSION_DEBUG} config has been save in file successfully') 33 | except Exception as e: 34 | # 打开错误日志文件 35 | wrongFile = open('data/wrongMessage.dat', 'a+') 36 | # 获取当前时间 37 | currentTime = str( 38 | datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), '%Y-%m-%d-%H-%M-%S')) 39 | # 生成报错的错误信息 40 | wrongMessage = { 41 | '|currentTime': currentTime, 42 | '|file': 'SystemTools-ConfFileRead-saveConfigFile', 43 | '|configMainName': configMainName, 44 | '|configSubName': configSubName, 45 | '|value': value, 46 | '|wrongMessage': str(e) 47 | } 48 | # 存入文件 49 | wrongFile.write(str(wrongMessage)) 50 | # 增加换行符 51 | wrongFile.write('\n') 52 | wrongFile.close() 53 | 54 | 55 | # 配置文件读取测试 56 | if __name__ == '__main__': 57 | s = SaveConfigFile(fileName='F:\python17\pythonPro\MemortAssit\conf\main.ini') 58 | print(s.saveConfigFile('VERSION', 'version', 'v1.0')) 59 | -------------------------------------------------------------------------------- /src/Update/SystemTools/ConfFileRead/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Update/SystemTools/ConfFileRead/__init__.py -------------------------------------------------------------------------------- /src/Update/SystemTools/ConfFileRead/configFileRead.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | 4 | from src.Update.Conf.config import * 5 | from src.Update.SystemTools.ConfFileRead.Tools import readConfigFile 6 | from src.Update.SystemTools.ConfFileRead.Tools import saveConfigFile 7 | 8 | 9 | class ConfigFileRead(): 10 | def __init__(self, fileName='./conf/main.ini'): 11 | self.readConfigFileTools = readConfigFile.ReadConfigFile(fileName=fileName) 12 | self.saveConfigFileTools = saveConfigFile.SaveConfigFile(fileName=fileName) 13 | pass 14 | 15 | def readFile(self, configMainName, configSubName): 16 | """ 17 | 读取配置文件 18 | :param configMainName: 配置文件主名称 19 | :param configSubName: 配置文件副名称 20 | :return: 配置信息的值 21 | """ 22 | message = self.readConfigFileTools.readConfigFile(configMainName=configMainName, configSubName=configSubName) 23 | return message 24 | 25 | def saveFile(self, configMainName, configSubName, value): 26 | """ 27 | 保存到配置文件 28 | :param configMainName: 配置文件主名称 29 | :param configSubName: 配置文件副名称 30 | :param value: 配置文件的值 31 | :return: 32 | """ 33 | self.saveConfigFileTools.saveConfigFile(configMainName=configMainName, configSubName=configSubName, value=value) 34 | 35 | if __name__ == '__main__': 36 | a = ConfigFileRead().readFile('VERSION', 'version') 37 | print(a) -------------------------------------------------------------------------------- /src/Update/SystemTools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Update/SystemTools/__init__.py -------------------------------------------------------------------------------- /src/Update/VersionControlSystem/GetNewFile/Tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Update/VersionControlSystem/GetNewFile/Tools/__init__.py -------------------------------------------------------------------------------- /src/Update/VersionControlSystem/GetNewFile/Tools/getIndexFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Update.Conf.config import * 3 | 4 | 5 | class GetIndexFile(): 6 | """ 7 | 从服务器获取更新索引文件 8 | """ 9 | def __init__(self, s): 10 | self.s = s 11 | 12 | def getFile(self): 13 | """ 14 | 获取服务器索引文件并保存 15 | :return: 16 | """ 17 | fileinfo_size = struct.calcsize('128si2s') 18 | buf = self.s.recv(fileinfo_size) 19 | if buf: 20 | filename, filesize, pw = struct.unpack('128si2s', buf) 21 | # 删除byte转为str后的\x00 用strip也可以 22 | newFileName = bytes.decode(filename).rstrip('\x00') 23 | new_filename = './data/fileIndex.properties' 24 | recvd_size = 0 # 定义已接收文件的大小 25 | fp = open(new_filename, 'wb') 26 | while not recvd_size == filesize: 27 | if filesize - recvd_size > 1024: 28 | data = self.s.recv(1024) 29 | recvd_size += len(data) 30 | else: 31 | data = self.s.recv(filesize - recvd_size) 32 | recvd_size = filesize 33 | fp.write(data) 34 | fp.close() 35 | if DEBUG and VERSION_CONTROL_DEBUG: 36 | print('{SYS}{VERSION_CONTROL_DEBUG}index file has been receive, filesize is ' + str(filesize)) 37 | 38 | 39 | if __name__ == '__main__': 40 | GetIndexFile().getFile() 41 | -------------------------------------------------------------------------------- /src/Update/VersionControlSystem/GetNewFile/Tools/getUpdateFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Update.Conf.config import * 3 | 4 | 5 | class GetUpdateFile(): 6 | """ 7 | 获取服务器发送过来的更新文件 8 | """ 9 | def __init__(self, s): 10 | self.s = s 11 | pass 12 | 13 | def get(self): 14 | """ 15 | 获取服务器发送到客户端的更新文件,并按照更新索引文件的地址保存 16 | :return: 17 | """ 18 | file_path = './data/fileIndex.properties' 19 | property = Properties(file_path) # 读取文件 20 | loopTime = property.getLength() 21 | while loopTime != 0: 22 | loopTime = loopTime - 1 23 | fileinfo_size = struct.calcsize('128si2s') 24 | buf = self.s.recv(fileinfo_size) 25 | if buf: 26 | filename, filesize, pwd = struct.unpack('128si2s', buf) 27 | 28 | 29 | # 删除byte转为str后的\x00 用strip也可以 30 | newFileName = bytes.decode(filename).rstrip('\x00') 31 | # 得到文件路径前缀 32 | dirPrefix = property.get(newFileName) 33 | new_filename = os.path.join(dirPrefix, '' + newFileName) 34 | print('file new name is {0}, filesize if {1}'.format(new_filename, filesize)) 35 | 36 | recvd_size = 0 # 定义已接收文件的大小 37 | fp = open(new_filename, 'wb') 38 | print('start receiving...') 39 | while not recvd_size == filesize: 40 | if filesize - recvd_size > 1024: 41 | data = self.s.recv(1024) 42 | recvd_size += len(data) 43 | else: 44 | data = self.s.recv(filesize - recvd_size) 45 | recvd_size = filesize 46 | fp.write(data) 47 | fp.close() 48 | print('end receive...') 49 | print('finish file receive') 50 | 51 | 52 | class Properties: 53 | """ 54 | 解析索引文件 55 | """ 56 | def __init__(self, file_name): 57 | self.file_name = file_name 58 | self.properties = {} 59 | try: 60 | fopen = open(self.file_name, 'r') 61 | for line in fopen: 62 | line = line.strip() 63 | if line.find('=') > 0 and not line.startswith('#'): 64 | strs = line.split('=') 65 | self.properties[strs[0].strip()] = strs[1].strip() 66 | except Exception: 67 | # raise Exception 68 | print("read file exception ...") 69 | else: 70 | fopen.close() 71 | 72 | def get(self, key, default_value='./'): 73 | """ 74 | 获取应该存放的路径 75 | :param key: 文件名 76 | :param default_value: 默认返回值(如果没做规定则默认放到根目录) 77 | :return: 78 | """ 79 | if key in self.properties: 80 | return self.properties[key] 81 | return default_value 82 | 83 | def getLength(self): 84 | """ 85 | 回去索引列表中更新文件长度 86 | :return: 87 | """ 88 | return len(self.properties) 89 | -------------------------------------------------------------------------------- /src/Update/VersionControlSystem/GetNewFile/Tools/unZipFile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Update.Conf.config import * 3 | 4 | class UnZipFile(): 5 | def __init__(self, file_name): 6 | self.fileName = file_name 7 | pass 8 | 9 | def un_zip(self): 10 | """ 11 | 解压文件 12 | :return: 13 | """ 14 | zip_file = zipfile.ZipFile(self.fileName) 15 | if os.path.isdir(self.fileName + "_files"): 16 | pass 17 | else: 18 | os.mkdir(self.fileName + "_files") 19 | for names in zip_file.namelist(): 20 | zip_file.extract(names, self.fileName + "_files/") 21 | zip_file.close() 22 | self.moveFile() 23 | 24 | 25 | def moveFile(self): 26 | """ 27 | 移动文件,将解压后的更新文件移动出来并删除 28 | :return: 29 | """ 30 | for filename in os.listdir('./update.zip_files/update/'): 31 | try: 32 | os.remove('./' + filename) 33 | except Exception as e: 34 | try: 35 | shutil.rmtree('./' + filename) 36 | except Exception as e: 37 | pass 38 | pass 39 | shutil.move('./update.zip_files/update/' + filename, './') 40 | # 对多余的文件进行删除 41 | shutil.rmtree('./update.zip_files') 42 | os.remove('./' + self.fileName) 43 | 44 | 45 | 46 | 47 | if __name__ == '__main__': 48 | pass 49 | -------------------------------------------------------------------------------- /src/Update/VersionControlSystem/GetNewFile/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Update/VersionControlSystem/GetNewFile/__init__.py -------------------------------------------------------------------------------- /src/Update/VersionControlSystem/GetNewFile/doUpdate.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | from src.Update.Conf.config import * 4 | from src.Update.VersionControlSystem.GetNewFile.Tools import getUpdateFile, getIndexFile, unZipFile 5 | 6 | 7 | class GetNewFile(): 8 | def __init__(self, filePath='update.zip'): 9 | try: 10 | self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 11 | self.s.connect((SERVER_IP, SERVER_FILE_PORT)) 12 | # 工具生成 13 | self.getUpdateFileTools = getUpdateFile.GetUpdateFile(self.s) 14 | self.getIndexFileTools = getIndexFile.GetIndexFile(self.s) 15 | self.unZipFileTools = unZipFile.UnZipFile(filePath) 16 | 17 | # 获取索引 18 | self.getIndexFileTools.getFile() 19 | # 获取更新文件夹 20 | self.getUpdateFileTools.get() 21 | # 解压更新文件 22 | self.unZipFileTools.un_zip() 23 | except socket.error as msg: 24 | # 打开错误日志文件 25 | wrongFile = open('data/wrongMessage.dat', 'a+') 26 | # 获取当前时间 27 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 28 | '%Y-%m-%d-%H-%M-%S')) 29 | # 生成报错的错误信息 30 | wrongMessage = { 31 | '|currentTime': currentTime, 32 | '|file': 'VersionControlSystem-GetNewFile-doUpdate', 33 | '|wrongMessage': msg 34 | } 35 | # 存入文件 36 | wrongFile.write(str(wrongMessage)) 37 | # 增加换行符 38 | wrongFile.write('\n') 39 | wrongFile.close() 40 | 41 | 42 | 43 | if __name__ == '__main__': 44 | GetNewFile() -------------------------------------------------------------------------------- /src/Update/VersionControlSystem/JudgeNeedUpdate/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Update/VersionControlSystem/JudgeNeedUpdate/__init__.py -------------------------------------------------------------------------------- /src/Update/VersionControlSystem/JudgeNeedUpdate/judgeNeedUpdate.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Update.Conf.config import * 3 | from src.Update.SystemTools.ConfFileRead import configFileRead 4 | 5 | 6 | class JudgeNeedUpdate(): 7 | def __init__(self): 8 | try: 9 | self.configFileReadTools = configFileRead.ConfigFileRead() 10 | self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 11 | self.s.connect((SERVER_IP, SERVER_MES_PORT)) 12 | print(SERVER_IP) 13 | 14 | 15 | except socket.error as msg: 16 | # 打开错误日志文件 17 | wrongFile = open('data/wrongMessage.dat', 'a+') 18 | # 获取当前时间 19 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 20 | '%Y-%m-%d-%H-%M-%S')) 21 | # 生成报错的错误信息 22 | wrongMessage = { 23 | '|currentTime': currentTime, 24 | '|file': 'VersionControlSystem-GetNewFile-judgeNeedUpdate', 25 | '|wrongMessage': msg 26 | } 27 | # 存入文件 28 | wrongFile.write(str(wrongMessage)) 29 | # 增加换行符 30 | wrongFile.write('\n') 31 | wrongFile.close() 32 | 33 | def judge(self): 34 | # return True 35 | version = self.configFileReadTools.readFile('VERSION', 'version') 36 | print(str(version)) 37 | # 请求码为100时 返回最新版本号 38 | code = '100'.encode('utf-8') 39 | self.s.send(code) 40 | returnData = self.s.recv(1024) 41 | print(returnData) 42 | if version == returnData: 43 | return False, returnData 44 | else: 45 | return True, returnData 46 | pass 47 | -------------------------------------------------------------------------------- /src/Update/VersionControlSystem/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Update/VersionControlSystem/__init__.py -------------------------------------------------------------------------------- /src/Update/VersionControlSystem/versionControl.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | from src.Update.Conf.config import * 3 | from src.Update.VersionControlSystem.GetNewFile import doUpdate 4 | from src.Update.VersionControlSystem.JudgeNeedUpdate import judgeNeedUpdate 5 | from src.Update.SystemTools.ConfFileRead import configFileRead 6 | 7 | 8 | class VersionControl(): 9 | def __init__(self): 10 | self.judgeNeedUpdateTools = judgeNeedUpdate.JudgeNeedUpdate() 11 | 12 | def handle(self): 13 | """ 14 | 版本控制一级系统 15 | :return: 16 | """ 17 | try: 18 | needUpdate, version = self.judgeNeedUpdateTools.judge() 19 | version = bytes.decode(version) 20 | print(version) 21 | if needUpdate: 22 | if messagebox.askokcancel(title='是否更新', message='检测到有新版本,是否更新,更新完成后自动运行'): 23 | doUpdate.GetNewFile() 24 | configFileRead.ConfigFileRead().saveFile('VERSION', 'version', version) 25 | except socket.error as msg: 26 | print('no network') 27 | # 打开错误日志文件 28 | wrongFile = open('data/wrongMessage.dat', 'a+') 29 | # 获取当前时间 30 | currentTime = str(datetime.datetime.strptime(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()), 31 | '%Y-%m-%d-%H-%M-%S')) 32 | # 生成报错的错误信息 33 | wrongMessage = { 34 | '|currentTime': currentTime, 35 | '|file': 'VersionControlSystem-versionControl', 36 | '|wrongMessage': msg, 37 | '|没有互联网连接|': '没有互联网连接', 38 | } 39 | # 存入文件 40 | wrongFile.write(str(wrongMessage)) 41 | # 增加换行符 42 | wrongFile.write('\n') 43 | wrongFile.close() 44 | 45 | finally: 46 | os.system('start run.exe') -------------------------------------------------------------------------------- /src/Update/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/Update/__init__.py -------------------------------------------------------------------------------- /src/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sniper970119/MemoryAssistInPython/434efd09edbda7919a3f754374add7f34912fab7/src/__init__.py --------------------------------------------------------------------------------