qdyxmas's Room

Done is better than perfect...

PR提交模板

【提交楼型】

【新增功能】-【新的功能点、新的需求】
【Bug修复】-【bug链接】
【代码重构】-【代码更改既不修复错误也不添加功能】
【回退更改】-【代码回退提交更改】
【其他提交】-【除以上所有类型之外的提交更改】

【简要描述】

如果提交类型是【Bug修复】,请简单描述一下产生bug的原因和修复的方法
如果提交类型是【新增功能】,简要描述代码实现功能的逻辑与注意事项
如果提交类型是其他类型,则简要描述根据你的理解,尽量用简短的文字描述出此次代码提交的目的

【单测覆盖】

是否加入单测用例

【影响范围】

是否对其他微服务或者本服务其他模块有影响

阅读全文 »

flask 数据库中添加用户名密码

生成密码

from werkzeug.security import generate_password_hash
pwd=generate_password_hash('123456')
#pwd='pbkdf2:sha1:1000$rmftwbH0$7344743f3e6d9c11750815aba6d78c7255a4abcc'
mail="123456@qq.com"
avatar_hash=hashlib.md5(mail.encode('utf-8')).hexdigest()
#avatar_hash='35de170fc7836ea645e1a7d7b307ff6e'

INSERT INTO users VALUES (id, 'username', mail, pwd, 3, avatar_hash);

阅读全文 »

k8s部署管理docker镜像

参考: K8S deployment.yml配置详解: https://blog.csdn.net/random_w/article/details/80612881 minikube安装详解: https://mp.weixin.qq.com/s/QIsQoWmuZbmhXViLXxBN9A k8s中文网站: https://www.kubernetes.org.cn/docs

阅读全文 »

同一台PC连接多个git服务器

同一台PC链接多个git服务器

1.在~/.ssh/目录下创建config文件
2.生成gitlab的公钥
    ssh-keygen -t rsa -C "qdyxmas@qq.com" -f ~/.ssh/id_rsa_lab
3.生成github的公钥
    ssh-keygen -t rsa -C "qdyxmas@gmail.com" -f ~/.ssh/id_rsa_hub
4.编辑config文件,把gitlab和github的信息输入
    Host github.com
        User qdyxmas@gmail.com
        Hostname ssh.github.com
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/id_rsa_hub
        Port 443
    Host gitlab.com
      Hostname altssh.gitlab.com
      User qdyxmas@qq.com 
      Port 443
      PreferredAuthentications publickey
      IdentityFile ~/.ssh/id_rsa_lab
6.把公钥信息复制到gitlab(github)上
     ~/.ssh/id_rsa_lab.pub
7.测试是否正常ssh -vT git@gitlab.com
    root@qdyxmas:~/unittest# ssh -vT git@gitlab.com
    OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g  1 Mar 2016
    debug1: Reading configuration data /root/.ssh/config
    debug1: /root/.ssh/config line 7: Applying options for gitlab.com
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 19: Applying options for *
    debug1: Connecting to altssh.gitlab.com [35.190.168.187] port 443.
    debug1: Connection established.
    debug1: permanently_set_uid: 0/0
    debug1: identity file /root/.ssh/id_rsa_lab type 1
    debug1: key_load_public: No such file or directory
    debug1: identity file /root/.ssh/id_rsa_lab-cert type -1
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4
    debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
    debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.8 pat OpenSSH* compat 0x04000000
    debug1: Authenticating to altssh.gitlab.com:443 as 'git'
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug1: kex: algorithm: curve25519-sha256@libssh.org
    debug1: kex: host key algorithm: ecdsa-sha2-nistp256
    debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
    debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
    debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
    debug1: Server host key: ecdsa-sha2-nistp256 SHA256:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw
    debug1: Host '[altssh.gitlab.com]:443' is known and matches the ECDSA host key.
    debug1: Found key in /root/.ssh/known_hosts:3
    debug1: rekey after 134217728 blocks
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: rekey after 134217728 blocks
    debug1: SSH2_MSG_NEWKEYS received
    debug1: SSH2_MSG_EXT_INFO received
    debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug1: Authentications that can continue: publickey
    debug1: Next authentication method: publickey
    debug1: Offering RSA public key: /root/.ssh/id_rsa_lab
    debug1: Server accepts key: pkalg rsa-sha2-512 blen 279
    debug1: Authentication succeeded (publickey).
    Authenticated to altssh.gitlab.com ([35.190.168.187]:443).
    debug1: channel 0: new [client-session]
    debug1: Requesting no-more-sessions@openssh.com
    debug1: Entering interactive session.
    debug1: pledge: network
    debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
    debug1: Remote: Forced command.
    debug1: Remote: Port forwarding disabled.
    debug1: Remote: X11 forwarding disabled.
    debug1: Remote: Agent forwarding disabled.
    debug1: Remote: PTY allocation disabled.
    debug1: Remote: Forced command.
    debug1: Remote: Port forwarding disabled.
    debug1: Remote: X11 forwarding disabled.
    debug1: Remote: Agent forwarding disabled.
    debug1: Remote: PTY allocation disabled.
    debug1: Sending environment.
    debug1: Sending env LANG = en_US.UTF-8
    Welcome to GitLab, @qudeyong!
    debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
    debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
    debug1: channel 0: free: client-session, nchannels 1
    Transferred: sent 2672, received 3304 bytes, in 0.5 seconds
    Bytes per second: sent 5369.5, received 6639.6
    debug1: Exit status 0

阅读全文 »

pipeline语法汇总

def services_to_build = params.services.split(','); pipeline { agent any stages { stage("start") { steps { echo ("拉取${params.services}代码"); } } stage("update code") { steps { script { for (i = 0; i < services_to_build.size(); i++) { def service = services_to_build[i]; echo ("开始拉${service}的代码"); dir("${service}") { echo ("service=${service}的代码"); git branch: "${source_branch}", credentialsId: 'xxxxxxxxxxxx', url: "https://git.xkool.org/xkool/${service}.git" ; //checkout 目的分支 checkout([$class: 'GitSCM', branches: [[name: "${target_branch}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'LocalBranch', localBranch: "${target_branch}"]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'xxxxxxxxxxxx', url: "https://git.xkool.org/xkool/${service}.git"]]]); } } } } }
stage("compare branch") { steps { sh("python3 diff_branch.py ${source_branch} ${target_branch}") }
} } }

阅读全文 »

Linux-dd命令分割文件详解

dd分割文件

dd if=xkool.jpg bs=1024 count=20 skip=0 of=20K
if=xkool.jpg:表示输入源文件为xkool.jpg
bs=1024: 表示每次写入1024byte
count=20:表示写入20个块 文件大小就是1024B*20 = 20KB
skip=0: 表示从第0个块开始写,就是相当于获取57KB的前20KB大小
of=20K: 表示输出文件名叫20K

阅读全文 »

linux下后台运行selenium

linux下后台运行selenium:

安装浏览器:

Google Chrome 77.0.3865.75configure
ChromeDriver 77.0.3865.40

pyautogui:

安装Xvfb后启动虚拟显示器
Xvfb -ac :0 -screen 0 1920x1080x24
export DISPLAY=:0

FAQ:

Q:    NOTE: You must install tkinter on Linux to use MouseInfo. Run the following: sudo apt-get install python3-tk python3-dev
A:    python3.6安装tk/tcl:
      1.下载tcl包和tk包 https://www.tcl.tk/software/tcltk/download.html
      2.安装包https://blog.csdn.net/and_december/article/details/71178539

运行脚本

# coding:utf-8 
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--remote-debugging-port=9222')
browser = webdriver.Chrome(chrome_options=chrome_options)
driver.get("https://www.baidu.com")

阅读全文 »