小编Raf*_*Paz的帖子

如何在 Python 中的 Google Cloud Function 中运行子进程

我正在尝试在 GCP 函数中运行 bash 脚本,但不知何故它不起作用。这是我的函数,它基本上将文件(代理)导出到 Google Apigee:

def test2(request):
    cmd = "python ./my-proxy/tools/deploy.py -n myProxy -u userName:!password -o myOrg -e test -d ./my-proxy -p /"
    # no block, it start a sub process.
    p = subprocess.Popen(cmd , shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

    # and you can block util the cmd execute finish
    p.wait()
    # or stdout, stderr = p.communicate()
    return "Proxy deployed to Apigee"
Run Code Online (Sandbox Code Playgroud)

这是我的deploy.py文件:

!/usr/bin/env python

import base64
import getopt
import httplib
import json
import re
import os
import …
Run Code Online (Sandbox Code Playgroud)

python apigee google-cloud-platform google-cloud-functions

9
推荐指数
1
解决办法
3432
查看次数

无法连接到 AWS EC2 上的 Kafka

我在 AWS EC2 上创建了一个 Ubuntu VM,在同一 VM 中我运行一个 Zookeeper 实例和一个 Kafka 实例。Zookeeper 和 Kafka 运行得很好,我什至能够创建一个主题,但是,当我尝试从终端从本地计算机 (macOS) 连接时,我收到以下消息:

Producer clientId=console-producer] Connection to node -1 (ec2-x-x-x-x.ap-southeast-2.compute.amazonaws.com/x.x.x.x:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
Run Code Online (Sandbox Code Playgroud)

/config/server.properties中,当我阅读与我的问题相关的许多主题时,我更改了属性监听器advertising.listeners(见下图),但仍然无法从我的本地计算机连接 EC2 上的 Kafka:

在此输入图像描述

我真的不知道我在这里错过了什么......

卡夫卡版本:kafka_2.12-2.2.1

listeners=PLAINTEXT://PRIVATE_IP_ADDRESS:9092
advertised.listeners=PLAINTEXT://PUBLIC_IP_ADDRESS:9092
Run Code Online (Sandbox Code Playgroud)

amazon-ec2 apache-kafka

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

如何使用命令行在 Gradle 上运行空手道测试

我正在查看空手道文档: https://github.com/intuit/karate#command-line

我的文件如下:

跑步者类别:

import org.junit.runner.RunWith;
import com.intuit.karate.junit4.Karate;
import cucumber.api.CucumberOptions;

@RunWith(Karate.class)
@CucumberOptions(features = "classpath:feature/country.feature")
public class APITest {}
Run Code Online (Sandbox Code Playgroud)

将其放入我的 build.gradle 中:

test {
    // pull cucumber options into the cucumber jvm
    systemProperty "cucumber.options", System.properties.getProperty("cucumber.options")
    // pull karate options into the jvm
    systemProperty "karate.env", System.properties.getProperty("karate.env")
    // ensure tests are always run
    outputs.upToDateWhen { false }
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试像这样运行 gradle:

./gradlew test -Dtest=APITest
Run Code Online (Sandbox Code Playgroud)

但我得到这样的回应:

Rafaels-MacBook-Pro:TestProject rafaelpaz$ ./gradlew test -Dtest=APITest
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test
Run Code Online (Sandbox Code Playgroud)

但是,我看不到我的测试是否通过。我究竟做错了什么?

摇篮版本:2.14.1

java gradle gradlew build.gradle karate

2
推荐指数
1
解决办法
8408
查看次数

排序后无法从JTable获取正确的行(Swing)

我有一个AbstractTableModel,像这样:

public class TableModelClienteFornecedor extends AbstractTableModel {

    private List<ClienteFornecedorDTO> linhas;
    private String[] colunas = new String[]{"Nome", "Conta"};

    public TableModelClienteFornecedor() {
        linhas = new ArrayList<>();
    }

    @Override
    public int getRowCount() {
        return linhas.size();
    }

    @Override
    public int getColumnCount() {
        return colunas.length;
    }

    @Override
    public String getColumnName(int column) {
        return colunas[column];
    }

     @Override
    public Class getColumnClass(int column) {
         return (getValueAt(0, column).getClass());        
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        ClienteFornecedorDTO cf = linhas.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return cf.getNome();

            case …
Run Code Online (Sandbox Code Playgroud)

java swing netbeans jtable abstracttablemodel

0
推荐指数
1
解决办法
1988
查看次数