我正在尝试使用Ansible来运行以下两个命令:
sudo apt-get update && sudo apt-get upgrade -y
我知道你可以使用ansible:
ansible all -m shell -u user -K -a "uptime"
会运行以下命令吗?或者我必须使用某种raw
命令
ansible all -m shell -u user -K -a "sudo apt-get update && sudo apt-get upgrade -y"
我目前正在尝试为项目设置一个新的虚拟环境.我有一个用pycharm设置的vagrant/virtualbox.
看来即使我正确设置了远程解释器,我仍然需要使用本地解释器来设置虚拟环境.有没有办法使用远程虚拟环境而不是使用本地环境?
我正在尝试刮掉后面的json输出 'https://sports.bovada.lv/soccer/premier-league'
它有一个来源如下
<script type="text/javascript">var swc_market_lists = {"items":[{"description":"Game Lines","id":"23", ... </script>
Run Code Online (Sandbox Code Playgroud)
我正在尝试获取swc_market_lists
var 的内容
现在我遇到的问题是,当我使用以下代码时
import requests
from lxml import html
url = 'https://sports.bovada.lv/soccer/premier-league'
r = requests.get(url)
tree = html.fromstring(r.content)
var = tree.xpath('//script')
print(var)
Run Code Online (Sandbox Code Playgroud)
我得到一个空的var值.
我也试过保存r.text
并查看它,但我没有在那里看到脚本标签.
我错过了什么?
我目前有这个功能,它通过 ffmpeg 传输多个 youtubedl 命令,然后将 ffmpeg 的输出通过管道传输到 HTTP 客户端。
func pipeThruFfmpegToMp4(vi *VideoInfo, rw web.ResponseWriter) error {
var ffmpeg *exec.Cmd
ffmpeg = exec.Command(
"ffmpeg",
"-i", "-",
"-i", "pipe:3",
"-c:v", "copy", "-c:a", "copy",
"-preset", "veryfast",
"-metadata", fmt.Sprintf(`title=%s`, vi.GetTitle()),
"-movflags", "frag_keyframe+empty_moov",
"-f", "mp4",
"-")
youtubevideo := exec.Command(YoutubeDLPath, "-c", "-f", fmt.Sprintf("%s/bestvideo[ext=mp4]/bestvideo/best", vi.GetFormat()), "--no-cache-dir", "--restrict-filenames", "--hls-prefer-native", "-o", "-", fmt.Sprintf("%s", vi.GetVideoUrl()))
fmt.Println(youtubevideo)
youtube := exec.Command(YoutubeDLPath, "-c", "-f", "bestaudio[ext=m4a]/bestaudio/best", "--no-cache-dir", "--restrict-filenames", "--hls-prefer-native", "-o", "-", fmt.Sprintf("%s", vi.GetVideoUrl()))
fmt.Println(youtube)
var ytvbuf, ytbuf, ffbuf bytes.Buffer
youtubevideo.Stderr = &ytvbuf
youtube.Stderr = …
Run Code Online (Sandbox Code Playgroud) 我目前有这个功能,它通过 ffmpeg 管道 youtubedl 命令,然后将 ffmpeg 的输出通过管道传输到 HTTP 客户端。
func pipeThruFfmpegToMp3(vi *VideoInfo, rw web.ResponseWriter) error {
var ffmpeg *exec.Cmd
ffmpeg = exec.Command("ffmpeg", "-i", "-","-acodec", "libmp3lame","-f", "mp3","-")
}
youtube := exec.Command("youtube-dl", "-f", "137", "video_url", "-o", "-")
var ytbuf, ffbuf bytes.Buffer
youtube.Stderr = &ytbuf
ffmpeg.Stderr = &ffbuf
audio, err := youtube.StdoutPipe()
if err != nil {
log.Printf("pipeThruFfmpegToMp3: %v\n", err)
return err
}
ffmpeg.Stdin = audio
ffmpeg.Stdout = rw
// Headers sent, no turning back now
rw.Header().Set("Content-Type", "audio/mpeg")
rw.Header().Set("Content-Disposition", fmt.Sprintf("attachment;filename=\"%s.mp3\"", vi.GetSlug()))
rw.Flush()
youtube.Start() …
Run Code Online (Sandbox Code Playgroud) 尝试使用键前缀存储超过x时间的值
我正在使用redis.我目前正在使用hset存储值
import redis
r = redis.StrictRedis('localhost')
for i in range(10):
r.hset('name', i, i)
print(r.hgetall('name'))
Run Code Online (Sandbox Code Playgroud)
我希望每个密钥都有不同的到期时间,因为我将单独存储每个密钥.
我该怎么做呢?
我目前正在尝试安装一个需求,它告诉我当我尝试将它们注释掉时找不到它,它会发生在其他人身上。
我刚刚部署了一个Ubuntu 18.04
服务器。通过以下命令创建虚拟环境,python3 -m venv --system-site-packages env
但每次我尝试运行pip install -r requirements.txt
它都会失败
Collecting apparmor==2.12 (from -r requirements.txt (line 1))
Could not find a version that satisfies the requirement apparmor==2.12 (from -r requirements.txt (line 1)) (from versions: )
No matching distribution found for apparmor==2.12 (from -r requirements.txt (line 1))
Run Code Online (Sandbox Code Playgroud)
如果我尝试安装说它pip install apparmor
告诉我
Collecting apparmor
Could not find a version that satisfies the requirement apparmor (from versions: )
No matching distribution found for apparmor
Run Code Online (Sandbox Code Playgroud)
但是如果我注释掉 apparmor …
我的 nginx 服务器在这个配置下运行良好。
server {
location / {
proxy_pass http://127.0.0.1:8000;
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试修改缓冲区大小时,它失败了。
server {
location / {
client_body_buffer_size 10K;
client_header_buffer_size 1k;
client_max_body_size 8m;
large_client_header_buffers 2 1k;
proxy_pass http://127.0.0.1:8000;
}
}
Run Code Online (Sandbox Code Playgroud)
我收到这个错误
Reloading nginx configuration: nginx: [emerg] "client_header_buffer_size" directive is not allowed here
Run Code Online (Sandbox Code Playgroud)
有什么建议?
我试图在服务器部署中尽可能自动化,总体目标是以用户身份登录,上传 bashscript 并让它按照我需要的方式配置我的服务器。
首先,我正在尝试禁用 root 登录,我知道我必须编辑/etc/ssh/sshd_config
为PermitRootLogin no
我想知道是否有办法通过 bash 脚本来做到这一点?
我目前正在尝试安装libvirt-python
到virtualenv.
当我运行它时,我得到这个输出
$ pip install libvirt-python
Collecting libvirt-python
Using cached libvirt-python-3.5.0.tar.gz
Building wheels for collected packages: libvirt-python
Running setup.py bdist_wheel for libvirt-python ... error
Complete output from command /home/john/virtenvs/hw/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3_fz8vok/libvirt-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpg1j1nq_wpip-wheel- --python-tag cp35:
Package libvirt was not found in the pkg-config search path.
Perhaps you should add the directory containing `libvirt.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libvirt' found
Package libvirt was not found in the …
Run Code Online (Sandbox Code Playgroud) python ×5
go ×2
pip ×2
ubuntu ×2
virtualenv ×2
ansible ×1
bash ×1
ffmpeg ×1
lxml ×1
nginx ×1
pipe ×1
pycharm ×1
python-3.x ×1
redis ×1
ubuntu-18.04 ×1
vagrant ×1
virtualbox ×1
youtube-dl ×1