小编Mic*_* P.的帖子

防止Python包重新导出导入的名称

在Python包中,我有文件结构

package/
    __init__.py
    import_me.py
Run Code Online (Sandbox Code Playgroud)

该文件import_me.py被认为提供了功能片段:

import re
import sys

def hello():
    pass
Run Code Online (Sandbox Code Playgroud)

这样就package.import_me.hello可以通过动态导入import.不幸的是,这也让进口resyspackage.import_me.repackage.import_me.sys分别.

有没有办法防止导入的模块import_me.py再次重新导出?优选地,这应该超出名称修改或下划线前缀导入的模块,因为在我的情况下,它可能在某些情况下造成安全问题.

python module

19
推荐指数
3
解决办法
4693
查看次数

如何计算 Grafana 中 Prometheus 查询的平均值

我试图在 Grafana 上创建一个 Prometheus 图,但我找不到计算平均值的函数。

例如,要为 read_latency 创建图表,结果包含许多标签。如果有3台机器,则会有3个标签,分别为machine1、machine2、machine3。这是一张图(点击显示) Prometheus

我想将这三个组合在一起,因此只有一个标签:机器,并且该值是这三个标签的平均值。

看来普罗米修斯查询函数没有像average()这样的东西,所以我不知道如何做到这一点。

我曾经在 InfluxDB 上工作,图表可以显示如下(点击显示): influxDB

grafana prometheus

8
推荐指数
3
解决办法
7万
查看次数

我可以使用 VSCode 在外部库中搜索吗?

我想转而全职使用 VSCode,但让我继续使用 IntellijIDEA 的一件事是它能够在项目以及添加到项目中但位于文件系统其他位置的所有库中进行搜索。特别是,我希望它能够与 Dart 一起使用。到目前为止,我还没有找到合适的解决方案。

提前致谢!

dart visual-studio-code

8
推荐指数
1
解决办法
4748
查看次数

Flutter Cloud Firestore Map <字符串,动态>错误

我正在尝试使用Flutter和Firestore构建应用程序。使用StreamBuilder从Firestore加载Collection以便在ListView中显示它时,出现以下错误

The following assertion was thrown building StreamBuilder<QuerySnapshot>(dirty, state:
I/flutter (26287): _StreamBuilderBaseState<QuerySnapshot, AsyncSnapshot<QuerySnapshot>>#d5638):

I/flutter (26287): type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>'

I/flutter (26287): where

I/flutter (26287):   _InternalLinkedHashMap is from dart:collection

I/flutter (26287):   Map is from dart:core

I/flutter (26287):   String is from dart:core
Run Code Online (Sandbox Code Playgroud)

这就是我要从 DocumentSnapshot

The following assertion was thrown building StreamBuilder<QuerySnapshot>(dirty, state:
I/flutter (26287): _StreamBuilderBaseState<QuerySnapshot, AsyncSnapshot<QuerySnapshot>>#d5638):

I/flutter (26287): type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>'

I/flutter (26287): where

I/flutter (26287):   _InternalLinkedHashMap …
Run Code Online (Sandbox Code Playgroud)

dart firebase flutter google-cloud-firestore

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

如何在dart控制台应用程序中禁用stdin echo

下面的示例将读取用户密码,但也以纯文本形式回显它,有没有办法解决这个问题?

Future<String> promptPassword() {
  var completer = new Completer<String>();
  var stream = new StringInputStream(stdin);
  stdout.writeString("Warning: Password will be displayed here until I find a better way to do this.\n");
  stdout.writeString("Watch your back...\n");
  stdout.writeString("GitHub password for $gituser: ");
  stream.onLine = () {
    var str = stream.readLine();
    stdin.close();
    completer.complete(str);
  };
  return completer.future;
}
Run Code Online (Sandbox Code Playgroud)

dart dart-io

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