-
Notifications
You must be signed in to change notification settings - Fork 6
/
panda-helper
executable file
·72 lines (54 loc) · 2.19 KB
/
panda-helper
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import argparse
import panda
def main(args):
p = panda.Panda()
if args.cur is not None:
status = p.get_grub_state()
print status
if args.types is not None:
types = p.get_driver_types()
print ",".join(types)
if args.up is not None:
status = p.update_grub_entries(args.up[0])
print status
if args.check is not None:
packages = p.get_needed_driver_packages(installable=True)
print ",".join(packages)
def argument():
'''Command line parser'''
parser = argparse.ArgumentParser(description='Pardus Alternative Driver Administration',
prog='panda',
usage='%(prog)s [options]')
parser.add_argument('-v', '--version',
action='version',
version='%(prog)s 0.0.1')
subparsers = parser.add_subparsers(help='Commands')
parser_cur = subparsers.add_parser('cur', help='Show currently used driver')
parser_cur.add_argument('cur',
nargs='*',
help="Show currently used driver")
parser_update = subparsers.add_parser('types', help='List available driver types')
parser_update.add_argument('types',
nargs='*',
help="List available driver types")
parser_update = subparsers.add_parser('up', help='Update grub.conf')
parser_update.add_argument('up',
nargs=1,
help="Update grub.conf")
parser_update = subparsers.add_parser('check', help='Check for installable packages')
parser_update.add_argument('check',
nargs='*',
help="Check for installable packages")
# We have to set them all to false, otherwise optional arguments are not
# passed to the args() namespace
parser.set_defaults(cur=None,
check=None,
types=None,
up=None)
return parser.parse_args()
if __name__ == '__main__':
args = argument()
sys.exit(main(args))