我有一个自托管的gitlab,我想安装一个使用ssh托管的软件包.
我试过了:
pip install git+ssh://git@<my_domain>:se7entyse7en/<project_name>.git
Run Code Online (Sandbox Code Playgroud)
这是输出:
Downloading/unpacking git+ssh://git@<my_domain>:se7entyse7en/<project_name>.git
Cloning ssh://git@<my_domain>:se7entyse7en/<project_name>.git to /var/folders/3r/v7swlvdn2p7_wyh9wj90td2m0000gn/T/pip-4_JdRU-build
ssh: Could not resolve hostname <my_domain>:se7entyse7en: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
Run Code Online (Sandbox Code Playgroud)
更新:
我试图在gitlab.com上传它,在上传了repo之后我尝试通过运行来安装它:
pip install git+ssh://git@gitlab.com:loumarvincaraig/<project_name>.git
Run Code Online (Sandbox Code Playgroud)
但没有改变.特别是这里的内容pip.log
:
/Users/se7entyse7en/Envs/test/bin/pip run on Mon Nov 17 22:14:51 2014
Downloading/unpacking git+ssh://git@gitlab.com:loumarvincaraig/<project_name>.git
Cloning ssh://git@gitlab.com:loumarvincaraig/<project_name>.git to /var/folders/3r/v7swlvdn2p7_wyh9wj90td2m0000gn/T/pip-91JVFi-build
Found command 'git' at '/usr/local/bin/git'
Running command /usr/local/bin/git clone -q ssh://git@gitlab.com:loumarvincaraig/<project_name>.git /var/folders/3r/v7swlvdn2p7_wyh9wj90td2m0000gn/T/pip-91JVFi-build …
Run Code Online (Sandbox Code Playgroud) 我注意到,如果我在创建该类的实例时定义一个等于函数的类属性,该属性将成为绑定方法.有人能解释一下这种行为的原因吗?
In [9]: def func():
...: pass
...:
In [10]: class A(object):
....: f = func
....:
In [11]: a = A()
In [12]: a.f
Out[12]: <bound method A.func of <__main__.A object at 0x104add190>>
In [13]: a.f()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-13-19134f1ad9a8> in <module>()
----> 1 a.f()
global a.f = <bound method A.func of <__main__.A object at 0x104add190>>
TypeError: func() takes no arguments (1 given)
Run Code Online (Sandbox Code Playgroud) 是否可以编写CSS规则来选择没有特定类的元素的第一个子元素?
例:
<div>
<span class="common-class ignore"></span>
<span class="common-class ignore"></span>
<span class="common-class"></span>
<span class="common-class"></span>
</div>
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我想选择第一个span
没有课程ignore
.我试过这个,但似乎没有用:
.common-class:first-child:not(.ignore) {
...some rules...
}
Run Code Online (Sandbox Code Playgroud)
更新:
如果我向一个名为父div的类添加一个类,那么parent-class
Jukka建议的选择器的修改版本可以工作,除非第一个span
类ignore
在第一个没有之后.上述选择器如下:
.parent-class > .common-class.ignore + .common-class:not(.ignore) {
...some rules...
}
Run Code Online (Sandbox Code Playgroud) 我是Scala和Apache Spark的新手,我正在尝试使用Spark SQL.克隆了repo后,我通过输入启动了spark shell bin/spark-shell
并运行以下命令:
val sqlContext = new org.apache.spark.sql.SQLContext(sc)
import sqlContext.createSchemaRDD
val pathUsers = "users.txt"
case class User(uid: String, name: String, surname: String)
val users = sc.textFile(pathUsers).map(_.split(" ")).map(u => User(u(0), u(1), u(2)))
users.registerTempTable("users")
val res = sqlContext.sql("SELECT * FROM users")
res.collect().foreach(println)
Run Code Online (Sandbox Code Playgroud)
一切都按预期工作.该users.txt
文件类似于:
uid-1 name1 surname1
uid-2 name2 surname2
...
Run Code Online (Sandbox Code Playgroud)
之后我尝试创建一个独立项目,并使用构建依赖项sbt
.列出的依赖项build.sbt
如下:
"org.apache.spark" % "spark-streaming_2.10" % "1.2.0",
"org.apache.spark" % "spark-streaming-kafka_2.10" % "1.2.0",
"org.apache.spark" % "spark-sql_2.10" % "1.2.0",
"org.apache.spark" % "spark-catalyst_2.10" % "1.2.0" …
Run Code Online (Sandbox Code Playgroud) 我正在使用Django 1.7.7与python 2.7.6和Postgres作为数据库,我有一个问题TransactionTestCase
.在我的迁移中,我有两个datamigrations,我希望它们在测试期间可用,所以我添加serialized_rollback = True
到我的测试用例中(https://docs.djangoproject.com/en/1.7/topics/testing/overview/#test-case -serialized-rollback).
测试用例的第一次测试还可以,但是django正抱怨IntegrityError
:
IntegrityError: duplicate key value violates unique constraint "django_content_type_app_label_6032a1f08b99c274_uniq"
DETAIL: Key (app_label, model)=(admin, logentry) already exists.
Run Code Online (Sandbox Code Playgroud)
我设法运行测试并通过在我的设置中添加以下内容来避免此错误(https://docs.djangoproject.com/en/1.7/ref/settings/#std:setting-TEST_NON_SERIALIZED_APPS):
TEST_NON_SERIALIZED_APPS = ['django.contrib.contenttypes',
'django.contrib.auth']
Run Code Online (Sandbox Code Playgroud)
但我想知道为什么需要它?这是回滚中的错误还是我这方面的问题?
我正在尝试编写一个git别名,从提交消息中删除字符串"[ci skip]"(放在消息的末尾),但是我遇到了转义问题.别名从作为参数传递的提交中获取所有提交HEAD
.
如果我运行以下命令:
git filter-branch -f --msg-filter "sed -e \"s/\[ci skip\]$//g\"" master..HEAD
Run Code Online (Sandbox Code Playgroud)
它按预期工作.无论如何,如果我创建以下别名:
unwip = !sh -c 'git filter-branch -f --msg-filter \"sed -e \\\"s/\[ci skip\]$//g\\\"\" $0..HEAD'
Run Code Online (Sandbox Code Playgroud)
我运行git unwip master
它抱怨错误的配置,但我希望它的行为与以前的commads一样.我怎样才能解决这个问题?
这是我的问题.我无法通过pip
源代码安装MatPlotLib (在Mavericks上安装Matplotlib).我试过brew install matplotlib
,安装成功结束了.但是,它全局安装了MatPlotLib,而不是在当前激活的VirtualEnv中.
是否可以告诉brew在当前VirtualEnv中安装包?
我还是个新手。我正在尝试模拟struct
using的单一方法testify
,但我不知道该怎么做。
这是代码:
type HelloWorlder interface {
SayHello() string
GetName() string
}
type HelloWorld struct{}
func (hw *HelloWorld) SayHello() string {
return fmt.Sprintf("Hello World from %s!", hw.GetName())
}
func (hw *HelloWorld) GetName() string {
return "se7entyse7en"
}
Run Code Online (Sandbox Code Playgroud)
这是测试:
type MockHelloWorld struct {
mock.Mock
HelloWorld
}
func (m *MockHelloWorld) GetName() string {
args := m.Called()
return args.String(0)
}
type SomeTestSuite struct {
suite.Suite
}
func (s *SomeTestSuite) TestMocking() {
mhw := new(MockHelloWorld)
mhw.On("GetName").Return("foo bar")
fmt.Println(mhw.SayHello())
}
Run Code Online (Sandbox Code Playgroud)
这个想法是仅模拟该GetName …
对于某些罐子的冲突版本,我遇到了一些问题.我有一个库的依赖性group-a:artifact-a:0.0.1
具有的依赖关系group-b:artifact-b:0.0.1
,但我不希望那些group-b:artifact-b:0.0.1
被列入因为我知道,在运行时会出现group-b:artifact-b:0.0.2
.
我该如何写pom.xml
文件?
这是下列之一吗?这些之间有什么区别?
解决方案1:
排除group-b:artifact-b
自group-a:artifact-a:0.0.1
:
<dependencies>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
<version>0.0.1</version>
<exclusions>
<exclusion>
<groupId>group-b</groupId>
<artifactId>artifact-b</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
解决方案2:
group-b:artifact-b
按提供添加依赖项:
<dependencies>
<dependency>
<groupId>group-b</groupId>
<artifactId>artifact-b</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
解决方案3:
添加group-b:artifact-b
依赖作为运行时:
<dependencies>
<dependency>
<groupId>group-b</groupId>
<artifactId>artifact-b</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
解决方案4:
添加提供的group-b:artifact-b
依赖项或运行时并将其排除.group-a:artifact-a:0.0.1
更新:
抱歉没有明确,但是@Tunaki的假设是正确的,group-b:artifact-b:0.0.2
编译时不需要依赖.
我正在使用 Django 1.4 并且有一个类似于以下内容的项目:
project/
__init__.py
app1/
__init__.py
models.py
views.py
management/
__init__.py
commands/
__init__.py
...many commands...
test/
__init__.py
...many tests...
app2/
__init__.py
models.py
management/
__init__.py
commands/
__init__.py
...many commands...
test/
__init__.py
...many tests...
Run Code Online (Sandbox Code Playgroud)
其中models.py
ofapp2
是一个空文件,并且 和app1
都app2
列在 中INSTALLED_APPS
。问题是当我跑步时
python manage.py --help
Run Code Online (Sandbox Code Playgroud)
命令app1
显示为:
[app1]
command1
command2
...
commandsn
Run Code Online (Sandbox Code Playgroud)
但不是那些app2
好像没有安装的app2
。app2
如果尝试运行名为的命令,app2command
它会抱怨Unknown command: 'app2command'
。但是两个应用程序的测试都可以运行,特别是
python manage.py test app2
Run Code Online (Sandbox Code Playgroud)
进展顺利。问题是app2
没有模型吗?
是否可以filter_horizontal
用于ManyToManyField
具有中间表的字段,例如没有中间表的字段?
例如:
class A(models.Model):
f1 = models.ManyToManyField(B)
f2 = models.ManyToManyField(C, through='T')
class B(models.Model):
pass
class C(models.Model):
pass
class T(models.Model):
a = models.ForeignKey(A)
c = models.ForeignKey(C)
class AAdmin(admin.ModelAdmin):
filter_horizontal = ('f1', 'f2', )
Run Code Online (Sandbox Code Playgroud) 我是很新,Scala和我想知道是否有某种方式来创建一个虚拟的Future
对象来模拟isCompleted
来false
.我需要这个用于测试目的.
目前我正在使用的是一个假人Future[Int]
是这样的:
Future({
while (true) {}
1
})
Run Code Online (Sandbox Code Playgroud)
这非常难看.
编辑
我有object
一个变量x
是一个Option[Future[Int]]
.在同一个object
我有检查是否x
不同的方法,None
如果是它检查是否完成.如果未来尚未完成,则可以避免在外部辅助对象上调用方法.测试期间这个外部辅助对象被模拟,我正在检查它是否被调用.为了实现这一点,我目前将x
变量设置为Future
上面所写的.
django ×3
python ×3
scala ×3
sbt ×2
testing ×2
apache-spark ×1
bash ×1
css ×1
dependencies ×1
django-1.4 ×1
django-admin ×1
escaping ×1
future ×1
git ×1
git-alias ×1
gitlab ×1
go ×1
homebrew ×1
java ×1
matplotlib ×1
maven ×1
methods ×1
mocking ×1
pip ×1
postgresql ×1
ssh ×1
testcase ×1
virtualenv ×1