小编neo*_*k23的帖子

如何使用 SSL 在 RHEL 上编译 python3?无法导入 SSL

我正在尝试在 RHEL 上编译 python,因为我当前的 python 使用的是旧的 1.0.2k ssl 版本。

\n
(test_env) [brad@reason tlscheck]$ python3 --version\nPython 3.9.3\n(test_env) [brad@reason tlscheck]$ python3 -c "import ssl; print(ssl.OPENSSL_VERSION)"\nOpenSSL 1.0.2k-fips  26 Jan 2017\n(test_env) [brad@reason tlscheck]$ openssl version\nOpenSSL 1.1.1l  24 Aug 2021\n
Run Code Online (Sandbox Code Playgroud)\n

我认为问题是当我编译 3.9.3 时,我没有更新我的 OpenSSL 版本。我已经更新了我的 OpenSSL 并需要将它与 python 一起使用。所以我下载了最新的python 3.10,但在make阶段我收到一个错误,它不会用ssl制作。我的消息如下:

\n
Following modules built successfully but were removed because they could not be imported:\n_hashlib              _ssl                                     \n\n\nCould not build the ssl module!\nPython requires a OpenSSL 1.1.1 or newer\n
Run Code Online (Sandbox Code Playgroud)\n

这是尝试编译的完整日志:\n https://pastebin.com/36EntpFz

\n

当我使用 @tony-yip 提到的配置选项时,我在配置中得到以下内容。 …

python ssl openssl redhat

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

如何深入覆盖类属性两个级别?

覆盖和继承似乎与我的预期不同,让我解释一下这种情况.我有三个班:卡片,宝藏和铜.铜继承自Treasure和Treasure继承自Card.Treasure和Card之间的唯一区别是Treasure覆盖的单一方法.Treasure和Copper之间的唯一区别是Copper覆盖的属性.Copper覆盖的属性最初来自Card,它是Treasure在其独特方法中使用的属性.我遇到的问题是,当调用Copper的方法它继承自Treasure时,它仍然使用Card的属性值,而不是Copper应该覆盖它的属性值.以下是一些代码,任何帮助表示赞赏.

卡类:

class Card:
    normal_full_table = 6
    pile_player_rate = 10

    @staticmethod
    def pile_setup(player_count):
        pass
Run Code Online (Sandbox Code Playgroud)

宝藏类:

from card.card import Card
from math import floor

class Treasure(Card):
    @staticmethod
    def pile_setup(player_count):
        return (floor(player_count/Card.normal_full_table) + 1) * Card.pile_player_rate
Run Code Online (Sandbox Code Playgroud)

铜级:

from card.basic.card_treasure import Treasure


class Copper(Treasure):
    pile_player_rate = 60
Run Code Online (Sandbox Code Playgroud)

我期望发生的是当Copper.pile_setup(6)被调用时,值pile_player_rate为60,因为Copper覆盖了该值,但是在检查时它仍然是10.为什么会这样?这是因为我说具体是Card.pile_player_rate吗?我怎样才能让Copper使用它为pile_player_rate的唯一值而不是Card中的通用值?谢谢.

python inheritance python-3.x

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

x个唯一字符的Python排列每次重复y次

我正在尝试获得每个重复y次的x个唯一字符的排列列表.所以这看起来像这样:

x = ['0', '1']
y = 2

permutation_list = ['0011','0101','1001','1010','0110','1100']
Run Code Online (Sandbox Code Playgroud)

我不想要额外的东西('0001','1110'等),我不想要重复 - 有没有人知道这样做的简洁方法?

我尝试过使用itertools,但我最终得到了重复项.

python math permutation python-2.7

4
推荐指数
1
解决办法
96
查看次数

Git 不认为 gpg 密钥是秘密,即使它是,我该如何修复它?

所以看起来我的 gpg 密钥是秘密的,但是当我尝试在 git 中签署我的提交时,它不被识别为秘密。我完全不知道为什么会这样。我相信我的设置正确,但我的提交标志失败。难道我做错了什么?在此先感谢您的帮助。

[brad@reason entry-criteria-test]$ gpg --list-secret-keys --keyid-format LONG
/home/brad/.gnupg/secring.gpg
-----------------------------
sec   4096R/15980D34B4EED3FA 2019-03-11
uid                          Brad <brad@work.com>
ssb   4096R/3B437BF0F7366F6C 2019-03-11

[brad@reason entry-criteria-test]$ git config user.signingkey 15980D34B4EED3FA
[brad@reason entry-criteria-test]$ git config --global user.signingkey 15980D34B4EED3FA
[brad@reason entry-criteria-test]$ git commit -S -m "testing signed commit"
gpg: key B4EED3FA: secret key without public key - skipped
gpg: skipped "15980D34B4EED3FA": No secret key
gpg: signing failed: No secret key
error: gpg failed to sign the data
fatal: failed to write commit object
[brad@reason …
Run Code Online (Sandbox Code Playgroud)

git gnupg gpg-signature

4
推荐指数
1
解决办法
1848
查看次数

如何授权 django-rest-knox 登录路径而不出现 401 错误?

我正在尝试在我的 django 应用程序上放置一个身份验证 api,以便我可以开始使用 Vue+Node 前端。我已阅读knox 文档,但似乎没有看到任何表明问题所在的内容。任何见解将不胜感激。我的怀疑如下。

我正在做什么: 我正在遵循教程,该教程建议使用 knox,它似乎具有不错的功能。当我尝试使用curl创建用户时,一切都按预期工作,但是当我尝试登录(通过curl)时,我在控制台中收到以下响应(401):

API调用

(venv) brads-mbp:ReportVisualization brads$ curl --request POST --url http://127.0.0.1:8000/backend/auth/register/ --header 'content-type: application/json' --data '{"username": "user3", "password": "hunter2"}'
{"user":{"id":4,"username":"user3"},"token":"2b261fcdcbfff47cd8819accc2a3a08befa169c59982659a64012c680a69c3e8"}
(venv) brads-mbp:ReportVisualization brads$ curl --request POST --url http://127.0.0.1:8000/backend/auth/login/ --header 'content-type: application/json' --data '{"username": "user3","password": "hunter2"}'
{"detail":"Authentication credentials were not provided."}
Run Code Online (Sandbox Code Playgroud)

服务器日志

System check identified no issues (0 silenced).
December 18, 2018 - 07:47:05
Django version 2.1.3, using settings 'project.settings'
Starting ASGI/Channels version 2.1.5 development server at http://127.0.0.1:8000/
Quit …
Run Code Online (Sandbox Code Playgroud)

python authentication django single-page-application django-rest-framework

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

使用 Rust 和 Amethyst 的 Linux 上缺少库

当我在 Ubuntu 18.04 上尝试使用amethystcargo build的“hello world”时,收到有关缺少 lxbcb 库的错误。我不确定这个错误试图告诉我什么或如何修复它。似乎我缺少库、和,但我似乎找不到它们。-lxcb-render-lxcb-shap-lxcb-xfixes

紫水晶的hello world代码

extern crate amethyst;

use amethyst::{
    prelude::*,
    renderer::{DisplayConfig, DrawFlat, Pipeline, PosNormTex, RenderBundle, Stage, VirtualKeyCode},
    utils::application_root_dir,
    input::is_key_down,
};

struct Example;

impl SimpleState for Example {}

fn main() -> amethyst::Result<()> {
    amethyst::start_logger(Default::default());

    let path = format!(
        "{}/resources/display_config.ron",
        application_root_dir()
    );
    let config = DisplayConfig::load(&path);

    let pipe = Pipeline::build().with_stage(
        Stage::with_backbuffer()
            .clear_target([0.00196, 0.23726, 0.21765, 1.0], 1.0)
            .with_pass(DrawFlat::<PosNormTex>::new()),
    );

    let game_data =
        GameDataBuilder::default().with_bundle(RenderBundle::new(pipe, Some(config)))?;
    let mut game = Application::new("./", Example, game_data)?; …
Run Code Online (Sandbox Code Playgroud)

linux ld rust rust-cargo amethyst

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