[elbe-devel] [PATCH 2/2] elbepack: initvm: remove unneeded function ensure_outdir()

Thomas Weißschuh thomas.weissschuh at linutronix.de
Mon Jul 22 10:42:33 CEST 2024


The function is effectively the same as default option value.
Just more complicated.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/commands/initvm.py |  4 +++-
 elbepack/initvmaction.py    | 14 +-------------
 2 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/elbepack/commands/initvm.py b/elbepack/commands/initvm.py
index 3bfe6ab32944..306457068755 100644
--- a/elbepack/commands/initvm.py
+++ b/elbepack/commands/initvm.py
@@ -2,6 +2,7 @@
 # SPDX-License-Identifier: GPL-3.0-or-later
 # SPDX-FileCopyrightText: 2015-2017 Linutronix GmbH
 
+import datetime
 import os
 import sys
 from optparse import OptionParser, SUPPRESS_HELP
@@ -27,7 +28,8 @@ def run_command(argv):
                        dest='skip_download', default=False,
                        help='Skip downloading generated Files')
 
-    oparser.add_option('--output', dest='outdir', default=None,
+    oparser.add_option('--output', dest='outdir',
+                       default='elbe-build-' + datetime.datetime.now().strftime('%Y%m%d-%H%M%S'),
                        help='directory where to save downloaded Files')
 
     oparser.add_option(
diff --git a/elbepack/initvmaction.py b/elbepack/initvmaction.py
index 61d78d36dbed..6f5751ba52d4 100644
--- a/elbepack/initvmaction.py
+++ b/elbepack/initvmaction.py
@@ -4,7 +4,6 @@
 # SPDX-FileCopyrightText: 2015 Silvio Fricke <silvio.fricke at gmail.com>
 
 import contextlib
-import datetime
 import io
 import os
 import shutil
@@ -29,17 +28,6 @@ def is_soap_local():
 
 prog = os.path.basename(sys.argv[0])
 
-# Create download directory with timestamp,
-# if necessary
-
-
-def ensure_outdir(opt):
-    if opt.outdir is None:
-        opt.outdir = (
-            f"elbe-build-{datetime.datetime.now().strftime('%Y%m%d-%H%M%S')}")
-
-    print(f'Saving generated Files to {opt.outdir}')
-
 
 class InitVMError(Exception):
     pass
@@ -596,7 +584,7 @@ def submit_and_dl_result(xmlfile, cdrom, opt):
         print('Getting generated Files')
         print('')
 
-        ensure_outdir(opt)
+        print(f'Saving generated Files to {opt.outdir}')
 
         try:
             run_elbe(['control', 'get_files', '--output', opt.outdir, prjdir], check=True)

-- 
2.45.2



More information about the elbe-devel mailing list