小编xud*_*fsd的帖子

paramiko不兼容的ssh peer(没有可接受的kex算法)

尝试使用paramiko库ssh到Cisco ACS设备时出现以下错误.我已经在python中使用了paramiko而没有问题,我可以从命令行ssh到这个框,或者使用putty而没有问题.我打开了调试并在这里复制了信息.如果你能帮助我,请告诉我.

import paramiko
import sys
import socket

try:
    paramiko.common.logging.basicConfig(level=paramiko.common.DEBUG)
    sshConnection = paramiko.SSHClient()
    sshConnection.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    sshConnection.connect('server',username='username',password='password')
except paramiko.BadAuthenticationType:
    sys.stdout.write('Bad Password!\n')     
    sys.exit()
except paramiko.SSHException, sshFail:
    sys.stdout.write('Connection Failed!\n')
    sys.stdout.write('%s\n' % sshFail)
    sys.exit()
except socket.error, socketFail:
    sys.stdout.write('Failed to open socket\n')
    sys.stdout.write('%s\n' % socketFail)
    sys.exit()
Run Code Online (Sandbox Code Playgroud)

并返回调试输出:

DEBUG:paramiko.transport:starting thread (client mode): 0x14511d0L
INFO:paramiko.transport:Connected (version 2.0, client OpenSSH_5.3)
DEBUG:paramiko.transport:kex algos:['diffie-hellman-group14-sha1'] server key:['ssh-rsa'] client encrypt:['aes256-cbc', 'aes128-cbc', '3des-cbc'] server encrypt:['aes256-cbc', 'aes128-cbc', '3des-cbc'] client mac:['hmac-sha1'] server mac:['hmac-sha1'] client compress:['none', 'zlib@openssh.com'] server compress:['none', 'zlib@openssh.com'] client lang:[''] server lang:[''] kex follows?False
ERROR:paramiko.transport:Exception: …
Run Code Online (Sandbox Code Playgroud)

python ssh cisco paramiko

23
推荐指数
2
解决办法
3万
查看次数

clojure defmacro中的多个arity

我在Clojure中遇到了一个与defmacro有关的奇怪问题,我的代码就像

(defmacro ttt
  ([] (ttt 1))
  ([a] (ttt a 2))
  ([a b] (ttt a b 3))
  ([a b c] `(println ~a ~b ~c)))
Run Code Online (Sandbox Code Playgroud)

我跑(ttt),它想成为(println 1 2 3),并打印"1 2 3",但我得到的是

ArityException Wrong number of args (-1) passed to: t1$ttt clojure.lang.Compiler.macroexpand1 (Compiler.java:6473)
Run Code Online (Sandbox Code Playgroud)

经过一番调查,我明白我应该写

(defmacro ttt
  ([] `(ttt 1))
  ([a] `(ttt ~a 2))
  ([a b] `(ttt ~a ~b 3))
  ([a b c] `(println ~a ~b ~c)))
Run Code Online (Sandbox Code Playgroud)

但为什么第一个版本失败了?和args太奇怪了了解,其中-1从自带?

macros clojure

23
推荐指数
1
解决办法
2904
查看次数

标准如何指定原子写入常规文件(不是管道或fifo)?

posix标准指定当写入少于PIPE_BUF字节到管道或FIFO被授予原子时,也就是说,我们的写入不会与其他进程混合.但是我没有找到关于常规文件的标准规范.我的意思是,当我们写的少于PIPE_BUF时,它也会被授予原子性.但我想知道常规文件有这样的限制吗?我的意思是,管道有容量,所以当写入管道并超出其容量时,内核会让编写器进入休眠状态,因此其他进程将有机会写入,但是常规文件似乎没有这样的限制,我是对的?

我正在做的是几个进程生成一个文件的日志.当然,设置O_APPEND.

c linux posix systems-programming

11
推荐指数
2
解决办法
1891
查看次数

不能在core.async的go块中使用for循环?

我是clojure core.async库的新手,我试图通过实验来理解它.

但当我尝试时:

(let [i (async/chan)] (async/go (doall (for [r [1 2 3]] (async/>! i r)))))
Run Code Online (Sandbox Code Playgroud)

它给了我一个非常奇怪的例外:

CompilerException java.lang.IllegalArgumentException: No method in multimethod '-item-to-ssa' for dispatch value: :fn
Run Code Online (Sandbox Code Playgroud)

我尝试了另一个代码:

(let [i (async/chan)] (async/go (doseq [r [1 2 3]] (async/>! i r))))
Run Code Online (Sandbox Code Playgroud)

它根本没有编译器异常.

我完全糊涂了.发生了什么事?

clojure core.async

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

kubernetes 有没有办法等待 daemonset 准备好

我不确定DaemonSet中是否有就绪条件。我的意思是,该 DaemonSet 拥有的所有 Pod 都已准备就绪。

我知道kubectl wait,但似乎无法检查 DaemonSet 的准备情况。

kubernetes

5
推荐指数
2
解决办法
4761
查看次数

如何在Clojure中的函数/宏中的另一个命名空间中定义变量?

nsClojure中进行实验,这是我尝试的内容:

user=> (in-ns 'some-ns)
#<Namespace some-ns>
some-ns=> (def aa 100)
#'some-ns/aa
some-ns=> (in-ns 'user)
#<Namespace user>
user=> (= some-ns/aa 100)
true
user=> (= user/aa 100)
CompilerException java.lang.RuntimeException: No such var: user/aa, compiling:(NO_SOURCE_PATH:5:1) ;this works as expected
user=> (defn function [] (in-ns 'some-other-ns) (def cc 100) (in-ns 'user))
#'user/function
user=> (function)
#<Namespace user>
user=> (= some-other-ns/cc 100)
CompilerException java.lang.RuntimeException: No such var: some-other-ns/cc, compiling:(NO_SOURCE_PATH:8:1)
user=> (= user/cc 100)
true
Run Code Online (Sandbox Code Playgroud)

我很困惑,为什么它在功能上不起作用?另外,我试过以下:

user=> (binding [*ns* (create-ns 'some-a-ns)] (def dd …
Run Code Online (Sandbox Code Playgroud)

namespaces clojure

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

`Iterator` trait 中的 `type Item` 是什么意思

Iterator性状的定义如下:

pub trait Iterator {
    type Item;
    fn next(&mut self) -> Option<Self::Item>;
}
Run Code Online (Sandbox Code Playgroud)

什么type Item;意思?以及如何称呼它?

上面的定义等价于这个定义吗?

pub trait Iterator<T> {
    fn next(&mut self) -> Option<T>;
}
Run Code Online (Sandbox Code Playgroud)

如果是一样的,为什么要那样声明呢?如果不一样,那么有什么区别呢?

rust

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

迭代列表时借用的 RefCell 持续时间不够长

我正在尝试实现一个链表来理解 Rust 中的智能指针。我定义了一个Node

use std::{cell::RefCell, rc::Rc};

struct Node {
    val: i32,
    next: Option<Rc<RefCell<Node>>>,
}
Run Code Online (Sandbox Code Playgroud)

并像这样迭代

fn iterate(node: Option<&Rc<RefCell<Node>>>) -> Vec<i32> {
    let mut p = node;
    let mut result = vec![];

    loop {
        if p.is_none() {
            break;
        }

        result.push(p.as_ref().unwrap().borrow().val);

        p = p.as_ref().unwrap().borrow().next.as_ref();
    }

    result
}
Run Code Online (Sandbox Code Playgroud)

编译器报错:

error[E0716]: temporary value dropped while borrowed
  --> src/main.rs:27:13
   |
27 |         p = p.as_ref().unwrap().borrow().next.as_ref();
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^              -
   |             |                                         |
   |             |                                         temporary value is freed at the end of this statement …
Run Code Online (Sandbox Code Playgroud)

linked-list smart-pointers rust

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