Skip to content

Commit 8c6a6e1

Browse files
committed
add some timeouts
1 parent 1d02cd7 commit 8c6a6e1

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

build-rpm.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ def clone_repo(git_repo, project_version):
185185
for i in range(tries):
186186
try:
187187
print('cloning [{}], branch: [{}] to [{}]'.format(git_repo, project_version, build_package))
188-
subprocess.check_output(['/usr/bin/git', 'clone', git_repo, build_package])
189-
subprocess.check_output(['git', 'checkout', project_version], cwd=build_package)
188+
subprocess.check_output(['git', 'clone', git_repo, build_package], timeout=3600, env={'LC_ALL': 'C.UTF-8'})
189+
subprocess.check_output(['git', 'checkout', project_version], cwd=build_package, timeout=3600, env={'LC_ALL': 'C.UTF-8'})
190190
except subprocess.CalledProcessError:
191191
if i < tries - 1:
192192
time.sleep(5)
@@ -196,13 +196,14 @@ def clone_repo(git_repo, project_version):
196196
sys.exit(1)
197197
break
198198
# generate commit_id
199-
git_commit = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=build_package)
199+
git_commit = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=build_package, timeout=3600, env={'LC_ALL': 'C.UTF-8'})
200200
print(git_commit.decode('utf-8'), file=open(get_home + '/commit_hash', "a"))
201201

202202

203203
def hash_file(rpm):
204-
""""This function returns the SHA-1 hash
205-
of the file passed into it"""
204+
# This function returns the SHA-1 hash
205+
# of the file passed into it
206+
206207
# make a hash object
207208
h = hashlib.sha1()
208209
# open file for reading in binary mode
@@ -259,7 +260,7 @@ def container_data():
259260
full_list = []
260261
if not os.path.basename(pkg).endswith("src.rpm"):
261262
try:
262-
dependencies = subprocess.check_output(['dnf', 'repoquery', '-q', '--latest-limit=1', '--qf', '%{NAME}', '--whatrequires', name])
263+
dependencies = subprocess.check_output(['dnf', 'repoquery', '-q', '--latest-limit=1', '--qf', '%{NAME}', '--whatrequires', name], timeout=3600, env={'LC_ALL': 'C.UTF-8'})
263264
full_list = dependencies.decode().split('\n')
264265
except subprocess.CalledProcessError:
265266
print('some problem with dnf repoquery for %s' % name)
@@ -505,7 +506,7 @@ def cleanup_all():
505506
for dirs in ["/var/lib/mock/{}-{}".format(platform_name, platform_arch) + s for s in umount_dirs]:
506507
if os.path.exists(dirs):
507508
try:
508-
subprocess.check_output(['sudo', 'umount', '-ql', dirs])
509+
subprocess.check_output(['sudo', 'umount', '-ql', dirs], text=True)
509510
except subprocess.CalledProcessError as e:
510511
print(e.output)
511512
continue

0 commit comments

Comments
 (0)