我正在开发一个Ansible模块,它生成一个url,从我的内部artifactory中获取该url的tarball(如get_url),然后将其解压缩.我想知道是否有办法在我的模块中包含或扩展get_url Ansible核心模块.我不能在多个步骤中使用它,因为正在使用的url是从git哈希生成的,需要多步搜索.
如果没有办法,我可能只需复制整个get_url模块并在我的模块中使用它,但我想避免这种情况.
我想做点什么:
module_json_response = module.get_module('get_url').issue_command('url=http://myartifactory.com/my_artifact.tar.gz dest=/path/to/local/my_artifact.tar.gz');
我对Ansible的理解是它上传了正在使用的模块并执行它,包括不支持或没有记录的另一个模块.
在此先感谢您的帮助.
我有一堆文件.我有一个与每行开头对应的字节偏移列表.我希望每行与字节偏移量相对应.有没有办法在unix,perl或python中执行此操作?我必须以比描述更大的规模来做这件事.
文件:
abcd
bcde
cdef
Run Code Online (Sandbox Code Playgroud)
字节偏移:
0
10
Run Code Online (Sandbox Code Playgroud)
期望的输出:
abcd
cdef
Run Code Online (Sandbox Code Playgroud) 我正在尝试将过滤器应用于带注释的查询集,就像在这里完成的一样:https : //docs.djangoproject.com/en/2.0/topics/db/aggregation/#filtering-on-annotations
与下面的代码片段类似,我想让那highly_rated部分成为一个 FilterSet 来获取请求参数
highly_rated = Count('books', filter=Q(books__rating__gte=7))
Author.objects.annotate(num_books=Count('books'), highly_rated_books=highly_rated)
Run Code Online (Sandbox Code Playgroud)
我想让那highly_rated部分成为一个 FilterSet 来接收请求查询。就像是:
class MainFilter(FilterSet):
class Meta:
model = Author
fields = {
author: ['in', 'exact'],
genre: ['in', 'exact']
}
class AnnotatedFilter(FilterSet):
class Meta:
fields = {
'books__rating': ['gt', 'lt' ],
}
class MyView(ListApiView):
filter_class = AuthorFilter
def get_queryset(self):
annotated_filter = AnnotatedFilter(request) # how do I set up another filter based on the request?
Author.objects.annotate(num_books=Count('books'), FilterSet=annotated_filter) # how do I apply it to …Run Code Online (Sandbox Code Playgroud)