小编mar*_*ele的帖子

使用多个查找字段休息调用以进行反向查找

在Django休息框架中,有没有办法拥有多个查找字段?我知道这听起来不是很REST友好.

我有一个Company模型,我想首先通过他们的国家列出它们,然后通过一个slug字段列出它们,例如:/companies/<iso_country>/<slug>/.有没有办法做到这一点?

python django rest django-rest-framework

9
推荐指数
2
解决办法
2913
查看次数

Python - 超过4gb的Wave文件:struct.error:'L'格式需要0 <= number <= 4294967295

我试图在我的python脚本中创建超过4GB的音频波形文件,但是我收到错误.这是一个重现问题的简短脚本.有人可以告诉我为什么我会遇到这样的错误以及如何修复它,或者它可能是一个错误?

我尝试使用python 2.7和3.4,但两者都有相同的错误.

# script for python 2
import wave

# create a large (>4gb) file
wf = wave.open("foo.wav", "w")
wf.setnchannels(2)
wf.setsampwidth(2)
wf.setframerate(44100)
text = 'a' * 1024**2
for i in xrange(5 * 1024):
    print i
    wf.writeframes(text)
wf.close()
Run Code Online (Sandbox Code Playgroud)

输出:

4088
4089
4090
4091
4092
4093
4094
4095
Traceback (most recent call last):
  File "test.py", line 16, in <module>
    wf.writeframes(text)
  File "/usr/lib/python2.7/wave.py", line 444, in writeframes
    self._patchheader()
  File "/usr/lib/python2.7/wave.py", line 496, in _patchheader
    self._file.write(struct.pack('<L', 36 + self._datawritten))
struct.error: 'L' format requires …
Run Code Online (Sandbox Code Playgroud)

python wave

5
推荐指数
1
解决办法
1242
查看次数

Maven版本/ Github OAuth令牌/ Jenkins:无法读取'https://github.com'的用户名:无此类设备或地址

我正在尝试从Jenkins发布Maven版本,并将代码托管在github上的一个仓库中。对于构建用户,我生成了一个OAuth令牌来以RW模式访问存储库。

在Jenkins中,我像https://token@github.com/username/project没有任何凭据一样配置了存储库签出url ,因为前面的令牌应该足够了。

在pom中,我确实设置了任何用户名/密码,也没有设置令牌。该值很简单:

<developerConnection>scm:git:https://github.com/username/project</developerConnection>
Run Code Online (Sandbox Code Playgroud)

但是当maven尝试将提交提交到pom文件时,出现了一个错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.1:prepare (default-cli) on project cloudstack: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] fatal: could not read Username for 'https://github.com': No such device or address
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.1:prepare (default-cli) on project cloudstack:     Unable to commit files
Provider message:
The git-push command failed.
Command output:
fatal: could not read Username for 'https://github.com': No …
Run Code Online (Sandbox Code Playgroud)

git oauth github maven jenkins

4
推荐指数
2
解决办法
8122
查看次数

禁用 checkstyle maven 插件生成的源目录

在一个多模块项目中,有一个在目录中生成一些源代码target/generated-sources/xjc3/com/...,我试图使 Maven checkstyle 插件跳过这个生成的源目录。尽管尝试了许多标记语法<excludes>,但它仍然扫描此源目录。有谁知道如何从审核中删除这个生成的源目录?

Maven 插件配置

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-checkstyle-plugin</artifactId>
      <version>3.0.0</version>
      <dependencies>
        <dependency>
          <groupId>org.apache.cloudstack</groupId>
          <artifactId>checkstyle</artifactId>
          <version>${project.version}</version>
        </dependency>
        <dependency>
          <groupId>com.puppycrawl.tools</groupId>
          <artifactId>checkstyle</artifactId>
          <version>8.7</version>
        </dependency>
      </dependencies>
      <executions>
        <execution>
          <id>cloudstack-checkstyle</id>
          <phase>validate</phase>
          <goals>
            <goal>check</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <failsOnError>true</failsOnError>
        <configLocation>cloud-style.xml</configLocation>
        <consoleOutput>true</consoleOutput>
        <includeTestSourceDirectory>true</includeTestSourceDirectory>
        <includes>**\/*.java</includes>
        <excludes>**\/deps\/,**\/test\/,**\/target\/,**\/bin\/,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat,**\/apidoc\/,**\/generated-sources\/,**\/generated-sources\/*,**\/generated-sources\/**,**\/generated-sources\/**\/*.*,**/generated-sources/**/*.*,**/generated-sources/**/*,**/generated-sources/**,**/generated-sources/*,**/generated-sources/*.*</excludes>
      </configuration>
    </plugin>
Run Code Online (Sandbox Code Playgroud)

Maven 运行调试输出

这是插件调试输出,它显示它不断包含生成的源目录:

[INFO] --- maven-checkstyle-plugin:3.0.0:check (cloudstack-checkstyle) @ cloud-plugin-network-vcs ---
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0, parent: sun.misc.Launcher$AppClassLoader@74a14482]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check' with basic configurator -->
[DEBUG]   (f) cacheFile = /home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/checkstyle-cachefile
[DEBUG]   (f) …
Run Code Online (Sandbox Code Playgroud)

checkstyle maven maven-checkstyle-plugin

3
推荐指数
1
解决办法
7501
查看次数