-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackages.py
32 lines (25 loc) · 873 Bytes
/
packages.py
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
import os
import platform
import sys
from sys import platform
def _get_manager():
if platform == "linux" or platform == "linux2":
if os.path.exists('/usr/bin/apt-get'):
return 'apt'
elif os.path.exists('/usr/bin/yum'):
return 'yum'
elif platform == "darwin":
return "MacOS"
elif platform == "win32":
return ("win32")
def checkupdates():
if _get_manager() == "yum":
import yum_check
return yum_check.packages()
if _get_manager() == "apt":
import apt_check
from collections import namedtuple
Options = namedtuple('Options', ['security_updates_unattended', 'show_package_names', 'readable_output'])
options = Options(False, False, False)
(num_updates, num_security_updates) = apt_check.run(options)
return num_updates, num_security_updates