我正在使用一个简单的基于 Docker 的 PHP 应用程序 ( https://github.com/fuhrysteve/php-docker-apache-example.git ) 来演示 Blackfirekfire 分析:
1. 为 BlackFire 安装 Chrome 扩展程序(在 chrome 上)
2.定义这些环境变量:
$export BLACKFIRE_CLIENT_ID=921b5dfa-a9e0-4979-8bd1-a7a7a2acf031
$export BLACKFIRE_CLIENT_TOKEN=af050bfc9cf3761082828e3f5e4f31ada89649f0635c0cb445c86f26f72a8e18
$export BLACKFIRE_SERVER_ID=3534d1d9-7c0b-4c5b-9aad-eda497b27494
$export BLACKFIRE_SERVER_TOKEN=79082e6b82122630d6be03bb8f3f8c9544fadada78156ef4606d86f639644eb0
Run Code Online (Sandbox Code Playgroud)
3. 安装代理
docker run --name="blackfire" -d -e BLACKFIRE_SERVER_ID -e BLACKFIRE_SERVER_TOKEN blackfire/blackfire
Run Code Online (Sandbox Code Playgroud)
4. 启用 PHP 探针
$cat Dockerfile
FROM php:7.0-apache
RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \
&& mkdir -p /tmp/blackfire \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire-*.so …Run Code Online (Sandbox Code Playgroud) 我试图找到如何在python中使用urllib2进行基本身份验证以获取问题KEY JIRA REST API描述了URI的可用性
感谢sugestions,我会尝试它,同时,我只是想用自己的努力更新这个:这是我试过的示例python代码:
import urllib2, sys, re, base64
from urlparse import urlparse
theurl = 'http://my.rest-server.com:8080/rest/api/latest/AA-120' # if you want to run this example you'll need to supply a protected page with y
our username and password
username = 'username'
password = 'password' # a very bad password
req = urllib2.Request(theurl)
print req
try:
handle = urllib2.urlopen(req)
print handle
except IOError, e: # here we are assuming we fail
pass
else: # If we don't fail then the …Run Code Online (Sandbox Code Playgroud) 我想要完成的是能够编写 SQL 语句并验证结果。SQL 语句中会有变量,例如:
String sql = "Select zoneid from zone where zonename = myZoneName";
Run Code Online (Sandbox Code Playgroud)
myZoneName 是从 count + 生成的
注意:我使用 Apache POI 来解析 Excel 电子表格。
这是代码:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import org.apache.log4j.Logger;
import org.junit.Test;
public class VerifyDBSingleDomain {
static Logger log = Logger.getLogger(VerifyDBSingleDomain.class.getName());
String url = "jdbc:oracle:thin:@a.b.c.d:1521:mname";
@Test
public void VerifyDBSingleDomainTest() throws SQLException {
Properties props = new Properties();
props.setProperty("user", "user");
props.setProperty("password", "password");
String sql = "Select zoneid from zone where …Run Code Online (Sandbox Code Playgroud) 我在{project_home} / src / test / groovy /中进行了一些功能测试
我希望能够使用gradle任务:
使用{project_home} / src / test / groovy /下的所有.groovy文件(包括所有依赖项)制作一个jar文件
能够运行此jar文件来代替运行单个groovy文件
我遇到的所有示例都有一个main方法,而我没有main()
所以我试图使用“项目的” build.gradle并附加
task fatJar(type: Jar) {
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
Run Code Online (Sandbox Code Playgroud)
跑了 $gradle clean fatJar
但是编译失败:
:Tests:EndToEndFunctionalTests:fatJar FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':Tests:EndToEndFunctionalTests:fatJar'.
> archive contains more than 65535 entries.
To build this archive, please enable the …Run Code Online (Sandbox Code Playgroud) 以下 Ansible 游戏如何工作:
- name: Generate join command
command: kubeadm token create --print-join-command
register: join_command
- name: Copy join command to local file
local_action: copy content="{{ join_command.stdout_lines[0] }}" dest="./join-command"
Run Code Online (Sandbox Code Playgroud)
据我了解,local_action 与 delegate_to 相同,但是 copy content= 没有任何意义。是不是需要指定像“cp”这样的实际命令?
拿这个例子:
local_action: command ping -c 1 {{ inventory_hostname }}
我们可以使用这样的东西:
local_action: command cp content="{{ join_command.stdout_lines[0] }}" dest="./join-command"
我们可以使用以下内容来获取XML数据
curl -v --basic --user USERNAME:PASSWORD --request POST "http://teamcity:8111/httpAuth/app/rest/users/" --data @data.xml --header "Content-Type: application/xml"
Run Code Online (Sandbox Code Playgroud)
我们可以为JSON做同样的事吗?
curl -v --basic --user USERNAME:PASSWORD --request POST "http://teamcity:8111/httpAuth/app/rest/users/" --data @data.json --header "Content-Type: application/json"
Run Code Online (Sandbox Code Playgroud)
两个,回来
HTTP/1.1 200 OK Date: Sun, 05 Aug 2012 02:18:36 GMT Server: Apache-Coyote/1.1 Pragma: no-cache Expires: Thu, 01 Jan 1970 00:00:00 GMT Cache-Control: no-cache Cache-Control: no-store Content-Type: application/xml
因此,Content-Type:xml
我怎样才能得到JSON Reponse.
我正在对 Teamcity URI 进行 REST 调用,以获取 lastSuccessful 版本号,但得到 406。如果我在 Chrome 的 REST 控制台中使用相同的 URI,我会得到正确的字符串(这是最新的版本号
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
public class LastSuccessBuildNum {
public static void main(String[] args) {
try {
Client client = Client.create();
// client basic auth demonstration
client.addFilter(new HTTPBasicAuthFilter("username", "password"));
WebResource webResource = client
.resource("http://localteamcity.com/teamcity/app/rest/buildTypes/id:bt26/builds/status:SUCCESS/number");
ClientResponse response = webResource.accept("application/json")
.get(ClientResponse.class);
if (response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatus());
}
String output = response.getEntity(String.class);
System.out.println("Output from Server …Run Code Online (Sandbox Code Playgroud) 就像是:
WebElement inputs = driver.findElement(By.tagName("input"));
Run Code Online (Sandbox Code Playgroud)
或者
List<WebElement> links = driver.findElementsBy(By.tagName("a"));
Run Code Online (Sandbox Code Playgroud)
我想要的是一个类似名称/值对的结构,它给了我 tagName 与 Quantity 我的目标是拥有这些元素的列表并进行一系列与它们相关的测试,因为不同的用户每个都有自己独特的这些元素集页。我希望我的信息得到传达。
我尝试将角色用作:
~/.aws/credentials
[default]
role_arn=arn:aws:iam::xxxxxxx:role/yyyy
Run Code Online (Sandbox Code Playgroud)
但我得到错误:
Partial credentials found in assume-role, missing: source_profile or credential_source
Run Code Online (Sandbox Code Playgroud)
因此看来IAM角色无法取代
[default]
aws_access_key_id = AAAAAAAAAAAAAAAAAAAAAAAA
aws_secret_access_key = BBBBBBBBBBBBBBBBBBBBBBBBBBB
Run Code Online (Sandbox Code Playgroud)
由于根据http://boto3.readthedocs.io/en/latest/guide/configuration.html
# In ~/.aws/credentials:
[development]
aws_access_key_id=foo
aws_access_key_id=bar
# In ~/.aws/config
[profile crossaccount]
role_arn=arn:aws:iam:...
source_profile=development
Run Code Online (Sandbox Code Playgroud)
我仍然必须使用密钥,即使没有在代码中使用它也可能带来安全风险
有没有一种方法可以使用具有管理员权限的boto3而不使用AWS API凭证?
所以基本上:
$curl http://169.254.169.254/latest/meta-data/iam/security-credentials/
test boto3 script
#!/usr/bin/env python
import boto3
ec2_client = boto3.client('ec2')
def main():
vpcs = ec2_client.describe_vpcs()
for vpc_info in vpcs['Vpcs']:
print(vpc_info['VpcId'])
if name == "main":
main()
我在github上遇到了一个可解决此问题的应用程序: