Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #5692
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Stefan Fuhrmann <stefan@fuhrmann.homedns.org> |
| Newsgroups | de.comp.lang.python |
| Subject | Re: [Python-de] yaml config mit python editieren |
| Date | Sat, 10 Oct 2020 10:12:53 +0200 |
| Lines | 92 |
| Message-ID | <mailman.1289.1602317576.9580.python-de@python.org> (permalink) |
| References | <09de33f7-e3b5-26b6-90d3-8e9c9b7788be@fuhrmann.homedns.org> <adb8aa19-8f37-7f87-e103-6bf8c0eead2c@fuhrmann.homedns.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Trace | news.uni-berlin.de hUYRZFSKMmK53BrmefL4AQlOyi/yz+ACHPraDAOOQAXg== |
| Return-Path | <stefan@fuhrmann.homedns.org> |
| X-Original-To | python-de@python.org |
| Delivered-To | python-de@mail.python.org |
| Authentication-Results | mail.python.org; dkim=none reason="no signature"; dkim-adsp=none (unprotected policy); dkim-atps=neutral |
| X-Virus-Scanned | Debian amavisd-new at willy.nopanicsystems.net |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
| In-Reply-To | <09de33f7-e3b5-26b6-90d3-8e9c9b7788be@fuhrmann.homedns.org> |
| Content-Language | en-US |
| X-BeenThere | python-de@python.org |
| X-Mailman-Version | 2.1.34 |
| Precedence | list |
| List-Id | Die Deutsche Python Mailingliste <python-de.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-de>, <mailto:python-de-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-de/> |
| List-Post | <mailto:python-de@python.org> |
| List-Help | <mailto:python-de-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-de>, <mailto:python-de-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <adb8aa19-8f37-7f87-e103-6bf8c0eead2c@fuhrmann.homedns.org> |
| X-Mailman-Original-References | <09de33f7-e3b5-26b6-90d3-8e9c9b7788be@fuhrmann.homedns.org> |
| Xref | csiph.com de.comp.lang.python:5692 |
Show key headers only | View raw
manchmal muss man erst an Liste schreiben... ;)
mit
docker_compose["services"]["db"]["environment"] =
dict(MYSQL_ROOT_PASSWORD= "passing")
funktioniert es!
Danke!
Gruß
Stefan
Am 10.10.20 um 09:39 schrieb Stefan Fuhrmann:
> Hallo zusammen,
>
> ich habe eine docker-compose.yml und möchte diese editieren, was mir
> nicht gelingt.
>
> #!/usr/bin/python3
> 2
> 3 import subprocess
> 4 import shutil
> 5 import os
> 6 import docker
> 7 #client =
> docker.DockerClient(base_url="unix://var/run/docker.sock",
> version='auto')
> 8 client = docker.from_env()
> 9 import sys
> 10 import yaml
> 11print(sys.version)
> 12
> 1
> 21
> 22
> 23 with open('docker-compose.yml', "r") as f:
>
> 24 # The FullLoader parameter handles the conversion from YAML
> 25 # scalar values to Python the dictionary format26 #
> docker_compose = yaml.load(file, Loader=yaml.FullLoader)
>
> 27 docker_compose = yaml.full_load(f)
>
> 28 # docker_compose = yaml.load(f, Loader=yaml.FullLoader)
> 29 # docker_compose['MYSQL_ROOT_PASSWORD'] = "test"
> 30
> #docker_compose["services"]["db"]["environment"]['MYSQL_ROOT_PASSWORD']
> = docker_compose.update("{{{pass}}}", "passing")
> 31
> 32 #docker_compose.update("{{{pass}}}", "Passing")
> 33
> 34 # txt = "pass"
> 35 # x = txt.replace("pass", "apples")
> 36 docker_compose["services"]["db"]["environment"] =
> docker_compose.update("pass", "apples")
> 37
> 38 # print(docker_compose)
> 39 # docker_compose = docker_compose.replace("{{{pass}}}",
> "passingpass")
> 40
> 41
> 42 with open('docker-compose.yml', "w") as f:
> 43 yaml.dump(docker_compose, f)
>
> in der docker-compose habe ich bei MYSQL_ROOT_PASSWORD=pass
> eingetragen, weil ich dachte, wenn ich da was einfaches stehen habe,
> kann ich es ersetzen.
>
> Das funktioniert so leider nicht. Jetzt wird bis "environment" in der
> yaml alles weggeschnitten.
>
>
> Wie kann ich eine docker-compose.yml mit python editieren?
>
> Kann jemand helfen?
>
>
> Danke!
>
> Gruß
>
> Stefan
>
>
> _______________________________________________
> python-de maillist - python-de@python.org
> https://mail.python.org/mailman/listinfo/python-de
Back to de.comp.lang.python | Previous | Next | Find similar
Re: [Python-de] yaml config mit python editieren Stefan Fuhrmann <stefan@fuhrmann.homedns.org> - 2020-10-10 10:12 +0200
csiph-web