码头工人组成
web:
container_name: authserver
restart: always
build: ./authserver
expose:
- "8000"
links:
- redis:redis
environment:
DEBUG: 'true'
redis:
restart: always
image: redis:latest
ports:
- "6379:6379"
Run Code Online (Sandbox Code Playgroud)
码头工人检查authserver_redis_1
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:03"
Run Code Online (Sandbox Code Playgroud)
从主机上的Python解释器(即从运行docker-compose的位置开始),我可以使用Redis并获取/设置值
client = redis.StrictRedis(host='172.17.0.3', port=6379, db=0)
client.set("key01", "value01")
print client.get("key01")
>>>>"value01"
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,如果我从命令行运行redis-cli
redis-cli -h 172.17.0.3 -p 6379
Run Code Online (Sandbox Code Playgroud)
在同一台主机上(与Python解释器进行交互的同一台机器上),然后运行HGETALL *,我希望返回key01和value01,但是它将返回
(empty list or set)
Run Code Online (Sandbox Code Playgroud)
我在阅读redis-cli和python redis库文档时都遇到了麻烦,所以我猜我做错了一些事情。
我正在尝试按照以下教程 http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world#commentform
我好像很迷茫.首先从我的理解.运行命令'python virtualenv.py flask'在文件夹'flask'中创建一个虚拟python环境.它是否正确?
第二,这是不是意味着如果我cd到这个文件夹然后运行'pip install flask'它应该将flask安装到该文件夹?当我运行任何这些pip安装命令时,我的终端充满了疯狂的疯狂,我不明白.
Benjamins-MacBook:flask test$ pip install flask==0.9
Downloading/unpacking flask==0.9
Downloading Flask-0.9.tar.gz (481kB): 481kB downloaded
Running setup.py egg_info for package flask
warning: no files found matching '*' under directory 'tests'
warning: no previously-included files matching '*.pyc' found under directory 'docs'
warning: no previously-included files matching '*.pyo' found under directory 'docs'
warning: no previously-included files matching '*.pyc' found under directory 'tests'
warning: no previously-included files matching '*.pyo' found under directory 'tests'
warning: no previously-included files matching …Run Code Online (Sandbox Code Playgroud) curl --user testuser:passwordz -d '{"name":"testplatform"}' -X POST http://localhost:8080/api/v1/platforms
Run Code Online (Sandbox Code Playgroud)
错误
{"name":["This field is required."]}%
Run Code Online (Sandbox Code Playgroud)
views.py
class platform_list(APIView):
def get(self, request, format=None):
query = request.GET.get('name')
if query:
platforms = Platform.objects.filter(name=query)
else:
platforms = Platform.objects.all()
serializer = PlatformSerializer(platforms, many=True)
return Response(serializer.data)
def post(self, request, format=None):
serializer = PlatformSerializer(data=request.data)
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Run Code Online (Sandbox Code Playgroud)
我知道身份验证有效,因为如果我输入错误的用户或将错误更改传递给“无效凭据”。为什么我会收到字段必填错误?
我试图将django项目移至生产环境中,因此我从使用sqlite切换到了postgres。在开发环境中,每当我更改模型或任何会显着改变数据库设置方式的更改时,我实际上只是将sqlite文件拖到垃圾箱中,然后运行syncdb来创建一个新的空文件(可能是错误的做法) 。既然我正在使用postgres,我想做同样的事情而不实际删除数据库。基本上,我想知道是否有一种方法可以完全清空或清除它,然后运行syncdb并重新开始?
我也欢迎任何其他可能导致我走上正确道路的建议,对此我是新手。
我只是尝试使用键盘键从左到右移动图像。我尝试创建一个从 Image 继承的名为movableImage的类。我认为这是我做错的地方,特别是init函数。当我运行下面的代码时,我在第 16 行收到 AttributeError: 'function' object has no attribute 'widget'。我在这里做错了什么?
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.image import Image
from kivy.input.motionevent import MotionEvent
from kivy.core.window import Window
class character(Widget):
pass
class moveableImage(Image):
def __init__(self, **kwargs):
super(moveableImage, self).__init__(**kwargs)
self._keyboard = Window.request_keyboard
if self._keyboard.widget:
# If it exists, this widget is a VKeyboard object which you can use
# to change the keyboard layout.
pass
self._keyboard.bind(on_key_down=self._on_keyboard_down)
def on_keyboard_down(self, keyboard, keycode, text, modifiers):
if keycode[1] == …Run Code Online (Sandbox Code Playgroud) class testing():
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
def house(self):
d = self.a+self.b+self.c
print d
module="hello"
p = testing(1, 2, 3)
p.house()
Run Code Online (Sandbox Code Playgroud)
如何module从我的testing班级中访问变量?我知道我可以通过执行以下操作将其作为参数添加到类构造函数中:
p=testing(1,2,3,module)
Run Code Online (Sandbox Code Playgroud)
但我不想这样做,除非我必须这样做.还有哪些方法可以module从testing课堂内访问变量?
如何单击大小按钮并使用Selenium Web驱动程序和python将其添加到购物车?
这是下面的网站
请让我知道是否有什么我应该在此处粘贴与尺寸按钮有关的内容。
我在 vue 单文件组件中收到此错误:
Errors compiling template:
invalid expression: Unexpected token { in
{{ jobs[0].build_link }}
Raw expression: v-bind:href="{{ jobs[0].build_link }}"
Run Code Online (Sandbox Code Playgroud)
完整的行是:
<td :style=tdStyle><a v-bind:href="{{ jobs[0].build_link }}">{{ jobs[0].build_link }}</a></td>
Run Code Online (Sandbox Code Playgroud)
作业是在我的组件的数据方法中定义的,我可以毫无问题地console.log此数据。
也不确定为什么,但这一行与内联模板 vue.js 脚本一起工作正常,但在转换为单页面组件后抛出此错误。
所以在我的 Dockerfile 的末尾我有这个:
WORKDIR /home
CMD django-admin startproject whattt
CMD /bin/bash
Run Code Online (Sandbox Code Playgroud)
当我创建图像然后运行容器时,一切都按预期工作,没有错误,Docker 日志中也没有错误。但是,仍然有一些我似乎无法弄清楚的问题。
第一个也是最重要的问题是 CMD django-admin startproject 实际上并没有创建任何项目。运行容器后,我可以手动运行 django-admin startproject 并且它按预期工作。但是,当我从 Dockerfile 将其作为 CMD 发出时,不会创建任何项目。
第二个问题是在 django-admin 行之后,我用 /bin/bash 放置了第二个 CMD,所以当我运行容器时,它会打开一个 shell(这样我就可以进去检查我的 django 项目是否已创建)。这会与之前的 django-admin 行产生问题或冲突吗?如果我删除这一行,那么当我运行容器时,我无法打开外壳并检查我的 django 项目是否在那里?
任何帮助将不胜感激,谢谢。
所以我试图导入一个模块,并从该模块中的类测试方法。
这是方法的示例。
def production_warning(self, targetenv):
if targetenv == 'prdv':
prodwarning1 = raw_input("WARNING: You are deploying to the production environment. Are you sure you want to do this? Y/N: ").upper()
if prodwarning1 == "N":
sys.exit()
prodwarning2 = raw_input("DEPLOYING TO PRDV, ARE YOU REALLY, REALLY SURE? Y/N: ").upper()
if prodwarning2 == "N":
sys.exit()
else:
return True
Run Code Online (Sandbox Code Playgroud)
这是我尝试编写的测试示例。
def production_warning():
try:
assert test.production_warning('prdv') is not errors
assert test.validate_params('fakeenv') is errors
print "Test Passed {0}/5: validate_params".format(counter)
test_db_refresh()
except:
print "Test Failed {0}/5: validate_params".format(counter)
test_db_refresh() …Run Code Online (Sandbox Code Playgroud) python ×5
django ×2
assert ×1
bash ×1
class ×1
docker ×1
dockerfile ×1
flask ×1
javascript ×1
kivy ×1
linux ×1
oop ×1
pip ×1
post ×1
postgresql ×1
python-2.7 ×1
redis ×1
selenium ×1
unit-testing ×1
virtualenv ×1
vue.js ×1
xpath ×1