1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/usr/bin/python
import os, json, sys, re, pprint
from landscape_api.base import API, HTTPError
# change these accordingly
uri = "https://landscape.canonical.com/api/"
key = "<please insert your key here>"
secret = "<pleaseinsert your secret here>"
if key == "<please insert your key here>":
print "please add your personal key in file"
sys.exit(1)
if key == "<please insert your secret here>":
print "please add your personal secret in file"
sys.exit(1)
api = API(uri, key, secret)
try:
usns= api.get_usn_time_to_fix(query="in_last=30")
except HTTPError, e:
print ("\nGot server error:\n"
"Code: %d\n"
"Message: %s\n") % (e.code, e.message)
sys.exit(1)
print "USN analyze for the last 30 days:"
print "#################################"
if len(usns) == 0:
print "No USN data available"
else:
for values in sorted(usns, key=len):
print "USNs patched within a range of ", values, "days =>", usns[values]
|