我刚刚创建了一个Python包(这里有源代码),但是在安装后我无法使用它.一个简单的导入给了我一个ImportError
.
下面我将准确显示我做了什么,以便您可以重现它:
$ git clone git@github.com:kramer65/peewee-versioned.git
Cloning into 'peewee-versioned'
etc. etc.
Checking connectivity... done.
$ virtualenv venv
New python executable in the/path/to/my/venv/bin/python
Installing setuptools, pip, wheel...done.
$ . venv/bin/activate
(venv) $ cd peewee-versioned/
(venv) $ python setup.py install
running install
etc. etc. everything installs without errors
Finished processing dependencies for peewee-versioned==0.1
(venv) $ cd ..
(venv) $ pip freeze
peewee==2.8.0
peewee-versioned==0.1 # AS YOU CAN SEE IT IS INSTALLED
six==1.10.0
(venv) $ python
Python …
Run Code Online (Sandbox Code Playgroud) 我经常在Apache中使用a2ensite
以及a2dissite
启用和禁用站点。据我所知,它只不过是创建从/etc/apache2/sites-enabled
to 的符号链接而已/etc/apache2/sites-available
。我也可以手动执行此操作,但是由于它省去了键入几个字符的麻烦,因此我使用了这些快捷方式。
我只是做了一个cat /usr/sbin/a2ensite
,而令我惊讶的是,这是一个相当复杂的程序。根据手册页的内容,它仅能启用站点。我简要地看了一下(Perl)源代码,但是即使有很多代码,我也不能真正理解它的作用,而不仅仅是创建一个符号链接。
为什么只需要创建符号链接就需要那么多代码?我在这里想念什么?
我在 OSX 上,我以前使用过 docker-machine,但现在有一个适用于 Mac的本机Docker,我想安装它。所以我使用这个卸载脚本卸载了 docker-machine ,然后我安装并启动了 Docker for Mac 没有问题。
我可以运行docker --help
,它按预期显示了所有选项。
docker ps
但是,当我运行时,我得到以下信息:
$ docker ps 无法读取 CA 证书“/Users/kramer65/.docker/machine/machines/default/ca.pem”:打开/Users/kramer65/.docker/machine/machines/default/ca.pem:没有这样的文件或目录
我尝试了这个答案中的解决方案(包括寻找.bash_profile
激活它),但这并没有解决任何问题。
有谁知道我能做些什么来解决这个问题?
我正在设置一个带有ansible的服务器,我想安装和配置sendmail
.要做到这一点,我首先使用apt安装它,然后我需要运行sendmailconfig
AND asnwer y
它问的所有问题.
最后一部分是我认为最难的部分.sendmailconfig
没有-y
一面旗帜可以回答所有问题,所以我如何让Ansible简单地同意它所要求的所有问题?
我有一个Python脚本,可以读出我的网络摄像头并在窗口中显示.我现在想存储结果,所以按照本教程我编写了以下代码:
import cv2
import imutils
camera = cv2.VideoCapture(0)
# Define the codec and create VideoWriter object to save the video
fourcc = cv2.VideoWriter_fourcc(*'XVID')
video_writer = cv2.VideoWriter('output.avi', fourcc, 20.0, (640, 480))
while True:
try:
(grabbed, frame) = camera.read() # grab the current frame
frame = imutils.resize(frame, width=640, height=480)
cv2.imshow("Frame", frame) # show the frame to our screen
key = cv2.waitKey(1) & 0xFF # I don't really have an idea what this does, but it works..
video_writer.write(frame) # Write the …
Run Code Online (Sandbox Code Playgroud) 我刚开始使用Go,在我编写的第一个程序中,我打印了一个结构,该结构还显示了
{wall:0 ext:63533980800 loc:<nil>}
Run Code Online (Sandbox Code Playgroud)
对似乎是类型的东西感到困惑time.Time()
,谷歌搜索将我带到了Go源代码的这一部分,其中在注释中解释了“挂钟”和“单调时钟”之间的区别。
因此,为了进行隔离测试,我创建了一个新的简约程序:
package main
import (
"fmt"
"time"
)
type TheStruct struct {
the_time time.Time
}
func main() {
the_struct := TheStruct{time.Now()}
fmt.Println(the_struct)
fmt.Printf("%+v\n", the_struct)
fmt.Println(the_struct.the_time)
fmt.Println()
the_struct_2 := TheStruct{time.Unix(1505099248, 200)}
fmt.Println(the_struct_2)
fmt.Printf("%+v\n", the_struct_2)
fmt.Println(the_struct_2.the_time)
}
Run Code Online (Sandbox Code Playgroud)
打印出以下内容:
{{13719544904843884912 534246 0x1140680}}
{the_time:{wall:13719544904843884912 ext:534246 loc:0x1140680}}
2017-09-11 05:08:11.35635032 +0200 CEST m=+0.000534246
{{200 63640696048 0x1140680}}
{the_time:{wall:200 ext:63640696048 loc:0x1140680}}
2017-09-11 05:07:28 +0200 CEST
Run Code Online (Sandbox Code Playgroud)
所以我想知道这里的两件事:
the_struct.the_time
)时更常用的日期时间表示法相比,为什么将结构的一部分打印为墙上时钟的时间呢?<nil>
为该位置打印出来是一个问题吗?我将如何解决呢?在节点中我想测试我给函数的变量是否是"某事".我的意思是不是null
值或empy数组或空对象.所以我写了以下内容,它按预期工作:
function f(v) {
if (v === null) {
return false;
}
if (v.constructor === Array) {
if (v.length) {
return true;
} else {
return false;
}
}
if (v.constructor === Object) {
if (Object.keys(v).length) {
return true;
} else {
return false;
}
}
}
f(null); // false
f([]); // false
f({}); // false
f([1]); // true
f({a: 1}); // true
Run Code Online (Sandbox Code Playgroud)
这看起来非常冗长.我认为有一种更简单/更简单的方法.这是一个选项,但不太可读,我认为仍然太冗长:
function f(v) {
if (v === null) {
return false;
}
if (v.constructor === …
Run Code Online (Sandbox Code Playgroud) 出于测试目的,我想将日期设置为特定日期。我现在尝试使用Carbon lib来做到这一点,但它失败了:
Carbon::setTestNow(Carbon::createFromDate(2000, 1, 1));
printf(date("Y-m-d H:i:s")); // prints 2018-06-28 13:21:06
Run Code Online (Sandbox Code Playgroud)
我在这里做错了什么?如何将时间全局设置为特定日期?
我试图了解time.Now()
和之间的区别time.Now().Local()
.我开始在笔记本电脑上打印出来(运行Ubuntu 18.04):
fmt.Println(time.Now())
fmt.Println(time.Now().Local())
Run Code Online (Sandbox Code Playgroud)
这给了我
2018-12-23 19:57:08.606595466 +0100 CET m=+0.000583834
2018-12-23 19:57:08.606667843 +0100 CET
Run Code Online (Sandbox Code Playgroud)
我不确定是什么m=+0.000583834
.也许我的机器和NTP服务器之间的区别?
现在返回当前的本地时间.
和
本地返回t,位置设置为本地时间.
他们都返回当地时间,所以我仍然不确定有什么区别.我试着四处寻找,但我找不到明确的答案.
谁能对此有所了解?
我正在 Django 项目中编写单元测试。我有一个使用该.create()
方法创建对象的工厂。所以在我的单元测试中,我使用了这个:
device = DeviceFactory.create()
Run Code Online (Sandbox Code Playgroud)
不过,这总是会在数据库中创建一条记录。有没有办法让工厂创建一个对象而不将它保存到数据库?
我查看了文档,但找不到。我错过了什么吗?
python ×3
datetime ×2
go ×2
macos ×2
time ×2
ansible ×1
apache ×1
bash ×1
certificate ×1
django ×1
docker ×1
factory ×1
factory-boy ×1
filesystems ×1
if-statement ×1
javascript ×1
linux ×1
module ×1
node.js ×1
opencv ×1
package ×1
perl ×1
php ×1
php-carbon ×1
sendmail ×1
setup.py ×1
setuptools ×1
struct ×1
timezone ×1
unit-testing ×1
video ×1