我正在使用Eclipse 3.7.2 + Android + Maven + m2e,我有一个问题,通过Maven包含的Android库作为apklibs.我用两个项目mvntest1(主项目)和mvntest2(我的库项目)构建了一个测试场景.的pom.xml
的是该文本之后包括在内.
到现在为止还挺好.我可以通过控制台构建mvntest2$ mvn install
而不会出现任何错误.因此,我在我的本地maven存储库(~/.m2/repository/mvntest2/mvntest2/0.0.1-SNAPSHOT/mvntest2-0.0.1-SNAPSHOT.apklib
)中有一个apklib .
但是:包括不起作用.Eclipse不包含mvntest1中mvntest2的类等.我已经清理,更新了配置和依赖项,没有任何帮助.
我究竟做错了什么?请帮忙.如果缺少某些信息,请问.
======= mvntest1/pom.xml =====
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mvntest1</groupId>
<artifactId>mvntest1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>apk</packaging>
<name>mvntest1</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mvntest2</groupId>
<artifactId>mvntest2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>apklib</type>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<sdk>
<platform>7</platform>
</sdk>
<deleteConflictingFiles>true</deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions> …
Run Code Online (Sandbox Code Playgroud) 这工作得很好
@task
def foo(context):
with context.cd('/'):
context.run('pwd')
Run Code Online (Sandbox Code Playgroud)
输出:
/
Run Code Online (Sandbox Code Playgroud)
但这不会:
@task
def bar(context):
with context.cd('/'):
context.sudo('pwd', password='mysecretpassword')
Run Code Online (Sandbox Code Playgroud)
输出:
[sudo] password: sudo: cd: Befehl nicht gefunden
Run Code Online (Sandbox Code Playgroud)
如何让第二个示例运行?
在我的Django项目中,我有一个需要确认页面的管理操作.我将它定位在delete_selected操作上,但它不起作用.这就是我所拥有的.
def my_action(modeladmin, request, queryset):
if request.POST.get('post'):
print "Performing action"
# action code here
return None
else:
return TemplateResponse(request, "admin/my_action_confirmation.html")
Run Code Online (Sandbox Code Playgroud)
<form action="" method="post">{% csrf_token %}
<div>
<input type="hidden" name="post" value="yes" />
<input type="hidden" name="action" value="my_action" />
<input type="submit" value="Confirm" />
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
这几乎起作用.我进入确认页面,但是如果我点击"确认",我就会回到原始页面.永远不会到达带有操作代码的部分.实际上,my_action函数不是第二次调用.那么我怎么告诉django,一旦我点击确认,我的第二次调用my_action函数?
所以我有一个简单的声明示例with
。它适用于 Python 3.8 和 3.9:
class Foo:
def __enter__(self, *args):
print("enter")
def __exit__(self, *args):
print("exit")
with Foo() as f, Foo() as b:
print("Foo")
Run Code Online (Sandbox Code Playgroud)
输出(如预期):
enter
enter
Foo
exit
exit
Run Code Online (Sandbox Code Playgroud)
但如果我像这样添加括号,它只适用于 Python 3.9:
class Foo:
def __enter__(self, *args):
print("enter")
def __exit__(self, *args):
print("exit")
with (Foo() as f, Foo() as b):
print("Foo")
Run Code Online (Sandbox Code Playgroud)
3.8 中的输出:
File "foo.py", line 8
with (Foo() as f, Foo() as b):
^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)
我知道,我可以删除括号,但我不明白为什么它首先在 Python 3.9 中工作。我找不到相关的变更日志。
python ×3
django ×2
android ×1
django-admin ×1
django-forms ×1
eclipse ×1
fabric ×1
m2e ×1
maven ×1
python-3.9 ×1
python-3.x ×1