Black-Gold 5 years ago
parent 246e7cd5e9
commit 1ee76ca2a9

@ -46,6 +46,8 @@ echo -n xxx | openssl md5 # 方法二
echo $RANDOM | md5sum | cut -c 1-8 # 方法一
openssl rand -base64 4 # 方法二
cat /proc/sys/kernel/random/uuid | cut -c 1-8 # 方法三
< /dev/urandom tr -dc A-Za-z0-9 | head -c8;echo # 方法四
date +%s | sha256sum | base64 | head -c 8;echo # 方法五
# 获取8位随机数字
echo $RANDOM | cksum | cut -c 1-8 # 方法一

@ -179,6 +179,14 @@ comment
```
```bash
# 查找当前目录xls文件名包含-字符文件并替换-为_
find . -type f -name '*-*.xls' | while read FILE ; do
newfile="$(echo ${FILE} |sed -e 's/-/_/')" ;
mv "${FILE}" "${newfile}" ;
done
```
### 根据-type文件类型进行搜索
```bash

@ -12,6 +12,3 @@
-s, --separator=字符串 使用指定字符串代替换行作为分隔标志
```

@ -1,4 +1,4 @@
# tee
# **tee**
## 说明
@ -17,11 +17,9 @@
```
## 选项
## 实例
```bash
ls | tee out.txt # 在终端打印stdout同时重定向到文件中
```

@ -74,4 +74,3 @@ cat file | tr -s "\r" "\n" > new_file
cat file | tr -d "\r" > new_file
```

@ -1,4 +1,4 @@
## **whatis**
# **whatis**
## 说明
@ -21,18 +21,12 @@ Usage: whatis [OPTION...] 关键词...
-L, --locale=区域 定义本次搜索所使用的区域设置
-m, --systems=系统 use manual pages from other systems
-M, --manpath=路径 设置搜索手册页的路径为“路径”
-s, --sections=列表, --section=列表
search only these sections (colon-separated)
-?, --help give this help list
--usage give a short usage message
-V, --version print program version
-s, --sections=列表, --section=列表 search only these sections (colon-separated)
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
```
## 实例
```bash
@ -60,5 +54,3 @@ man页面所属的分类标识(常用的是分类1和分类3)
comment
```

@ -1,9 +1,20 @@
def digital_to_chinese(digital):
str_digital = str(digital)
chinese = {'1': '', '2': '', '3': '', '4': '', '5': '', '6': '', '7': '', '8': '', '9': '', '0': ''}
chinese2 = ['', '', '', '', '', '', '']
jiao = ''
bs = str_digital.split('.')
chinese = {
"1": "",
"2": "",
"3": "",
"4": "",
"5": "",
"6": "",
"7": "",
"8": "",
"9": "",
"0": "",
}
chinese2 = ["", "", "", "", "", "", ""]
jiao = ""
bs = str_digital.split(".")
yuan = bs[0]
if len(bs) > 1:
jiao = bs[1]
@ -11,13 +22,13 @@ def digital_to_chinese(digital):
count = 0
for i in range(len(yuan)):
if i == 0:
r_yuan[i] += ''
r_yuan[i] += ""
continue
r_yuan[i] += chinese2[count]
count += 1
if count == 4:
count = 0
chinese2[3] = '亿'
chinese2[3] = "亿"
s_jiao = [i for i in jiao][:3] # 去掉小于厘之后的
@ -27,7 +38,7 @@ def digital_to_chinese(digital):
j_count -= 1
last = [i for i in reversed(r_yuan)] + s_jiao
last_str = ''.join(last)
last_str = "".join(last)
print(str_digital)
print(last_str)
for i in range(len(last_str)):
@ -39,7 +50,7 @@ def digital_to_chinese(digital):
# number = float(input("输入需要转换的数字:"))
number = float(4650)
number = float(3000)
if __name__ == '__main__':
if __name__ == "__main__":
digital_to_chinese(number)

@ -4,7 +4,7 @@ import json
# 如有报错Result window is too large, from + size must be less than or equal to: [10000]
# 执行以下修改【不再使用此方式防止内存溢出使用如下的scroll api处理】
# curl -XPUT "http://192.168.2.15:9200/props_change_log/_settings" -d '{ "index" : { "max_result_window" : 1000000 } }'
# curl -XPUT "http://192.168.2.15:9200/index/_settings" -d '{ "index" : { "max_result_window" : 1000000 } }'
# 定义数据写入的文件路径
root_path = "D:/xxx.json"
@ -18,8 +18,8 @@ def record_docs(root_path, record):
# 定义配置
host = "192.168.2.15:9200"
# index = "props_change_log"
index = "time_limited_props_log"
# index = "index"
index = "index"
scroll = "1m"
size = 1000
body = {
@ -29,7 +29,7 @@ body = {
es = Elasticsearch(hosts=host)
# es.indices.refresh(index="by_petskill_log")
# es.indices.refresh(index="index")
# 利用json.dumps处理hits数据,将返回str类型

@ -3,7 +3,7 @@ from selenium.webdriver.chrome.webdriver import Service
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions, expected_conditions, wait
from selenium.webdriver.support import expected_conditions, wait
from selenium.common.exceptions import (
ElementNotSelectableException,
ElementNotVisibleException,
@ -64,22 +64,23 @@ browser.current_window_handle
# 上下文管理器启动驱动程序
with webdriver.Firefox() as browser:
browser.get("https://www.xxx.com")
# 设置等待时间
wait_time = WebDriverWait(browser, 10)
# 设置显式等待时间通常和该类的WebDriverWait.until()方法和WebDriverWait.until_not()方法结合使用
# 每隔2秒检查一次若条件成立则进行下一步否则继续等待直到超过设置的10秒然后抛出TimeoutException
wait_time = WebDriverWait(browser, 10, 2)
# 存储原始窗口id
origin_window = browser.current_window_handle
# 检查其他未打开的窗口
assert len(browser.window_handles) == 1
browser.find_element_by_link_text("new window").click()
# 等待新窗口或标签页
wait.until(EC.number_of_windows_to_be(2))
wait.until(expected_conditions.number_of_windows_to_be(2))
# 循环找到新的窗口句柄
for window_handle in browser.window_handles:
if window_handle != origin_window:
browser.switch_to.window(window_handle)
break
# 等待加载完成 发
wait.until(EC.title_is("xxx"))
wait.until(expected_conditions.title_is("xxx"))
# 创建新的标签页和窗口,此特性只适用于selenium4
browser.switch_to.new_window("tab")
@ -114,7 +115,8 @@ browser.maximize_window() # 最大化窗口
# 隐式等待是告诉WebDriver如果在查找一个或多个不是立即可用的元素时轮询DOM一段时间。默认设置为0表示禁用
# 一旦设置好,隐式等待就被设置为会话的生命周期
browser.implicitly_wait(10) # 等待10秒
# 在页面完全加载完毕期间等待10秒若10秒还未加载完则进行下一步
browser.implicitly_wait(10)
# 流畅等待定义等待条件的最大时间量及检查条件的频率
# 例如设置等待来忽略NoSuchElementException异常
@ -125,11 +127,11 @@ wait = WebDriverWait(
poll_frequency=1,
ignored_exceptions=[ElementNotVisibleException, ElementNotSelectableException],
)
element = wait.until(EC.element_to_be_clickable((By.XPATH, "//div")))
element = wait.until(expected_conditions.element_to_be_clickable((By.XPATH, "//div")))
# js的alerts警告框
browser.find_element_by_link_text("xxx").click()
# browser.find_element_by_link_text("xxx").click()
# 等待alert窗口显示后存储到变量中
alert = wait.until(expected_conditions.alert_is_present())
# 将警告中的文本存储到变量

@ -4,33 +4,30 @@ import subprocess
from shutil import copy2
xxxpath="xxx/xxx"
# 私钥可以被paramiko使用执行转换命令ssh-keygen -p -m PEM -f ~/.ssh/copyid_rsa
# RSA格式私钥可以被paramiko使用执行转换命令ssh-keygen -p -m PEM -t RSA -f ~/.ssh/copyid_rsa
key_path = 'xxx/.ssh/copyid_rsa'
# 定义上传函数,paramiko通过公钥免密连接
def upload(root_path, key_private_path):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname='服务器ip', port='端口',
username='用户', key_filename=key_private_path, allow_agent=True)
sftp = ssh.open_sftp()
for root, dirs, files in os.walk(xxxpath):
root_linux = root.replace('\\', '/')
def upload(root_path, privateKey):
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname='服务器ip', port='端口',
username='用户', key_filename=privateKey, allow_agent=True)
sftp = client.open_sftp()
# 利用os的walk函数获取本地目录文件列表
for dirspath, dirsname, files in os.walk(xxxpath):
root_linux = dirspath.replace('\\', '/')
# sftp的mkdir函数不支持创建多级目录固使用ssh连接后linux原生命令创建
remote_path = os.path.join('xxx/path', root_linux[29:])
stdin, stdout, stderr = ssh.exec_command(
stdin, stdout, stderr = client.exec_command(
''.join(['mkdir -p ' + remote_path]))
# 利用os的walk函数获取本地目录文件列表
for root, dirs, files in os.walk(xxxpath):
root_linux = root.replace('\\', '/')
remote_path = os.path.join('xxx/path/', root_linux[29:])
for file in files:
upload_file = os.path.join(root_linux, file).replace('\\', '/')
print(u'Put files...' + upload_file)
sftp.put(upload_file, os.path.join(
remote_path, file).replace('\\', '/'))
ssh.close()
client.close()
sftp.close()

Loading…
Cancel
Save