sysview-py 0.4.4__tar.gz → 0.4.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sysview-py
3
- Version: 0.4.4
3
+ Version: 0.4.6
4
4
  Summary: Add your description here
5
5
  Author: Michael Wilson
6
6
  Author-email: Michael Wilson <mw@1wilson.org>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sysview-py"
3
- version = "0.4.4"
3
+ version = "0.4.6"
4
4
  description = "Add your description here"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -76,6 +76,8 @@ class ReportItem:
76
76
  host=None,
77
77
  report_type=None,
78
78
  report_id=None,
79
+ is_only_item=False,
80
+ is_history_item=False
79
81
  ):
80
82
  self.raw_item = raw_item
81
83
  self.command = command
@@ -86,6 +88,8 @@ class ReportItem:
86
88
  self.report_type = report_type
87
89
  self.report_id = report_id
88
90
  self.host = host
91
+ self.is_only_item = is_only_item
92
+ self.is_history_item = is_history_item
89
93
 
90
94
  def __repr__(self):
91
95
  return f"ReportItem(command={self.command}, status={self.status})"
@@ -97,7 +101,9 @@ class ReportItem:
97
101
  @property
98
102
  def name(self):
99
103
  result = self.command
100
- if len(result) > self.max_name_length:
104
+ if self.is_only_item:
105
+ result = self.report_type
106
+ elif len(result) > self.max_name_length:
101
107
  result = result[: self.max_name_length]
102
108
  return result
103
109
 
@@ -113,7 +119,7 @@ class ReportItem:
113
119
  def status(self):
114
120
  status = self._status
115
121
  threshold = timedelta(days=1)
116
- if self.date is not None:
122
+ if self.date is not None and not self.is_history_item:
117
123
  age = datetime.now() - self.date
118
124
  if age > threshold:
119
125
  status = "UNKNOWN"
@@ -201,8 +207,9 @@ class Report:
201
207
  if line.startswith("Hostname:") and item_pointer == 0:
202
208
  self.hostname = line.split(":")[1].strip()
203
209
  elif line.startswith("Date:") and item_pointer == 0:
210
+ pass
204
211
  raw_date = line.replace("Date:", "").strip()
205
- self.date = datetime.strptime(raw_date, "%a %b %d %X %Z %Y")
212
+ #self.date = datetime.strptime(raw_date, "%a %b %d %X %Z %Y")
206
213
  elif line.startswith("Type:") and item_pointer == 0:
207
214
  self.type = "".join(line.split(":")[1].strip())
208
215
  elif item_pointer > 0 and line != "---":
@@ -220,4 +227,6 @@ class Report:
220
227
  item.parse()
221
228
  self.items.append(item)
222
229
  self.items.sort(key=lambda item: item.status_code, reverse=True)
230
+ if len(self.items) == 1:
231
+ self.items[0].is_only_item = True
223
232
  self.raw_report = "\n".join(raw_report)
@@ -58,8 +58,6 @@ class Sysview:
58
58
  env = Environment(
59
59
  loader=PackageLoader("sysview_py"), autoescape=select_autoescape()
60
60
  )
61
- for host in self.hosts:
62
- host.all_items
63
61
  for host in self.hosts:
64
62
  html = env.get_template("card_view.html").render(
65
63
  items=host.all_items,
File without changes