-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
49 lines (35 loc) · 1.07 KB
/
main.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import urllib.request
from analyze import checks
def build_argparser():
parser = argparse.ArgumentParser()
parser.add_argument('--id', type=str, help='kernel git repository patch id')
parser.add_argument('--file', type=str, help='Patch file local pc location')
return parser
def dispatch_cmd(args):
if args.id:
cmd_a(args.id)
elif args.file:
cmd_b(args.file)
else:
pass
def cmd_a(patch_id):
print ("Dowloading patch file")
print (patch_id)
print('Downloading patch from the kernel repository...')
url = 'https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/patch/?id=' + patch_id
urllib.request.urlretrieve(url, '/tmp/temporary.patch')
commit_check = checks()
commit_check.parse()
def cmd_b(args):
print ("Opening local patch file")
file_check = checks(args)
file_check.parse()
def main():
args = build_argparser().parse_args()
print (args)
dispatch_cmd(args)
if __name__ == "__main__":
main()