admin管理员组文章数量:1025244
I am trying to write a script for RHEL8 servers which takes input parameter postgresql version, and it will install a postgresql instance of that version number.
e.g.
db_version = 15.6
db_version_short = 15
I am trying to use python's Subprocess library to install postgresql, but the script is hanging and times-out with errors:
#!/usr/bin/env python3
import sys
import subprocess;
import os
def runcmd(cmd, verbose = True, *args, **kwargs):
process = subprocess.Popen(
cmd,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
shell = True
)
std_out, std_err = processmunicate()
if verbose:
print((std_out.strip()).decode('utf-8'), std_err)
pass
db_version = 15.6
db_version_short = (str(db_version)).split('.')[0]
runcmd('dnf install -y .noarch.rpm')
#You can verify the PostgreSQL package details with the following command
runcmd('rpm -qi pgdg-redhat-repo')
#If the default PostgreSQL version is enabled in your RHEL8 installation, then disable it by running the following
runcmd('dnf module disable postgresql -y')
runcmd('dnf clean all')
#dnf install
install_cmd = f'dnf -y install postgresql{db_version_short}-server-{db_version}'
runcmd(install_cmd, verbose = True)
The above steps work without issue when I run them manually in my terminal.
But it seems to encounter some issues when I run them from the scipt and the script hangs.
I believe it is hanging on the following line when I run it:
runcmd('dnf install -y .noarch.rpm')
outputs from last time I ran it:
Updating Subscription Management repositories.
Red Hat Enterprise Linux 8 for x86_64 - AppStre 53 kB/s | 2.8 kB 00:00
Red Hat Enterprise Linux 8 for x86_64 - Supplem 39 kB/s | 2.1 kB 00:00
Red Hat Enterprise Linux 8 for x86_64 - BaseOS 46 kB/s | 2.4 kB 00:00
Red Hat Satellite Tools 6.6 for RHEL 8 x86_64 ( 41 kB/s | 2.1 kB 00:00
[MIRROR] pgdg-redhat-repo-latest.noarch.rpm: Curl error (28): Timeout was reached for .noarch.rpm [Connection timed out after 30000 milliseconds]
[MIRROR] pgdg-redhat-repo-latest.noarch.rpm: Curl error (28): Timeout was reached for .noarch.rpm [Connection timed out after 30000 milliseconds]
[MIRROR] pgdg-redhat-repo-latest.noarch.rpm: Curl error (28): Timeout was reached for .noarch.rpm [Connection timed out after 30000 milliseconds]
pgdg-redhat-repo-latest.noarch.rpm 170 B/s | 15 kB 01:30
Package pgdg-redhat-repo-42.0-45PGDG.noarch is already installed.
Dependencies resolved.
Nothing to do.
The issue is inconsistent, it will install it sometimes and then sometimes it will hang,
It would be great if someone could help identify why I am facing the hanging issue with this, or any tips on best practice for this install
I am trying to write a script for RHEL8 servers which takes input parameter postgresql version, and it will install a postgresql instance of that version number.
e.g.
db_version = 15.6
db_version_short = 15
I am trying to use python's Subprocess library to install postgresql, but the script is hanging and times-out with errors:
#!/usr/bin/env python3
import sys
import subprocess;
import os
def runcmd(cmd, verbose = True, *args, **kwargs):
process = subprocess.Popen(
cmd,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
shell = True
)
std_out, std_err = processmunicate()
if verbose:
print((std_out.strip()).decode('utf-8'), std_err)
pass
db_version = 15.6
db_version_short = (str(db_version)).split('.')[0]
runcmd('dnf install -y .noarch.rpm')
#You can verify the PostgreSQL package details with the following command
runcmd('rpm -qi pgdg-redhat-repo')
#If the default PostgreSQL version is enabled in your RHEL8 installation, then disable it by running the following
runcmd('dnf module disable postgresql -y')
runcmd('dnf clean all')
#dnf install
install_cmd = f'dnf -y install postgresql{db_version_short}-server-{db_version}'
runcmd(install_cmd, verbose = True)
The above steps work without issue when I run them manually in my terminal.
But it seems to encounter some issues when I run them from the scipt and the script hangs.
I believe it is hanging on the following line when I run it:
runcmd('dnf install -y .noarch.rpm')
outputs from last time I ran it:
Updating Subscription Management repositories.
Red Hat Enterprise Linux 8 for x86_64 - AppStre 53 kB/s | 2.8 kB 00:00
Red Hat Enterprise Linux 8 for x86_64 - Supplem 39 kB/s | 2.1 kB 00:00
Red Hat Enterprise Linux 8 for x86_64 - BaseOS 46 kB/s | 2.4 kB 00:00
Red Hat Satellite Tools 6.6 for RHEL 8 x86_64 ( 41 kB/s | 2.1 kB 00:00
[MIRROR] pgdg-redhat-repo-latest.noarch.rpm: Curl error (28): Timeout was reached for .noarch.rpm [Connection timed out after 30000 milliseconds]
[MIRROR] pgdg-redhat-repo-latest.noarch.rpm: Curl error (28): Timeout was reached for .noarch.rpm [Connection timed out after 30000 milliseconds]
[MIRROR] pgdg-redhat-repo-latest.noarch.rpm: Curl error (28): Timeout was reached for .noarch.rpm [Connection timed out after 30000 milliseconds]
pgdg-redhat-repo-latest.noarch.rpm 170 B/s | 15 kB 01:30
Package pgdg-redhat-repo-42.0-45PGDG.noarch is already installed.
Dependencies resolved.
Nothing to do.
The issue is inconsistent, it will install it sometimes and then sometimes it will hang,
It would be great if someone could help identify why I am facing the hanging issue with this, or any tips on best practice for this install
本文标签: Postgresql dnf install issues when running from python subprocess scriptStack Overflow
版权声明:本文标题:Postgresql dnf install issues when running from python subprocess script - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745618319a2159423.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论