Stupid python3 issue in helpers

This commit is contained in:
Alexandre Aubin 2021-06-07 16:39:06 +02:00
parent 8a5213c88b
commit bd196c875b
2 changed files with 3 additions and 3 deletions

View file

@ -207,14 +207,14 @@ ynh_restore () {
# usage: _get_archive_path ORIGIN_PATH # usage: _get_archive_path ORIGIN_PATH
_get_archive_path () { _get_archive_path () {
# For security reasons we use csv python library to read the CSV # For security reasons we use csv python library to read the CSV
python -c " python3 -c "
import sys import sys
import csv import csv
with open(sys.argv[1], 'r') as backup_file: with open(sys.argv[1], 'r') as backup_file:
backup_csv = csv.DictReader(backup_file, fieldnames=['source', 'dest']) backup_csv = csv.DictReader(backup_file, fieldnames=['source', 'dest'])
for row in backup_csv: for row in backup_csv:
if row['source']==sys.argv[2].strip('\"'): if row['source']==sys.argv[2].strip('\"'):
print row['dest'] print(row['dest'])
sys.exit(0) sys.exit(0)
raise Exception('Original path for %s not found' % sys.argv[2]) raise Exception('Original path for %s not found' % sys.argv[2])
" "${YNH_BACKUP_CSV}" "$1" " "${YNH_BACKUP_CSV}" "$1"

View file

@ -80,7 +80,7 @@ ynh_validate_ip()
[ "$family" == "4" ] || [ "$family" == "6" ] || return 1 [ "$family" == "4" ] || [ "$family" == "6" ] || return 1
python /dev/stdin << EOF python3 /dev/stdin << EOF
import socket import socket
import sys import sys
family = { "4" : socket.AF_INET, "6" : socket.AF_INET6 } family = { "4" : socket.AF_INET, "6" : socket.AF_INET6 }