├── .gitignore ├── Example ├── Soft_WingIDE │ ├── CalcActivationCode.py │ └── README.md ├── create_file │ ├── config.ini │ └── test_create_file_fixedsize.py ├── learn_DirtConfig_footprint │ ├── README.md │ ├── build.py │ ├── config.py │ └── footprint.html ├── log_visual │ ├── 1_log.py │ ├── 2_log.py │ ├── README.md │ ├── doc │ │ ├── date.md │ │ ├── ip.md │ │ └── scripts │ │ │ └── month.sh │ ├── log_if_sort.py │ └── log_ip_AccessSort.py ├── python_base │ ├── README.md │ ├── exception │ │ ├── README.md │ │ └── exception.py │ ├── filemd5 │ │ ├── README.md │ │ └── filemd5.py │ ├── is │ │ └── README.md │ ├── re │ │ ├── README.md │ │ ├── reg.py │ │ └── zabbix_re.py │ └── urllib2 │ │ ├── README.md │ │ ├── urllib2_e1.py │ │ └── urllib2_e2.py ├── python_count │ ├── README.md │ └── py_count.py ├── python_interactive │ ├── README.md │ └── pythonstartup.sh ├── random_test │ ├── README.md │ ├── doc │ │ ├── test.txt │ │ └── user.txt │ └── random_test.py └── store_test │ ├── config.ini │ ├── test_check.py │ └── test_create_file.py ├── LICENSE ├── My_lib ├── Example │ ├── Agent │ │ ├── __init__.py │ │ ├── agent.py │ │ ├── agent.server │ │ ├── daemon.py │ │ ├── monitems.py │ │ ├── monitor.py │ │ ├── netlib │ │ │ ├── NetBase.py │ │ │ ├── NetUtils.py │ │ │ ├── __init__.py │ │ │ └── daemon.py │ │ └── run_daemon.py │ ├── README.md │ └── saver │ │ ├── SaverDB.py │ │ └── netlib │ │ ├── .gitignore │ │ ├── NetBase.py │ │ ├── NetUtils.py │ │ ├── __init__.py │ │ └── daemon.py ├── color │ └── color.py ├── command_utils │ ├── README.md │ ├── command.py │ ├── command_class.py │ └── command_simple.py ├── daemon │ ├── README.md │ ├── ceshi.py │ ├── run_daemon.py │ └── xlib │ │ ├── __init__.py │ │ └── daemon.py ├── easyrun │ ├── README.md │ └── easyrun.py ├── file_utils │ ├── README.md │ ├── config │ └── file_util.py ├── log_utils │ ├── README.md │ └── blog.py ├── monitor_process │ └── monitor.py ├── mpms │ ├── demo.py │ ├── mylib │ │ ├── BLog.py │ │ ├── __init__.py │ │ └── mpms.py │ └── readme.md ├── netlib │ ├── .gitignore │ ├── NetBase.py │ ├── NetUtils.py │ ├── README.md │ └── __init__.py ├── peewee │ ├── README.md │ └── user.py ├── progressbar │ ├── Progressbar.py │ └── Progressbar.py_bak ├── pymysql │ └── README.md ├── pytest │ └── README.md ├── query_ip │ ├── QQWry.Dat │ ├── README.md │ └── query_ip.py ├── redis-rdb-tools │ └── README.md ├── schema │ ├── README.md │ ├── demo.py │ ├── schema │ │ ├── __init__.py │ │ └── contextlib2.py │ └── test_schema.py ├── serverinfo_config │ ├── README.md │ ├── sc.py │ └── si.py ├── ttable │ ├── README.md │ └── ttable.py ├── validator │ └── README.md ├── w_mpms │ ├── demo.py │ ├── readme.md │ └── w_lib │ │ ├── BLog.py │ │ ├── __init__.py │ │ └── mpms.py └── xmltodict │ ├── README.md │ └── xmltodict.py └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | 55 | # Sphinx documentation 56 | docs/_build/ 57 | 58 | # PyBuilder 59 | target/ 60 | 61 | #Ipython Notebook 62 | .ipynb_checkpoints 63 | -------------------------------------------------------------------------------- /Example/Soft_WingIDE/CalcActivationCode.py: -------------------------------------------------------------------------------- 1 | import sha 2 | import string 3 | BASE2 = '01' 4 | BASE10 = '0123456789' 5 | BASE16 = '0123456789ABCDEF' 6 | BASE30 = '123456789ABCDEFGHJKLMNPQRTVWXY' 7 | BASE36 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' 8 | BASE62 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz' 9 | BASEMAX = string.printable 10 | def BaseConvert(number, fromdigits, todigits, ignore_negative = True): 11 | """ converts a "number" between two bases of arbitrary digits 12 | 13 | The input number is assumed to be a string of digits from the 14 | fromdigits string (which is in order of smallest to largest 15 | digit). The return value is a string of elements from todigits 16 | (ordered in the same way). The input and output bases are 17 | determined from the lengths of the digit strings. Negative 18 | signs are passed through. 19 | 20 | decimal to binary 21 | >>> baseconvert(555,BASE10,BASE2) 22 | '1000101011' 23 | 24 | binary to decimal 25 | >>> baseconvert('1000101011',BASE2,BASE10) 26 | '555' 27 | 28 | integer interpreted as binary and converted to decimal (!) 29 | >>> baseconvert(1000101011,BASE2,BASE10) 30 | '555' 31 | 32 | base10 to base4 33 | >>> baseconvert(99,BASE10,"0123") 34 | '1203' 35 | 36 | base4 to base5 (with alphabetic digits) 37 | >>> baseconvert(1203,"0123","abcde") 38 | 'dee' 39 | 40 | base5, alpha digits back to base 10 41 | >>> baseconvert('dee',"abcde",BASE10) 42 | '99' 43 | 44 | decimal to a base that uses A-Z0-9a-z for its digits 45 | >>> baseconvert(257938572394L,BASE10,BASE62) 46 | 'E78Lxik' 47 | 48 | ..convert back 49 | >>> baseconvert('E78Lxik',BASE62,BASE10) 50 | '257938572394' 51 | 52 | binary to a base with words for digits (the function cannot convert this back) 53 | >>> baseconvert('1101',BASE2,('Zero','One')) 54 | 'OneOneZeroOne' 55 | 56 | """ 57 | if not ignore_negative and str(number)[0] == '-': 58 | number = str(number)[1:] 59 | neg = 1 60 | else: 61 | neg = 0 62 | x = long(0) 63 | for digit in str(number): 64 | x = x * len(fromdigits) + fromdigits.index(digit) 65 | 66 | res = '' 67 | while x > 0: 68 | digit = x % len(todigits) 69 | res = todigits[digit] + res 70 | x /= len(todigits) 71 | 72 | if neg: 73 | res = '-' + res 74 | return res 75 | 76 | def SHAToBase30(digest): 77 | """Convert from a hexdigest form SHA hash into a more compact and 78 | ergonomic BASE30 representation. This results in a 17 'digit' 79 | number.""" 80 | tdigest = ''.join([ c for i, c in enumerate(digest) if i / 2 * 2 == i ]) 81 | result = BaseConvert(tdigest, BASE16, BASE30) 82 | while len(result) < 17: 83 | result = '1' + result 84 | 85 | return result 86 | def AddHyphens(code): 87 | """Insert hyphens into given license id or activation request to 88 | make it easier to read""" 89 | return code[:5] + '-' + code[5:10] + '-' + code[10:15] + '-' + code[15:] 90 | 91 | LicenseID='CN123-12345-12345-12345' 92 | #Copy the Request Code from the dialog 93 | RequestCode='RL539-XMGG2-A3DBA-LKA8J' 94 | hasher = sha.new() 95 | hasher.update(RequestCode) 96 | hasher.update(LicenseID) 97 | digest = hasher.hexdigest().upper() 98 | lichash = RequestCode[:3] + SHAToBase30(digest) 99 | lichash=AddHyphens(lichash) 100 | 101 | #Calculate the Activation Code 102 | data=[7,123,23,87] 103 | tmp=0 104 | realcode='' 105 | for i in data: 106 | for j in lichash: 107 | tmp=(tmp*i+ord(j))&0xFFFFF 108 | realcode+=format(tmp,'=05X') 109 | tmp=0 110 | 111 | act30=BaseConvert(realcode,BASE16,BASE30) 112 | while len(act30) < 17: 113 | act30 = '1' + act30 114 | act30='AXX'+act30 115 | act30=AddHyphens(act30) 116 | print "The Activation Code is: "+act30 117 | -------------------------------------------------------------------------------- /Example/Soft_WingIDE/README.md: -------------------------------------------------------------------------------- 1 | # wingIDE 2 | ## the license id 3 | CN123-12345-12345-12345 4 | ## the request code 5 | we use the request code create the Activation code 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/create_file/config.ini: -------------------------------------------------------------------------------- 1 | [default] 2 | # Sub-directory numbers 3 | DIR_PATH_NUM = 1 4 | # File numbers in each sub-directory 5 | FILE_NUM = 3 6 | # Path to write file 7 | PATH_STORE = /tmp/test/ 8 | # Path to record logs 9 | PATH_LOG_RECORD = /tmp/record/ 10 | # file size(kb) 11 | FILE_SIZE_KB = 1024 12 | -------------------------------------------------------------------------------- /Example/create_file/test_create_file_fixedsize.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #coding=utf8 3 | """ 4 | # Author: meetbill 5 | # Created Time : 2017-03-07 22:59:17 6 | 7 | # File Name: test_create_file_fixedsize.py 8 | # Description: 9 | 10 | """ 11 | import os 12 | import random 13 | import hashlib 14 | import threading 15 | import ConfigParser 16 | 17 | config = ConfigParser.ConfigParser() 18 | config.read('./config.ini') 19 | 20 | DIR_PATH_NUM= int(config.get('default', 'DIR_PATH_NUM')) 21 | FILE_NUM = int(config.get('default','FILE_NUM')) 22 | PATH_STORE = config.get('default','PATH_STORE') 23 | PATH_LOG_RECORD = config.get('default','PATH_LOG_RECORD') 24 | FILE_SIZE_KB = int(config.get('default','FILE_SIZE_KB')) 25 | 26 | def log(path, data, suffix="log"): 27 | fout = open(path + "md5log." + suffix, "a") 28 | fout.write(data) 29 | fout.write("\n") 30 | 31 | def get_md5(filename): 32 | if not os.path.isfile(filename): 33 | return 34 | myhash = hashlib.md5() 35 | f = file(filename, 'rb') 36 | while True: 37 | b = f.read(8096) 38 | if not b : 39 | break 40 | myhash.update(b) 41 | f.close() 42 | return myhash.hexdigest() 43 | 44 | 45 | def write_file(path_store, file_index, dir_index): 46 | 47 | ceshi_path = path_store + "/" + dir_index + "/" 48 | if not os.path.exists(ceshi_path): 49 | os.makedirs(os.path.dirname(ceshi_path)) 50 | 51 | ceshi_full_path = ceshi_path + file_index 52 | 53 | 54 | data=(str(random.randint(0,1024)).zfill(16)+ str(random.randint(0,1024)).zfill(16))* 32 * FILE_SIZE_KB 55 | #data = (str(8).zfill(8)) * random.randint(0, 128 * 1024 * MAX_FIlE_SIZE_MB) 56 | #data = (str(8).zfill(8)) * random.randint(0, 128 * 1024 * MAX_FIlE_SIZE_MB) 57 | 58 | fout = open(ceshi_full_path, "w") 59 | fout.write(data) 60 | fout.flush() 61 | md5_ceshifile = get_md5(ceshi_full_path) 62 | os.rename(os.path.join(ceshi_path, file_index), os.path.join(ceshi_path,md5_ceshifile)) 63 | 64 | log_data = md5_ceshifile 65 | log(PATH_LOG_RECORD, log_data, dir_index) 66 | print dir_index, file_index, log_data 67 | 68 | 69 | def write_files(path_store, file_num, dir_index): 70 | 71 | for i in xrange(0, file_num): 72 | write_file(path_store, str(i), dir_index) 73 | 74 | def writ_files_mutilthread(path_store, file_num): 75 | 76 | if not os.path.exists(PATH_LOG_RECORD): 77 | os.makedirs(os.path.dirname(PATH_LOG_RECORD)) 78 | 79 | threads = [] 80 | 81 | for i in xrange(0, DIR_PATH_NUM): 82 | dir_index = str(i); 83 | t = threading.Thread(target=write_files, args=(path_store, file_num, dir_index)) 84 | t.start() 85 | threads.append(t) 86 | 87 | for t in threads: 88 | t.join() 89 | 90 | if __name__ == '__main__': 91 | writ_files_mutilthread(PATH_STORE, FILE_NUM) 92 | -------------------------------------------------------------------------------- /Example/learn_DirtConfig_footprint/README.md: -------------------------------------------------------------------------------- 1 | # 记录去过的足迹 2 | 3 | 4 | ### python版本 5 | 6 | * 下载本项目,进入到python目录下,有两个文件,config是你需要修改的. 7 | * 项目依赖于requests模块 需要pip安装 8 | 9 | ``` 10 | config={ 11 | 'title':'去过的地方', 12 | 'subtitle':'北京 昆明 西北 呼和浩特', 13 | 'foot':[ 14 | '北京 昆明 丽江 香格里拉 丽江 昆明 北京', 15 | ] 16 | } 17 | 18 | ``` 19 | 20 | * 修改上面这个配置里的title(标题),subtitle(副标题)和foot(行程) 21 | * foot是一个数组,每个元素是一个行程,目的地(景点)之间用空格分开 22 | * 执行 python build.py ,会生成一个footprint.html,大功告成,浏览器打开看效果吧 23 | * 谢谢大家,开发时间很短,如有bug 请轻喷 24 | 25 | 26 | ### 彩色版本和定制区域 27 | 28 | * config加一个color变量,就会把足迹线变成彩色,如下 29 | 30 | ``` 31 | config={ 32 | 'title':'去过的地方', 33 | 'subtitle':'北京 昆明 西北 呼和浩特', 34 | 'color':True, 35 | 'foot':[ 36 | '北京 昆明 丽江 香格里拉 丽江 昆明 北京', 37 | '霍营地铁站 布达拉宫', 38 | '北京 北戴河 北京', 39 | '北京 兰州 敦煌 张掖 祁连 西宁 青海湖 茶卡盐湖 西宁 银川 呼和浩特 北京' 40 | ] 41 | } 42 | ``` 43 | * 如果你只在北京内部玩,或者定制一个北京旅游计划,可以加一个region字段,如下 44 | 45 | ``` 46 | config={ 47 | 'title':'北京去过的地方', 48 | 'subtitle':'走啊走', 49 | 'color':True, 50 | 'region':'北京', 51 | 'foot':[ 52 | '北京交通大学 霍营地铁站 古北水镇', 53 | '北京交通大学 八达岭 北京交通大学', 54 | '北京交通大学 妙峰山 潭柘寺' 55 | 56 | ] 57 | } 58 | ``` 59 | -------------------------------------------------------------------------------- /Example/learn_DirtConfig_footprint/build.py: -------------------------------------------------------------------------------- 1 | #encoding:utf-8 2 | import requests 3 | import os,sys 4 | import config 5 | reload(sys) 6 | sys.setdefaultencoding("utf-8") 7 | import requests 8 | import json 9 | import random 10 | #{{{html 11 | htmlStr = ''' 12 | 13 | 14 |
15 | 16 |