Recent changes (master)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The following changes since commit cab9bedf70f34142b70cf97bf4d8c8df57a6f82f:

  examples: remove test.png (2023-01-19 13:10:22 -0500)

are available in the Git repository at:

  git://git.kernel.dk/fio.git master

for you to fetch changes up to 13bc47b65d32df6fd212c4687c7fd29b4ab7c09d:

  tools/fiograph: accommodate job files not ending in .fio (2023-01-23 13:51:16 -0500)

----------------------------------------------------------------
Vincent Fu (1):
      tools/fiograph: accommodate job files not ending in .fio

 tools/fiograph/fiograph.py | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

---

Diff of recent changes:

diff --git a/tools/fiograph/fiograph.py b/tools/fiograph/fiograph.py
index 86ed40a8..cfb9b041 100755
--- a/tools/fiograph/fiograph.py
+++ b/tools/fiograph/fiograph.py
@@ -1,4 +1,6 @@
 #!/usr/bin/env python3
+import uuid
+import time
 import errno
 from graphviz import Digraph
 import argparse
@@ -293,13 +295,6 @@ def main():
     global config_file
     args = setup_commandline()
 
-    if args.output is None:
-        output_file = args.file
-        if output_file.endswith('.fio'):
-            output_file = output_file[:-4]
-    else:
-        output_file = args.output
-
     if args.config is None:
         if os.path.exists('fiograph.conf'):
             config_filename = 'fiograph.conf'
@@ -312,9 +307,25 @@ def main():
     config_file = configparser.RawConfigParser(allow_no_value=True)
     config_file.read(config_filename)
 
-    fio_to_graphviz(args.file, args.format).render(output_file, view=args.view)
+    temp_filename = uuid.uuid4().hex
+    image_filename = fio_to_graphviz(args.file, args.format).render(temp_filename, view=args.view)
+
+    output_filename_stub = args.file
+    if args.output:
+        output_filename = args.output
+    else:
+        if output_filename_stub.endswith('.fio'):
+            output_filename_stub = output_filename_stub[:-4]
+        output_filename = image_filename.replace(temp_filename, output_filename_stub)
+    if args.view:
+        time.sleep(1)
+        # allow time for the file to be opened before renaming it
+    os.rename(image_filename, output_filename)
+
     if not args.keep:
-        os.remove(output_file)
+        os.remove(temp_filename)
+    else:
+        os.rename(temp_filename, output_filename_stub + '.gv')
 
 
 main()



[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux