提交代码
This commit is contained in:
parent
bdf3021fc3
commit
ef6fd0c076
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
// 使用 IntelliSense 了解相关属性。
|
||||
// 悬停以查看现有属性的描述。
|
||||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: ptvsd",
|
||||
"type": "python",
|
||||
"request": "attach",
|
||||
"port": 5678,
|
||||
"host": "192.168.1.12",
|
||||
"pathMappings": [
|
||||
{
|
||||
"localRoot": "${workspaceFolder}",
|
||||
"remoteRoot": "/opt/install/"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Python: 当前文件",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${file}",
|
||||
// "args": [
|
||||
// "app5vfffdhz8371",
|
||||
// "-pl"
|
||||
// ],
|
||||
"console": "integratedTerminal"
|
||||
},
|
||||
{
|
||||
"name": "Python: main",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}\\bin\\faker_diary.py",
|
||||
// "args": [
|
||||
// "-k",
|
||||
// "--tags=-wip",
|
||||
// "feature\\01test.feature"
|
||||
// ],
|
||||
"console": "integratedTerminal"
|
||||
//"cwd": "${workspaceRoot}\\tests"
|
||||
},
|
||||
{
|
||||
"name": "start testcafe",
|
||||
"type": "node",
|
||||
"protocol": "inspector",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/node_modules/testcafe/bin/testcafe.js",
|
||||
"runtimeExecutable": "${workspaceRoot}/node/node.exe",
|
||||
"args": [
|
||||
"chrome",
|
||||
"${relativeFile}"
|
||||
],
|
||||
"cwd": "${workspaceRoot}"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"python.formatting.provider": "black"
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "My Server",
|
||||
"host": "192.168.1.12",
|
||||
"protocol": "sftp",
|
||||
"port": 22,
|
||||
"username": "root",
|
||||
"password": "123456",
|
||||
"remotePath": "/opt/install/test",
|
||||
"uploadOnSave": true,
|
||||
"downloadOnOpen": true,
|
||||
"watcher": {
|
||||
"files": "**/*",
|
||||
"autoUpload": true,
|
||||
"autoDelete": false
|
||||
},
|
||||
"ignore": [
|
||||
".vscode",
|
||||
".git",
|
||||
".DS_Store"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
[[source]]
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
jinja2 = "*"
|
||||
faker = "*"
|
||||
chinese-calendar = "*"
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[requires]
|
||||
python_version = "3.8"
|
|
@ -0,0 +1,107 @@
|
|||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "b4955563cbf31925e708fe7b16e8b899b6499c553dad50e20a045aa191785051"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_version": "3.8"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"chinese-calendar": {
|
||||
"hashes": [
|
||||
"sha256:140276c044ffae5730e69fa05a3a0e14eef496c048773dfc0dcbe300a39170e1",
|
||||
"sha256:29c66cf29018cc1650b8e0cf1135c8e0d2043434a24016bd2fd22a420064c78b"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.7.2"
|
||||
},
|
||||
"faker": {
|
||||
"hashes": [
|
||||
"sha256:4a3465624515a6807e8aa7e8eeb85bdd86a2fa53de4e258892dd6be95362462e",
|
||||
"sha256:b9dd2fd9a9ac68a4e0c5040cd9e9bfaa099fa8dd15bae5f01f224a45431818d5"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==15.3.1"
|
||||
},
|
||||
"jinja2": {
|
||||
"hashes": [
|
||||
"sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852",
|
||||
"sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==3.1.2"
|
||||
},
|
||||
"markupsafe": {
|
||||
"hashes": [
|
||||
"sha256:0212a68688482dc52b2d45013df70d169f542b7394fc744c02a57374a4207003",
|
||||
"sha256:089cf3dbf0cd6c100f02945abeb18484bd1ee57a079aefd52cffd17fba910b88",
|
||||
"sha256:10c1bfff05d95783da83491be968e8fe789263689c02724e0c691933c52994f5",
|
||||
"sha256:33b74d289bd2f5e527beadcaa3f401e0df0a89927c1559c8566c066fa4248ab7",
|
||||
"sha256:3799351e2336dc91ea70b034983ee71cf2f9533cdff7c14c90ea126bfd95d65a",
|
||||
"sha256:3ce11ee3f23f79dbd06fb3d63e2f6af7b12db1d46932fe7bd8afa259a5996603",
|
||||
"sha256:421be9fbf0ffe9ffd7a378aafebbf6f4602d564d34be190fc19a193232fd12b1",
|
||||
"sha256:43093fb83d8343aac0b1baa75516da6092f58f41200907ef92448ecab8825135",
|
||||
"sha256:46d00d6cfecdde84d40e572d63735ef81423ad31184100411e6e3388d405e247",
|
||||
"sha256:4a33dea2b688b3190ee12bd7cfa29d39c9ed176bda40bfa11099a3ce5d3a7ac6",
|
||||
"sha256:4b9fe39a2ccc108a4accc2676e77da025ce383c108593d65cc909add5c3bd601",
|
||||
"sha256:56442863ed2b06d19c37f94d999035e15ee982988920e12a5b4ba29b62ad1f77",
|
||||
"sha256:671cd1187ed5e62818414afe79ed29da836dde67166a9fac6d435873c44fdd02",
|
||||
"sha256:694deca8d702d5db21ec83983ce0bb4b26a578e71fbdbd4fdcd387daa90e4d5e",
|
||||
"sha256:6a074d34ee7a5ce3effbc526b7083ec9731bb3cbf921bbe1d3005d4d2bdb3a63",
|
||||
"sha256:6d0072fea50feec76a4c418096652f2c3238eaa014b2f94aeb1d56a66b41403f",
|
||||
"sha256:6fbf47b5d3728c6aea2abb0589b5d30459e369baa772e0f37a0320185e87c980",
|
||||
"sha256:7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b",
|
||||
"sha256:86b1f75c4e7c2ac2ccdaec2b9022845dbb81880ca318bb7a0a01fbf7813e3812",
|
||||
"sha256:8dc1c72a69aa7e082593c4a203dcf94ddb74bb5c8a731e4e1eb68d031e8498ff",
|
||||
"sha256:8e3dcf21f367459434c18e71b2a9532d96547aef8a871872a5bd69a715c15f96",
|
||||
"sha256:8e576a51ad59e4bfaac456023a78f6b5e6e7651dcd383bcc3e18d06f9b55d6d1",
|
||||
"sha256:96e37a3dc86e80bf81758c152fe66dbf60ed5eca3d26305edf01892257049925",
|
||||
"sha256:97a68e6ada378df82bc9f16b800ab77cbf4b2fada0081794318520138c088e4a",
|
||||
"sha256:99a2a507ed3ac881b975a2976d59f38c19386d128e7a9a18b7df6fff1fd4c1d6",
|
||||
"sha256:a49907dd8420c5685cfa064a1335b6754b74541bbb3706c259c02ed65b644b3e",
|
||||
"sha256:b09bf97215625a311f669476f44b8b318b075847b49316d3e28c08e41a7a573f",
|
||||
"sha256:b7bd98b796e2b6553da7225aeb61f447f80a1ca64f41d83612e6139ca5213aa4",
|
||||
"sha256:b87db4360013327109564f0e591bd2a3b318547bcef31b468a92ee504d07ae4f",
|
||||
"sha256:bcb3ed405ed3222f9904899563d6fc492ff75cce56cba05e32eff40e6acbeaa3",
|
||||
"sha256:d4306c36ca495956b6d568d276ac11fdd9c30a36f1b6eb928070dc5360b22e1c",
|
||||
"sha256:d5ee4f386140395a2c818d149221149c54849dfcfcb9f1debfe07a8b8bd63f9a",
|
||||
"sha256:dda30ba7e87fbbb7eab1ec9f58678558fd9a6b8b853530e176eabd064da81417",
|
||||
"sha256:e04e26803c9c3851c931eac40c695602c6295b8d432cbe78609649ad9bd2da8a",
|
||||
"sha256:e1c0b87e09fa55a220f058d1d49d3fb8df88fbfab58558f1198e08c1e1de842a",
|
||||
"sha256:e72591e9ecd94d7feb70c1cbd7be7b3ebea3f548870aa91e2732960fa4d57a37",
|
||||
"sha256:e8c843bbcda3a2f1e3c2ab25913c80a3c5376cd00c6e8c4a86a89a28c8dc5452",
|
||||
"sha256:efc1913fd2ca4f334418481c7e595c00aad186563bbc1ec76067848c7ca0a933",
|
||||
"sha256:f121a1420d4e173a5d96e47e9a0c0dcff965afdf1626d28de1460815f7c4ee7a",
|
||||
"sha256:fc7b548b17d238737688817ab67deebb30e8073c95749d55538ed473130ec0c7"
|
||||
],
|
||||
"markers": "python_version >= '3.7'",
|
||||
"version": "==2.1.1"
|
||||
},
|
||||
"python-dateutil": {
|
||||
"hashes": [
|
||||
"sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86",
|
||||
"sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
|
||||
"version": "==2.8.2"
|
||||
},
|
||||
"six": {
|
||||
"hashes": [
|
||||
"sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926",
|
||||
"sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
|
||||
"version": "==1.16.0"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import jinja2
|
||||
import datetime
|
||||
import subprocess
|
||||
import random
|
||||
import shutil
|
||||
|
||||
from pathlib import Path
|
||||
from faker import Faker
|
||||
from chinese_calendar import is_workday
|
||||
|
||||
|
||||
NOW = Path(__file__).parent
|
||||
ETC = NOW.parent / "etc"
|
||||
OUTPUT = NOW.parent / "output"
|
||||
|
||||
|
||||
def faker_datas(number=7):
|
||||
"""
|
||||
生成日志模板所需要的内容,一天一个默认7天,排除掉工作日(排除掉的也算一天)
|
||||
"""
|
||||
f = Faker(locale="zh_CN")
|
||||
# 用来存所有的
|
||||
datas = []
|
||||
# 现在的时间
|
||||
today = datetime.datetime.now().date()
|
||||
# 默认生成前7天的数据
|
||||
for n in range(0, number):
|
||||
# 前N天
|
||||
date = today + datetime.timedelta(days=-n)
|
||||
# 判断是不是工作日
|
||||
if not is_workday(date):
|
||||
continue
|
||||
# 用来保存1天所需要的内容
|
||||
diary_log = {}
|
||||
# 创建日期
|
||||
diary_log["create_date"] = date
|
||||
# 创建时间,控制在8点~11点之间
|
||||
str_time1 = date.strftime("%Y-%m-%d ") + "08:00:00"
|
||||
start_time = datetime.datetime.strptime(str_time1, "%Y-%m-%d %H:%M:%S")
|
||||
str_time2 = date.strftime("%Y-%m-%d ") + "11:00:00"
|
||||
end_time = datetime.datetime.strptime(str_time2, "%Y-%m-%d %H:%M:%S")
|
||||
|
||||
CreationTime = f.date_time_between(start_date=start_time, end_date=end_time)
|
||||
diary_log["CreationTime"] = CreationTime
|
||||
# 修改时间,比创建时间晚6~10小时
|
||||
LastWriteTime = CreationTime + datetime.timedelta(
|
||||
hours=f.pyint(min_value=6, max_value=10),
|
||||
seconds=f.pyint(min_value=1, max_value=300),
|
||||
)
|
||||
diary_log["LastWriteTime"] = LastWriteTime
|
||||
|
||||
# 访问时间,比修改时间晚1~n天
|
||||
LastAccessTime = LastWriteTime + datetime.timedelta(
|
||||
days=f.pyint(min_value=0, max_value=n),
|
||||
seconds=f.pyint(min_value=1, max_value=300),
|
||||
)
|
||||
diary_log["LastAccessTime"] = LastAccessTime
|
||||
# 随机的状态,成功失败比 8:2
|
||||
status_list = {"sucess": 80, "failed": 20}
|
||||
diary_log["status1"] = random_weight(status_list)
|
||||
|
||||
datas.append(diary_log)
|
||||
|
||||
return datas
|
||||
|
||||
|
||||
def random_weight(weight_data):
|
||||
"""
|
||||
按照权重,随机取值
|
||||
eg:
|
||||
weight_data = {'a': 10, 'b': 40, 'c': 50}
|
||||
random_weight(weight_data)
|
||||
"""
|
||||
total = sum(weight_data.values()) # 权重求和
|
||||
ra = random.uniform(0, total) # 在0与权重和之前获取一个随机数
|
||||
curr_sum = 0
|
||||
ret = None
|
||||
# keys = weight_data.iterkeys() # 使用Python2.x中的iterkeys
|
||||
keys = weight_data.keys() # 使用Python3.x中的keys
|
||||
for k in keys:
|
||||
curr_sum += weight_data[k] # 在遍历中,累加当前权重值
|
||||
if ra <= curr_sum: # 当随机数<=当前权重和时,返回权重key
|
||||
ret = k
|
||||
break
|
||||
return ret
|
||||
|
||||
|
||||
def main(number):
|
||||
# 获取数据
|
||||
datas = faker_datas(number)
|
||||
# 初始化输出目录
|
||||
if OUTPUT.exists():
|
||||
shutil.rmtree(OUTPUT)
|
||||
OUTPUT.mkdir()
|
||||
|
||||
# 根据模板来生成数据
|
||||
template_file = ETC / "template.md.j2"
|
||||
for day_log in datas:
|
||||
# 读取模板
|
||||
jinja2_env = jinja2.Environment()
|
||||
tempate_data = open(template_file, encoding="utf-8").read()
|
||||
# 渲染模板
|
||||
temp_out = jinja2_env.from_string(tempate_data).render({"datas": day_log})
|
||||
|
||||
# 输出结果
|
||||
file_name = day_log["create_date"].strftime("%Y-%m-%d") + ".md"
|
||||
output_file = OUTPUT / file_name
|
||||
with open(output_file, "w", encoding="utf-8") as f:
|
||||
f.writelines(temp_out)
|
||||
|
||||
# 修改生成文本的创建时间、修改时间和访问时间
|
||||
# ls 'sysin.txt' | foreach-object { $_.CreationTime = '02/02/2021 01:01:01'; $_.LastWriteTime = '01/01/2021 01:01:01'; $_.LastAccessTime = '03/03/2021 01:01:01' }
|
||||
args = (
|
||||
"powershell.exe"
|
||||
+ ' "ls '
|
||||
+ "'"
|
||||
+ str(output_file)
|
||||
+ "'"
|
||||
+ " | foreach-object { $_.CreationTime = '"
|
||||
+ day_log["CreationTime"].strftime("%m/%d/%Y %H:%M:%S")
|
||||
+ "'; $_.LastWriteTime = '"
|
||||
+ day_log["LastWriteTime"].strftime("%m/%d/%Y %H:%M:%S")
|
||||
+ "'; $_.LastAccessTime = '"
|
||||
+ day_log["LastAccessTime"].strftime("%m/%d/%Y %H:%M:%S")
|
||||
+ "' }\""
|
||||
)
|
||||
subprocess.call(args, shell=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 生成30天的数据
|
||||
main(30)
|
|
@ -0,0 +1,39 @@
|
|||
# {{ datas['create_date'] }}
|
||||
|
||||
## 每日事项
|
||||
### 上班
|
||||
1. 打卡 --ok
|
||||
2. 看邮件 --ok
|
||||
3. 看任务 --ok
|
||||
4. 看消息 --ok
|
||||
5. 为晨会做准备 --ok
|
||||
### 下班
|
||||
1. 看任务完成情况 --ok
|
||||
2. 看是否有编译不过的 --ok
|
||||
3. 打卡 --ok
|
||||
----------------------------------------------------------------------------------------------
|
||||
## 长期任务
|
||||
### 1. 自动化测试监控,今日运行情况 --{{ datas['status1'] }}
|
||||
{# 如果是失败的,放一些日志 -#}
|
||||
{% if datas['status1'] == "failed" -%}
|
||||
失败日志:
|
||||
xxxxxxxxxxxxx
|
||||
|
||||
{% endif -%}
|
||||
----------------------------------------------------------------------------------------------
|
||||
## 今日事项
|
||||
### 1. xxx
|
||||
详细内容:
|
||||
```
|
||||
xxxxxxxxxxxxx
|
||||
|
||||
```
|
||||
### 2. xxxxxxxxxxxxx
|
||||
详细内容:
|
||||
```
|
||||
xxxxxxxxxxxxx
|
||||
|
||||
```
|
||||
## TODO
|
||||
1. xxxxxxxxxxxxx
|
||||
2. xxxxxxxxxxxxx
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
set PROJECT_HOME=%~dp0
|
||||
|
||||
|
||||
rem 确保vscode在path里面
|
||||
start code %PROJECT_HOME%
|
Loading…
Reference in New Issue