小编jhu*_*tar的帖子

在bash中检测夏令时

我想知道我是在冬天还是夏天.我目前的做法是:

if date +%Z | grep -e CET -e EST; then
  # I'm in winter time
else
  # I'm in summer time
fi
Run Code Online (Sandbox Code Playgroud)

这有明显的缺点,因为你必须知道所有的时区名称.

bash date dst

13
推荐指数
3
解决办法
7038
查看次数

用空格分割字符串,然后在ansible/jinja2中再次连接它

我试图在Ansible(ansible-2.1.1.0-1.fc24.noarch)剧本中的一个变量中"清理"空格,我虽然我先拆分()然后再加入('').由于某种原因,这种方法给我以下错误: - /

---
- hosts: all
  remote_user: root
  vars:
    mytext: |
      hello
      there how   are
      you?
  tasks:
    - debug:
        msg: "{{ mytext }}"
    - debug:
        msg: "{{ mytext.split() }}"
    - debug:
        msg: "{{ mytext.split().join(' ') }}"
...
Run Code Online (Sandbox Code Playgroud)

给我:

TASK [debug] *******************************************************************
ok: [192.168.122.193] => {
    "msg": "hello\nthere how   are\nyou?\n"
}

TASK [debug] *******************************************************************
ok: [192.168.122.193] => {
    "msg": [
        "hello", 
        "there", 
        "how", 
        "are", 
        "you?"
    ]
}

TASK [debug] *******************************************************************
fatal: [192.168.122.193]: FAILED! => {"failed": true, …
Run Code Online (Sandbox Code Playgroud)

jinja2 ansible

6
推荐指数
1
解决办法
1万
查看次数

基本 aiosmtpd SMTP 服务器示例

如何转换以下基本SMTP服务器使用smtpd一个使用aiosmtpd呢?

import smtpd

class CustomSMTPServer(smtpd.SMTPServer):

    def process_message(self, peer, mailfrom, rcpttos, data):
        myqueue.queue.put(data)

self.server = CustomSMTPServer(('127.0.0.1', 10025), None)
Run Code Online (Sandbox Code Playgroud)

python aiosmtpd

1
推荐指数
1
解决办法
2473
查看次数

标签 统计

aiosmtpd ×1

ansible ×1

bash ×1

date ×1

dst ×1

jinja2 ×1

python ×1