Make quotes more uniform
authorAntoine Busque <antoinebusque@gmail.com>
Fri, 16 May 2014 14:52:29 +0000 (10:52 -0400)
committerAntoine Busque <antoinebusque@gmail.com>
Fri, 16 May 2014 14:52:29 +0000 (10:52 -0400)
fd-info.py

index 869c1a02a4411407a5ea5710cd046c36d9d577f3..40f63dcb78ffe9d581a96f12daa393caf6f4f3ea 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
+# of this software and associated documentation files (the 'Software'), to deal
 # in the Software without restriction, including without limitation the rights
 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 # copies of the Software, and to permit persons to whom the Software is
@@ -31,14 +31,14 @@ class FDInfo():
         self.tids = {}
         self.disks = {}
         self.syscalls = {}
-        self.open_syscalls = ["sys_open", "sys_openat"]
-        self.close_syscalls = ["sys_close"]
+        self.open_syscalls = ['sys_open', 'sys_openat']
+        self.close_syscalls = ['sys_close']
 
 
     def process_event(self, event, sched, syscall, statedump, started=1):
-        if event.name == "sched_switch":
+        if event.name == 'sched_switch':
             sched.switch(event)
-        elif event.name.startswith("sys_"):
+        elif event.name.startswith('sys_'):
             if event.name in self.open_syscalls \
             and self.isOutputEnabled['open']:
                 self.output_open(event)
@@ -46,20 +46,20 @@ class FDInfo():
             and self.isOutputEnabled['close']:
                 self.output_close(event)
             syscall.entry(event)
-        elif event.name == "exit_syscall":
+        elif event.name == 'exit_syscall':
             syscall.exit(event, started)
-        elif event.name == "sched_process_fork":
+        elif event.name == 'sched_process_fork':
             sched.process_fork(event)
-        elif event.name == "lttng_statedump_process_state":
+        elif event.name == 'lttng_statedump_process_state':
             statedump.process_state(event)
-        elif event.name == "lttng_statedump_file_descriptor":
+        elif event.name == 'lttng_statedump_file_descriptor':
             statedump.file_descriptor(event)
             if self.isOutputEnabled['dump']:
                 self.output_dump(event)
 
 
     def run(self, args):
-        """Process the trace"""
+        '''Process the trace'''
         self.current_sec = 0
         self.start_ns = 0
         self.end_ns = 0
@@ -72,31 +72,31 @@ class FDInfo():
             self.process_event(event, sched, syscall, statedump)
 
     def output_dump(self, event):
-        pid = event["pid"]
+        pid = event['pid']
         comm = self.tids[pid].comm
         evt = event.name
-        filename = event["filename"]
-        time = "File opened before trace"
+        filename = event['filename']
+        time = 'File opened before trace'
 
         if filename.startswith(self.prefix):
             print(pid, comm, evt, filename, time)
             
     def output_open(self, event):
-        pid = self.cpus[event["cpu_id"]].current_tid
+        pid = self.cpus[event['cpu_id']].current_tid
         comm = self.tids[pid].comm
         evt = event.name
-        filename = event["filename"]
+        filename = event['filename']
         time = ns_to_asctime(event.timestamp)
         
         if filename.startswith(self.prefix):
             print(pid, comm, evt, filename, time)
 
     def output_close(self, event):
-        pid = self.cpus[event["cpu_id"]].current_tid
+        pid = self.cpus[event['cpu_id']].current_tid
         comm = self.tids[pid].comm
         evt = event.name
         fds = self.tids[pid].fds
-        fd = event["fd"]
+        fd = event['fd']
         if not fd in fds.keys():
             return
         filename = fds[fd].filename
@@ -105,12 +105,12 @@ class FDInfo():
         if filename.startswith(self.prefix):
             print(pid, comm, evt, filename, time)
 
-if __name__ == "__main__":
+if __name__ == '__main__':
     parser = argparse.ArgumentParser(description='FD syscalls analysis')
-    parser.add_argument('path', metavar="<path/to/trace>", help='Trace path')
-    parser.add_argument('-p', '--prefix', type=str, default="/",
+    parser.add_argument('path', metavar='<path/to/trace>', help='Trace path')
+    parser.add_argument('-p', '--prefix', type=str, default='/',
                         help='Prefix in which to search')
-    parser.add_argument('-t', '--type', type=str, default="all",
+    parser.add_argument('-t', '--type', type=str, default='all',
         help='Types of events to display. Possible values: all, open, close, dump')
 
     args = parser.parse_args()
@@ -133,7 +133,7 @@ if __name__ == "__main__":
                 sys.exit(1)
     
     traces = TraceCollection()
-    handle = traces.add_trace(args.path, "ctf")
+    handle = traces.add_trace(args.path, 'ctf')
     if handle is None:
         sys.exit(1)
 
This page took 0.028737 seconds and 5 git commands to generate.