Motr  M0
main.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright (c) 2020 Seagate Technology LLC and/or its Affiliates
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 # For any questions about this software or licensing,
18 # please email opensource@seagate.com or cortx-questions@seagate.com.
19 #
20 
21 
22 import fileinput
23 import record
24 import getopt
25 import sys
26 
27 def recdone(tr, rec):
28  if rec != None:
29  rec.done(tr)
30 
31 def processinput(argv):
32  kw = {
33  "height" : 1000000,
34  "width" : 40000,
35  "loc_nr" : 4,
36  "duration" : 100,
37  "step" : 100,
38  "starttime" : None
39  }
40  xlate = {
41  "-h" : ("height", int, "Output image height in pixels."),
42  "-w" : ("width", int, "Output image width in pixels."),
43  "-v" : ("verbosity", int, "Verbosity level."),
44  "-d" : ("duration", float, "Duration of the part of the input"
45  " to process in seconds."),
46  "-l" : ("loc_nr", int, "Number of localities in the analysed"
47  " process. If 1, localities are ignored."),
48  "-s" : ("step", int, "Milliseconds between timestamp axes."),
49  "-f" : ("maxfom", int, "Maximum number of foms per locality."),
50  "-t" : ("starttime", str, "Timestamp in the addb format at which"
51  " output generation starts."),
52  "-L" : ("label", int, "If 0, omit text labels,"),
53  "-o" : ("outname", str, "Output file name.")
54  }
55  try:
56  opts, args = getopt.getopt(argv[1:], "h:w:l:d:s:t:o:f:v:L:")
57  except getopt.GetoptError:
58  print "{} [options]\n\nOptions:\n".format(argv[0])
59  for k in xlate:
60  print " {} : {}".format(k, xlate[k][2])
61  sys.exit(2)
62  for opt, arg in opts:
63  xl = xlate[opt]
64  kw[xl[0]] = xl[1](arg)
65 
66  tr = record.trace(**kw)
67  rec = None;
68  for line in fileinput.input([]):
69  params = line[1:].split()
70  if line[0] == "*":
71  recdone(tr, rec)
72  rec = record.parse(tr, params)
73  elif line[0] == "|":
74  if rec != None:
75  rec.add(params)
76  else:
77  assert False
78  recdone(tr, rec)
79  tr.done()
80 
81 if __name__ == "__main__":
82  processinput(sys.argv)
83 
84 
static void split(m0_bindex_t offset, int nr, bool commit)
Definition: extmap.c:230
def recdone(tr, rec)
Definition: main.py:27
format
Definition: hist.py:128
def processinput(argv)
Definition: main.py:31