diff options
author | Roberto Hueso Gómez <rhueso@soleta.eu> | 2020-02-05 13:39:39 +0100 |
---|---|---|
committer | Alvaro Neira Ayuso <aneira@soleta.eu> | 2020-02-05 16:49:37 +0100 |
commit | 1c236b4548ec8ac9511e6c608179a2baed850a12 (patch) | |
tree | a27430da30dad1640533a94cca802de64716cc4a | |
parent | eaba1acbc37df6685cd991815e94bfcee46f3fa9 (diff) |
Use python f-strings for commands composition
-rw-r--r-- | src/linux/ogOperations.py | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/linux/ogOperations.py b/src/linux/ogOperations.py index 605bde9..483e7f2 100644 --- a/src/linux/ogOperations.py +++ b/src/linux/ogOperations.py @@ -79,10 +79,9 @@ def software(request, path, ogRest): partition = request.getPartition() try: - cmd = OG_PATH + 'interfaceAdm/InventarioSoftware ' - cmd += str(disk) + ' ' - cmd += str(partition) + ' ' - cmd += path + cmd = f'{OG_PATH}interfaceAdm/InventarioSoftware {disk} ' \ + f'{partition} {path}' + ogRest.proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, shell=True) @@ -94,8 +93,8 @@ def software(request, path, ogRest): def hardware(path, ogRest): try: - cmd = [OG_PATH + 'interfaceAdm/InventarioHardware ' + path] - ogRest.proc = subprocess.Popen(cmd, + cmd = f'{OG_PATH}interfaceAdm/InventarioHardware {path}' + ogRest.proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, shell=True) (output, error) = ogRest.proc.communicate() @@ -107,19 +106,19 @@ def hardware(path, ogRest): def setup(request, ogRest): disk = request.getDisk() cache = request.getCache() - cachesize = request.getCacheSize() + cache_size = request.getCacheSize() partlist = request.getPartitionSetup() - listConfigs = [] - cfg = 'dis=' + disk + '*che=' + cache + '*tch=' + cachesize + '!' + cfg = f'dis={disk}*che={cache}*tch={cache_size}!' for part in partlist: - cfg += 'par=' + part["partition"] + '*cpt='+part["code"] + \ - '*sfi=' + part['filesystem'] + '*tam=' + \ - part['size'] + '*ope=' + part['format'] + '%' + cfg += f'par={part["partition"]}*cpt={part["code"]}*' \ + f'sfi={part["filesystem"]}*tam={part["size"]}*' \ + f'ope={part["format"]}%' + if ogRest.terminated: break - cmd = OG_PATH + 'interfaceAdm/Configurar' + " " + disk + " " + cfg + cmd = f'{OG_PATH}interfaceAdm/Configurar {disk} {cfg}' try: ogRest.proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, @@ -186,7 +185,7 @@ def image_create(path, request, ogRest): def refresh(ogRest): try: - cmd = OG_PATH + 'interfaceAdm/getConfiguration' + cmd = f'{OG_PATH}interfaceAdm/getConfiguration' ogRest.proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, shell=True) |