refs #631 - Modify 'sendFileMcast.py' and 'sendFileUFTP.py'
parent
e4d5d72a9c
commit
9eea598cb0
|
@ -7,21 +7,27 @@ En principio, debería hacer lo mismo que el script bash original (cuyo nombre e
|
||||||
|
|
||||||
Parámetros
|
Parámetros
|
||||||
------------
|
------------
|
||||||
sys.argv[1] - Nombre completo de la imagen a enviar (con o sin ruta)
|
sys.argv[1] - Nombre completo de la imagen a enviar (con o sin ruta), pero incluyendo el subdirectorio correspondiente a la OU, si es el caso.
|
||||||
- Ejemplo1: image1.img
|
- Ejemplo1: image1.img
|
||||||
- Ejemplo2: /opt/opengnsys/images/image1.img
|
- Ejemplo2: /opt/opengnsys/images/image1.img
|
||||||
|
- Ejemplo3: ou_subdir/image1.img
|
||||||
|
- Ejemplo4: /ou_subdir/image1.img
|
||||||
|
- Ejemplo5: /opt/opengnsys/images/ou_subdir/image1.img
|
||||||
|
|
||||||
sys.argv[2] - Parámetros Multicast (en formato "Port:Duplex:IP:Mpbs:Nclients:Timeout")
|
sys.argv[2] - Parámetros Multicast (en formato "Port:Duplex:IP:Mpbs:Nclients:Timeout")
|
||||||
- Ejemplo: 9000:full:239.194.17.2:70M:20:120
|
- Ejemplo: 9000:full:239.194.17.2:70M:20:120
|
||||||
|
|
||||||
Sintaxis
|
Sintaxis
|
||||||
----------
|
----------
|
||||||
./sendFileMcast.py image_name|/image_path/image_name Port:Duplex:IP:Mpbs:Nclients:Timeout
|
./sendFileMcast.py [ou_subdir/]image_name|/image_path/image_name Port:Duplex:IP:Mpbs:Nclients:Timeout
|
||||||
|
|
||||||
Ejemplos
|
Ejemplos
|
||||||
---------
|
---------
|
||||||
./sendFileMcast.py image1.img 9000:full:239.194.17.2:70M:20:120
|
./sendFileMcast.py image1.img 9000:full:239.194.17.2:70M:20:120
|
||||||
./sendFileMcast.py /opt/opengnsys/images/image1.img 9000:full:239.194.17.2:70M:20:120
|
./sendFileMcast.py /opt/opengnsys/images/image1.img 9000:full:239.194.17.2:70M:20:120
|
||||||
|
./sendFileMcast.py ou_subdir/image1.img 9000:full:239.194.17.2:70M:20:120
|
||||||
|
./sendFileMcast.py /ou_subdir/image1.img 9000:full:239.194.17.2:70M:20:120
|
||||||
|
./sendFileMcast.py /opt/opengnsys/images/ou_subdir/image1.img 9000:full:239.194.17.2:70M:20:120
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# --------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------------
|
||||||
|
@ -52,9 +58,12 @@ def show_help():
|
||||||
""" Imprime la ayuda, cuando se ejecuta el script con el parámetro "help".
|
""" Imprime la ayuda, cuando se ejecuta el script con el parámetro "help".
|
||||||
"""
|
"""
|
||||||
help_text = f"""
|
help_text = f"""
|
||||||
Sintaxis: {script_name} image_name|/image_path/image_name Port:Duplex:IP:Mpbs:Nclients:Timeout
|
Sintaxis: {script_name} [ou_subdir/]image_name|/image_path/image_name Port:Duplex:IP:Mpbs:Nclients:Timeout
|
||||||
Ejemplo1: {script_name} image1.img 9000:full-duplex:239.194.17.2:70M:20:120
|
Ejemplo1: {script_name} image1.img 9000:full-duplex:239.194.17.2:70M:20:120
|
||||||
Ejemplo2: {script_name} /opt/opengnsys/images/image1.img 9000:full-duplex:239.194.17.2:70M:20:120
|
Ejemplo2: {script_name} /opt/opengnsys/images/image1.img 9000:full-duplex:239.194.17.2:70M:20:120
|
||||||
|
Ejemplo3: {script_name} ou_subdir/image1.img 9000:full-duplex:239.194.17.2:70M:20:120
|
||||||
|
Ejemplo4: {script_name} /ou_subdir/image1.img 9000:full-duplex:239.194.17.2:70M:20:120
|
||||||
|
Ejemplo5: {script_name} /opt/opengnsys/images/ou_subdir/image1.img 9000:full-duplex:239.194.17.2:70M:20:120
|
||||||
"""
|
"""
|
||||||
print(help_text)
|
print(help_text)
|
||||||
|
|
||||||
|
@ -84,6 +93,11 @@ def build_file_path():
|
||||||
(agregando "/opt/opengnsys/images/" si no se ha especificado en el parámetro).
|
(agregando "/opt/opengnsys/images/" si no se ha especificado en el parámetro).
|
||||||
"""
|
"""
|
||||||
param_path = sys.argv[1]
|
param_path = sys.argv[1]
|
||||||
|
# Si la ruta comienza con una barra, pero que no corresponde a "repo_path"
|
||||||
|
# (porque corresponderá al subdirectorio de una OU), eliminamos la barra:
|
||||||
|
if param_path.startswith('/') and not param_path.startswith(repo_path):
|
||||||
|
param_path = param_path.lstrip('/')
|
||||||
|
# Construimos la ruta completa:
|
||||||
if not param_path.startswith(repo_path):
|
if not param_path.startswith(repo_path):
|
||||||
file_path = os.path.join(repo_path, param_path)
|
file_path = os.path.join(repo_path, param_path)
|
||||||
else:
|
else:
|
||||||
|
@ -107,6 +121,7 @@ def get_repo_iface():
|
||||||
sys.exit(4)
|
sys.exit(4)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
# --------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------------
|
||||||
|
@ -141,11 +156,8 @@ def main():
|
||||||
repo_iface = get_repo_iface()
|
repo_iface = get_repo_iface()
|
||||||
|
|
||||||
# Creamos una lista con el comando a enviar (esto es requerido por la función "subprocess.run").
|
# Creamos una lista con el comando a enviar (esto es requerido por la función "subprocess.run").
|
||||||
# NOTA: Se desabilita el uso de mbuffer, ya que esta versión del upd-sender no la admite (ya estaba así en el script original).
|
|
||||||
mbuffer = "" # which mbuffer &> /dev/null && MBUFFER="--pipe 'mbuffer -m 20M'"
|
|
||||||
splitted_cmd = [
|
splitted_cmd = [
|
||||||
os.path.join(bin_path, 'udp-sender'),
|
os.path.join(bin_path, 'udp-sender'),
|
||||||
mbuffer,
|
|
||||||
'--nokbd',
|
'--nokbd',
|
||||||
'--retries-until-drop', '65',
|
'--retries-until-drop', '65',
|
||||||
'--portbase', port,
|
'--portbase', port,
|
||||||
|
@ -157,6 +169,7 @@ def main():
|
||||||
'--ttl', '16',
|
'--ttl', '16',
|
||||||
'--min-clients', nclients,
|
'--min-clients', nclients,
|
||||||
'--max-wait', maxtime,
|
'--max-wait', maxtime,
|
||||||
|
'--autostart', '20', # Esto hace que empiece el envío automáticamente a los 20 segundos (desde ogLive le envían "120", pero con ese valor da timeout)
|
||||||
'--file', file_path
|
'--file', file_path
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,12 @@ Paquetes APT requeridos: "uftp"
|
||||||
|
|
||||||
Parámetros
|
Parámetros
|
||||||
------------
|
------------
|
||||||
sys.argv[1] - Nombre completo de la imagen a enviar (con o sin ruta)
|
sys.argv[1] - Nombre completo de la imagen a enviar (con o sin ruta), pero incluyendo el subdirectorio correspondiente a la OU, si es el caso.
|
||||||
- Ejemplo1: image1.img
|
- Ejemplo1: image1.img
|
||||||
- Ejemplo2: /opt/opengnsys/images/image1.img
|
- Ejemplo2: /opt/opengnsys/images/image1.img
|
||||||
|
- Ejemplo3: ou_subdir/image1.img
|
||||||
|
- Ejemplo4: /ou_subdir/image1.img
|
||||||
|
- Ejemplo5: /opt/opengnsys/images/ou_subdir/image1.img
|
||||||
|
|
||||||
sys.argv[2] - Parámetros Multicast/Unicast (en formato "Port:IP:Bitrate")
|
sys.argv[2] - Parámetros Multicast/Unicast (en formato "Port:IP:Bitrate")
|
||||||
- Ejemplo1: 9000:239.194.17.2:100M
|
- Ejemplo1: 9000:239.194.17.2:100M
|
||||||
|
@ -20,12 +23,15 @@ sys.argv[2] - Parámetros Multicast/Unicast (en formato "Port:IP:Bitrate")
|
||||||
|
|
||||||
Sintaxis
|
Sintaxis
|
||||||
----------
|
----------
|
||||||
./sendFileUFTP.py image_name|/image_path/image_name Port:IP:Bitrate
|
./sendFileUFTP.py [ou_subdir/]image_name|/image_path/image_name Port:IP:Bitrate
|
||||||
|
|
||||||
Ejemplos
|
Ejemplos
|
||||||
---------
|
---------
|
||||||
./sendFileUFTP.py image1.img 9000:239.194.17.2:100M
|
./sendFileUFTP.py image1.img 9000:239.194.17.2:100M
|
||||||
./sendFileUFTP.py /opt/opengnsys/images/image1.img 9000:192.168.56.101:1G
|
./sendFileUFTP.py /opt/opengnsys/images/image1.img 9000:239.194.17.2:100M
|
||||||
|
./sendFileUFTP.py ou_subdir/image1.img 9000:192.168.56.101:1G
|
||||||
|
./sendFileUFTP.py /ou_subdir/image1.img 9000:192.168.56.101:1G
|
||||||
|
./sendFileUFTP.py /opt/opengnsys/images/ou_subdir/image1.img 9000:192.168.56.101:1G
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# --------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------------
|
||||||
|
@ -55,9 +61,12 @@ def show_help():
|
||||||
""" Imprime la ayuda, cuando se ejecuta el script con el parámetro "help".
|
""" Imprime la ayuda, cuando se ejecuta el script con el parámetro "help".
|
||||||
"""
|
"""
|
||||||
help_text = f"""
|
help_text = f"""
|
||||||
Sintaxis: {script_name} image_name|/image_path/image_name Port:IP:Bitrate
|
Sintaxis: {script_name} [ou_subdir/]image_name|/image_path/image_name Port:IP:Bitrate
|
||||||
Ejemplo1: {script_name} image1.img 9000:239.194.17.2:100M
|
Ejemplo1: {script_name} image1.img 9000:239.194.17.2:100M
|
||||||
Ejemplo2: {script_name} /opt/opengnsys/images/image1.img 9000:192.168.56.101:1G
|
Ejemplo2: {script_name} /opt/opengnsys/images/image1.img 9000:239.194.17.2:100M
|
||||||
|
Ejemplo3: {script_name} ou_subdir/image1.img 9000:192.168.56.101:1G
|
||||||
|
Ejemplo4: {script_name} /ou_subdir/image1.img 9000:192.168.56.101:1G
|
||||||
|
Ejemplo5: {script_name} /opt/opengnsys/images/ou_subdir/image1.img 9000:192.168.56.101:1G
|
||||||
"""
|
"""
|
||||||
print(help_text)
|
print(help_text)
|
||||||
|
|
||||||
|
@ -87,6 +96,11 @@ def build_file_path():
|
||||||
(agregando "/opt/opengnsys/images/" si no se ha especificado en el parámetro).
|
(agregando "/opt/opengnsys/images/" si no se ha especificado en el parámetro).
|
||||||
"""
|
"""
|
||||||
param_path = sys.argv[1]
|
param_path = sys.argv[1]
|
||||||
|
# Si la ruta comienza con una barra, pero que no corresponde a "repo_path"
|
||||||
|
# (porque corresponderá al subdirectorio de una OU), eliminamos la barra:
|
||||||
|
if param_path.startswith('/') and not param_path.startswith(repo_path):
|
||||||
|
param_path = param_path.lstrip('/')
|
||||||
|
# Construimos la ruta completa:
|
||||||
if not param_path.startswith(repo_path):
|
if not param_path.startswith(repo_path):
|
||||||
file_path = os.path.join(repo_path, param_path)
|
file_path = os.path.join(repo_path, param_path)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue