几乎每一个PSQL查询出来如果不是由前面难以辨认的混乱显示配置命令,如\x auto.为每个psql实例手动键入此内容很烦人.
有没有办法配置更好的默认显示?或许答案是使用更先进的交互式终端?
我一直在寻找一种从Python代码中打开一个新的默认浏览器窗口的方法.
根据文档webbrowser.open_new(url) 应该这样做.不幸的是,如果Chrome是默认浏览器,它只会打开一个新标签.有没有办法打开默认浏览器(不知道浏览器是什么)?
好的,如果你去这里的文件:https: //docs.djangoproject.com/en/dev/topics/http/shortcuts/
并向下滚动以查看redirect()的最后一个示例,它说"默认情况下,redirect()返回一个临时重定向.所有上述表单都接受一个永久参数;如果设置为True,将返回一个永久重定向:"
现在,临时重定向和永久重定向之间有什么区别?我正在使用它,以便当用户登录并进行身份验证时,然后将其重定向到登录页面.我应该使用HttpResponseRedirect()吗?它是否提供使用redirect()而不是HttpResponseRedirect()的任何好处?
我一直在努力开始进行单元测试,同时开发一个小的cli程序.
我的程序基本上解析命令行参数和选项,并决定调用哪个函数.每个函数都对数据库执行一些操作.
所以,例如,我可能有一个创建函数:
def create(self, opts, args):
#I've left out the error handling.
strtime = datetime.datetime.now().strftime("%D %H:%M")
vals = (strtime, opts.message, opts.keywords, False)
self.execute("insert into mytable values (?, ?, ?, ?)", vals)
self.commit()
Run Code Online (Sandbox Code Playgroud)
我的测试用例应该调用这个函数,然后执行select sql来检查是否输入了行?这听起来很合理,但也使测试更难维护.你会重写函数来返回一些东西并检查返回值吗?
谢谢
我正在使用带有Python绑定的Selenium来从具有无头Firefox的网页中抓取AJAX内容.它在我的本地机器上运行时效果很好.当我在我的VPS上运行完全相同的脚本时,会在看似随机(但一致)的行上抛出错误.我的本地和远程系统具有相同的操作系统/体系结构,因此我猜测与VPS相关的区别.
对于每个回溯,该行在引发错误之前运行4次.
在执行JavaScript以将元素滚动到视图中时,我经常会遇到此URLError.
File "google_scrape.py", line 18, in _get_data
driver.execute_script("arguments[0].scrollIntoView(true);", e)
File "/home/ryne/.virtualenvs/DEV/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 396, in execute_script
{'script': script, 'args':converted_args})['value']
File "/home/ryne/.virtualenvs/DEV/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 162, in execute
response = self.command_executor.execute(driver_command, params)
File "/home/ryne/.virtualenvs/DEV/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 355, in execute
return self._request(url, method=command_info[0], data=data)
File "/home/ryne/.virtualenvs/DEV/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 402, in _request
response = opener.open(request)
File "/usr/lib64/python2.7/urllib2.py", line 404, in open
response = self._open(req, data)
File "/usr/lib64/python2.7/urllib2.py", line 422, in _open
'_open', req)
File "/usr/lib64/python2.7/urllib2.py", line 382, in _call_chain
result = func(*args)
File "/usr/lib64/python2.7/urllib2.py", line 1214, …Run Code Online (Sandbox Code Playgroud) 这是完整的 dockerfile
FROM ubuntu:12.04
# Create directory
RUN mkdir -p /dir/subdir
# Download wget
RUN apt-get install -y wget
# Make sure package is up to date
RUN apt-get update
# Install nodejs
WORKDIR /dir
RUN wget http://nodejs.org/dist/v0.10.26/node-v0.10.26-linux-x64.tar.gz
RUN tar -zxf node-v0.10.26-linux-x64.tar.gz
RUN cd /node-v0.10.26-linux-x64 && ./configure
RUN cd /node-v0.10.26-linux-x64 && make
RUN cd /node-v0.10.26-linux-x64 && make install
# Update again
RUN apt-get-update
# Copy all the files
ADD dir/subdir dir/subdir
EXPOSE 8080
CMD ["node", "/dir/subdir/index.js"]
Run Code Online (Sandbox Code Playgroud)
这是日志的一部分,其中出现错误
Step 6 : …Run Code Online (Sandbox Code Playgroud) 我有一个简单的出版物:
return Companies.find({}, {fields: {'myField1': 1, 'myField2': 1}});
在我的Companies收藏中,对于每个公司,我都有一个数组customers和一个数组managers.这些数组包含具有'_id'和各种其他属性的对象.
对于可视化,可以添加新公司,如下所示:
Companies.insert({
customers: [{_id: <userId>, otherProp: <data>}, ...],
managers: [{_id: <userId>, otherProp: <data>}, ...]
});
Run Code Online (Sandbox Code Playgroud)
该_id字段是users集合中相应用户的id.
我想只返回那些可以在customers数组的对象(或管理器数组,具体取决于用户)中找到用户的_id的公司.
这可能是一个mongo问题,但我不确定.=>在文档中,他们提到了mongo选择器:http://docs.meteor.com/#selectors ( http://docs.mongodb.org/manual/reference/operator/query/)但我无法弄清楚如何把它用于我的情况.
python ×3
browser ×1
collections ×1
database ×1
django ×1
django-views ×1
docker ×1
httpresponse ×1
javascript ×1
meteor ×1
mongodb ×1
node.js ×1
postgresql ×1
psql ×1
redirect ×1
ubuntu ×1
unit-testing ×1
vps ×1
web-scraping ×1