mirror of
https://github.com/HorlogeSkynet/archey4
synced 2025-04-25 04:00:12 +02:00
added support for Ubuntu
This commit is contained in:
parent
2cbf832471
commit
0c9128fff4
99
archey
99
archey
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# archey [version 0.2.3]
|
||||
# archey [version 0.2.4]
|
||||
#
|
||||
# Maintained by Melik Manukyan <melik@archlinux.us>
|
||||
# Distributed under the terms of the GNU General Public License v3.
|
||||
@ -9,7 +9,7 @@
|
||||
# System information tool for Archlinux written in python.
|
||||
|
||||
# Import libraries
|
||||
import os, sys, subprocess, optparse, re
|
||||
import os, sys, subprocess, optparse, re, linecache
|
||||
from subprocess import Popen, PIPE
|
||||
from optparse import OptionParser
|
||||
from getpass import getuser
|
||||
@ -17,7 +17,7 @@ from time import ctime, sleep
|
||||
|
||||
# Display [Comment/Uncomment to Enable/Disable information.]
|
||||
display = [
|
||||
'os', # Display Operating System
|
||||
'distro', # Display Distribution
|
||||
'hostname', # Display Machine Hostname
|
||||
'kernel', # Display Kernel Version
|
||||
'uptime', # Display System Uptime
|
||||
@ -36,20 +36,12 @@ result = []
|
||||
|
||||
# Options
|
||||
if __name__=='__main__':
|
||||
parser = OptionParser(usage='%prog [-c COLOR] [-s, --screenshot]', description='To customize the info displayed on archey, edit "/usr/bin/archey" directly and look for the display array. Note: Archey can only allow up to 15 fields.', version="%prog 0.2.3")
|
||||
parser.add_option('-c',
|
||||
action='store', default='blue', type='choice', dest='color', choices=('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'), help='choose a color: black, red, green, yellow, blue, magenta, cyan, white [Default: blue]')
|
||||
parser = OptionParser(usage='%prog [-s, --screenshot]', description='Archey is a system information tool written in Python.', version="%prog 0.2.4")
|
||||
parser.add_option('-s', '--screenshot',
|
||||
action='store_true', dest='screenshot', help='take a screenshot')
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
# Define colors
|
||||
colorscheme = '%s' % options.color
|
||||
colors = {'black': '0', 'red': '1', 'green': '2', 'yellow': '3', 'blue': '4', 'magenta': '5', 'cyan': '6', 'white': '7'}
|
||||
for key in colors.keys():
|
||||
if key in colorscheme: colorcode = colors[key]
|
||||
color = '\x1b[1;3%sm' % colorcode
|
||||
color2 = '\x1b[0;3%sm' % colorcode
|
||||
# Clear
|
||||
clear = '\x1b[0m'
|
||||
|
||||
# Define processes for identifying Desktop Environmentss, Window Managers, Shells.
|
||||
@ -102,7 +94,11 @@ p1 = None
|
||||
|
||||
# Print coloured key with normal value.
|
||||
def output(key, value):
|
||||
output = '%s%s:%s %s' % (color, key, clear, value)
|
||||
if Popen(['grep', '-i', 'ubuntu', '/etc/lsb-release'], stdout=PIPE):
|
||||
ucolor = '\x1b[1;31m'
|
||||
output ='%s%s:%s %s' % (ucolor, key, clear, value)
|
||||
if os.path.exists('/etc/arch-release'):
|
||||
output = '%s%s:%s %s' % (color, key, clear, value)
|
||||
result.append(output)
|
||||
|
||||
# RAM Function
|
||||
@ -126,10 +122,15 @@ def screenshot():
|
||||
subprocess.check_call(['scrot'])
|
||||
|
||||
# Operating System Function
|
||||
def os_display():
|
||||
arch = Popen(['uname', '-m'], stdout=PIPE).communicate()[0].rstrip('\n')
|
||||
os = 'Arch Linux %s' % (arch)
|
||||
output('OS', os)
|
||||
def distro_display():
|
||||
arch = Popen(['uname', '-m'], stdout=PIPE).communicate()[0].rstrip('\n'
|
||||
)
|
||||
urelease = linecache.getline('/etc/lsb-release', 2).rstrip('\n').split('=')[1].title()
|
||||
if Popen(['grep', '-i', 'ubuntu', '/etc/lsb-release'], stdout=PIPE).communicate()[0].rstrip('\n'):
|
||||
distro = 'Ubuntu %s %s' % (urelease, arch)
|
||||
if os.path.exists('/etc/arch-release'):
|
||||
distro = 'Arch Linux %s' % arch
|
||||
output('OS', distro)
|
||||
|
||||
# Kernel Function
|
||||
def kernel_display():
|
||||
@ -191,10 +192,17 @@ def term_display():
|
||||
|
||||
# Packages Function
|
||||
def packages_display():
|
||||
p1 = Popen(['pacman', '-Q'], stdout=PIPE)
|
||||
p2 = Popen(['wc', '-l'], stdin=p1.stdout, stdout=PIPE)
|
||||
packages = p2.communicate()[0].rstrip('\n')
|
||||
output ('Packages', packages)
|
||||
if Popen(['grep', '-i', 'ubuntu', '/etc/lsb-release'], stdout=PIPE):
|
||||
p1 = Popen(['dpkg', '--get-selections'], stdout=PIPE)
|
||||
p2 = Popen(['grep', '-v', 'deinstall'], stdin=p1.stdout, stdout=PIPE)
|
||||
p3 = Popen(['wc', '-l'], stdin=p2.stdout, stdout=PIPE)
|
||||
packages = p3.communicate()[0].rstrip('\n')
|
||||
output ('Packages', packages)
|
||||
if os.path.exists('/etc/arch-release'):
|
||||
p1 = Popen(['pacman', '-Q'], stdout=PIPE)
|
||||
p2 = Popen(['wc', '-l'], stdin=p1.stdout, stdout=PIPE)
|
||||
packages = p2.communicate()[0].rstrip('\n')
|
||||
output ('Packages', packages)
|
||||
|
||||
# File System Function
|
||||
def fs_display():
|
||||
@ -225,7 +233,50 @@ for x in display:
|
||||
result.extend(['']*(20 - len(display)))
|
||||
|
||||
###### Result #######
|
||||
print """%s
|
||||
|
||||
## Ubuntu
|
||||
# Colors
|
||||
ucolor = '\x1b[1;33m'
|
||||
ucolor2 = '\x1b[1;31m'
|
||||
ucolor3 = '\x1b[0;31m'
|
||||
|
||||
if Popen(['grep', '-i', 'ubuntu', '/etc/lsb-release'], stdout=PIPE):
|
||||
print """
|
||||
%s ++++++ %s
|
||||
%s ++++++++ %s
|
||||
%s ++++++++++ %s++++++++ %s
|
||||
%s ++++++++++++ %s++++++++ %s
|
||||
%s ++ %s++++++++++++ %s++++++ %s
|
||||
%s +++++ %s++++++++++++ %s**** %s
|
||||
%s +++++++ %s+++++++++++++++++++ %s
|
||||
%s +++++++++ %s+++++++++++ %s
|
||||
%s ++++++++++ %s++++++++++ %s
|
||||
%s ++++++++ %s++++++++++ %s
|
||||
%s ++++++ %s++++++ %s++++++++++ %s
|
||||
%s ++++++++ %s+++++ %s+++++++++ %s
|
||||
%s +++++++++ %s++++ %s
|
||||
%s ++++++++ %s+++++ %s+++++++++ %s
|
||||
%s ++++++ %s++++++ %s++++++++++ %s
|
||||
%s ++++++++ %s++++++++++ %s
|
||||
%s +++++++++ %s++++++++++ %s
|
||||
%s +++++++++ %s++++++++++++ %s
|
||||
%s +++++++ %s+++++++++++++++++++
|
||||
%s +++++ %s++++++++++++ %s,,,,
|
||||
%s ++ %s++++++++++++ %s++++++
|
||||
%s ++++++++++++ %s++++++++
|
||||
%s ++++++++++ %s++++++++
|
||||
%s ++++++++
|
||||
%s ++++++
|
||||
%s """ % (ucolor3, result[0], ucolor3, result[1], ucolor2, ucolor3, result[2], ucolor2, ucolor3, result[3], ucolor, ucolor2, ucolor3, result[4], ucolor, ucolor2, ucolor3, result[5], ucolor, ucolor2, result[6], ucolor, ucolor2, result[7], ucolor, ucolor2, result[8], ucolor, ucolor2, result[9], ucolor2, ucolor, ucolor2, result[10], ucolor2, ucolor, ucolor2, result[11], ucolor2, ucolor, result[12], ucolor2, ucolor, ucolor3, result[13], ucolor2, ucolor, ucolor3, result[14], ucolor, ucolor3, result[15], ucolor, ucolor3, result[16], ucolor, ucolor3, ucolor, ucolor, ucolor3, ucolor, ucolor3, ucolor, ucolor, ucolor3, ucolor, ucolor3, ucolor, ucolor3, ucolor, ucolor, ucolor, clear)
|
||||
|
||||
|
||||
## Arch Linux
|
||||
# Colors
|
||||
acolor = '\x1b[1;34m'
|
||||
acolor2 = '\x1b[0;34m'
|
||||
|
||||
if os.path.exists('/etc/arch-release'):
|
||||
print """%s
|
||||
%s + %s
|
||||
%s # %s
|
||||
%s ### %s
|
||||
@ -244,7 +295,7 @@ print """%s
|
||||
%s ;#### ####; %s
|
||||
%s ##' '## %s
|
||||
%s #' `# %s
|
||||
%s """ % (color, color, result[0], color, result[1], color, result[2], color, result[3], color, result[4], color, result[5], color, result[6], color, result[7], color, color2, color, result[8], color, color2, color, result[9], color, color2, result[10], color2, result[11], color2, result[12], color2, result[13], color2, result[14], color2, result[15], color2, result[16], color2, result[17], clear)
|
||||
%s """ % (acolor, acolor, result[0], acolor, result[1], acolor, result[2], acolor, result[3], acolor, result[4], acolor, result[5], acolor, result[6], acolor, result[7], acolor, acolor2, acolor, result[8], acolor, acolor2, acolor, result[9], acolor, acolor2, result[10], acolor2, result[11], acolor2, result[12], acolor2, result[13], acolor2, result[14], acolor2, result[15], acolor2, result[16], acolor2, result[17], clear)
|
||||
|
||||
if screen == 'True':
|
||||
screenshot()
|
||||
|
Loading…
x
Reference in New Issue
Block a user