refs #1101 add ogUcastSendFile()
parent
d75e8a56fa
commit
40f31f784c
|
@ -183,6 +183,61 @@ def ogUcastReceiverPartition (disk, par, sess, tool, level):
|
|||
#*/ ##
|
||||
#
|
||||
|
||||
## TODO esta función es idéntica a ogMcastSendFile pero con s/Ucast/Mcast/;
|
||||
|
||||
#ogUcastSendFile ([str_REPOSITORY] [int_ndisk int_npart] /Relative_path_file sesionMcast(puerto:ip:ip:ip)" \
|
||||
#ogUcastSendFile (disk=1, par=1, file='/aula1/winxp.img', sess='8000:172.17.36.11:172.17.36.12')
|
||||
#ogUcastSendFile (take_from='REPO', file='/aula1/ubuntu.iso', sess='sesionUcast')
|
||||
#ogUcastSendFile (take_from='CACHE', file='/aula1/winxp.img', sess='sesionUcast')
|
||||
#ogUcastSendFile ( file='/opt/opengnsys/images/aula1/hd500.vmx', sess='sesionUcast')
|
||||
def ogUcastSendFile (disk=None, par=None, take_from=None, file=None, sess=None):
|
||||
if file is None:
|
||||
raise TypeError ('missing required argument: "file"')
|
||||
if sess is None:
|
||||
raise TypeError ('missing required argument: "sess"')
|
||||
|
||||
if take_from is not None:
|
||||
if disk is None and par is None:
|
||||
## we were given take_from=
|
||||
source = FileLib.ogGetPath (src=take_from, file=file)
|
||||
dev_err = f'{take_from} {file}'
|
||||
print (f'ogGetPath (src=({take_from}), file=({file})) = source ({source})')
|
||||
else:
|
||||
raise TypeError ('argument "take_from" can be specified along neither "disk" nor "par"')
|
||||
|
||||
else:
|
||||
if disk is not None and par is not None:
|
||||
## we were given disk= par=
|
||||
source = FileLib.ogGetPath (src=f'{disk} {par}', file=file)
|
||||
dev_err = f'{disk} {par} {file}'
|
||||
print (f'ogGetPath (src=({disk} {par}), file=({file})) = source ({source})')
|
||||
elif disk is None and par is None:
|
||||
## we were given nothing
|
||||
source = FileLib.ogGetPath (file=file)
|
||||
dev_err = file
|
||||
print (f'ogGetPath (file=({file})) = source ({source})')
|
||||
else:
|
||||
raise TypeError ('if one of "disk" and "par" are specified, then both must be')
|
||||
|
||||
if not source:
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, f'device or file {dev_err} not found')
|
||||
return
|
||||
|
||||
path2 = FileLib.ogGetPath (file=source)
|
||||
print (f'path2 ({path2})')
|
||||
if not path2:
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, f'device or file {dev_err} not found')
|
||||
return
|
||||
|
||||
cmd = ogUcastSyntax ('SENDFILE', sess, file=source)
|
||||
if not cmd: return None
|
||||
print (f'cmd ({cmd})')
|
||||
try:
|
||||
subprocess.run (cmd, shell=True, check=True)
|
||||
except subprocess.CalledProcessError:
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_UCASTSENDFILE, ' ')
|
||||
return None
|
||||
|
||||
def _clientip():
|
||||
ipas = subprocess.run (['ip', '-json', 'address', 'show', 'up'], capture_output=True, text=True).stdout
|
||||
ipasj = json.loads (ipas)
|
||||
|
|
Loading…
Reference in New Issue