小编Tim*_*iam的帖子

无需重新加载的 Vagrant 同步文件夹?

我的主机上有一个文件~/ansible/provisioning/playbook.yml,对应/vagrant/provisioning/playbook.yml于来宾上的文件。每次我对主机上的文件进行更改时,这些更改都不会显示在来宾上,除非我运行vagrant reload它完全重新启动 VirtualBox VM。是否有另一种方法可以使用另一种文件系统类型(可能是 NFS)实时同步文件?我的主机是 MacOS,来宾是 CentOS 7。我使用的是 vagrant 2.0.0 版。

编辑:

我已经包含了我Vagrantfilepastebin。是的,看来我正在使用rsync.

$ cat .vagrant/machines/default/virtualbox/synced_folders 
{"rsync":{"/vagrant":{"type":"rsync","guestpath":"/vagrant","hostpath":"/Users/timothy/Desktop/code/ansible","disabled":false,"__vagrantfile":true,"owner":"vagrant","group":"vagrant"}}}
Run Code Online (Sandbox Code Playgroud)

除了添加config.vm.synced_folder ".", "/vagrant", type: "virtualbox"到我的 Vagrantfile 之外,我还必须运行 $ vagrant plugin install vagrant-vbguest

vagrant

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

ValueError: view limit minimum -5.1000000000000005 小于 1 并且是无效的 Matplotlib 日期值

我有一个 Pandas 数据框,其中包含一些我想在 matplotlib 中绘制的 sar 输出。示例数据如下。

>>> cpu_data.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 70 entries, 0 to 207
Data columns (total 8 columns):
00:00:01    70 non-null datetime64[ns]
CPU         70 non-null object
%user       70 non-null float64
%nice       70 non-null float64
%system     70 non-null float64
%iowait     70 non-null float64
%steal      70 non-null float64
%idle       70 non-null float64
dtypes: float64(6), object(2)
memory usage: 4.4+ KB

>>> cpu_data
     00:00:01  CPU  %user  %nice  %system  %iowait  %steal  %idle
0    00:10:01  all   0.30   0.00     0.30     0.06     0.0  99.34 …
Run Code Online (Sandbox Code Playgroud)

python matplotlib pandas

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

Python MySQLdb 变量作为表名

我的 python 中有一个语法错误,它阻止 MySQLdb 插入到我的数据库中。SQL 插入如下。

cursor.execute("INSERT INTO %s (description, url) VALUES (%s, %s);", (table_name.encode("utf-8"), key.encode("utf-8"), data[key].encode("utf-8"))) 
Run Code Online (Sandbox Code Playgroud)

我的堆栈跟踪中出现以下错误。

_mysql_exceptions.ProgrammingError: (1064, "You have an error in your 
SQL syntax; check the manual that corresponds to your MariaDB server 
version for the right syntax to use near ''four' (description, url) VALUES ('', 'http://imgur.com/a/V8sdH')' at line 1")
Run Code Online (Sandbox Code Playgroud)

我非常感谢您的帮助,因为我无法弄清楚这一点。

编辑:

使用以下行修复它:

cursor.execute("INSERT INTO " + table_name + " (description, url) VALUES (%s, %s);", (key.encode("utf-8"), data[key].encode("utf-8")))
Run Code Online (Sandbox Code Playgroud)

不是最复杂的,但我希望用它作为起点。

python mysql

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

为什么 vagrant 使用 2 个 ssh 私钥?

位于 的私钥~/.vagrant.d/insecure_private_key和与.vagrant/machines/default/virtualbox/private_keymy 位于同一目录中的私钥有什么区别Vagrantfile?为什么需要两者?我如何使用其中之一?

vagrant

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

Gunicorn Docker 容器仅侦听“0.0.0.0”

我正在尝试设置一个 nginx 反向代理到为我的 Flask 应用程序提供服务的 Gunicorn 应用程序服务器。Gunicorn 容器监听端口 5000,nginx 监听端口 80。问题是我仍然可以通过浏览器访问该应用程序localhost:5000,即使我已将 Gunicorn 设置为仅监听 docker 容器的 localhost 以及所有请求应该通过端口 80 通过 nginx 容器到达 Gunicorn 容器。这是我的设置。

docker-compose.yml

version: "3.3"
services:
  web_app:
    build:
      context: .
      dockerfile: Dockerfile.web
    restart: always
    ports:
      - "5000:5000"
    volumes:
      - data:/home/microblog
    networks:
      - web

  web_proxy:
    container_name: web_proxy
    image: nginx:alpine
    restart: always
    ports:
      - "80:80"
    volumes:
      - data:/flask:ro
      - ./nginx/config/nginx.conf:/etc/nginx/nginx.conf:ro
    networks:
      - web

networks:
  web:

volumes:
  data:
Run Code Online (Sandbox Code Playgroud)

Dockerfile.web

FROM python:3.6-alpine

# Environment Variables
ENV FLASK_APP=microblog.py
ENV FLASK_ENVIRONMENT=production
ENV FLASK_RUN_PORT=5000 …
Run Code Online (Sandbox Code Playgroud)

nginx flask gunicorn docker

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

标签 统计

python ×2

vagrant ×2

docker ×1

flask ×1

gunicorn ×1

matplotlib ×1

mysql ×1

nginx ×1

pandas ×1