Tag: python

Github回购与多个Python包

我创build了一个Github仓库,其中保存了我的项目的所有代码。 结构是: myproject \ – package api – package database – package feature api包负责与itunes api等外部apis进行通信。 数据库包负责与我的数据库通信。 最后,function包是我正在构build的实际项目。 每个软件包都有自己的setup.py。 这个结构有三个问题: 我如何添加api和数据库的依赖关系的functionsetup.py? 你会如何build议我在亚马逊部署这个Python代码? 使用docker? 拼盘? 别的东西? 如果我们假设更多function将作为单独的软件包添加到function中。 我怎样才能部署在服务器中的代码的一个子集? 让我们说包API与另一个使用它的function。 让我知道如果我的问题不清楚,我会改进它们。

无法连接到Docker容器上的neo4j数据库

我在一台主机上使用了两个docker容器。 第一个是基于普通的neo4j:2.3镜像和一些转发端口(7474)。 第二个是python:基于2.7的容器。 使用curl,我可以从主机级别和第二台机器(使用主机本身的IP)访问数据库。 问题是我已经写入并移植到该容器的代码将不再运行。 我得到这样的错误: Traceback (most recent call last): File "/app/runserver.py", line 1, in <module> from orangebox import app File "/app/orangebox/__init__.py", line 5, in <module> from orangebox.context import ob File "/app/orangebox/context.py", line 2, in <module> from orangebox.domain.factory import DomainFactory File "/app/orangebox/domain/factory.py", line 4, in <module> from orangebox.domain.boxes import Box File "/app/orangebox/domain/boxes.py", line 3, […]

docker-compose psql无法连接到服务器

我看了瓶装水的github MD文件使用docker,我遇到了关于postgresql的一个问题 如果我运行docker-compose run –rm postgres psql我得到的错误 /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may […]

Django与Docker错误 – “无法连接到'127.0.0.1'(111)上的MySQL服务器”)

我想用Django使用Docker,但是我得到错误 – db_1 | error: database is uninitialized and password option is not specified db_1 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' (111)") db_1 | error: database is uninitialized and password option is not specified db_1 | You need to specify one […]

如何在使用gcloud和google应用程序引擎时debuggingdockerfiles

我正在使用Google App Engine和PyCharm 4.0.4和GCloud managedvm。 我试图访问更多的信息关于我的dockerfile的build设比由控制台输出当使用dev_appserver.py本地运行给出。 medusavm是一个Python的Linux控制台应用程序,可以将python代码转换为dart代码等function。 在我的dockerfile中, medusavm安装顺利。 我已经设法使用PyCharm进行debugging,所以我可以访问断点debuggingfunction,如果需要的话。 我运行medusavm时遇到问题,即使安装没有问题。 目前我只能从控制台访问信息。 我使用gcloud版本的dev_appserver.py运行本地debugging,可从以下位置访问: C:/Program Files/Google/Cloud SDK/google-cloud-sdk/platform/google_appengine/dev_appserver.py 我已经成功地运行gcloud gae教程应用程序使用这个确切的设置,所以我认为这是我在dockerfile中做的修改与安装medusavm做的一个问题。 我的泊坞窗文件的文本文件的链接是在这里,并从docker文件(我想了解更多信息的debugging目的,如果你知道如何)的build设从控制台输出在这里 。 如果奇迹般地,你知道我面临的问题(目前我不知道,除了它是源于没有正确安装medusavm),这将是非常有益的! 此外,如果您碰巧知道如何在使用gcloud和gae时debuggingdockerfiles,我也将非常感激。 感谢您花时间阅读本文。

在主pipe中使用docker环境-evariables

我一直试图通过-e选项将一个环境variables传递给Docker容器。 该variables旨在用于容器内的主pipe脚本。 不幸的是,该variables没有得到解决(即他们留在例如$INSTANCENAME )。 我尝试了${var}和"${var}" ,但是这也没有帮助。 有什么我可以做或者这是不可能的? docker运行命令: sudo docker run -d -e "INSTANCENAME=instance-1" -e "FOO=2" -v /var/app/tmp:/var/app/tmp -t myrepos/app:tag 和主pipe文件: [program:app] command=python test.py –param1=$FOO stderr_logfile=/var/app/log/$INSTANCENAME.log directory=/var/app autostart=true

无法使用Ubuntu在Docker容器中安装pip包

我遵循无花果指南使用docker与python应用程序,但是当docker得到的命令 RUN pip install -r requirements.txt 我收到以下错误信息: Step 3 : RUN pip install -r requirements.txt —> Running in fe0b84217ad1 Collecting blinker==1.3 (from -r requirements.txt (line 1)) Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', gaierror(-2, 'Name or service not known'))': /simple/blinker/ 这几次重复,然后我得到另一个消息: Could not find any downloads that satisfy the requirement blinker==1.3 […]

将Django和Postgresql与Docker链接起来

我有两个Docker容器。 第一个是Postgresql容器,我使用下面的命令运行。 sudo docker run -v /home/mpmsp/project/ezdict/postgresql/data:/var/lib/postgresql/data -p 127.0.0.1:5432:5432 -name my-postgres -d postgres 它是基于官方的形象 ,它工作得很好,我可以从主机连接到Postgresql。 第二个容器是我的Django应用程序的容器。 该图像使用以下Dockerfile(基于此图像 )构build: FROM python:3-onbuild EXPOSE 8000 5432 CMD ["/bin/bash"] 我用下面的命令运行这个容器 sudo docker run –link my-postgres:my-postgres -v /home/mpmsp/project/ezdict/ezbkend:/usr/src/app -name my-app -i -t my-app docker ps输出显示容器已链接 NAMES my-app/my-postgres, my-postgres 但是,当我去localhost:8000,我看到从Django的错误页面,输出如下 OperationalError at /api-auth/login/ could not connect to server: Connection refused Is […]

在Docker容器中运行py.test作为服务

我正在build立一个dockerisedselenium电网。 我可以通过附加的pytest容器(见下面)发送pythontesting[pytest运行]。 但是我已经安装了另一个要控制pytest的LAMP容器。 所以我想让pytest容器独立运行,运行空闲并等待来自LAMP容器的命令。 我有这个Dockerfile: # Starting from base image FROM ubuntu #—————————————————– # Set the Github personal token ENV GH_TOKEN blablabla # Install Python & pip RUN apt-get update RUN apt-get upgrade -y RUN apt-get install -y python python-pip python-dev && pip install –upgrade pip # Install nano for #debugging RUN apt-get install -y […]

有没有办法用pytest来testing沙箱,特别是文件系统的访问?

我有兴趣使用pytest在像docker这样的沙箱中执行可能不受信任的testing,类似于持续集成服务所做的。 我知道,为了正确的沙箱化一个python进程,你需要操作系统级别的隔离,就像在一次性的chroot /容器中运行testing一样,但是在我的用例中,我不需要防止有意识的恶意代码,只能从配对的危险行为“随机”function与参数。 所以较不严格的沙盒仍然可以接受。 但我没有find任何插件,使任何forms的沙箱​​。 在pytest中,沙盒testing执行的最佳方式是什么? 更新 :这个问题不是关于python sandboxing的一般情况,因为testing的代码是由pytest运行的,我不能改变它被执行的方式来使用exec或ast或其他。 另外使用pypy-sandbox不是一个不幸的select,因为它是PyPy特性页面的 “仅限原型”。 更新2 :pytest-dev邮件列表上的Hoger Krekel build议通过pytest-xdist使用专用的testuser进行用户级隔离: py.test –tx ssh=OTHERUSER@localhost –dist=each 这让我意识到 ,对于我的CI类用例: 拥有一个“一次性”环境与隔离环境同样重要,因此每个testing或每个会话都从相同的初始状态运行,并且不受可能由testuser (/ home / testuser,/ tmp,/ var / tmp等)。 因此,testuser + xdist接近解决scheme,但不是那里。 只是为了上下文我需要隔离来运行pytest-nodev 。